Merge "Show words indicating booted from volume for server image"
This commit is contained in:
commit
e7b2528c4a
openstackclient
@ -39,6 +39,8 @@ from openstackclient.network import common as network_common
|
|||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
IMAGE_STRING_FOR_BFV = 'N/A (booted from volume)'
|
||||||
|
|
||||||
|
|
||||||
def _format_servers_list_networks(networks):
|
def _format_servers_list_networks(networks):
|
||||||
"""Return a formatted string of a server's networks
|
"""Return a formatted string of a server's networks
|
||||||
@ -148,6 +150,12 @@ def _prep_server_detail(compute_client, image_client, server, refresh=True):
|
|||||||
info['image'] = "%s (%s)" % (image.name, image_id)
|
info['image'] = "%s (%s)" % (image.name, image_id)
|
||||||
except Exception:
|
except Exception:
|
||||||
info['image'] = image_id
|
info['image'] = image_id
|
||||||
|
else:
|
||||||
|
# NOTE(melwitt): An server booted from a volume will have no image
|
||||||
|
# associated with it. We fill in the image with "N/A (booted from
|
||||||
|
# volume)" to help users who want to be able to grep for
|
||||||
|
# boot-from-volume servers when using the CLI.
|
||||||
|
info['image'] = IMAGE_STRING_FOR_BFV
|
||||||
|
|
||||||
# Convert the flavor blob to a name
|
# Convert the flavor blob to a name
|
||||||
flavor_info = info.get('flavor', {})
|
flavor_info = info.get('flavor', {})
|
||||||
@ -1526,8 +1534,12 @@ class ListServer(command.Lister):
|
|||||||
s.image_name = image.name
|
s.image_name = image.name
|
||||||
s.image_id = s.image['id']
|
s.image_id = s.image['id']
|
||||||
else:
|
else:
|
||||||
s.image_name = ''
|
# NOTE(melwitt): An server booted from a volume will have no
|
||||||
s.image_id = ''
|
# image associated with it. We fill in the Image Name and ID
|
||||||
|
# with "N/A (booted from volume)" to help users who want to be
|
||||||
|
# able to grep for boot-from-volume servers when using the CLI.
|
||||||
|
s.image_name = IMAGE_STRING_FOR_BFV
|
||||||
|
s.image_id = IMAGE_STRING_FOR_BFV
|
||||||
if 'id' in s.flavor:
|
if 'id' in s.flavor:
|
||||||
flavor = flavors.get(s.flavor['id'])
|
flavor = flavors.get(s.flavor['id'])
|
||||||
if flavor:
|
if flavor:
|
||||||
|
@ -16,6 +16,7 @@ import uuid
|
|||||||
|
|
||||||
from tempest.lib import exceptions
|
from tempest.lib import exceptions
|
||||||
|
|
||||||
|
from openstackclient.compute.v2 import server as v2_server
|
||||||
from openstackclient.tests.functional.compute.v2 import common
|
from openstackclient.tests.functional.compute.v2 import common
|
||||||
from openstackclient.tests.functional.volume.v2 import common as volume_common
|
from openstackclient.tests.functional.volume.v2 import common as volume_common
|
||||||
|
|
||||||
@ -509,6 +510,20 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
server['name'],
|
server['name'],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# check that image indicates server "booted from volume"
|
||||||
|
self.assertEqual(
|
||||||
|
v2_server.IMAGE_STRING_FOR_BFV,
|
||||||
|
server['image'],
|
||||||
|
)
|
||||||
|
# check server list too
|
||||||
|
servers = json.loads(self.openstack(
|
||||||
|
'server list -f json'
|
||||||
|
))
|
||||||
|
self.assertEqual(
|
||||||
|
v2_server.IMAGE_STRING_FOR_BFV,
|
||||||
|
servers[0]['Image']
|
||||||
|
)
|
||||||
|
|
||||||
# check volumes
|
# check volumes
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = json.loads(self.openstack(
|
||||||
'volume show -f json ' +
|
'volume show -f json ' +
|
||||||
@ -781,8 +796,8 @@ class ServerTests(common.ComputeTestCase):
|
|||||||
self.addCleanup(self.openstack, 'volume delete ' + vol['id'])
|
self.addCleanup(self.openstack, 'volume delete ' + vol['id'])
|
||||||
|
|
||||||
# Since the server is volume-backed the GET /servers/{server_id}
|
# Since the server is volume-backed the GET /servers/{server_id}
|
||||||
# response will have image=''.
|
# response will have image='N/A (booted from volume)'.
|
||||||
self.assertEqual('', cmd_output['image'])
|
self.assertEqual(v2_server.IMAGE_STRING_FOR_BFV, cmd_output['image'])
|
||||||
|
|
||||||
# check the volume that attached on server
|
# check the volume that attached on server
|
||||||
cmd_output = json.loads(self.openstack(
|
cmd_output = json.loads(self.openstack(
|
||||||
|
@ -2609,7 +2609,7 @@ class TestServerList(TestServer):
|
|||||||
s.status,
|
s.status,
|
||||||
server._format_servers_list_networks(s.networks),
|
server._format_servers_list_networks(s.networks),
|
||||||
# Image will be an empty string if boot-from-volume
|
# Image will be an empty string if boot-from-volume
|
||||||
self.image.name if s.image else s.image,
|
self.image.name if s.image else server.IMAGE_STRING_FOR_BFV,
|
||||||
self.flavor.name,
|
self.flavor.name,
|
||||||
))
|
))
|
||||||
self.data_long.append((
|
self.data_long.append((
|
||||||
@ -2622,8 +2622,8 @@ class TestServerList(TestServer):
|
|||||||
),
|
),
|
||||||
server._format_servers_list_networks(s.networks),
|
server._format_servers_list_networks(s.networks),
|
||||||
# Image will be an empty string if boot-from-volume
|
# Image will be an empty string if boot-from-volume
|
||||||
self.image.name if s.image else s.image,
|
self.image.name if s.image else server.IMAGE_STRING_FOR_BFV,
|
||||||
s.image['id'] if s.image else s.image,
|
s.image['id'] if s.image else server.IMAGE_STRING_FOR_BFV,
|
||||||
self.flavor.name,
|
self.flavor.name,
|
||||||
s.flavor['id'],
|
s.flavor['id'],
|
||||||
getattr(s, 'OS-EXT-AZ:availability_zone'),
|
getattr(s, 'OS-EXT-AZ:availability_zone'),
|
||||||
@ -2636,7 +2636,7 @@ class TestServerList(TestServer):
|
|||||||
s.status,
|
s.status,
|
||||||
server._format_servers_list_networks(s.networks),
|
server._format_servers_list_networks(s.networks),
|
||||||
# Image will be an empty string if boot-from-volume
|
# Image will be an empty string if boot-from-volume
|
||||||
s.image['id'] if s.image else s.image,
|
s.image['id'] if s.image else server.IMAGE_STRING_FOR_BFV,
|
||||||
s.flavor['id']
|
s.flavor['id']
|
||||||
))
|
))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user