Add default-subnetpools to DFPlugin
default subnetpools is pure control plane functionality in neutron. df can just enable it. And fullstack can use it to avoid subnet collisions. TODO: should we remove all unintentional, explicit subnet cidr defination in fullstack? Change-Id: I32afc73c1cf289bdbfb51ea3c140aff903c7261b Closes-Bug: #1562966
This commit is contained in:
parent
daf6b780e8
commit
2fe96282e3
|
@ -26,5 +26,6 @@ SUPPORTED_API_EXTENSIONS = [
|
|||
'subnet_allocation',
|
||||
'port-security',
|
||||
'allowed-address-pairs',
|
||||
'net-mtu'
|
||||
'net-mtu',
|
||||
'default-subnetpools'
|
||||
]
|
||||
|
|
|
@ -46,6 +46,12 @@ class DFTestBase(base.BaseTestCase):
|
|||
password=creds['password'], auth_url=auth_url,
|
||||
tenant_name=tenant_name)
|
||||
self.neutron.format = 'json'
|
||||
|
||||
# NOTE: Each env can only have one default subnetpool for each
|
||||
# IP version.
|
||||
if not self.get_default_subnetpool():
|
||||
self.create_default_subnetpool()
|
||||
|
||||
common_config.init(['--config-file', '/etc/neutron/neutron.conf'])
|
||||
self.conf = cfg.CONF.df
|
||||
self.integration_bridge = self.conf.integration_bridge
|
||||
|
@ -61,6 +67,25 @@ class DFTestBase(base.BaseTestCase):
|
|||
if cfg.CONF.df.enable_selective_topology_distribution:
|
||||
self.start_subscribing()
|
||||
|
||||
def get_default_subnetpool(self):
|
||||
default_subnetpool = None
|
||||
subnetpool_filter = {'is_default': True,
|
||||
'ip_version': 4}
|
||||
subnetpools = self.neutron.list_subnetpools(
|
||||
**subnetpool_filter).get('subnetpools')
|
||||
if subnetpools:
|
||||
default_subnetpool = subnetpools[0]
|
||||
|
||||
return default_subnetpool
|
||||
|
||||
def create_default_subnetpool(self):
|
||||
default_subnetpool = {'prefixes': ['10.0.0.0/8'],
|
||||
'name': 'default_subnetpool_v4',
|
||||
'is_default': True,
|
||||
'default_prefixlen': 24}
|
||||
self.neutron.create_subnetpool(
|
||||
body={'subnetpool': default_subnetpool})
|
||||
|
||||
def store(self, obj, close_func=None):
|
||||
close_func = close_func if close_func else obj.close
|
||||
self.__objects_to_close.append(close_func)
|
||||
|
|
|
@ -312,7 +312,7 @@ class SubnetTestObj(object):
|
|||
def create(self, subnet=None):
|
||||
if not subnet:
|
||||
subnet = {
|
||||
'cidr': '192.168.199.0/24',
|
||||
'use_default_subnetpool': True,
|
||||
'ip_version': 4,
|
||||
'network_id': self.network_id
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue