From 57d2a22dfd1db37d1dc5b5b4ae4e5a7b20c3d5da Mon Sep 17 00:00:00 2001 From: Andrey Kurilin Date: Mon, 21 Aug 2017 18:57:09 +0300 Subject: [PATCH] Simplify deployment config format There is upgoing work related to deployment refactoring. The bunch of different enitities will be removed and inner code will be rewritten almost from scratch. This patch introduces a new simpler dedployment config format. Despite the fact that it requires several workarounds, we need to merge it before actual refactoring is done, since we want to provide a good deprecation period and as quicker we introduce a new format as quicker we will able to remove deprecated stuff:) An example of old deployment config: { "type": "ExistingCloud", "creds": { "openstack": { "auth_url": "https://example.com", "admin": { "username": "admin", "password": "pass", "project_name": "admin" } } } } An example of a new format: { "openstack": { "auth_url": "https://example.com", "admin": { "username": "admin", "password": "pass", "project_name": "admin" } } } Change-Id: If88317a0aefdd3d1adc6c380672d83e2bad11f15 --- devstack/lib/rally | 38 +++++++--------- .../existing-keystone-v3-osprofiler.json | 31 ++++++------- samples/deployments/existing-keystone-v3.json | 29 ++++++------- .../existing-with-given-endpoint.json | 27 ++++++------ .../existing-with-predefined-users.json | 43 +++++++++---------- samples/deployments/existing.json | 25 +++++------ tests/check_samples/test_task_samples.py | 7 ++- tests/ci/osresources.py | 2 +- tests/ci/rally_gate_functions.sh | 35 +++++++-------- tests/ci/rally_self_job.sh | 2 +- 10 files changed, 107 insertions(+), 132 deletions(-) diff --git a/devstack/lib/rally b/devstack/lib/rally index e2c03c58..4a0f4b00 100644 --- a/devstack/lib/rally +++ b/devstack/lib/rally @@ -49,16 +49,13 @@ if [[ "$IDENTITY_API_VERSION" == 2.0 ]] then cat >$1 <$1 <:// 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://:// example: http://172.16.0.2:35357/v2.0/", + "admin": { + "username": "admin", + "password": "pa55word", + "tenant_name": "demo" + }, + "https_insecure": false, + "https_cacert": "" } } diff --git a/samples/deployments/existing-with-predefined-users.json b/samples/deployments/existing-with-predefined-users.json index 1b961436..d34d1952 100644 --- a/samples/deployments/existing-with-predefined-users.json +++ b/samples/deployments/existing-with-predefined-users.json @@ -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" + } + ] } } diff --git a/samples/deployments/existing.json b/samples/deployments/existing.json index 53e12f0d..24951a75 100644 --- a/samples/deployments/existing.json +++ b/samples/deployments/existing.json @@ -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": "" } } diff --git a/tests/check_samples/test_task_samples.py b/tests/check_samples/test_task_samples.py index 588684a1..fad1898b 100644 --- a/tests/check_samples/test_task_samples.py +++ b/tests/check_samples/test_task_samples.py @@ -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) diff --git a/tests/ci/osresources.py b/tests/ci/osresources.py index 2be0a537..fc590f13 100755 --- a/tests/ci/osresources.py +++ b/tests/ci/osresources.py @@ -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"] diff --git a/tests/ci/rally_gate_functions.sh b/tests/ci/rally_gate_functions.sh index b7e98226..dc4ed5ab 100644 --- a/tests/ci/rally_gate_functions.sh +++ b/tests/ci/rally_gate_functions.sh @@ -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 diff --git a/tests/ci/rally_self_job.sh b/tests/ci/rally_self_job.sh index 6ee43f1b..5960c65b 100755 --- a/tests/ci/rally_self_job.sh +++ b/tests/ci/rally_self_job.sh @@ -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