def graph_json(): Node.reset_counter() # FIXME: NO! Edge.reset_counter() # FIXME: NO! dot = DotGraph('', file_contents=run_tf_graph()) tf = Terraform(os.getcwd()) for node in dot.nodes: node.definition = tf.get_def(node) return dot.json()
def __init__(self, action, name, definition): self.action = action self.simple_name = name self.definition = definition self.type = DotNode._resource_type(self.simple_name) self.resource_name = DotNode._resource_name(self.simple_name) self.svg_id = 'node_' + str(Node.svg_id_counter())
def __init__(self, label, plan_data, apply_data, cost_data, policy_data, time_data, fmt=None): self.label = DotNode._label_fixup(label) self.fmt = fmt if fmt else Format('') # graphviz formatting. self.simple_name = re.sub(r'\[root\]\s+', '', self.label) # strip root module notation. self.type = DotNode._resource_type( self.label) # e.g. var, aws_instance, output... self.resource_name = DotNode._resource_name(self.label) # self.svg_id = 'node_' + str(Node.svg_id_counter()) # self.definition = {} # self.group = 20000 # for coloration. placeholder. replaced in javascript. self.module = DotNode._module( self.label ) # for module groupings. 'root' or 'module.foo.module.bar' self.cluster = None # for stacked resources (usually var/output). self.collapsed = False self.plan = plan_data self.apply = apply_data self.cost = cost_data self.policy = policy_data self.time = time_data self.fmt.add(id=self.svg_id, shape='box') self.modules = [m for m in self.module.split('.') if m != 'module']
def __init__(self, modules): self.label = '[root] ' + 'module.' + '.module.'.join(modules) + '.collapsed.etc' self.fmt = Format('') self.simple_name = re.sub(r'\[root\]\s+', '', self.label) # strip root module notation. self.type = DotNode._resource_type(self.label) self.resource_name = DotNode._resource_name(self.label) self.svg_id = 'node_' + str(Node.svg_id_counter()) self.definition = {} self.group = 20000 # for coloration. placeholder. replaced in javascript. self.module = DotNode._module(self.label) # for module groupings. 'root' or 'module.foo.module.bar' self.cluster = None # for stacked resources (usually var/output). self.modules = [ m for m in self.module.split('.') if m != 'module' ] self.collapsed = True
def __init__(self, label, fmt=None): self.label = label # node name exactly as it appears in tf graph output. self.fmt = fmt if fmt else Format('') # graphviz formatting. self.simple_name = re.sub(r'\[root\]\s+', '', label) # strip root module notation. self.type = DotNode._resource_type(label) # e.g. var, aws_instance, output... self.resource_name = DotNode._resource_name(label) # self.svg_id = 'node_' + str(Node.svg_id_counter()) # self.definition = {} # self.group = 20000 # for coloration. placeholder. replaced in javascript. self.module = DotNode._module(label) # for module groupings. 'root' or 'module.foo.module.bar' self.cluster = None # for stacked resources (usually var/output). self.collapsed = False self.modules = [ m for m in self.module.split('.') if m != 'module' ]
def __init__(self, label, fmt=None): self.label = label # node name exactly as it appears in tf graph output. self.fmt = fmt if fmt else Format('') # graphviz formatting. self.simple_name = re.sub(r'\[root\]\s+', '', label) # strip root module notation. self.type = DotNode._resource_type( label) # e.g. var, aws_instance, output... self.resource_name = DotNode._resource_name(label) # self.svg_id = 'node_' + str(Node.svg_id_counter()) # self.definition = {} # self.group = 20000 # for coloration. placeholder. replaced in javascript. self.module = DotNode._module( label) # for module groupings. 'root' or 'module.foo.module.bar' self.cluster = None # for stacked resources (usually var/output). self.modules = [m for m in self.module.split('.') if m != 'module']
def __init__(self, modules): self.label = '[root] ' + 'module.' + '.module.'.join( modules) + '.collapsed.etc' self.fmt = Format('') self.simple_name = re.sub(r'\[root\]\s+', '', self.label) # strip root module notation. self.type = DotNode._resource_type(self.label) self.resource_name = DotNode._resource_name(self.label) self.svg_id = 'node_' + str(Node.svg_id_counter()) self.definition = {} self.group = 20000 # for coloration. placeholder. replaced in javascript. self.module = DotNode._module( self.label ) # for module groupings. 'root' or 'module.foo.module.bar' self.cluster = None # for stacked resources (usually var/output). self.modules = [m for m in self.module.split('.') if m != 'module'] self.collapsed = True
def graph_svg(): Node.reset_counter() Edge.reset_counter() # FIXME: NO! dot = DotGraph('', file_contents=run_tf_graph()) return dot.svg()