From 2f1e0299e84b7e3acfdb0c927025a84ae4c0704c Mon Sep 17 00:00:00 2001 From: Brian Rosmaita Date: Mon, 10 Sep 2012 19:19:20 +0000 Subject: [PATCH] Corrects URI to display hostname, port properly Fixes bug 1035931 Change-Id: I1b4e8a226c21d137b24bc5b75299bcf4ab4efefb --- glanceclient/v1/legacy_shell.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/glanceclient/v1/legacy_shell.py b/glanceclient/v1/legacy_shell.py index b6f3903..56bce65 100644 --- a/glanceclient/v1/legacy_shell.py +++ b/glanceclient/v1/legacy_shell.py @@ -20,6 +20,7 @@ legacy glance client. import argparse import sys +import urlparse from glanceclient.common import utils @@ -72,10 +73,12 @@ def print_image_formatted(client, image): :param client: The Glance client object :param image: The image metadata """ - print "URI: http://%s:%s/v1/images/%s" % ( - client.endpoint[0], - client.endpoint[1], - image.id) + uri_parts = urlparse.urlparse(client.endpoint) + if uri_parts.port: + hostbase = "%s:%s" % (uri_parts.hostname, uri_parts.port) + else: + hostbase = uri_parts.hostname + print "URI: %s://%s/v1/images/%s" % (uri_parts.scheme, hostbase, image.id) print "Id: %s" % image.id print "Public: " + (image.is_public and "Yes" or "No") print "Protected: " + (image.protected and "Yes" or "No")