Commit Graph

119 Commits

Author SHA1 Message Date
Brian Haley cca0b3a026 Fix some pylint indentation warnings
Running with a stricter .pylintrc generates a lot of
C0330 warnings (hanging/continued indentation). Fix
the ones in neutron/services.

Trivialfix

Change-Id: Ie9779b257981bc80e69639cdaa4d7dfd0ffa5809
2022-12-01 16:21:37 +00:00
Rajesh Tailor 8ab5ee1d17 Fix remaining typos in comments and tests
Change-Id: I872422cffd1f9a2e59b5e18a86695e5cb6edc2cd
2022-07-06 21:20:27 +05:30
Jakub Libosvar 4d3a274765 Don't register config options on imports
Importing some modules lead to registering config options that may
collide with config options from a project that calls the import. This
patch wraps the side effect that registers config options into a
function that needs to be called in case the caller wants to register
the options.

This solution is also not perfect as it guards the common options to be
registered only once even if the function is called multiple times. This
is to solve problems in unittests, ideally we should always call the
function just once even in our testing suites.

Resolves-Bug: #1968606
Change-Id: Ic1532eb8de887ff1b1085206df11f53e22f7f524
Signed-off-by: Jakub Libosvar <libosvar@redhat.com>
2022-04-13 05:49:15 +00:00
Rodolfo Alonso Hernandez edf1d0c759 Replace "tenant_id" with "project_id" in metering service
This is part of the remaining technical debt of the specs
https://specs.openstack.org/openstack/neutron-specs/specs/newton/moving-to-keystone-v3.html

Change-Id: If86ecce15b077f6baef74903a3a4f41a450ec755
Blueprint: https://blueprints.launchpad.net/neutron/+spec/keystone-v3
2021-10-28 09:42:52 +00:00
Bernard Cafarelli 8d6c301301
Update requirements for recent pip failures
Bump astroid test requirement to 2.4.0
Older versions trigger an error on wrapt dependency:
https://github.com/PyCQA/astroid/issues/755

Bump pylint accordingly to new astroid

Fix some new PEP8 warnings appearing with new versions, and filter out
the larget I202 "Additional newline in a group of imports" one for now

Drop psutil from functional requirements, it indicated an old version
and we have it in common requirements now

Bump a series of lower-constraints and requirements to work with new pip
resolver, testing with steps outlined at:
http://lists.openstack.org/pipermail/openstack-discuss/2020-December/019285.html
This includes eventlet 0.22.1, previous versions triggered a hard to
track error on enum34
Cap cryptography in lower-constraints to prevent discovery failure in
relevant job (other jobs have it capped via upper-constraints)

Change-Id: Ie74ea517a403e6e2a7a4e0a245dd20e5281339e8
Closes-Bug: #1907242
2020-12-09 13:17:51 +01:00
Zuul 144c70f896 Merge "Set metering iptables chain not found LOG level to WARNING" 2020-11-20 11:46:59 +00:00
Rafael Weingärtner 3c0d57c884 Set metering iptables chain not found LOG level to WARNING
When routers are migrated from one Neutron agent to the other, the metering IPtables
rules are removed, which can cause some exceptions that can be ignored. The metering
agent already handled this situation. However, it logs the message as an ERROR, which
can triggers alarms. Therefore, we propose here to change the LOG message from error
to warning.

Closes-Bug: #1904874
Change-Id: I1805a07cef7fc7d7b041e582a4d79fb1a805df71
2020-11-19 09:14:28 -03:00
Rafael Weingärtner 10091f9346 Add source_ip_prefix and destination_ip_prefix to metering label rules
As proposed in the RFE and then approved in the spec, we are adding to
the neutron metering rules two new parameters. The source IP prefix, and
destination IP prefix.

Partially-Implements: https://bugs.launchpad.net/neutron/+bug/1889431
RFE: https://bugs.launchpad.net/neutron/+bug/1889431

Depends-On: https://review.opendev.org/#/c/746203/
Depends-On: https://review.opendev.org/#/c/744702/
Depends-On: https://review.opendev.org/#/c/743828/
Depends-On: https://review.opendev.org/#/c/746142/

Change-Id: I38991de2b4937becd0f1f14f3a32dc39c590e0d9
2020-09-29 09:06:03 -03:00
Rafael Weingärtner 95558d0bf5 Metering fix error that might happen when labels are removed during processing
If a metering label is removed during a data collection and processing, and
error might happen. This patch address such situations, and creates an execution
flow that avoids such problems.

Change-Id: Iba68173c304dccf97521dcec9a87fce67e21cec2
2020-09-18 15:01:16 -03:00
Zuul bdd6c6cdb5 Merge "Granular metering data in neutron-metering-agent" 2020-09-08 16:52:23 +00:00
Rafael Weingärtner bd1467b47c Granular metering data in neutron-metering-agent
Extend neutron metering agent to generate Granular metering data.
The rationale here is to have data (bytes and packets) not just in
a label basis, but also in tenant, router, and router-label, and tenant-label
basis. This allows operators to develop more complex network monitoring
solutions.

Moreover, I added documentation to explain what is the neutron metering agent,
its configs, and different message formats.

Change-Id: I7b6172f88efd4df89d7bed9a0af52f80c61acbe0
Implements: https://blueprints.launchpad.net/neutron/+spec/granular-metering-data
Closes-Bug: #1886949
2020-09-04 09:20:54 -03:00
Rafael Weingärtner b0c6cb35e7 Announce deprecation of `remote_ip_prefix` in metering label rules
As proposed in the RFE and then approved in the spec, we are adding to
the neutron metering rules two new parameters. The source IP prefix, and
destination IP prefix. Moreover, with that new spec implementation, we
deprecate the use of `remote_ip_prefix`.

This patch introduces a log message to inform people to migrate to the new API usage.

Change-Id: I5e81d8b27c6126f10011f2d1b4d8f8697e987f13
Partially-Implements: https://bugs.launchpad.net/neutron/+bug/1889431
RFE: https://bugs.launchpad.net/neutron/+bug/1889431
Depends-On: https://review.opendev.org/#/c/744702/
Depends-On: https://review.opendev.org/#/c/743828/
Depends-On: https://review.opendev.org/#/c/746142/
2020-08-19 10:29:00 -03:00
Bernard Cafarelli 5ce0595803
Set process name for agents
Now that we use setproctitle for neutron-server workers (and
neutron-keepalived-state-change), this has the side effect of changing
the process name for agents, impacting some monitoring systems. More
details in launchpad bug.

This patch fixes it by setting the name with setproctitle to:
agent name (original process name).

Also use the newly introduced name constants to replace existing
hardcoded uses.

Change-Id: I74c3a4d3e9f833752571a75f196560cd45529385
Closes-Bug: #1881297
2020-07-01 12:28:29 +02:00
Brian Haley 08a60f7483 Remove usage of six.add_metaclass
With python 3.x, classes can use the metaclass= logic
to not require usage of the six library.

One step in removing all of six usage from neutron.

Change-Id: I2f815e412d9a96eb5faf2b3bb3a1e393a9db9309
2020-05-21 14:41:18 -04:00
Brian Haley 555238da69 Start using oslo_utils.netutils.is_ipv6_enabled()
Seems that is_enabled_and_bind_by_default() from
neutron.common.ipv6_utils was copied directly into
oslo_utils.netutils, so start using it instead.

Trivialfix

Change-Id: I00fa441e7a20fcd1115485bb8ab75750e6a8cf07
2019-10-16 21:44:56 -04:00
Brian Haley b79842f289 Start enforcing E125 flake8 directive
Removed E125 (continuation line does not distinguish itself
from next logical line) from the ignore list and fixed all
the indentation issues.  Didn't think it was going to be
close to 100 files when I started.

Change-Id: I0a6f5efec4b7d8d3632dd9dbb43e0ab58af9dff3
2019-07-19 23:39:41 -04:00
bno1 9f541521bb Retry creating iptables managers and adding metering rules
This change makes the metering agent retry creating the iptables
managers for each router and applying the metering rules.
This is needed in case the metering agent starts before some or all of
the namespaces are created.

Change-Id: Ifc565feb98c7f02df5c2831a3607c3e526a2e703
Closes-Bug: #1807153
2019-07-13 16:10:19 +03:00
Boden R 9bbe9911c4 remove neutron.common.constants
All of the externally consumed variables from neutron.common.constants
now live in neutron-lib. This patch removes neutron.common.constants
and switches all uses over to lib.

NeutronLibImpact

Depends-On: https://review.openstack.org/#/c/647836/
Change-Id: I3c2f28ecd18996a1cee1ae3af399166defe9da87
2019-04-04 14:10:26 -06:00
Zuul 4db4adbefb Merge "Change Metering agent to log message after failure" 2019-02-07 20:12:48 +00:00
Boden R 024802aafd remove neutron.common.rpc
The neutron.common.rpc module has been in neutron-lib for awhile now and
neutron is shimmed to use neutron-lib already.
This patch removes neutron.common.rpc and switches the code over to use
neutron-lib's implementation where needed.

NeutronLibImpact

Change-Id: I733f07a8c4a2af071b3467bd710290eee11a4f4c
2019-02-06 11:05:55 -07:00
Brian Haley a8afd1f124 Change Metering agent to log message after failure
If the Metering agent fails to send its report_state
to the server, it logs an exception:

   Failed reporting state!: MessagingTimeout: Timed out...

If it then tries a second time and succeeds it just
goes on happily. It would be nice if it logged that
it had success on the subsequent attempt so someone
looking at the logs know it recovered.

Change-Id: If5522e5a975e05f195f1760d7fbd60264ac91fc3
2019-02-05 11:53:25 +00:00
Zuul b4b725ade9 Merge "Update metering driver to load interface driver" 2018-08-11 14:41:34 +00:00
Hongbin Lu 38309ca4dc Update metering driver to load interface driver
Currently the metering iptables driver is using the old method
to load the interface driver. This patch allows it to load
interface driver via stevedore aliases.

Change-Id: I9e3027c1ec695ec3a09db0c53a0388e406e4ced6
Related-Bug: #1504536
2018-08-10 15:44:50 +00:00
Dongcan Ye 40d92d40ec Config privsep in the metering agent
Enable privsep to execute ip netns or other commands.

Change-Id: I4e20a1e92c0d154b76615437efe5eced4e0cc6bd
Closes-Bug: #1786213
2018-08-09 10:05:36 +00:00
Hongbin Lu 2b1d8ea4a2 Implement filter validation
Enforce validation on filter parameters on list requests.
If an API request contains an unknown or unsupported parameter,
the server will return a 400 response instead of silently ignoring
the invalid input.

In resource attributes map, all filter parameters are annotated by
the ``is_filter`` keyword. Attributes with is_filter set to True
are candidates for validation.

Enabling filter validation requires support from core plugin and
all service plugins so each plugin need to indicate if it supports
the validation by setting ``__filter_validation_support`` to True.
If this field is not set, the default is False and validation is
turned off. Right now, the ML2 plugin and all the in-tree service
plugin support filter validation. Out-of-tree plugins will have
filter validation disabled by default.

An API extension is introduced to allow API users to discover this
new API behavior. This feature can be disabled by cloud operators
if they choose to do that. If it is disabled, the extension won't
be presented.

Depends-On: Ic3ab5b3ffdc378d570678b9c967cb42b0c7a8a9b
Depends-On: I4397df1c35463a8b532afdc9c5d28b37224a37b4
Depends-On: I3f2e6e861adaeef81a1a5819a57b28f5c6281d80
Depends-On: I1189bc9a50308df5c7e18c329f3a1262c90b9e12
Depends-On: I057cd917628c77dd20c0ff7747936c3fec7b4844
Depends-On: I0b24a304cc3466a2c05426cdbb6f9d99f1797edd

Change-Id: I21bf8a752813802822fd9966dda6ab3b6c4abfdc
Partial-Bug: #1749820
2018-07-19 04:13:43 +00:00
Boden R 81f7347b53 remove rpc create_connection
The neutron.common.rpc.create_connection function is just a reference to
the Connection class constructor. This patch removes create_connection
and replaces all uses with Connection instead.

NeutronLibImpact

Change-Id: I2f4b24ba732be47fc9911be1e24406fb1ffe821e
2018-04-27 09:51:11 -06:00
Sławek Kapłoński b6b23a8f77 Enable mutable config in Neutron
New releases of oslo.config support a 'mutable' parameter to Opts.
This is only respected when the new method mutate_config_files is
called instead of reload_config_files. Neutron delegates making this
call to oslo.service. This was provided in patchset
Icec3e664f3fe72614e373b2938e8dee53cf8bc5e

Further patches will be needed to make select config options be
marked as mutable. This change enables support for oslo provided
config options to be updated via SIGHUP such as log level.

Task: 6389
Story: 2001545

Change-Id: I9442965607f3248706464643c6d87a04edcae24e
2018-03-21 20:35:19 +00:00
Boden R ef93f7e7f0 use common agent topics from neutron-lib
The neutron.common.topics module was rehomed into neutron-lib with
commit Ie88b84949cbd55a4e7ad06341aab77b286cdc485
This patch consumes it by removing the rehomed module from neutron
and using the module from neutron-lib instead.

NeutronLibImpact

Change-Id: Ia4a4604c259ce862597de80c6deeb3d408bf0e95
2018-03-13 11:35:50 -06:00
leegy 92db1d4a2c Fix meter-label-rule creation
The existing method is to meter outgoing traffic from the entire VM
to a specific "remote_ip_addr"(in case of outbound),
but the method I suggested can meter outgoing traffic
from a particular subnet to external network.

From a metering point of view,
it does not matter which address/CIDR is the destination for outbound.
But, it is important to know where(subnet or VM) the packet leaves from.
That way you can see how much VMs are using the external network.
For outbound metering, dst is 0.0.0.0/0 and src is network of VMs
and for inbound metering, src is 0.0.0.0/0 and dst is network of VMs.

When creating a meter-label-rule, it is correct
to specify src address for "remote_ip_prefix" option for outbound
and specify dst address for inbound.
If you are confused by the term "remote_ip_prefix",
you need to clarify this option.

Change-Id: Ia3f3e26410a73d7b44abae637703fda41c4bc09a
Closes-Bug: #1716913
2017-12-03 09:20:53 +00:00
Boden R c6ed3bf819 use metering api def from neutron-lib
The metering extension's API definition was rehomed into neutron-lib
with commit I1b3285287be2429f7cf9913a7e6204db26371ced. This patch
consumes the API definition removing the rehomed code from neutron
and updating references to use lib's code.

NeutronLibImpact

Change-Id: Iacd69a3b332ee494946befc2f35638410e27cfb9
2017-11-03 14:03:20 -06:00
yanyaohua 9dffd9b391 Fix the wrong usage of new style class in metering
This problem will cause self.host to be overridden by cfg.CONF.host
instead of the passed host value when calling MeteringAgent.__init__(host).

Change-Id: I50c5136e1cf1eb0db28edd02129f963948a54741
2017-10-30 18:47:15 +08:00
Zuo ZongMing 00f6163ba6 Remove the unused code
The "return" here is redundant.

Change-Id: I647f381d7d04fdc6a149fca901b728211b35b5af
2017-10-27 17:41:50 +08:00
Boden R 864f8072b2 consume load_class_by_alias_or_classname from neutron-lib
neutron-lib now contains the load_class_by_alias_or_classname function.
This patch removes the function from neutron and uses it from lib.

NeutronLibImpact

Change-Id: I47ef642fcb3c8ded5eb7ed0a637033c7bcb3632b
2017-10-21 06:01:15 -06:00
Nguyen Van Trung 1b7d6da521 Redundant alias in import statement
Change-Id: I4a48eef728fff824461344efaf377ccbbc02726b
2017-10-19 15:31:03 +07:00
Jenkins 8df4cf30de Merge "Change ip_lib network namespace code to use pyroute2" 2017-10-13 22:53:20 +00:00
Brian Haley 4f627b4e8d Change ip_lib network namespace code to use pyroute2
Change network namespace add/delete/list code to use
pyroute2 library instead of calling /sbin/ip.

Also changed all in-tree callers to use the new calls.

Closes-bug: #1717582
Related-bug: #1492714

Change-Id: Id802e77543177fbb95ff15c2c7361172e8824633
2017-10-04 21:09:28 +00:00
Boden R 60f8048c7c use synchronized lock decorator from neutron-lib
neutron-lib contains the synchronized lockutils decorator as well as
the SYNCHRONIZED_PREFIX global. This patch consumes them from
neutron-lib and removes them from neutron.

NeutronLibImpact

Change-Id: I729da348e340509f2d09f8a6436716e2398f1583
2017-10-04 13:57:42 -06:00
sindhu devale 51ca683797 Refactoring agent linux&ovsdb config
Refactoring neutron agent linux and ovsdb config opts
to be in neutron/conf/agent so that all the config options
reside in a centralized location. This simplifies the
process of looking up the config opts and provides an easy
way to import.

NeutronLibImpact

Change-Id: Ib1e0e63dec2985c417412d1ecc68e2a74ef87182
Partial-Bug: #1563069
2017-08-25 10:41:39 -04:00
Inessa Vasilevskaya 7322bd6efb Make code follow log translation guideline
Since Pike log messages should not be translated.
This patch removes calls to i18n _LC, _LI, _LE, _LW from
logging logic throughout the code. Translators definition
from neutron._i18n is removed as well.
This patch also removes log translation verification from
ignore directive in tox.ini.

Change-Id: If9aa76fcf121c0e61a7c08088006c5873faee56e
2017-08-14 02:01:48 +00:00
Jenkins 96d13e42f4 Merge "Verify metering label exists before applying rule" 2017-05-02 21:01:30 +00:00
Jenkins 16c37c1e0f Merge "Replace six.iteritems with dict.items(Part-2)" 2017-04-18 18:07:55 +00:00
fpxie 574312165b Replace six.iteritems with dict.items(Part-2)
according to https://wiki.openstack.org/wiki/Python3, now we should avoid
using six.iteritems and replace it with dict.items.

Change-Id: I58a399baa2275f280acc0e6d649f81838648ce5c
Closes-Bug: #1680761
2017-04-18 18:56:46 +08:00
Jenkins 6ae1ef2ad3 Merge "Remove unused variable" 2017-04-18 08:43:14 +00:00
Béla Vancsics 4698b7b931 Remove unused variable
TrivialFix

Change-Id: I9483695a4ad9a1aa3ae26afd9b760891376c23c6
2017-04-14 23:09:21 +00:00
Jenkins e3ffe24b2c Merge "Update metering agent to use stevedore alias for driver" 2017-04-02 03:50:09 +00:00
Brian Haley 29652e0aff Verify metering label exists before applying rule
If the metering-agent receives a label rule before it
has added the label, it will fail to update the iptables
rules as there are no existing chains.

When the action is "create", check if there is an existing
label, and create one and the corresponding iptables chains,
before trying to add the rule.

Closes-Bug: #1617248

Change-Id: Ia0ec1361188cca53023667d249c2b1e10bc22089
2017-03-28 14:27:05 -04:00
Jean-Philippe Evrard c9d4698409 Update metering agent to use stevedore alias for driver
Currently the metering agent is using the old import method,
use stevedore instead.

DocImpact

Two places in the networking guide should change to
'driver = iptables' from current format.

Partial-Bug: #1504536
Change-Id: I1e6d196a3ada8fbfc2b70d6a983984d8db09bbd0
2017-03-27 16:28:15 -04:00
John Perkins 7f23ccce23 Agent common config
Refactoring Neutron configuration options for agent common config to be
in neutron/conf/agent/common. This will allow centralization of all
configuration options and provide an easy way to import.

Partial-Bug: #1563069
Change-Id: Iebac0cdd3bcfd0135349128921b7ad7a1a939ab8
Needed-By: Ib676003bbe909b5a9013a3178b12dbe291d936af
2017-03-15 09:52:18 -06:00
Armando Migliaccio ca751a1486 Spin off context module
NeutronLibImpact

Partially-implements: blueprint neutron-lib

Change-Id: I48cf45dc1b07035d952152eac2548a3bd9fc2832
2017-03-06 16:25:29 +00:00
Jenkins 2614bc6498 Merge "DVR: Fix IPtables driver for metering with DVR routers" 2017-01-20 04:08:55 +00:00