summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-03-07 08:01:45 +0000
committerGerrit Code Review <review@openstack.org>2019-03-07 08:01:45 +0000
commit7feb9d38d0f6b3a92fcd80d7fac639aded5a5e76 (patch)
treee44ebe966379e18df19308bc7c40e3e5676a2628 /openstackclient
parentf992617f798426ff996eb776d8e16a03adef0bab (diff)
parent239b103849b96213dc9cb317006346ce311228e4 (diff)
downloadpython-openstackclient-7feb9d38d0f6b3a92fcd80d7fac639aded5a5e76.tar.gz
Merge "API microversion 2.69: Handles Down Cells"
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/compute/v2/server.py8
-rw-r--r--openstackclient/tests/unit/compute/v2/test_server.py44
2 files changed, 52 insertions, 0 deletions
diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py
index eb012e02..306345bd 100644
--- a/openstackclient/compute/v2/server.py
+++ b/openstackclient/compute/v2/server.py
@@ -1314,6 +1314,14 @@ class ListServer(command.Lister):
# Populate image_name, image_id, flavor_name and flavor_id attributes
# of server objects so that we can display those columns.
for s in data:
+ if compute_client.api_version >= api_versions.APIVersion('2.69'):
+ # NOTE(tssurya): From 2.69, we will have the keys 'flavor'
+ # and 'image' missing in the server response during
+ # infrastructure failure situations.
+ # For those servers with partial constructs we just skip the
+ # processing of the image and flavor informations.
+ if not hasattr(s, 'image') or not hasattr(s, 'flavor'):
+ continue
if 'id' in s.image:
image = images.get(s.image['id'])
if image:
diff --git a/openstackclient/tests/unit/compute/v2/test_server.py b/openstackclient/tests/unit/compute/v2/test_server.py
index c529d840..c30af8fb 100644
--- a/openstackclient/tests/unit/compute/v2/test_server.py
+++ b/openstackclient/tests/unit/compute/v2/test_server.py
@@ -2272,6 +2272,50 @@ class TestServerList(TestServer):
'Invalid time value'
)
+ def test_server_list_v269_with_partial_constructs(self):
+ self.app.client_manager.compute.api_version = \
+ api_versions.APIVersion('2.69')
+ arglist = []
+ verifylist = []
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+ # include "partial results" from non-responsive part of
+ # infrastructure.
+ server_dict = {
+ "id": "server-id-95a56bfc4xxxxxx28d7e418bfd97813a",
+ "status": "UNKNOWN",
+ "tenant_id": "6f70656e737461636b20342065766572",
+ "created": "2018-12-03T21:06:18Z",
+ "links": [
+ {
+ "href": "http://fake/v2.1/",
+ "rel": "self"
+ },
+ {
+ "href": "http://fake",
+ "rel": "bookmark"
+ }
+ ],
+ # We need to pass networks as {} because its defined as a property
+ # of the novaclient Server class which gives {} by default. If not
+ # it will fail at formatting the networks info later on.
+ "networks": {}
+ }
+ server = compute_fakes.fakes.FakeResource(
+ info=server_dict,
+ )
+ self.servers.append(server)
+ columns, data = self.cmd.take_action(parsed_args)
+ # get the first three servers out since our interest is in the partial
+ # server.
+ next(data)
+ next(data)
+ next(data)
+ partial_server = next(data)
+ expected_row = (
+ 'server-id-95a56bfc4xxxxxx28d7e418bfd97813a', '',
+ 'UNKNOWN', '', '', '')
+ self.assertEqual(expected_row, partial_server)
+
class TestServerLock(TestServer):