Fixes LP #920782 - Malformed request URL

Sometime recently, the tenant ID instead of the tenant Name
was used in Compute URLs, and we were appending the tenant Name
to the management URL returned from Keystone improperly.

This patch grabs the tenant ID from the returned management URl
and appends the tenant ID instead of the tenant Name.

Change-Id: I4d4d23b3722c5c67463592397c5b23c5f3281c30
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index ea09cc0..357bbd8 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -68,6 +68,11 @@
             for ep in auth_data['serviceCatalog']:
                 if ep["name"] == service:
                     mgmt_url = ep['endpoints'][0]['publicURL']
+                    # See LP#920817. The tenantId is *supposed*
+                    # to be returned for each endpoint accorsing to the
+                    # Keystone spec. But... it isn't, so we have to parse
+                    # the tenant ID out of hte public URL :(
+                    tenant_id = mgmt_url.split('/')[-1]
                     break
 
             if mgmt_url == None:
@@ -77,7 +82,7 @@
             #Need to join strings more cleanly
             temp = mgmt_url.rsplit('/')
             service_url = temp[0] + '//' + temp[2] + '/' + temp[3] + '/'
-            management_url = service_url + tenant_name
+            management_url = service_url + tenant_id
             return token, management_url
         elif resp.status == 401:
             raise exceptions.AuthenticationFailure(user=user, password=api_key)