From 75088205f1e7b491c83f3638aef35995f1afab92 Mon Sep 17 00:00:00 2001 From: Alex Tomic Date: Fri, 13 Mar 2015 15:55:35 +0100 Subject: [PATCH] Change nova_proxy_admin_tenant_name to id The task manager can be configured with periodic events that check for the existence of running nova instances. The events run via a separate admin connection to nova. Taskmanager.Manager populates the admin client context with the tenant name provided by nova_proxy_admin_tenant_name parameter instead of the uuid, which results in an invalid management url that is composed of the two parameters: /. Changing tenant_name to tenant_id results in a valid endpoint. DocImpact deprecating option 'nova_proxy_admin_tenant_name' to 'nova_proxy_admin_tenant_id' Change-Id: Ia1315e41288ab1b24ac402bad15176cb1ae0e5cd Co-Authored-By: Li Ma Closes-Bug: #1289101 --- etc/trove/trove-taskmanager.conf.sample | 2 +- etc/trove/trove.conf.test | 2 +- trove/common/cfg.py | 5 +++-- trove/taskmanager/manager.py | 2 +- trove/tests/unittests/common/test_remote.py | 17 +++++++++-------- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/etc/trove/trove-taskmanager.conf.sample b/etc/trove/trove-taskmanager.conf.sample index a805341b79..a15613104c 100644 --- a/etc/trove/trove-taskmanager.conf.sample +++ b/etc/trove/trove-taskmanager.conf.sample @@ -112,7 +112,7 @@ use_nova_server_config_drive = False # basically acting like the client via that proxy token. nova_proxy_admin_user = admin nova_proxy_admin_pass = 3de4922d8b6ac5a1aad9 -nova_proxy_admin_tenant_name = admin +nova_proxy_admin_tenant_id = # Manager impl for the taskmanager taskmanager_manager=trove.taskmanager.manager.Manager diff --git a/etc/trove/trove.conf.test b/etc/trove/trove.conf.test index b56c6bfedc..339484f67c 100644 --- a/etc/trove/trove.conf.test +++ b/etc/trove/trove.conf.test @@ -69,7 +69,7 @@ db_api_implementation = trove.db.sqlalchemy.api # basically acting like the client via that proxy token. nova_proxy_admin_user = admin nova_proxy_admin_pass = 3de4922d8b6ac5a1aad9 -nova_proxy_admin_tenant_name = admin +nova_proxy_admin_tenant_id = trove_auth_url = http://0.0.0.0:5000/v2.0 nova_region_name = RegionOne diff --git a/trove/common/cfg.py b/trove/common/cfg.py index e0d31cfccd..ecb064f5c3 100644 --- a/trove/common/cfg.py +++ b/trove/common/cfg.py @@ -331,8 +331,9 @@ common_opts = [ help="Admin username used to connect to Nova.", secret=True), cfg.StrOpt('nova_proxy_admin_pass', default='', help="Admin password used to connect to Nova.", secret=True), - cfg.StrOpt('nova_proxy_admin_tenant_name', default='', - help="Admin tenant used to connect to Nova.", secret=True), + cfg.StrOpt('nova_proxy_admin_tenant_id', default='', + deprecated_name='nova_proxy_admin_tenant_name', + help="Admin tenant ID used to connect to Nova.", secret=True), cfg.StrOpt('network_label_regex', default='^private$', help='Regular expression to match Trove network labels.'), cfg.StrOpt('ip_regex', default=None, diff --git a/trove/taskmanager/manager.py b/trove/taskmanager/manager.py index 1a21dee3af..a51458ae29 100644 --- a/trove/taskmanager/manager.py +++ b/trove/taskmanager/manager.py @@ -41,7 +41,7 @@ class Manager(periodic_task.PeriodicTasks): self.admin_context = TroveContext( user=CONF.nova_proxy_admin_user, auth_token=CONF.nova_proxy_admin_pass, - tenant=CONF.nova_proxy_admin_tenant_name) + tenant=CONF.nova_proxy_admin_tenant_id) if CONF.exists_notification_transformer: self.exists_transformer = importutils.import_object( CONF.exists_notification_transformer, diff --git a/trove/tests/unittests/common/test_remote.py b/trove/tests/unittests/common/test_remote.py index a5a5512a5c..1d05da5b07 100644 --- a/trove/tests/unittests/common/test_remote.py +++ b/trove/tests/unittests/common/test_remote.py @@ -21,6 +21,7 @@ import testtools from testtools import matchers import swiftclient.client +import uuid from trove.tests.fakes.swift import SwiftClientStub from trove.common.context import TroveContext @@ -49,7 +50,7 @@ class TestRemote(testtools.TestCase): 'publicURL': 'example.com'}], 'type': 'object-store'}] client = remote.create_swift_client(TroveContext( - tenant='123', + tenant=uuid.uuid4().hex, service_catalog=service_catalog)) headers, container = client.get_container('bob') self.assertIs(headers, "text") @@ -287,7 +288,7 @@ class TestCreateCinderClient(testtools.TestCase): def test_create_with_conf_override(self): cinder_url_from_conf = 'http://example.com' - tenant_from_ctx = 'abc' + tenant_from_ctx = uuid.uuid4().hex cfg.CONF.set_override('cinder_url', cinder_url_from_conf) client = remote.create_cinder_client( @@ -297,7 +298,7 @@ class TestCreateCinderClient(testtools.TestCase): def test_create_with_conf_override_trailing_slash(self): cinder_url_from_conf = 'http://example.com/' - tenant_from_ctx = 'abc' + tenant_from_ctx = uuid.uuid4().hex cfg.CONF.set_override('cinder_url', cinder_url_from_conf) client = remote.create_cinder_client( TroveContext(tenant=tenant_from_ctx)) @@ -362,7 +363,7 @@ class TestCreateNovaClient(testtools.TestCase): def test_create_with_conf_override(self): nova_url_from_conf = 'http://example.com' - tenant_from_ctx = 'abc' + tenant_from_ctx = uuid.uuid4().hex cfg.CONF.set_override('nova_compute_url', nova_url_from_conf) client = remote.create_nova_client( @@ -372,7 +373,7 @@ class TestCreateNovaClient(testtools.TestCase): def test_create_with_conf_override_trailing_slash(self): nova_url_from_conf = 'http://example.com/' - tenant_from_ctx = 'abc' + tenant_from_ctx = uuid.uuid4().hex cfg.CONF.set_override('nova_compute_url', nova_url_from_conf) client = remote.create_nova_client( TroveContext(tenant=tenant_from_ctx)) @@ -437,7 +438,7 @@ class TestCreateHeatClient(testtools.TestCase): def test_create_with_conf_override(self): heat_url_from_conf = 'http://example.com' - tenant_from_ctx = 'abc' + tenant_from_ctx = uuid.uuid4().hex cfg.CONF.set_override('heat_url', heat_url_from_conf) client = remote.create_heat_client( @@ -447,7 +448,7 @@ class TestCreateHeatClient(testtools.TestCase): def test_create_with_conf_override_trailing_slash(self): heat_url_from_conf = 'http://example.com/' - tenant_from_ctx = 'abc' + tenant_from_ctx = uuid.uuid4().hex cfg.CONF.set_override('heat_url', heat_url_from_conf) client = remote.create_heat_client( TroveContext(tenant=tenant_from_ctx)) @@ -512,7 +513,7 @@ class TestCreateSwiftClient(testtools.TestCase): def test_create_with_conf_override(self): swift_url_from_conf = 'http://example.com/AUTH_' - tenant_from_ctx = 'abc' + tenant_from_ctx = uuid.uuid4().hex cfg.CONF.set_override('swift_url', swift_url_from_conf) client = remote.create_swift_client(