# ECOMP is a trademark and service mark of AT&T Intellectual Property.
#
-# VERSION = '1.0.0'
-
----
+"""
resources:
- vm_type_a_server_0:
- type: OS::Nova::Server
- properties:
- name: { get_param: [vm_type_a_names, 0] }
- flavor: { get_param: vm_type_a_flavor_name}
- image: { get_param: vm_type_a_image_name}
+{vm-type}_{vm-type_index}_{network-role}_port_{port-index}:
+"""
+
+import pytest
- vm_type_a_sErver_0:
- type: OS::Nova::Server
- properties:
- name: { get_param: [vm_type_a_names, 0] }
- flavor: { get_param: vm_type_a_flavor_name}
- image: { get_param: vm_type_a_image_name}
+from .structures import Heat
+from .helpers import validates
- vm_type_a_server_1:
- type: OS::Nova::Server
- properties:
- name: { get_param: [vm_type_a_names, 1] }
- flavor: { get_param: vm_type_a_flavor_name}
- image: { get_param: vm_type_a_image_name}
+VERSION = "1.1.0"
- vm_type_b_server_0:
- type: OS::Nova::Server
- properties:
- name: { get_param: vm_type_b_name_0 }
- flavor: { get_param: vm_type_b_flavor_name}
- image: { get_param: vm_type_b_image_name}
+# pylint: disable=invalid-name
- vm_type_b_server_1:
- type: OS::Nova::Server
- properties:
- name: { get_param: vm_type_b_name_1 }
- flavor: { get_param: vm_type_b_flavor_name}
- image: { get_param: vm_type_b_image_name}
+@validates("R-08975")
+def test_software_config_vm_type(heat_template):
+ """
+ A VNF's Heat Orchestration Template's Resource OS::Heat::SoftwareConfig
+ Resource ID **MUST** contain the {vm-type}.
+ """
+ heat = Heat(filepath=heat_template)
+ software_configs = heat.get_resource_by_type("OS::Heat::SoftwareConfig")
+ if not software_configs:
+ pytest.skip("No SoftwareConfig resources found")
+ vm_types = sorted(
+ list(
+ set(
+ x
+ for x in [
+ heat.get_vm_type(rid, resource=r)
+ for rid, r in heat.resources.items()
+ ]
+ if x
+ )
+ )
+ )
+ if not vm_types:
+ pytest.skip("No vm_types found")
+ bad = []
+ for rid in software_configs:
+ if not any(heat.part_is_in_name(part=v, name=rid) for v in vm_types):
+ bad.append("%s vm-type not in %s" % (rid, vm_types))
+ assert not bad, "; ".join(bad)