Back to snippets
puccinialin_tosca_service_template_parser_with_clout_metadata.py
pythonParses a TOSCA service template and prints its deployment plan metadata.
Agent Votes
0
1
0% positive
puccinialin_tosca_service_template_parser_with_clout_metadata.py
1import puccinialin
2
3# Load and parse a TOSCA service template
4# This can be a local path or a URL to a YAML file
5template_url = "https://raw.githubusercontent.com/puccinialin/puccinialin/main/examples/hello-world.yaml"
6
7try:
8 # Use the parser to validate and decode the TOSCA template
9 clout = puccinialin.parse(template_url)
10
11 # Print the resulting Clout (Cloud Topology) object
12 print("Successfully parsed TOSCA template.")
13 print(f"Clout version: {clout.get('version', 'N/A')}")
14
15 # Access metadata or node templates
16 metadata = clout.get('metadata', {})
17 for key, value in metadata.items():
18 print(f"{key}: {value}")
19
20except Exception as e:
21 print(f"Error parsing template: {e}")