Fix showing deployment config in case of old format
The original format of ExistingCloud deployment engine type supports only openstack credentials and there were not key "creds". We need to apply a compatibility workaround to support such deployment configs. Change-Id: Ief44e015e3deb78f458b5fe698d70ad4ab8e47c6
This commit is contained in:
parent
7153e0cbc5
commit
650618a607
@ -203,6 +203,14 @@ class _Deployment(APIGroup):
|
||||
deployment = self._get(deployment).to_dict()
|
||||
if deployment["config"].get("type", "") == "ExistingCloud":
|
||||
deployment_creds = {}
|
||||
if "creds" not in deployment["config"]:
|
||||
extra = deployment["config"].pop("extra", None)
|
||||
deployment["config"] = {
|
||||
"type": deployment["config"].pop("type"),
|
||||
"creds": {"openstack": deployment["config"]}
|
||||
}
|
||||
if extra is not None:
|
||||
deployment["config"]["extra"] = extra
|
||||
for platform, creds in deployment["config"]["creds"].items():
|
||||
if isinstance(creds, dict):
|
||||
deployment_creds[platform] = creds
|
||||
|
@ -859,6 +859,7 @@ class DeploymentAPITestCase(BaseDeploymentTestCase):
|
||||
|
||||
@mock.patch("rally.common.objects.deploy.db.deployment_get")
|
||||
def test_get(self, mock_deployment_get):
|
||||
origin_config = copy.deepcopy(self.deployment_config)
|
||||
deployment_id = "aaaa-bbbb-cccc-dddd"
|
||||
mock_deployment_get.return_value = self.deployment
|
||||
ret = self.deployment_inst.get(deployment=deployment_id)
|
||||
@ -866,7 +867,23 @@ class DeploymentAPITestCase(BaseDeploymentTestCase):
|
||||
self.assertIn(key, ret)
|
||||
if key != "config":
|
||||
self.assertEqual(self.deployment[key], ret[key])
|
||||
self.assertEqual(self.deployment_config["creds"], ret["config"])
|
||||
self.assertEqual(origin_config["creds"], ret["config"])
|
||||
|
||||
@mock.patch("rally.common.objects.deploy.db.deployment_get")
|
||||
def test_get_deprecated_formats(self, mock_deployment_get):
|
||||
origin_config = copy.deepcopy(self.deployment_config)
|
||||
self.deployment_config.update(
|
||||
**self.deployment_config.pop("creds")["openstack"])
|
||||
deployment_id = "aaaa-bbbb-cccc-dddd"
|
||||
mock_deployment_get.return_value = self.deployment
|
||||
ret = self.deployment_inst.get(deployment=deployment_id)
|
||||
for key in self.deployment:
|
||||
self.assertIn(key, ret)
|
||||
if key != "config":
|
||||
self.assertEqual(self.deployment[key], ret[key])
|
||||
origin_config.pop("type")
|
||||
|
||||
self.assertEqual(origin_config["creds"], ret["config"])
|
||||
|
||||
@mock.patch("rally.common.objects.Deployment.list")
|
||||
def test_list(self, mock_deployment_list):
|
||||
|
Loading…
Reference in New Issue
Block a user