Merge "Set prepare neutron_driver from NeutronMechanismDrivers"
This commit is contained in:
@@ -110,6 +110,21 @@ def build_service_filter(environment, roles_data):
|
||||
return enabled_services
|
||||
|
||||
|
||||
def set_neutron_driver(pd, mapping_args):
|
||||
"""Set the neutron_driver images variable based on parameters
|
||||
|
||||
:param pd: Parameter defaults from the environment
|
||||
:param mapping_args: Dict to set neutron_driver value on
|
||||
"""
|
||||
if not pd or 'NeutronMechanismDrivers' not in pd:
|
||||
return
|
||||
nmd = pd['NeutronMechanismDrivers']
|
||||
if 'opendaylight_v2' in nmd:
|
||||
mapping_args['neutron_driver'] = 'odl'
|
||||
elif 'ovn' in nmd:
|
||||
mapping_args['neutron_driver'] = 'ovn'
|
||||
|
||||
|
||||
def container_images_prepare_multi(environment, roles_data, dry_run=False,
|
||||
cleanup=image_uploader.CLEANUP_FULL):
|
||||
"""Perform multiple container image prepares and merge result
|
||||
@@ -135,7 +150,8 @@ def container_images_prepare_multi(environment, roles_data, dry_run=False,
|
||||
service_filter = build_service_filter(environment, roles_data)
|
||||
|
||||
for cip_entry in cip:
|
||||
mapping_args = cip_entry.get('set')
|
||||
mapping_args = cip_entry.get('set', {})
|
||||
set_neutron_driver(pd, mapping_args)
|
||||
push_destination = cip_entry.get('push_destination')
|
||||
# use the configured registry IP as the discovered registry
|
||||
# if it is available
|
||||
@@ -232,12 +248,6 @@ def container_images_prepare(template_file=DEFAULT_TEMPLATE_FILE,
|
||||
if mapping_args is None:
|
||||
mapping_args = {}
|
||||
|
||||
if service_filter:
|
||||
if 'OS::TripleO::Services::OpenDaylightApi' in service_filter:
|
||||
mapping_args['neutron_driver'] = 'odl'
|
||||
elif 'OS::TripleO::Services::OVNController' in service_filter:
|
||||
mapping_args['neutron_driver'] = 'ovn'
|
||||
|
||||
def ffunc(entry):
|
||||
imagename = entry.get('imagename', '')
|
||||
if service_filter is not None:
|
||||
|
@@ -603,12 +603,15 @@ class TestPrepare(base.TestCase):
|
||||
template_file=TEMPLATE_PATH,
|
||||
output_env_file=constants.CONTAINER_DEFAULTS_ENVIRONMENT,
|
||||
output_images_file='container_images.yaml',
|
||||
service_filter=['OS::TripleO::Services::NeutronServer'],
|
||||
service_filter=[
|
||||
'OS::TripleO::Services::NeutronServer'
|
||||
],
|
||||
mapping_args={
|
||||
'namespace': 't',
|
||||
'name_prefix': 'p',
|
||||
'name_suffix': '',
|
||||
'tag': 'l',
|
||||
'neutron_driver': None
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -639,6 +642,7 @@ class TestPrepare(base.TestCase):
|
||||
'name_prefix': 'p',
|
||||
'name_suffix': '',
|
||||
'tag': 'l',
|
||||
'neutron_driver': 'ovn'
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -669,6 +673,7 @@ class TestPrepare(base.TestCase):
|
||||
'name_prefix': '',
|
||||
'name_suffix': '',
|
||||
'tag': 'l',
|
||||
'neutron_driver': 'odl'
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -1005,3 +1010,32 @@ class TestPrepare(base.TestCase):
|
||||
},
|
||||
image_params
|
||||
)
|
||||
|
||||
def test_set_neutron_driver(self):
|
||||
mapping_args = {}
|
||||
kb.set_neutron_driver(None, mapping_args)
|
||||
self.assertNotIn('neutron_driver', mapping_args)
|
||||
|
||||
mapping_args = {}
|
||||
kb.set_neutron_driver({}, mapping_args)
|
||||
self.assertNotIn('neutron_driver', mapping_args)
|
||||
|
||||
mapping_args = {}
|
||||
kb.set_neutron_driver(
|
||||
{'NeutronMechanismDrivers': ['sriovnicswitch', 'openvswitch']},
|
||||
mapping_args
|
||||
)
|
||||
self.assertNotIn('neutron_driver', mapping_args)
|
||||
|
||||
mapping_args = {}
|
||||
kb.set_neutron_driver(
|
||||
{'NeutronMechanismDrivers': ['ovn']},
|
||||
mapping_args
|
||||
)
|
||||
self.assertEqual('ovn', mapping_args['neutron_driver'])
|
||||
mapping_args = {}
|
||||
kb.set_neutron_driver(
|
||||
{'NeutronMechanismDrivers': ['sriovnicswitch', 'opendaylight_v2']},
|
||||
mapping_args
|
||||
)
|
||||
self.assertEqual('odl', mapping_args['neutron_driver'])
|
||||
|
Reference in New Issue
Block a user