Merge "Simplify deployment config format"
This commit is contained in:
commit
3ed8f94c13
@ -49,16 +49,13 @@ if [[ "$IDENTITY_API_VERSION" == 2.0 ]]
|
||||
then
|
||||
cat >$1 <<EOF
|
||||
{
|
||||
"type": "ExistingCloud",
|
||||
"creds": {
|
||||
"openstack": {
|
||||
"auth_url": "$OS_AUTH_URL",
|
||||
"region_name": "$REGION_NAME",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
"password": "$ADMIN_PASSWORD",
|
||||
"tenant_name": "admin",
|
||||
}
|
||||
"openstack": {
|
||||
"auth_url": "$OS_AUTH_URL",
|
||||
"region_name": "$REGION_NAME",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
"password": "$ADMIN_PASSWORD",
|
||||
"tenant_name": "admin",
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -68,18 +65,15 @@ if [[ "$IDENTITY_API_VERSION" == 3 ]]
|
||||
then
|
||||
cat >$1 <<EOF
|
||||
{
|
||||
"type": "ExistingCloud",
|
||||
"creds": {
|
||||
"openstack": {
|
||||
"auth_url": "$OS_AUTH_URL",
|
||||
"region_name": "$REGION_NAME",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
"password": "$ADMIN_PASSWORD",
|
||||
"project_name": "admin",
|
||||
"user_domain_name": "Default",
|
||||
"project_domain_name": "Default"
|
||||
}
|
||||
"openstack": {
|
||||
"auth_url": "$OS_AUTH_URL",
|
||||
"region_name": "$REGION_NAME",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
"password": "$ADMIN_PASSWORD",
|
||||
"project_name": "admin",
|
||||
"user_domain_name": "Default",
|
||||
"project_domain_name": "Default"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
32
rally/api.py
32
rally/api.py
@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
import collections
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
@ -95,6 +96,15 @@ class _Deployment(APIGroup):
|
||||
:returns: Deployment object
|
||||
"""
|
||||
|
||||
# NOTE(andreykurilin): the following transformation is a preparatory
|
||||
# step for further refactoring (it will be done soon).
|
||||
print_warning = True
|
||||
if "type" not in config:
|
||||
# it looks like a new format! wow!
|
||||
config = {"type": "ExistingCloud",
|
||||
"creds": config}
|
||||
print_warning = False
|
||||
|
||||
try:
|
||||
deployment = objects.Deployment(name=name, config=config)
|
||||
except exceptions.DeploymentNameExists as e:
|
||||
@ -112,6 +122,17 @@ class _Deployment(APIGroup):
|
||||
deployment.update_status(consts.DeployStatus.DEPLOY_FAILED)
|
||||
raise
|
||||
|
||||
if print_warning and config.get("type", "") == "ExistingCloud":
|
||||
# credentials are stored in the list, but it contains one item.
|
||||
new_conf = dict(
|
||||
(name, cred[0])
|
||||
for name, cred in deployer._get_creds(config).items())
|
||||
LOG.warning(
|
||||
"The used config schema is deprecated since Rally 0.10.0. "
|
||||
"The new one is much simpler, try it now:\n%s",
|
||||
json.dumps(new_conf, indent=4)
|
||||
)
|
||||
|
||||
with deployer:
|
||||
credentials = deployer.make_deploy()
|
||||
deployment.update_credentials(credentials)
|
||||
@ -193,7 +214,16 @@ class _Deployment(APIGroup):
|
||||
@api_wrapper(path=API_REQUEST_PREFIX + "/deployment/get",
|
||||
method="GET")
|
||||
def get(self, deployment):
|
||||
return self._get(deployment).to_dict()
|
||||
deployment = self._get(deployment).to_dict()
|
||||
if deployment["config"].get("type", "") == "ExistingCloud":
|
||||
deployment_creds = {}
|
||||
for platform, creds in deployment["config"]["creds"].items():
|
||||
if isinstance(creds, dict):
|
||||
deployment_creds[platform] = creds
|
||||
else:
|
||||
deployment_creds[platform] = creds[0]
|
||||
deployment["config"] = deployment_creds
|
||||
return deployment
|
||||
|
||||
@api_wrapper(path=API_REQUEST_PREFIX + "/deployment/service_list",
|
||||
method="GET")
|
||||
|
@ -186,7 +186,8 @@ class ExistingCloud(engine.Engine):
|
||||
{
|
||||
"description": "List of credentials",
|
||||
"type": "array",
|
||||
"items": {"type": "object"}
|
||||
"items": {"type": "object"},
|
||||
"maxItems": 1,
|
||||
},
|
||||
]
|
||||
}
|
||||
@ -243,9 +244,6 @@ class ExistingCloud(engine.Engine):
|
||||
return credentials
|
||||
|
||||
def deploy(self):
|
||||
if "creds" not in self.config:
|
||||
LOG.warning("Old config schema is deprecated since Rally 0.10.0. "
|
||||
"Please use new config schema for ExistingCloud")
|
||||
creds_config = self._get_creds(self.config)
|
||||
parsed_credentials = {}
|
||||
for platform, config in creds_config.items():
|
||||
|
@ -1,20 +1,17 @@
|
||||
{
|
||||
"type": "ExistingCloud",
|
||||
"creds": {
|
||||
"openstack": {
|
||||
"auth_url": "http://example.net:5000/v3/",
|
||||
"region_name": "RegionOne",
|
||||
"endpoint_type": "public",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
"password": "myadminpass",
|
||||
"user_domain_name": "admin",
|
||||
"project_name": "admin",
|
||||
"project_domain_name": "admin"
|
||||
},
|
||||
"https_insecure": false,
|
||||
"https_cacert": "",
|
||||
"profiler_hmac_key": "SECRET_KEY"
|
||||
}
|
||||
"openstack": {
|
||||
"auth_url": "http://example.net:5000/v3/",
|
||||
"region_name": "RegionOne",
|
||||
"endpoint_type": "public",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
"password": "myadminpass",
|
||||
"user_domain_name": "admin",
|
||||
"project_name": "admin",
|
||||
"project_domain_name": "admin"
|
||||
},
|
||||
"https_insecure": false,
|
||||
"https_cacert": "",
|
||||
"profiler_hmac_key": "SECRET_KEY"
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,16 @@
|
||||
{
|
||||
"type": "ExistingCloud",
|
||||
"creds": {
|
||||
"openstack": {
|
||||
"auth_url": "http://example.net:5000/v3/",
|
||||
"region_name": "RegionOne",
|
||||
"endpoint_type": "public",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
"password": "myadminpass",
|
||||
"user_domain_name": "admin",
|
||||
"project_name": "admin",
|
||||
"project_domain_name": "admin"
|
||||
},
|
||||
"https_insecure": false,
|
||||
"https_cacert": ""
|
||||
}
|
||||
"openstack": {
|
||||
"auth_url": "http://example.net:5000/v3/",
|
||||
"region_name": "RegionOne",
|
||||
"endpoint_type": "public",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
"password": "myadminpass",
|
||||
"user_domain_name": "admin",
|
||||
"project_name": "admin",
|
||||
"project_domain_name": "admin"
|
||||
},
|
||||
"https_insecure": false,
|
||||
"https_cacert": ""
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,15 @@
|
||||
{
|
||||
"type": "ExistingCloud",
|
||||
"creds": {
|
||||
"openstack": {
|
||||
"auth_url": "http://example.net:5000/v2.0/",
|
||||
"region_name": "RegionOne",
|
||||
"endpoint_type": "public",
|
||||
"endpoint": "http://<public-identity-url-ip>:<mgmt-port>/<version>/ example: http://172.16.0.2:35357/v2.0/",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
"password": "pa55word",
|
||||
"tenant_name": "demo"
|
||||
},
|
||||
"https_insecure": false,
|
||||
"https_cacert": ""
|
||||
}
|
||||
"openstack": {
|
||||
"auth_url": "http://example.net:5000/v2.0/",
|
||||
"region_name": "RegionOne",
|
||||
"endpoint_type": "public",
|
||||
"endpoint": "http://<public-identity-url-ip>:<mgmt-port>/<version>/ example: http://172.16.0.2:35357/v2.0/",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
"password": "pa55word",
|
||||
"tenant_name": "demo"
|
||||
},
|
||||
"https_insecure": false,
|
||||
"https_cacert": ""
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +1,24 @@
|
||||
{
|
||||
"type": "ExistingCloud",
|
||||
"creds": {
|
||||
"openstack": {
|
||||
"auth_url": "http://example.net:5000/v2.0/",
|
||||
"region_name": "RegionOne",
|
||||
"endpoint_type": "public",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
"password": "pa55word",
|
||||
"tenant_name": "demo"
|
||||
"openstack": {
|
||||
"auth_url": "http://example.net:5000/v2.0/",
|
||||
"region_name": "RegionOne",
|
||||
"endpoint_type": "public",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
"password": "pa55word",
|
||||
"tenant_name": "demo"
|
||||
},
|
||||
"users": [
|
||||
{
|
||||
"username": "not_an_admin1",
|
||||
"password": "password",
|
||||
"tenant_name": "some_tenant"
|
||||
},
|
||||
"users": [
|
||||
{
|
||||
"username": "not_an_admin1",
|
||||
"password": "password",
|
||||
"tenant_name": "some_tenant"
|
||||
},
|
||||
{
|
||||
"username": "not_an_admin2",
|
||||
"password": "password2",
|
||||
"tenant_name": "some_tenant2"
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
"username": "not_an_admin2",
|
||||
"password": "password2",
|
||||
"tenant_name": "some_tenant2"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,14 @@
|
||||
{
|
||||
"type": "ExistingCloud",
|
||||
"creds": {
|
||||
"openstack": {
|
||||
"auth_url": "http://example.net:5000/v2.0/",
|
||||
"region_name": "RegionOne",
|
||||
"endpoint_type": "public",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
"password": "myadminpass",
|
||||
"tenant_name": "demo"
|
||||
},
|
||||
"https_insecure": false,
|
||||
"https_cacert": ""
|
||||
}
|
||||
"openstack": {
|
||||
"auth_url": "http://example.net:5000/v2.0/",
|
||||
"region_name": "RegionOne",
|
||||
"endpoint_type": "public",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
"password": "myadminpass",
|
||||
"tenant_name": "demo"
|
||||
},
|
||||
"https_insecure": false,
|
||||
"https_cacert": ""
|
||||
}
|
||||
}
|
||||
|
@ -70,8 +70,7 @@ class TestTaskSamples(unittest.TestCase):
|
||||
user_ctx.setup()
|
||||
self.addCleanup(user_ctx.cleanup)
|
||||
|
||||
config = deployment["config"]
|
||||
os_creds = config["creds"]["openstack"]
|
||||
os_creds = deployment["config"]["creds"]["openstack"]
|
||||
|
||||
user = copy.copy(os_creds["admin"])
|
||||
user["username"] = ctx["users"][0]["credential"].username
|
||||
@ -81,12 +80,12 @@ class TestTaskSamples(unittest.TestCase):
|
||||
user["project_name"] = ctx["users"][0]["credential"].tenant_name
|
||||
else:
|
||||
user["tenant_name"] = ctx["users"][0]["credential"].tenant_name
|
||||
config["creds"]["openstack"]["users"] = [user]
|
||||
os_creds["users"] = [user]
|
||||
|
||||
rally("deployment destroy MAIN", write_report=False)
|
||||
deployment_cfg = os.path.join(rally.tmp_dir, "new_deployment.json")
|
||||
with open(deployment_cfg, "w") as f:
|
||||
f.write(json.dumps(config))
|
||||
f.write(json.dumps({"openstack": os_creds}))
|
||||
rally("deployment create --name MAIN --filename %s" % deployment_cfg,
|
||||
write_report=False)
|
||||
|
||||
|
@ -516,7 +516,7 @@ def main():
|
||||
out = subprocess.check_output(["rally", "deployment", "config",
|
||||
"--deployment", "devstack"])
|
||||
config = json.loads(out if six.PY2 else out.decode("utf-8"))
|
||||
config = config["creds"]["openstack"]
|
||||
config = config["openstack"]
|
||||
config.update(config.pop("admin"))
|
||||
if "users" in config:
|
||||
del config["users"]
|
||||
|
@ -73,25 +73,22 @@ function setUp () {
|
||||
|
||||
echo '
|
||||
{
|
||||
"type": "ExistingCloud",
|
||||
"creds": {
|
||||
"openstack": {
|
||||
"users": [
|
||||
{"username": "rally-test-user-1",
|
||||
"password": "rally-test-password-1",
|
||||
"project_name": "rally-test-project-1",
|
||||
"user_domain_name": "Default",
|
||||
"project_domain_name": "Default"
|
||||
},
|
||||
{"username": "rally-test-user-2",
|
||||
"password": "rally-test-password-2",
|
||||
"project_name": "rally-test-project-2",
|
||||
"user_domain_name": "Default",
|
||||
"project_domain_name": "Default"
|
||||
}],
|
||||
"auth_url": "'$OS_AUTH_URL'",
|
||||
"region_name": "RegionOne"
|
||||
}
|
||||
"openstack": {
|
||||
"users": [
|
||||
{"username": "rally-test-user-1",
|
||||
"password": "rally-test-password-1",
|
||||
"project_name": "rally-test-project-1",
|
||||
"user_domain_name": "Default",
|
||||
"project_domain_name": "Default"
|
||||
},
|
||||
{"username": "rally-test-user-2",
|
||||
"password": "rally-test-password-2",
|
||||
"project_name": "rally-test-project-2",
|
||||
"user_domain_name": "Default",
|
||||
"project_domain_name": "Default"
|
||||
}],
|
||||
"auth_url": "'$OS_AUTH_URL'",
|
||||
"region_name": "RegionOne"
|
||||
}
|
||||
}
|
||||
' > $DEPLOYMENT_CONFIG_FILE
|
||||
|
@ -32,7 +32,7 @@ sed -i.bak "s|#connection =.*|connection = \"$DBCONNSTRING\"|" $TMP_RALLY_CONF
|
||||
rally-manage --config-file $TMP_RALLY_CONF db create
|
||||
|
||||
# Create self deployment
|
||||
echo '{"type": "ExistingCloud", "creds": {}}' > $TMP_RALLY_DEPLOYMENT
|
||||
echo '{}' > $TMP_RALLY_DEPLOYMENT
|
||||
$RALLY -d deployment create --file=$TMP_RALLY_DEPLOYMENT --name=self
|
||||
|
||||
# Run task
|
||||
|
@ -34,18 +34,19 @@ from tests.unit import test
|
||||
FAKE_DEPLOYMENT_CONFIG = {
|
||||
# TODO(akscram): A fake engine is more suitable for that.
|
||||
"type": "ExistingCloud",
|
||||
"auth_url": "http://example.net:5000/v2.0/",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
"password": "myadminpass",
|
||||
"tenant_name": "demo",
|
||||
"domain_name": None,
|
||||
"project_domain_name": "Default",
|
||||
"user_domain_name": "Default",
|
||||
"profiler_hmac_key": None
|
||||
},
|
||||
"region_name": "RegionOne",
|
||||
"endpoint_type": consts.EndpointType.INTERNAL,
|
||||
"creds": {"openstack": {
|
||||
"auth_url": "http://example.net:5000/v2.0/",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
"password": "myadminpass",
|
||||
"tenant_name": "demo",
|
||||
"domain_name": None,
|
||||
"project_domain_name": "Default",
|
||||
"user_domain_name": "Default",
|
||||
"profiler_hmac_key": None
|
||||
},
|
||||
"region_name": "RegionOne",
|
||||
"endpoint_type": consts.EndpointType.INTERNAL}}
|
||||
}
|
||||
|
||||
|
||||
@ -610,8 +611,8 @@ class BaseDeploymentTestCase(test.TestCase):
|
||||
self.deployment_inst = api._Deployment(mock_api)
|
||||
self.deployment_config = copy.deepcopy(FAKE_DEPLOYMENT_CONFIG)
|
||||
self.deployment_uuid = "599bdf1d-fe77-461a-a810-d59b1490f4e3"
|
||||
admin_credential = copy.deepcopy(FAKE_DEPLOYMENT_CONFIG)
|
||||
admin_credential.pop("type")
|
||||
creds = copy.deepcopy(FAKE_DEPLOYMENT_CONFIG)["creds"]
|
||||
admin_credential = creds["openstack"]
|
||||
admin_credential["endpoint"] = None
|
||||
admin_credential.update(admin_credential.pop("admin"))
|
||||
admin_credential["permission"] = consts.EndpointPermission.ADMIN
|
||||
@ -719,12 +720,14 @@ class DeploymentAPITestCase(BaseDeploymentTestCase):
|
||||
mock_deployment_get.return_value = self.deployment
|
||||
mock_deployment_update.return_value = self.deployment
|
||||
config = copy.deepcopy(self.deployment_config)
|
||||
config["admin"] = {"username": "admin",
|
||||
"password": "pass1",
|
||||
"tenant_name": "demo"}
|
||||
config["users"] = [{"username": "user1",
|
||||
"password": "pass2",
|
||||
"tenant_name": "demo"}]
|
||||
config["creds"]["openstack"]["admin"] = {
|
||||
"username": "admin",
|
||||
"password": "pass1",
|
||||
"tenant_name": "demo"}
|
||||
config["creds"]["openstack"]["users"] = [
|
||||
{"username": "user1",
|
||||
"password": "pass2",
|
||||
"tenant_name": "demo"}]
|
||||
|
||||
self.deployment_inst.recreate(deployment=self.deployment_uuid,
|
||||
config=config)
|
||||
@ -767,7 +770,10 @@ class DeploymentAPITestCase(BaseDeploymentTestCase):
|
||||
mock_deployment_get.return_value = self.deployment
|
||||
ret = self.deployment_inst.get(deployment=deployment_id)
|
||||
for key in self.deployment:
|
||||
self.assertEqual(ret[key], self.deployment[key])
|
||||
self.assertIn(key, ret)
|
||||
if key != "config":
|
||||
self.assertEqual(self.deployment[key], ret[key])
|
||||
self.assertEqual(self.deployment_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