Skip to content

Commit 54beac6

Browse files
author
Carlos Konstanski
committed
Create servicedependency objects based on tags
When a resource has a tag with the form 'parent:', create a servicedependency object. Issue: CIRRUS-4265
1 parent ec40841 commit 54beac6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

puppetdb_stencil.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
ENVIRONMENT = jinja2.Environment(trim_blocks=True, lstrip_blocks=True, loader=LOADER, extensions=EXTENSIONS)
2525

2626

27+
def is_resource_visible(resource, localsite):
28+
return resource.exported and
29+
(('only-cross-site' not in resource.tags and 'no-cross-site' not in resource.tags) or
30+
('only-cross-site' in resource.tags and 'no-cross-site' not in resource.tags and localsite == 'false') or
31+
('only-cross-site' not in resource.tags and 'no-cross-site' in resource.tags and localsite == 'true'))
32+
33+
2734
def render_resources(database, resource_type, localsite, template_names):
2835
"""
2936
Render resources of the given type. They are queried from the given
@@ -45,7 +52,7 @@ def render_resources(database, resource_type, localsite, template_names):
4552
for resource in r:
4653
resources.append(resource)
4754
envs_to_ignore = []
48-
if resource.exported and ('only-cross-site' not in resource.tags or localsite == 'false'):
55+
if is_resource_visible(resource, localsite):
4956
dto = {}
5057
dto['object_name'] = object_name
5158
dto['named_object'] = named_object
@@ -79,7 +86,7 @@ def render_resources(database, resource_type, localsite, template_names):
7986
parent_service_description = item.replace('_', ' ')
8087
# lookup parent resource by its service_description
8188
for parent in resources:
82-
if parent.exported and ('only-cross-site' not in parent.tags or localsite == 'false'):
89+
if is_resource_visible(resource, localsite):
8390
for key, value in parent.parameters.items():
8491
if key == 'service_description' and parent_service_description in value.lower():
8592
for child in service_dependencies[item]:

0 commit comments

Comments
 (0)