]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Don't get nested stacks by name
authorZane Bitter <zbitter@redhat.com>
Fri, 7 Dec 2012 16:40:26 +0000 (17:40 +0100)
committerZane Bitter <zbitter@redhat.com>
Fri, 7 Dec 2012 16:43:07 +0000 (17:43 +0100)
Don't return nested stacks from stack_get_by_name(). This prevented the
user creating a stack with the same name as a nested stack, and was a
temporary workaround for the metadata server (see
be3c066ab87cc6e1a2ca8c097eeccd9217d7329a)

bug 1072954

Change-Id: I1e3d0289476377f5b4169835119052f4fa573f86
Signed-off-by: Zane Bitter <zbitter@redhat.com>
heat/db/sqlalchemy/api.py

index d52f0a43030abf04633c7e0768daf3da447c4c60..9cb14de3fdc86141a2e41c64cd452bf45cba7502 100644 (file)
@@ -114,10 +114,9 @@ def resource_get_all_by_stack(context, stack_id):
 def stack_get_by_name(context, stack_name, owner_id=None):
     query = model_query(context, models.Stack).\
                         filter_by(tenant=context.tenant_id).\
-                        filter_by(name=stack_name)
+                        filter_by(name=stack_name).\
+                        filter_by(owner_id=owner_id)
 
-    if owner_id:
-        query = query.filter_by(owner_id=owner_id)
     return query.first()