# ============LICENSE_START=======================================================
# org.onap.vvp/validation-scripts
# ===================================================================
# ============LICENSE_START=======================================================
# org.onap.vvp/validation-scripts
# ===================================================================
# ===================================================================
#
# Unless otherwise specified, all software contained herein is licensed
# ===================================================================
#
# Unless otherwise specified, all software contained herein is licensed
# you may not use this software except in compliance with the License.
# You may obtain a copy of the License at
#
# you may not use this software except in compliance with the License.
# You may obtain a copy of the License at
#
# you may not use this documentation except in compliance with the License.
# You may obtain a copy of the License at
#
# you may not use this documentation except in compliance with the License.
# You may obtain a copy of the License at
#
Check that all resource ids for cinder volumes follow the right
naming convention to include the {vm_type} of the
nova server it is associated to
Check that all resource ids for cinder volumes follow the right
naming convention to include the {vm_type} of the
nova server it is associated to
yml = yaml.load(fh)
# skip if resources are not defined
if "resources" not in yml:
pytest.skip("No resources specified in the heat template")
yml = yaml.load(fh)
# skip if resources are not defined
if "resources" not in yml:
pytest.skip("No resources specified in the heat template")
invalid_volumes = []
for k, v in resources.items():
if not isinstance(v, dict):
continue
invalid_volumes = []
for k, v in resources.items():
if not isinstance(v, dict):
continue
- volume_id = volume_id.lower()
+ if isinstance(volume_id, list):
+ volume_id = volume_id[0].lower()
+ else:
+ volume_id = volume_id.lower()
- elif 'get_resource' in properties['instance_uuid']:
- instance_uuid = properties['instance_uuid']['get_resource']
+ elif "get_resource" in properties["instance_uuid"]:
+ instance_uuid = properties["instance_uuid"]["get_resource"]
- volume_id = volume_id.lower()
+ if isinstance(volume_id, list):
+ volume_id = volume_id[0].lower()
+ else:
+ volume_id = volume_id.lower()
invalid_volumes.append(volume_id)
else:
# extract the assumed {vm_type} from volume_id
m = volume_pattern.match(volume_id)
if m:
vm_type = m.group(1).lower()
invalid_volumes.append(volume_id)
else:
# extract the assumed {vm_type} from volume_id
m = volume_pattern.match(volume_id)
if m:
vm_type = m.group(1).lower()
- assert not set(invalid_volumes)
+ msg = "The following volumes have invalid resource IDs: {}".format(
+ ", ".join(invalid_volumes)
+ )
+ assert not set(invalid_volumes), msg