From 8207d9dd43394f7ddc794c4715ea359eaa0363ed Mon Sep 17 00:00:00 2001 From: Yair Fried Date: Sun, 22 Mar 2015 15:37:12 +0200 Subject: [PATCH] Adds endpoint to --fromenv deployment creation Will read os-endpoint from environment variables. Fixes some typos in related docstring as well. Change-Id: I853a181130b7da885392211515784bdf93249774 --- rally/cmd/commands/deployment.py | 10 ++++++++-- tests/unit/cmd/commands/test_deployment.py | 7 ++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/rally/cmd/commands/deployment.py b/rally/cmd/commands/deployment.py index f9daaf3398..3eda750693 100644 --- a/rally/cmd/commands/deployment.py +++ b/rally/cmd/commands/deployment.py @@ -59,12 +59,14 @@ class DeploymentCommands(object): for you with Devstack or Fuel. For this purposes different deployment engines are developed. - If you use ExistionCloud deployment engine you can pass deployment + If you use ExistingCloud deployment engine you can pass deployment config by environment variables: OS_USERNAME OS_PASSWORD OS_AUTH_URL OS_TENANT_NAME + OS_ENDPOINT + OS_REGION_NAME All other deployment engines need more complex configuration data, so it should be stored in configuration file. @@ -72,7 +74,7 @@ class DeploymentCommands(object): You can use physical servers, lxc containers, KVM virtual machines or virtual machines in OpenStack for deploying the cloud in. Except physical servers, Rally can create cluster nodes for you. - Interaction with virtualisation software, OpenStack + Interaction with virtualization software, OpenStack cloud or physical servers is provided by server providers. :param fromenv: boolean, read environment instead of config file @@ -94,6 +96,7 @@ class DeploymentCommands(object): config = { "type": "ExistingCloud", "auth_url": os.environ["OS_AUTH_URL"], + "endpoint": os.environ.get("OS_ENDPOINT"), "admin": { "username": os.environ["OS_USERNAME"], "password": os.environ["OS_PASSWORD"], @@ -266,6 +269,9 @@ class DeploymentCommands(object): if endpoint.get("region_name"): env_file.write("export OS_REGION_NAME=%(region_name)s\n" % endpoint) + if endpoint.get("endpoint"): + env_file.write("export OS_ENDPOINT=%(endpoint)s\n" + % endpoint) expanded_path = os.path.expanduser("~/.rally/openrc") if os.path.exists(expanded_path): os.remove(expanded_path) diff --git a/tests/unit/cmd/commands/test_deployment.py b/tests/unit/cmd/commands/test_deployment.py index 72989e2c4e..abeb0cf0d1 100644 --- a/tests/unit/cmd/commands/test_deployment.py +++ b/tests/unit/cmd/commands/test_deployment.py @@ -45,6 +45,7 @@ class DeploymentCommandsTestCase(test.TestCase): "OS_PASSWORD": "fake_password", "OS_TENANT_NAME": "fake_tenant_name", "OS_REGION_NAME": "fake_region_name", + "OS_ENDPOINT": "fake_endpoint", "RALLY_DEPLOYMENT": "fake_deployment_id"}) @mock.patch("rally.cmd.commands.deployment.api.Deployment.create") @mock.patch("rally.cmd.commands.deployment.DeploymentCommands.list") @@ -55,6 +56,7 @@ class DeploymentCommandsTestCase(test.TestCase): "type": "ExistingCloud", "auth_url": "fake_auth_url", "region_name": "fake_region_name", + "endpoint": "fake_endpoint", "admin": { "username": "fake_username", "password": "fake_password", @@ -221,6 +223,7 @@ class DeploymentCommandsTestCase(test.TestCase): "username": "fake_username", "password": "fake_password", "tenant_name": "fake_tenant_name", + "endpoint": "fake_endpoint", "region_name": None} with mock.patch("rally.cmd.commands.deployment.open", mock.mock_open(), @@ -230,7 +233,9 @@ class DeploymentCommandsTestCase(test.TestCase): mock_env.assert_called_once_with(os.path.expanduser( "~/.rally/globals"), "RALLY_DEPLOYMENT", "%s\n" % deployment_id) - mock_file.return_value.write.assert_called_once_with( + mock_file.return_value.write.assert_any_call( + "export OS_ENDPOINT=fake_endpoint\n") + mock_file.return_value.write.assert_any_call( "export OS_AUTH_URL=fake_auth_url\n" "export OS_USERNAME=fake_username\n" "export OS_PASSWORD=fake_password\n"