Merge "Switched from all stacks polling to filtered list"

This commit is contained in:
Jenkins 2015-06-23 09:24:04 +00:00 committed by Gerrit Code Review
commit ab487a3f8e
3 changed files with 16 additions and 12 deletions

View File

@ -256,11 +256,10 @@ def check_cluster_unique_name(name):
def check_heat_stack_name(cluster_name): def check_heat_stack_name(cluster_name):
if CONF.infrastructure_engine == 'heat': if CONF.infrastructure_engine == 'heat':
for stack in heat.client().stacks.list(): if heat.get_stack(cluster_name, raise_on_missing=False):
if stack.stack_name == cluster_name: raise ex.NameAlreadyExistsException(
raise ex.NameAlreadyExistsException( _("Cluster name '%s' is already used as Heat stack name")
_("Cluster name '%s' is already used as Heat stack name") % cluster_name)
% cluster_name)
def check_cluster_hostnames_lengths(cluster_name, node_groups): def check_cluster_hostnames_lengths(cluster_name, node_groups):

View File

@ -77,8 +77,11 @@ def _get_availability_zone_list(detailed=True):
return [FakeAvailabilityZone('nova')] return [FakeAvailabilityZone('nova')]
def _get_heat_stack_list(): def _get_heat_stack_list(**kwargs):
return [FakeStack('test-heat')] if (kwargs.get('filters') and
kwargs.get('filters').get('name') == 'test-heat'):
return [FakeStack('test-heat')]
return []
class FakeStack(object): class FakeStack(object):

View File

@ -49,11 +49,13 @@ def client():
include_pass=True) include_pass=True)
def get_stack(stack_name): def get_stack(stack_name, raise_on_missing=True):
heat = client() for stack in base.execute_with_retries(
for stack in base.execute_with_retries(heat.stacks.list): client().stacks.list, filters={'name': stack_name}):
if stack.stack_name == stack_name: return stack
return stack
if not raise_on_missing:
return None
raise ex.NotFoundException({'stack': stack_name}, raise ex.NotFoundException({'stack': stack_name},
_('Failed to find stack %(stack)s')) _('Failed to find stack %(stack)s'))