Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions IM/tosca/Tosca.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,15 @@ def _get_placement_property(self, sys_name, prop):
return None

def _get_tosca_from_repo(self, input_yaml):
if 'tosca_definitions_version' not in input_yaml or not input_yaml.get('imports'):
if ('tosca_definitions_version' not in input_yaml or
not input_yaml.get('imports') or
len(input_yaml.get('imports')) != 1 or
not isinstance(input_yaml.get('imports')[0], dict) or
input_yaml.get('imports')[0].get("template_file") is None):
return input_yaml

# Check if the import URL
import_file = input_yaml.get('imports')[0]
import_file = input_yaml.get('imports')[0].get("template_file")
if self.tosca_repo:
import_file_url = urlparse(import_file)
# If the import is a URL, check if it is in the TOSCA repository
Expand Down
2 changes: 1 addition & 1 deletion test/files/tosca_repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0
description: TOSCA test for the IM

imports:
- simple-node-disk.yml
- template_file: simple-node-disk.yml

topology_template:

Expand Down
3 changes: 2 additions & 1 deletion test/unit/Tosca.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,8 @@ def test_tosca_repo(self):

# Test with a full URL in the template_file and not in the repo
tosca_yaml = yaml.safe_load(tosca_data)
tosca_yaml["imports"][0] = "https://raw.githubusercontent.com/grycap/tosca/main/templates/simple-node-disk.yml"
tosca_yaml["imports"][0]["template_file"] = \
"https://raw.githubusercontent.com/grycap/tosca/main/templates/simple-node-disk.yml"
tosca = Tosca(yaml.safe_dump(tosca_yaml))
_, radl = tosca.to_radl()
radl = parse_radl(str(radl))
Expand Down