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):
if CONF.infrastructure_engine == 'heat':
for stack in heat.client().stacks.list():
if stack.stack_name == cluster_name:
raise ex.NameAlreadyExistsException(
_("Cluster name '%s' is already used as Heat stack name")
% cluster_name)
if heat.get_stack(cluster_name, raise_on_missing=False):
raise ex.NameAlreadyExistsException(
_("Cluster name '%s' is already used as Heat stack name")
% cluster_name)
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')]
def _get_heat_stack_list():
return [FakeStack('test-heat')]
def _get_heat_stack_list(**kwargs):
if (kwargs.get('filters') and
kwargs.get('filters').get('name') == 'test-heat'):
return [FakeStack('test-heat')]
return []
class FakeStack(object):

View File

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