From 3f6d22857f116d6dba192aadcc128b2d0248bdda Mon Sep 17 00:00:00 2001 From: Sergey Vasilenko Date: Tue, 29 Apr 2014 16:35:51 +0400 Subject: [PATCH] add possibility of using public_urls for benchmarking Add 'use_public_urls' option to the deployment config This option will be used later for switching access method to the cloud. Because in some use-cases cloud may be accessible only by public endpoints. Add 'admin_port' option to the deployment config This option defines administrative keystone port on the public network. Closes-Bug: #1306448 Change-Id: Ifb838c5fe9eab5e81353d697aa747bd8adf77572 --- rally/cmd/commands/deployment.py | 2 +- rally/deploy/engines/existing.py | 16 ++++++++++++++-- rally/objects/endpoint.py | 8 ++++++-- rally/osclients.py | 12 ++++++++++++ tests/deploy/engines/test_existing.py | 2 ++ tests/objects/test_endpoint.py | 3 ++- tests/orchestrator/test_api.py | 4 +++- 7 files changed, 40 insertions(+), 7 deletions(-) diff --git a/rally/cmd/commands/deployment.py b/rally/cmd/commands/deployment.py index 84f56de9f1..1500009743 100644 --- a/rally/cmd/commands/deployment.py +++ b/rally/cmd/commands/deployment.py @@ -152,7 +152,7 @@ class DeploymentCommands(object): :param deploy_id: a UUID of the deployment """ headers = ['auth_url', 'username', 'password', 'tenant_name', - 'region_name'] + 'region_name', 'use_public_urls', 'admin_port'] table = prettytable.PrettyTable(headers) endpoints = db.deployment_get(deploy_id)['endpoints'] for ep in endpoints: diff --git a/rally/deploy/engines/existing.py b/rally/deploy/engines/existing.py index ddd67a5e4a..5630bc6bb7 100644 --- a/rally/deploy/engines/existing.py +++ b/rally/deploy/engines/existing.py @@ -30,7 +30,9 @@ class ExistingCloud(engine.EngineFactory): "username": "admin", "password": "password", "tenant_name": "demo", - "region_name": "RegionOne" + "region_name": "RegionOne", + "use_public_urls": False, + "keystone_admin_port": 35357 } } @@ -48,6 +50,12 @@ class ExistingCloud(engine.EngineFactory): 'password': {'type': 'string'}, 'tenant_name': {'type': 'string'}, 'region_name': {'type': 'string'}, + 'use_public_urls': {'type': 'boolean'}, + 'admin_port': { + 'type': 'integer', + 'minimum': 2, + 'maximum': 65535 + } }, 'required': ['auth_url', 'username', 'password', 'tenant_name'], @@ -63,7 +71,11 @@ class ExistingCloud(engine.EngineFactory): endpoint_dict['password'], endpoint_dict['tenant_name'], consts.EndpointPermission.ADMIN, - endpoint_dict.get('region_name')) + endpoint_dict.get('region_name'), + endpoint_dict.get('use_public_urls', + False), + endpoint_dict.get('admin_port', + 35357)) return [admin_endpoint] def cleanup(self): diff --git a/rally/objects/endpoint.py b/rally/objects/endpoint.py index 732a5fcb29..e9a6d1ee26 100644 --- a/rally/objects/endpoint.py +++ b/rally/objects/endpoint.py @@ -20,18 +20,22 @@ class Endpoint(object): def __init__(self, auth_url, username, password, tenant_name, permission=consts.EndpointPermission.USER, - region_name=None): + region_name=None, use_public_urls=False, admin_port=35357): self.auth_url = auth_url self.username = username self.password = password self.tenant_name = tenant_name self.permission = permission self.region_name = region_name + self.use_public_urls = use_public_urls + self.admin_port = admin_port def to_dict(self, include_permission=False): dct = {"auth_url": self.auth_url, "username": self.username, "password": self.password, "tenant_name": self.tenant_name, - "region_name": self.region_name} + "region_name": self.region_name, + "use_public_urls": self.use_public_urls, + "admin_port": self.admin_port} if include_permission: dct["permission"] = self.permission return dct diff --git a/rally/osclients.py b/rally/osclients.py index a43b9951b3..10b5b8def3 100644 --- a/rally/osclients.py +++ b/rally/osclients.py @@ -22,6 +22,7 @@ from keystoneclient.v2_0 import client as keystone from neutronclient.neutron import client as neutron from novaclient import client as nova from oslo.config import cfg +import urlparse from rally import exceptions @@ -74,6 +75,17 @@ class Clients(object): "insecure": CONF.https_insecure, "cacert": CONF.https_cacert } kw = dict(self.endpoint.to_dict().items() + new_kw.items()) + if kw["use_public_urls"]: + mgmt_url = urlparse.urlparse(kw["auth_url"]) + if mgmt_url.port != kw["admin_port"]: + kw["endpoint"] = "{0}://{1}:{2}{3}".format( + mgmt_url.scheme, + mgmt_url.hostname, + kw["admin_port"], + mgmt_url.path + ) + else: + kw["endpoint"] = kw["auth_url"] client = keystone.Client(**kw) client.authenticate() return client diff --git a/tests/deploy/engines/test_existing.py b/tests/deploy/engines/test_existing.py index 73f6113072..d1c1662600 100644 --- a/tests/deploy/engines/test_existing.py +++ b/tests/deploy/engines/test_existing.py @@ -33,6 +33,8 @@ class TestExistingCloud(test.TestCase): 'password': 'myadminpass', 'tenant_name': 'demo', 'region_name': 'RegionOne', + 'use_public_urls': False, + 'admin_port': 35357 }, }, } diff --git a/tests/objects/test_endpoint.py b/tests/objects/test_endpoint.py index 8275c000ec..f1d7706c01 100644 --- a/tests/objects/test_endpoint.py +++ b/tests/objects/test_endpoint.py @@ -24,4 +24,5 @@ class EndpointTestCase(test.TestCase): self.assertEqual(endpoint.to_dict(include_permission=True), {"auth_url": "url", "username": "user", "password": "pwd", "tenant_name": "tenant", - "region_name": None, "permission": "admin"}) + "region_name": None, "permission": "admin", + "use_public_urls": False, 'admin_port': 35357}) diff --git a/tests/orchestrator/test_api.py b/tests/orchestrator/test_api.py index 7082c85569..f24ab0bb12 100644 --- a/tests/orchestrator/test_api.py +++ b/tests/orchestrator/test_api.py @@ -32,7 +32,9 @@ FAKE_DEPLOY_CONFIG = { 'username': 'admin', 'password': 'myadminpass', 'tenant_name': 'demo', - 'region_name': 'RegionOne' + 'region_name': 'RegionOne', + 'use_public_urls': False, + 'admin_port': 35357, }, }