Corrects URI to display hostname, port properly

Fixes bug 1035931

Change-Id: I1b4e8a226c21d137b24bc5b75299bcf4ab4efefb
This commit is contained in:
Brian Rosmaita
2012-09-10 19:19:20 +00:00
parent 61b359efa8
commit 2f1e0299e8

View File

@@ -20,6 +20,7 @@ legacy glance client.
import argparse import argparse
import sys import sys
import urlparse
from glanceclient.common import utils from glanceclient.common import utils
@@ -72,10 +73,12 @@ def print_image_formatted(client, image):
:param client: The Glance client object :param client: The Glance client object
:param image: The image metadata :param image: The image metadata
""" """
print "URI: http://%s:%s/v1/images/%s" % ( uri_parts = urlparse.urlparse(client.endpoint)
client.endpoint[0], if uri_parts.port:
client.endpoint[1], hostbase = "%s:%s" % (uri_parts.hostname, uri_parts.port)
image.id) else:
hostbase = uri_parts.hostname
print "URI: %s://%s/v1/images/%s" % (uri_parts.scheme, hostbase, image.id)
print "Id: %s" % image.id print "Id: %s" % image.id
print "Public: " + (image.is_public and "Yes" or "No") print "Public: " + (image.is_public and "Yes" or "No")
print "Protected: " + (image.protected and "Yes" or "No") print "Protected: " + (image.protected and "Yes" or "No")