summaryrefslogtreecommitdiff
path: root/openstackclient/compute
diff options
context:
space:
mode:
authorPavlo Shchelokovskyy <shchelokovskyy@gmail.com>2018-05-14 17:57:28 +0000
committerPavlo Shchelokovskyy <shchelokovskyy@gmail.com>2018-07-09 15:07:24 +0300
commitb9fab849f7be93fa62e793ce68303a9473c54fa7 (patch)
tree7906e40861f4d7477fa24306de176686c176f600 /openstackclient/compute
parentc5a0c3ad5dff4cd59c16104e3c419aae6a8e91d9 (diff)
downloadpython-openstackclient-b9fab849f7be93fa62e793ce68303a9473c54fa7.tar.gz
Skip calls to glance and nova when got no servers
save (potentially many) HTTP calls to Glance API for image list and a call to Nova API for flavor list when the server list actually returned no servers. Change-Id: I93a56138c50b82fb4dce67a2f788107f71c5f423 Story: #2002039 Task: #19681
Diffstat (limited to 'openstackclient/compute')
-rw-r--r--openstackclient/compute/v2/server.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py
index b82f895c..777f7744 100644
--- a/openstackclient/compute/v2/server.py
+++ b/openstackclient/compute/v2/server.py
@@ -1226,7 +1226,7 @@ class ListServer(command.Lister):
# Create a dict that maps image_id to image object.
# Needed so that we can display the "Image Name" column.
# "Image Name" is not crucial, so we swallow any exceptions.
- if not parsed_args.no_name_lookup:
+ if data and not parsed_args.no_name_lookup:
try:
images_list = self.app.client_manager.image.images.list()
for i in images_list:
@@ -1238,7 +1238,7 @@ class ListServer(command.Lister):
# Create a dict that maps flavor_id to flavor object.
# Needed so that we can display the "Flavor Name" column.
# "Flavor Name" is not crucial, so we swallow any exceptions.
- if not parsed_args.no_name_lookup:
+ if data and not parsed_args.no_name_lookup:
try:
flavors_list = compute_client.flavors.list(is_public=None)
for i in flavors_list: