Fix deployment --fromenv option
* Updated config that created by fromenv option to new format Change-Id: I1e0a7dd1d12a97ff39cb9c4c243440510f5b2445
This commit is contained in:
parent
516b3628b7
commit
c7b48f3893
|
@ -88,8 +88,10 @@ class DeploymentCommands(object):
|
|||
"""
|
||||
|
||||
if fromenv:
|
||||
config = {"type": "ExistingCloud"}
|
||||
config.update(envutils.get_creds_from_env_vars())
|
||||
# TODO(astudenov): move this to Credential plugin
|
||||
config = {
|
||||
"type": "ExistingCloud",
|
||||
"creds": {"openstack": envutils.get_creds_from_env_vars()}}
|
||||
else:
|
||||
if not filename:
|
||||
print("Either --filename or --fromenv is required.")
|
||||
|
|
|
@ -203,9 +203,11 @@ class ExistingCloud(engine.Engine):
|
|||
builder_cls.validate(creds)
|
||||
|
||||
def _get_creds(self, config):
|
||||
# NOTE(astudenov): copy config to prevent compatibility changes
|
||||
# from saving to database
|
||||
config = copy.deepcopy(config)
|
||||
if "creds" not in config:
|
||||
# backward compatibility with old schema
|
||||
config = copy.deepcopy(config)
|
||||
del config["type"]
|
||||
creds_config = {"openstack": [config]}
|
||||
else:
|
||||
|
|
|
@ -46,20 +46,23 @@ class DeploymentTestCase(unittest.TestCase):
|
|||
self.rally.env.update(utils.TEST_ENV)
|
||||
self.rally("deployment create --name t_create_env --fromenv")
|
||||
config = json.loads(self.rally("deployment config"))
|
||||
self.assertIn("creds", config)
|
||||
self.assertIn("openstack", config["creds"])
|
||||
oscreds = config["creds"]["openstack"]
|
||||
self.assertEqual(utils.TEST_ENV["OS_USERNAME"],
|
||||
config["admin"]["username"])
|
||||
oscreds["admin"]["username"])
|
||||
self.assertEqual(utils.TEST_ENV["OS_PASSWORD"],
|
||||
config["admin"]["password"])
|
||||
if "project_name" in config["admin"]:
|
||||
oscreds["admin"]["password"])
|
||||
if "project_name" in oscreds["admin"]:
|
||||
# keystone v3
|
||||
self.assertEqual(utils.TEST_ENV["OS_TENANT_NAME"],
|
||||
config["admin"]["project_name"])
|
||||
oscreds["admin"]["project_name"])
|
||||
else:
|
||||
# keystone v2
|
||||
self.assertEqual(utils.TEST_ENV["OS_TENANT_NAME"],
|
||||
config["admin"]["tenant_name"])
|
||||
oscreds["admin"]["tenant_name"])
|
||||
self.assertEqual(utils.TEST_ENV["OS_AUTH_URL"],
|
||||
config["auth_url"])
|
||||
oscreds["auth_url"])
|
||||
|
||||
def test_destroy(self):
|
||||
self.rally.env.update(utils.TEST_ENV)
|
||||
|
@ -87,7 +90,7 @@ class DeploymentTestCase(unittest.TestCase):
|
|||
self.rally.env.update(utils.TEST_ENV)
|
||||
self.rally("deployment create --name t_create_env --fromenv")
|
||||
config = json.loads(self.rally("deployment config"))
|
||||
config["auth_url"] = "http://foo/"
|
||||
config["creds"]["openstack"]["auth_url"] = "http://foo/"
|
||||
file = utils.JsonTempFile(config)
|
||||
self.rally("deployment recreate --deployment t_create_env "
|
||||
"--filename %s" % file.filename)
|
||||
|
|
|
@ -59,17 +59,21 @@ class DeploymentCommandsTestCase(test.TestCase):
|
|||
self.fake_api.deployment.create.assert_called_once_with(
|
||||
{
|
||||
"type": "ExistingCloud",
|
||||
"auth_url": "fake_auth_url",
|
||||
"region_name": "fake_region_name",
|
||||
"endpoint_type": "fake_endpoint_type",
|
||||
"endpoint": "fake_endpoint",
|
||||
"admin": {
|
||||
"username": "fake_username",
|
||||
"password": "fake_password",
|
||||
"tenant_name": "fake_tenant_name"
|
||||
},
|
||||
"https_insecure": True,
|
||||
"https_cacert": "fake_cacert"
|
||||
"creds": {
|
||||
"openstack": {
|
||||
"auth_url": "fake_auth_url",
|
||||
"region_name": "fake_region_name",
|
||||
"endpoint_type": "fake_endpoint_type",
|
||||
"endpoint": "fake_endpoint",
|
||||
"admin": {
|
||||
"username": "fake_username",
|
||||
"password": "fake_password",
|
||||
"tenant_name": "fake_tenant_name"
|
||||
},
|
||||
"https_insecure": True,
|
||||
"https_cacert": "fake_cacert"
|
||||
}
|
||||
}
|
||||
},
|
||||
"from_env"
|
||||
)
|
||||
|
@ -92,19 +96,23 @@ class DeploymentCommandsTestCase(test.TestCase):
|
|||
self.fake_api.deployment.create.assert_called_once_with(
|
||||
{
|
||||
"type": "ExistingCloud",
|
||||
"auth_url": "fake_auth_url",
|
||||
"region_name": "fake_region_name",
|
||||
"endpoint_type": "fake_endpoint_type",
|
||||
"endpoint": "fake_endpoint",
|
||||
"admin": {
|
||||
"username": "fake_username",
|
||||
"password": "fake_password",
|
||||
"user_domain_name": "fake_udn",
|
||||
"project_domain_name": "fake_pdn",
|
||||
"project_name": "fake_tenant_name"
|
||||
},
|
||||
"https_insecure": True,
|
||||
"https_cacert": "fake_cacert"
|
||||
"creds": {
|
||||
"openstack": {
|
||||
"auth_url": "fake_auth_url",
|
||||
"region_name": "fake_region_name",
|
||||
"endpoint_type": "fake_endpoint_type",
|
||||
"endpoint": "fake_endpoint",
|
||||
"admin": {
|
||||
"username": "fake_username",
|
||||
"password": "fake_password",
|
||||
"user_domain_name": "fake_udn",
|
||||
"project_domain_name": "fake_pdn",
|
||||
"project_name": "fake_tenant_name"
|
||||
},
|
||||
"https_insecure": True,
|
||||
"https_cacert": "fake_cacert"
|
||||
}
|
||||
}
|
||||
},
|
||||
"from_env"
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue