Merge "Switched from all stacks polling to filtered list"
This commit is contained in:
commit
ab487a3f8e
@ -256,8 +256,7 @@ 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:
|
||||
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)
|
||||
|
@ -77,8 +77,11 @@ def _get_availability_zone_list(detailed=True):
|
||||
return [FakeAvailabilityZone('nova')]
|
||||
|
||||
|
||||
def _get_heat_stack_list():
|
||||
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):
|
||||
|
@ -49,12 +49,14 @@ 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:
|
||||
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'))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user