Fix environments sorting
This change ensures, that custom environments (which are not included in capabilities-map.yaml) are applied at the end of list of sorted environments rather than just skipped Closes-Bug: #1806406 Change-Id: Ia682284eff26883434fc516aefa8591599ec4394
This commit is contained in:
@@ -302,8 +302,8 @@ class UpdateCapabilitiesActionTest(base.TestCase):
|
||||
self.assertEqual({
|
||||
'name': 'test-container',
|
||||
'environments': [
|
||||
{'path': '/path/to/overcloud-default-env.yaml'},
|
||||
{'path': '/path/to/poc-custom-env.yaml'}
|
||||
{'path': '/path/to/poc-custom-env.yaml'},
|
||||
{'path': '/path/to/overcloud-default-env.yaml'}
|
||||
]},
|
||||
action.run(mock_ctx))
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ resource_registry:
|
||||
UNORDERED_PLAN_ENV_LIST = [
|
||||
{'path': 'overcloud-resource-registry-puppet.yaml'},
|
||||
{'path': 'environments/docker-ha.yaml'},
|
||||
{'path': 'environments/custom-environment-not-in-capabilities-map.yaml'},
|
||||
{'path': 'environments/containers-default-parameters.yaml'},
|
||||
{'path': 'environments/docker.yaml'}
|
||||
]
|
||||
@@ -283,7 +284,9 @@ class PlanTest(base.TestCase):
|
||||
{'path': 'overcloud-resource-registry-puppet.yaml'},
|
||||
{'path': 'environments/docker.yaml'},
|
||||
{'path': 'environments/docker-ha.yaml'},
|
||||
{'path': 'environments/containers-default-parameters.yaml'}
|
||||
{'path': 'environments/containers-default-parameters.yaml'},
|
||||
{'path':
|
||||
'environments/custom-environment-not-in-capabilities-map.yaml'}
|
||||
]
|
||||
|
||||
ordered_env = plan_utils.apply_environments_order(
|
||||
|
||||
@@ -192,9 +192,12 @@ def apply_environments_order(capabilities, environments):
|
||||
= environment.get('requires', [])
|
||||
|
||||
# apply ordering rules
|
||||
rest = []
|
||||
for e in environments:
|
||||
path = e.get('path', '')
|
||||
if path not in order_rules:
|
||||
environments.remove(e)
|
||||
rest.append(e)
|
||||
continue
|
||||
path_pos = environments.index(e)
|
||||
for requirement in order_rules[path]:
|
||||
@@ -204,4 +207,4 @@ def apply_environments_order(capabilities, environments):
|
||||
item = environments.pop(requirement_pos)
|
||||
environments.insert(path_pos, item)
|
||||
|
||||
return environments
|
||||
return environments + rest
|
||||
|
||||
Reference in New Issue
Block a user