Use default subnet mapping if subnet is not specified
This commit introduces default subnet mapping that maps different driverTypes to default subnet related to sertain driverType. Mapping is used then subnet is not specified in net-attach-def and continues previously merged patch that closes bug 1810344 Change-Id: I558cd73f9a30a684d99bab9b2a251ae24e5a4397 Closes-Bug: 1811243
This commit is contained in:
parent
7480cc36f8
commit
db6dcda9ec
@ -212,6 +212,10 @@ neutron_defaults = [
|
||||
help=_("Time (in seconds) that kuryr controller waits for "
|
||||
"neutron LBaaS to be activated"),
|
||||
default=300),
|
||||
cfg.DictOpt('subnet_mapping',
|
||||
help=_("A mapping of default subnets for certain driverType "
|
||||
"in a form of <driverType>:<SUBNET-ID>"),
|
||||
default={}),
|
||||
]
|
||||
|
||||
octavia_defaults = [
|
||||
|
@ -65,17 +65,26 @@ class NPWGMultiVIFDriver(base.MultiVIFDriver):
|
||||
|
||||
config = jsonutils.loads(nad_obj['metadata']['annotations']
|
||||
['openstack.org/kuryr-config'])
|
||||
subnet_id = config.get(
|
||||
constants.K8S_ANNOTATION_NPWG_CRD_SUBNET_ID,
|
||||
kuryr_config.CONF.neutron_defaults.pod_subnet
|
||||
)
|
||||
subnet = {subnet_id: utils.get_subnet(subnet_id)}
|
||||
|
||||
subnet_id = config.get(constants.K8S_ANNOTATION_NPWG_CRD_SUBNET_ID)
|
||||
neutron_defaults = kuryr_config.CONF.neutron_defaults
|
||||
if constants.K8S_ANNOTATION_NPWG_CRD_DRIVER_TYPE not in config:
|
||||
vif_drv = self._drv_vif_pool
|
||||
if not subnet_id:
|
||||
subnet_id = neutron_defaults.pod_subnet
|
||||
else:
|
||||
alias = config[constants.K8S_ANNOTATION_NPWG_CRD_DRIVER_TYPE]
|
||||
vif_drv = base.PodVIFDriver.get_instance(
|
||||
specific_driver=alias)
|
||||
if not subnet_id:
|
||||
try:
|
||||
subnet_id = neutron_defaults.subnet_mapping[alias]
|
||||
except KeyError:
|
||||
subnet_id = neutron_defaults.pod_subnet
|
||||
LOG.debug("Default subnet mapping in config file "
|
||||
"doesn't contain any subnet for %s driver "
|
||||
"alias. Default pod_subnet was used.", alias)
|
||||
subnet = {subnet_id: utils.get_subnet(subnet_id)}
|
||||
vif = vif_drv.request_vif(pod, project_id, subnet, security_groups)
|
||||
if vif:
|
||||
vifs.append(vif)
|
||||
|
Loading…
Reference in New Issue
Block a user