Fix rally deployment check fails with https auth_url

When create keystone client, rally will add admin_port(35357) to
auth_url if auth_url doesn't contain an obvious port. And thus,
causing the change of https auth_url.

So we should ignore adding admin_port for https auth_url.

Change-Id: If518687839c5e0734b85b69c680f7d124e135e94
Closes-bug: #1397160
This commit is contained in:
fandeliang 2014-11-28 00:10:05 -08:00
parent 80e20252f3
commit 1a302df237
2 changed files with 17 additions and 1 deletions

View File

@ -99,7 +99,8 @@ class Clients(object):
kw = dict(self.endpoint.to_dict().items() + new_kw.items())
if kw["endpoint_type"] == consts.EndpointType.PUBLIC:
mgmt_url = urlparse.urlparse(kw["auth_url"])
if mgmt_url.port != kw["admin_port"]:
if (mgmt_url.port != kw["admin_port"] and
mgmt_url.scheme != "https"):
kw["endpoint"] = "{0}://{1}:{2}{3}".format(
mgmt_url.scheme,
mgmt_url.hostname,

View File

@ -33,7 +33,10 @@ class OSClientsTestCase(test.TestCase):
super(OSClientsTestCase, self).setUp()
self.endpoint = endpoint.Endpoint("http://auth_url", "use", "pass",
"tenant")
self.endpoint_https = endpoint.Endpoint("https://auth_url/v2.0/admin",
"use", "pass", "tenant")
self.clients = osclients.Clients(self.endpoint)
self.clients_https = osclients.Clients(self.endpoint_https)
self.fake_keystone = fakes.FakeKeystoneClient()
self.fake_keystone.auth_token = mock.MagicMock()
@ -64,6 +67,18 @@ class OSClientsTestCase(test.TestCase):
self.mock_create_keystone_client.assert_called_once_with(kwargs)
self.assertEqual(self.clients.cache["keystone"], self.fake_keystone)
def test_keystone_with_https_auth_url(self):
self.assertNotIn("keystone", self.clients_https.cache)
client = self.clients_https.keystone()
self.assertEqual(client, self.fake_keystone)
endpoint = {"timeout": cfg.CONF.openstack_client_http_timeout,
"insecure": False, "cacert": None,
"endpoint": self.endpoint_https.auth_url}
kwargs = dict(self.endpoint_https.to_dict().items() + endpoint.items())
self.mock_create_keystone_client.assert_called_once_with(kwargs)
self.assertEqual(self.clients_https.cache["keystone"],
self.fake_keystone)
@mock.patch("rally.osclients.Clients.keystone")
def test_verified_keystone_user_not_admin(self, mock_keystone):
mock_keystone.return_value = fakes.FakeKeystoneClient()