summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Noriega <rnoriega@redhat.com>2018-03-28 10:35:11 -0700
committerRicardo Noriega <rnoriega@redhat.com>2018-03-28 11:25:58 -0700
commitb047099b609eac330486f23913e8046d0f22c1ab (patch)
treea054622d413c4f4376aa39c52699262f808004ff
parentf6dbb3929d904b4d5a9ee01f8270051e29ac1ec3 (diff)
Generalization of recursive function
Now, SDN_MAP is not needed to have a boolean true value, but it will check internally posible value formats such dicts and tuples. Change-Id: Idaf492952a7dd9e48e16f42dcbf5c59d981dd535 Signed-off-by: Ricardo Noriega <rnoriega@redhat.com>
-rw-r--r--apex/overcloud/deploy.py10
-rw-r--r--apex/tests/test_apex_overcloud_deploy.py8
2 files changed, 13 insertions, 5 deletions
diff --git a/apex/overcloud/deploy.py b/apex/overcloud/deploy.py
index 0701c188..eb7aefa1 100644
--- a/apex/overcloud/deploy.py
+++ b/apex/overcloud/deploy.py
@@ -110,7 +110,7 @@ def build_sdn_env_list(ds, sdn_map, env_list=None):
if env_list is None:
env_list = list()
for k, v in sdn_map.items():
- if ds['sdn_controller'] == k or (k in ds and ds[k] is True):
+ if ds['sdn_controller'] == k or (k in ds and ds[k]):
if isinstance(v, dict):
# Append default SDN env file first
# The assumption is that feature-enabled SDN env files
@@ -120,12 +120,12 @@ def build_sdn_env_list(ds, sdn_map, env_list=None):
env_list.append(os.path.join(con.THT_ENV_DIR,
v['default']))
env_list.extend(build_sdn_env_list(ds, v))
+ # check if the value is not a boolean
+ elif isinstance(v, tuple):
+ if ds[k] == v[0]:
+ env_list.append(os.path.join(con.THT_ENV_DIR, v[1]))
else:
env_list.append(os.path.join(con.THT_ENV_DIR, v))
- # check if the value is not a boolean
- elif isinstance(v, tuple):
- if ds[k] == v[0]:
- env_list.append(os.path.join(con.THT_ENV_DIR, v[1]))
if len(env_list) == 0:
try:
env_list.append(os.path.join(
diff --git a/apex/tests/test_apex_overcloud_deploy.py b/apex/tests/test_apex_overcloud_deploy.py
index 54f95bb7..6898d36c 100644
--- a/apex/tests/test_apex_overcloud_deploy.py
+++ b/apex/tests/test_apex_overcloud_deploy.py
@@ -74,6 +74,14 @@ class TestOvercloudDeploy(unittest.TestCase):
res = '/usr/share/openstack-tripleo-heat-templates/environments/test'
assert_equal(build_sdn_env_list(ds, sdn_map), [res])
+ def test_build_sdn_env_list_with_string(self):
+ ds = {'sdn_controller': 'opendaylight',
+ 'sriov': 'xxx'}
+ prefix = '/usr/share/openstack-tripleo-heat-templates/environments'
+ res = [os.path.join(prefix, 'neutron-opendaylight.yaml'),
+ os.path.join(prefix, 'neutron-opendaylight-sriov.yaml')]
+ assert_equal(build_sdn_env_list(ds, SDN_FILE_MAP), res)
+
def test_build_sdn_env_list_with_default(self):
ds = {'sdn_controller': 'opendaylight',
'vpn': True}