From 9a4012ba9d99ca30d9f6fc5a226cbd3baa727bc5 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Mon, 28 Jan 2019 18:54:24 +1300 Subject: [PATCH] Use set instead of list of server_deferred_statuses We only use this list to test for membership, so it's more efficient to use a set. Change-Id: I520fd87a18f37da3ae2e61c56fe00063348540b4 --- heat/engine/clients/os/nova.py | 4 ++-- heat/engine/resources/aws/ec2/instance.py | 2 +- heat/engine/resources/openstack/nova/server.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/heat/engine/clients/os/nova.py b/heat/engine/clients/os/nova.py index d8cd22a6fe..b070764fce 100644 --- a/heat/engine/clients/os/nova.py +++ b/heat/engine/clients/os/nova.py @@ -48,7 +48,7 @@ CLIENT_NAME = 'nova' class NovaClientPlugin(microversion_mixin.MicroversionMixin, client_plugin.ClientPlugin): - deferred_server_statuses = ['BUILD', + deferred_server_statuses = {'BUILD', 'HARD_REBOOT', 'PASSWORD', 'REBOOT', @@ -57,7 +57,7 @@ class NovaClientPlugin(microversion_mixin.MicroversionMixin, 'REVERT_RESIZE', 'SHUTOFF', 'SUSPENDED', - 'VERIFY_RESIZE'] + 'VERIFY_RESIZE'} exceptions_module = exceptions diff --git a/heat/engine/resources/aws/ec2/instance.py b/heat/engine/resources/aws/ec2/instance.py index 7311eb9956..3cdd4b5d1b 100644 --- a/heat/engine/resources/aws/ec2/instance.py +++ b/heat/engine/resources/aws/ec2/instance.py @@ -865,7 +865,7 @@ class Instance(resource.Resource, sh.SchedulerHintsMixin): status = cp.get_status(server) LOG.debug('%(name)s check_suspend_complete status = %(status)s', {'name': self.name, 'status': status}) - if status in list(cp.deferred_server_statuses + ['ACTIVE']): + if status in (cp.deferred_server_statuses | {'ACTIVE'}): return status == 'SUSPENDED' else: exc = exception.ResourceUnknownStatus( diff --git a/heat/engine/resources/openstack/nova/server.py b/heat/engine/resources/openstack/nova/server.py index 9d9b2df2f6..c1fc2c2bb6 100644 --- a/heat/engine/resources/openstack/nova/server.py +++ b/heat/engine/resources/openstack/nova/server.py @@ -1701,7 +1701,7 @@ class Server(server_base.BaseServer, sh.SchedulerHintsMixin, status = cp.get_status(server) LOG.debug('%(name)s check_suspend_complete status = %(status)s', {'name': self.name, 'status': status}) - if status in list(cp.deferred_server_statuses + ['ACTIVE']): + if status in (cp.deferred_server_statuses | {'ACTIVE'}): return status == 'SUSPENDED' else: exc = exception.ResourceUnknownStatus(