Commit Graph

18 Commits

Author SHA1 Message Date
Rodolfo Alonso Hernandez 303d24ab8a Allow to manually define the gateway IP when using subnet pools
Now is possible to define a gateway IP when creating a subnet using a
subnet pool. The IPAM subnet generator retrieves the available IP
ranges in the subnet pool and generates a list of candidate subnets
with the prefix lenght defined. If the gateway IP can be allocated in
one of those candidate subnets, the IPAM returns a valid IpamSubnet
that will be used to create a Neutron subnet.

Closes-Bug: #1904436

Change-Id: Ib1d1f591c4d0f59ebff3ddcb3be7b10b0b5e67dc
2021-02-27 10:06:35 +00:00
Maciej Józefczyk b2b40b6a8c [OVN] Use new distributed device_owner for OVN distributed services
OVN distributed services like Metadata and DHCP uses now
DEVICE_OWNER_DHCP device_owner which isn't distributed by its nature.

To fully use benefits of OVN Distributed ports (localports) [1]
and to not overlap with Neutron logic created for not-distributed
ports we should use new device_owner.

In this change we need also to bump minimum required
neutron-lib to 2.4.0.

[1] https://www.ovn.org/support/dist-docs/ovn-nb.5.txt
Change-Id: I0a69f1bddaa7030c7287216e62ec1ac6dd381475
2020-07-08 13:26:35 +00:00
Brian Haley 7594bb0627 Remove the dependency on the "mock" package
Now that we are python3 only, we should move to using the built
in version of mock that supports all of our testing needs and
remove the dependency on the "mock" package.

This patch moves all references to "import mock" to
"from unittest import mock". It also cleans up some new line
inconsistency.

Fixed an inconsistency in the OVSBridge.deferred() definition
as it needs to also have an *args argument.

Fixed an issue where an l3-agent test was mocking
functools.partial, causing a python3.8 failure.

Unit tests only, removing from tests/base.py affects
functional tests which need additional work.

Change-Id: I40e8a8410840c3774c72ae1a8054574445d66ece
2020-04-28 18:05:37 -04:00
Hongbin Lu 12bb26fd0e Use constant IP_VERSION_4/6 in unit tests
Change-Id: I54bec2c06940b0b1362fecacef7860361d081601
2018-08-27 21:45:39 +00:00
Gábor Antal 789acb3a7e Removed unnecessary setUp calls in tests
There are several places where base class setUp() method call was
called unnecessary. In this patchset, they are removed.

TrivialFix

Change-Id: I2961fa4a0216f7f1223ab87a249151f0feb91518
2017-07-31 17:16:01 +02: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
ChangBo Guo(gcb) 7913798a2c Use method get_ipv6_addr_by_EUI64 from oslo.utils
Oslo.utils provides same method get_ipv6_addr_by_EUI64, let's use
it and deprecate method get_ipv6_addr_by_EUI64 in neutron.

Closes-Bug: #1597213
Change-Id: If1eda1283b4405e13ccb60dab530ce4cc1b22948
2016-08-30 19:49:09 +08:00
Edan David 151d94521f Replace device owners hard coded strings to neutron_lib constants
Change-Id: I821f0def82164ab1303188d3f1bdfd85473470cd
2016-07-12 04:11:35 -04:00
Jakub Libosvar 766abb752a Make pep8 job great again
There is a bug in pep8, when 'select' used, it omits all default checks
and runs only those specified by 'select'.  We got hit by this issue
since I2d26534230ffe5d01aa0aab6ec902f81cfba774d was merged which lead to
almost no static checks in pep8 job.

Also note that off_by_default decorator has no effect for now because
factory in hacking is triggered after ignored checks are collected.
There will be a follow-up patch for that in order to make pep8 doing
its job quickly.

[1] https://github.com/PyCQA/pycodestyle/issues/390

Related-Bug: 1594756
Change-Id: I8e27f40908e1bb4307cc7c893169a9d99f3433c4
2016-06-21 16:23:51 +00:00
Kevin Benton 3f9cb90ca2 Use next available address for dhcp ports
Preserve sequential IP allocation for DHCP ports to
avoid interferring with templating systems like heat
that expect a freshly created subnet to have higher
numbered IP addresses available for resources.

The change to randomized allocations was breaking
heat templates that tried to use a specific address
in the subnet that didn't use to be near where DHCP
ports were allocated (e.g. the 10th address).

Change-Id: I4dbda44460adc873b2e4dc1638a34bfac9bb1fc4
2016-06-09 02:16:01 -07:00
Henry Gessau 4148a347b3 Use constants from neutron-lib
With this we enable the deprecation warnings by default.

Related-Blueprint: neutron-lib

Change-Id: I5b9e53751dd164010e5bbeb15f534ac0fe2a5105
2016-04-23 21:23:56 -04:00
Sreekumar S 7215168b11 Removing 'force_gateway_on_subnet' option
With this fix 'force_gateway_on_subnet' configuration
option is removed, and gateway outside the subnet is
always allowed. Gateway cannot be forced onto to the
subnet range.

DocImpact: All references of 'force_gateway_on_subnet'
configuration option and its description should be
removed from the docs.

Change-Id: I1a676f35828e46fcedf339235ef7be388341f91e
Closes-Bug: #1548193
2016-03-23 12:14:26 +05:30
Yalei Wang 8da632a22d Change the exception type from ValueError to IpamValueInvalid
The current ValueError in _validate_with_subnet will return an unfriendly
"Internal Server Error" to user who wrong configured the subnet and pool. This
patch introduces a new exception IpamValueInvalid and it will be mapped to an
meaningful webob exception.

Closes-Bug: #1531401

Change-Id: Ib50a4b3cd1881a0c364d354728fc43040c3ed520
2016-02-26 14:19:43 +08:00
Sreekumar S b6126bc0f1 Fix for adding gateway with IP outside subnet
Currently 'force_gateway_on_subnet' configuration is set to True
by default and enforces the subnet on to the gateway. With this
fix 'force_gateway_on_subnet' can be changed to False, and
gateway outside the subnet can be added.
Before adding the default route, a route to the gateway IP is
added. This applies to both external and internal networks.

This configuration option is deprecated, and should be removed
in a future release. It should always allow gateway outside the
subnet. This is done as a separate patch
https://review.openstack.org/#/c/277303/

Change-Id: I3a942cf98d263681802729cf09527f06c80fab2b
Closes-Bug: #1335023
Closes-Bug: #1398768
2016-02-19 10:57:09 +05:30
Cedric Brandily fd7f84b20b Use assertIsNone(observed) instead of assertEqual(None, observed)
Neutron should use the specific assertion:

  self.assertIsNone(observed)

instead of the generic assertion:

  self.assertEqual(None, observed)

as it raises more specific errors.

Closes-Bug: #1503055
Change-Id: Ib7e5875bd0a95320d89a7504f951998fb210acc1
2015-10-06 01:06:11 +02:00
Cyril Roelandt e2fb74e196 Python 3: do not use types.ClassType
In Python 3, one should just use 'type'. Still, the use of "ClassType" does not
seem necessary here, so just fix the tests.

Change-Id: I5574926fc338110cc989bf185fa454ec26f4d530
Blueprint: neutron-python3
2015-07-16 00:58:40 +02:00
Pavel Bondar 45f3bb810f Add Pluggable IPAM Backend Part 1
Add methods for allocating/deallocating ips using IPAM driver.
Methods are covered by unit tests and currently used only by them.

For pluggable IPAM case ipam driver may execute calls to third-party servers.
It means we can't rely on database transaction rollback in case of failure.
So if any bulk ip allocation/deallocation fails rollback should be done
on third-party servers as well.
Any completed ip allocation should be explicitly deallocated in case of
failure, and vise versa for failure on deallocation.
Try-except block is used to do manual rollback actions.
After rollback actions are done, exception is reraised and local db
transaction rollback occurs.

Pluggable IPAM was divided into two parts to keep review size small.
Following patches are expected to use these methods for ip address
allocation.

Partially-Implements: blueprint neutron-ipam

Change-Id: I8bb836c9883e189b065698ae0a862b2d909d5cbf
2015-07-10 17:11:59 +03:00
Sean M. Collins 310e1e0553 Make IPAM more pythonic
__init__.py is usually an empty file, or contains platform specific
code to make the package function. One more use is to have __init__.py
contain import statements, to import functions and classes, for convenience.

http://docs.python-guide.org/en/latest/writing/structure/#packages
http://mikegrouchy.com/blog/2012/05/be-pythonic-__init__py.html

Change-Id: I7408ac95f4970fbd7009257dfb698102ffabb6e3
2015-07-09 17:33:17 +00:00