[VVP] create new validation scripts 37/59937/1
authorstark, steven <ss820f@att.com>
Thu, 9 Aug 2018 22:33:25 +0000 (15:33 -0700)
committerstark, steven <ss820f@att.com>
Thu, 9 Aug 2018 22:34:02 +0000 (15:34 -0700)
- create validation scripts for R-04747, R-30804, R-11690, R-46839, R-98407
- other small script enhancements

Change-Id: I12c42a43c83e5cb4217895c19fd0beef928dc955
Issue-ID: VVP-103
Signed-off-by: stark, steven <ss820f@att.com>
39 files changed:
ice_validator/tests/fixtures/test_cloud_config_resource_id/fail/fail0.yaml [new file with mode: 0644]
ice_validator/tests/fixtures/test_cloud_config_resource_id/fail/fail1.yaml [new file with mode: 0644]
ice_validator/tests/fixtures/test_cloud_config_resource_id/pass/pass0.yaml [new file with mode: 0644]
ice_validator/tests/fixtures/test_multipart_mime_resource_id/fail/fail0.yaml [new file with mode: 0644]
ice_validator/tests/fixtures/test_multipart_mime_resource_id/fail/fail1.yaml [new file with mode: 0644]
ice_validator/tests/fixtures/test_multipart_mime_resource_id/pass/pass0.yaml [new file with mode: 0644]
ice_validator/tests/fixtures/test_nova_servers_index/fail/fail0.yaml [new file with mode: 0644]
ice_validator/tests/fixtures/test_nova_servers_index/fail/fail1.yaml [new file with mode: 0644]
ice_validator/tests/fixtures/test_nova_servers_index/fail/fail2.yaml [new file with mode: 0644]
ice_validator/tests/fixtures/test_nova_servers_index/pass/pass0.yaml [new file with mode: 0644]
ice_validator/tests/fixtures/test_vm_type_resource_id/fail/fail0.yaml [new file with mode: 0644]
ice_validator/tests/fixtures/test_vm_type_resource_id/pass/pass0.yaml [new file with mode: 0644]
ice_validator/tests/fixtures/test_vm_type_syntax/fail/fail0.yaml [new file with mode: 0644]
ice_validator/tests/fixtures/test_vm_type_syntax/pass/pass0.yaml [new file with mode: 0644]
ice_validator/tests/helpers.py [changed mode: 0755->0644]
ice_validator/tests/parametrizers.py [changed mode: 0755->0644]
ice_validator/tests/structures.py [new file with mode: 0644]
ice_validator/tests/test_all_referenced_resources_exists.py
ice_validator/tests/test_allowed_address_pair_format.py
ice_validator/tests/test_allowed_address_pairs_include_vm_type_network_role.py
ice_validator/tests/test_availability_zone.py
ice_validator/tests/test_base_template_names.py
ice_validator/tests/test_base_template_outputs_consumed.py
ice_validator/tests/test_cloud_config_resource_id.py [new file with mode: 0644]
ice_validator/tests/test_env_and_yaml_same_name.py
ice_validator/tests/test_env_files_provided.py
ice_validator/tests/test_environment_file_structure.py
ice_validator/tests/test_multipart_mime_resource_id.py [new file with mode: 0644]
ice_validator/tests/test_nova_servers_index.py [new file with mode: 0644]
ice_validator/tests/test_vm_type_resource_id.py [new file with mode: 0644]
ice_validator/tests/test_vm_type_syntax.py [new file with mode: 0644]
ice_validator/tests/utils/nested_dict.py [new file with mode: 0644]
ice_validator/tests/utils/nested_files.py
ice_validator/tests/utils/nested_iterables.py
ice_validator/tests/utils/network_roles.py
ice_validator/tests/utils/ports.py
ice_validator/tests/utils/vm_types.py
ice_validator/tests/utils/volumes.py [changed mode: 0755->0644]
ice_validator/tests/utils/yaml_custom_utils.py

diff --git a/ice_validator/tests/fixtures/test_cloud_config_resource_id/fail/fail0.yaml b/ice_validator/tests/fixtures/test_cloud_config_resource_id/fail/fail0.yaml
new file mode 100644 (file)
index 0000000..a95a7e9
--- /dev/null
@@ -0,0 +1,78 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# 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_a_server_2:
+        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}
+
+  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}
+
+  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}
+
+  ok_vm_type_a_rcc:
+        type: OS::Heat::CloudConfig
+
+  vm_type_c_rcc:
+        type: OS::Heat::CloudConfig
+
diff --git a/ice_validator/tests/fixtures/test_cloud_config_resource_id/fail/fail1.yaml b/ice_validator/tests/fixtures/test_cloud_config_resource_id/fail/fail1.yaml
new file mode 100644 (file)
index 0000000..ba9c0bd
--- /dev/null
@@ -0,0 +1,78 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+#
+
+# VERSION = '1.0.0'
+
+---
+resources:
+  vm_type_a_server_2:
+        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_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}
+
+  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}
+
+  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}
+
+  vm_type_x_rcc:
+        type: OS::Heat::CloudConfig
+
+  vm_type_y_rcc:
+        type: OS::Heat::CloudConfig
+
diff --git a/ice_validator/tests/fixtures/test_cloud_config_resource_id/pass/pass0.yaml b/ice_validator/tests/fixtures/test_cloud_config_resource_id/pass/pass0.yaml
new file mode 100644 (file)
index 0000000..6644531
--- /dev/null
@@ -0,0 +1,78 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# 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_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}
+
+  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}
+
+  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}
+
+  vm_type_a_rcc:
+        type: OS::Heat::CloudConfig
+
+  vm_type_b_rcc:
+        type: OS::Heat::CloudConfig
+
diff --git a/ice_validator/tests/fixtures/test_multipart_mime_resource_id/fail/fail0.yaml b/ice_validator/tests/fixtures/test_multipart_mime_resource_id/fail/fail0.yaml
new file mode 100644 (file)
index 0000000..d21e27c
--- /dev/null
@@ -0,0 +1,78 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# 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_a_server_2:
+        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}
+
+  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}
+
+  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}
+
+  ok_vm_type_a_rcc:
+        type: OS::Heat::MultipartMime
+
+  vm_type_c_rcc:
+        type: OS::Heat::MultipartMime
+
diff --git a/ice_validator/tests/fixtures/test_multipart_mime_resource_id/fail/fail1.yaml b/ice_validator/tests/fixtures/test_multipart_mime_resource_id/fail/fail1.yaml
new file mode 100644 (file)
index 0000000..1486586
--- /dev/null
@@ -0,0 +1,78 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+#
+
+# VERSION = '1.0.0'
+
+---
+resources:
+  vm_type_a_server_2:
+        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_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}
+
+  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}
+
+  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}
+
+  vm_type_x_rcc:
+        type: OS::Heat::MultipartMime
+
+  vm_type_y_rcc:
+        type: OS::Heat::MultipartMime
+
diff --git a/ice_validator/tests/fixtures/test_multipart_mime_resource_id/pass/pass0.yaml b/ice_validator/tests/fixtures/test_multipart_mime_resource_id/pass/pass0.yaml
new file mode 100644 (file)
index 0000000..0d4bb8b
--- /dev/null
@@ -0,0 +1,78 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# 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_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}
+
+  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}
+
+  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}
+
+  vm_type_a_rcc:
+        type: OS::Heat::MultipartMime
+
+  vm_type_b_rcc:
+        type: OS::Heat::MultipartMime
+
diff --git a/ice_validator/tests/fixtures/test_nova_servers_index/fail/fail0.yaml b/ice_validator/tests/fixtures/test_nova_servers_index/fail/fail0.yaml
new file mode 100644 (file)
index 0000000..b75f58c
--- /dev/null
@@ -0,0 +1,72 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# 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_a_server_2:
+        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}
+
+  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}
+
+  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}
+
diff --git a/ice_validator/tests/fixtures/test_nova_servers_index/fail/fail1.yaml b/ice_validator/tests/fixtures/test_nova_servers_index/fail/fail1.yaml
new file mode 100644 (file)
index 0000000..4ee1d8b
--- /dev/null
@@ -0,0 +1,72 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+#
+
+# VERSION = '1.0.0'
+
+---
+resources:
+  vm_type_a_server_2:
+        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_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}
+
+  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}
+
+  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}
+
diff --git a/ice_validator/tests/fixtures/test_nova_servers_index/fail/fail2.yaml b/ice_validator/tests/fixtures/test_nova_servers_index/fail/fail2.yaml
new file mode 100644 (file)
index 0000000..3d02a12
--- /dev/null
@@ -0,0 +1,79 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# 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_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_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}
+
+  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}
+
+  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}
+
diff --git a/ice_validator/tests/fixtures/test_nova_servers_index/pass/pass0.yaml b/ice_validator/tests/fixtures/test_nova_servers_index/pass/pass0.yaml
new file mode 100644 (file)
index 0000000..5f4a931
--- /dev/null
@@ -0,0 +1,72 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# 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_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}
+
+  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}
+
+  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}
+
diff --git a/ice_validator/tests/fixtures/test_vm_type_resource_id/fail/fail0.yaml b/ice_validator/tests/fixtures/test_vm_type_resource_id/fail/fail0.yaml
new file mode 100644 (file)
index 0000000..25f6753
--- /dev/null
@@ -0,0 +1,71 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START=======================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+#
+
+# VERSION = '1.1.0'
+
+---
+resources:
+  vm_type_a_server_0: # ok
+        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_a_server_1: # ok
+        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}
+
+  VM_TYPE_BOK_SERVER_0: # ok for this test.
+      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}
+
+  Vm_type_b_ad_server_1: # fails
+        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}
diff --git a/ice_validator/tests/fixtures/test_vm_type_resource_id/pass/pass0.yaml b/ice_validator/tests/fixtures/test_vm_type_resource_id/pass/pass0.yaml
new file mode 100644 (file)
index 0000000..eb07cae
--- /dev/null
@@ -0,0 +1,68 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START=======================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+#
+---
+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_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}
+
+  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}
+
+  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}
diff --git a/ice_validator/tests/fixtures/test_vm_type_syntax/fail/fail0.yaml b/ice_validator/tests/fixtures/test_vm_type_syntax/fail/fail0.yaml
new file mode 100644 (file)
index 0000000..aa80056
--- /dev/null
@@ -0,0 +1,68 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START=======================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+#
+---
+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_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}
+
+  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}
+
+  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}
diff --git a/ice_validator/tests/fixtures/test_vm_type_syntax/pass/pass0.yaml b/ice_validator/tests/fixtures/test_vm_type_syntax/pass/pass0.yaml
new file mode 100644 (file)
index 0000000..eb07cae
--- /dev/null
@@ -0,0 +1,68 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START=======================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+#
+---
+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_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}
+
+  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}
+
+  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}
old mode 100755 (executable)
new mode 100644 (file)
index 37fd01f..5e4f3d3
@@ -1,12 +1,12 @@
 # -*- coding: utf8 -*-
 # -*- coding: utf8 -*-
-# ============LICENSE_START=======================================================
+# ============LICENSE_START====================================================
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
-# under the Apache License, Version 2.0 (the “License”);
+# under the Apache License, Version 2.0 (the "License");
 # 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
 #
@@ -21,7 +21,7 @@
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
-# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 # 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
 #
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
 
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
 
-import yaml
+"""Helpers
+"""
+
 from boltons import funcutils
 from boltons import funcutils
+import yaml
+
+VERSION = '1.1.0'
 
 
 def check_basename_ending(template_type, basename):
 
 
 def check_basename_ending(template_type, basename):
@@ -62,12 +67,11 @@ def get_parsed_yml_for_yaml_files(yaml_files, sections=None):
     sections = [] if sections is None else sections
     parsed_yml_list = []
     for yaml_file in yaml_files:
     sections = [] if sections is None else sections
     parsed_yml_list = []
     for yaml_file in yaml_files:
-        yml = ''
-
         try:
             with open(yaml_file) as fh:
                 yml = yaml.load(fh)
         try:
             with open(yaml_file) as fh:
                 yml = yaml.load(fh)
-        except Exception as e:
+        except yaml.YAMLError as e:
+            # pylint: disable=superfluous-parens
             print('Error in %s: %s' % (yaml_file, e))
             continue
         if yml:
             print('Error in %s: %s' % (yaml_file, e))
             continue
         if yml:
@@ -76,7 +80,6 @@ def get_parsed_yml_for_yaml_files(yaml_files, sections=None):
                     if k not in sections:
                         del yml[k]
             parsed_yml_list.append(yml)
                     if k not in sections:
                         del yml[k]
             parsed_yml_list.append(yml)
-
     return parsed_yml_list
 
 
     return parsed_yml_list
 
 
@@ -89,6 +92,7 @@ def validates(*requirement_ids):
         ...     pass
         >>> assert test_something.requirement_ids == ['R-12345', 'R-12346']
     """
         ...     pass
         >>> assert test_something.requirement_ids == ['R-12345', 'R-12346']
     """
+    # pylint: disable=missing-docstring
     def decorator(func):
         # NOTE: We use a utility here to ensure that function signatures are
         # maintained because pytest inspects function signatures to inject
     def decorator(func):
         # NOTE: We use a utility here to ensure that function signatures are
         # maintained because pytest inspects function signatures to inject
old mode 100755 (executable)
new mode 100644 (file)
index 33b214b..dcfe402
@@ -1,12 +1,12 @@
 # -*- coding: utf8 -*-
 # -*- coding: utf8 -*-
-# ============LICENSE_START=======================================================
+# ============LICENSE_START====================================================
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
-# under the Apache License, Version 2.0 (the “License”);
+# under the Apache License, Version 2.0 (the "License");
 # 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
 #
@@ -21,7 +21,7 @@
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
-# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 # 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
 #
 #
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
 #
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
+
+"""parametrizers
+"""
+
 from os import path, listdir
 import re
 import yaml
 from os import path, listdir
 import re
 import yaml
@@ -104,16 +108,16 @@ def list_filenames_in_template_dir(
                      if path.isfile(path.join(template_dir, s, f))
                      and path.splitext(f)[-1] in extensions
                      and check_basename_ending(
                      if path.isfile(path.join(template_dir, s, f))
                      and path.splitext(f)[-1] in extensions
                      and check_basename_ending(
-                            template_type,
-                            path.splitext(f)[0])]
+                        template_type,
+                        path.splitext(f)[0])]
     else:
         filenames = [path.join(template_dir, f)
                      for f in listdir(template_dir)
                      if path.isfile(path.join(template_dir, f))
                      and path.splitext(f)[-1] in extensions
                      and check_basename_ending(
     else:
         filenames = [path.join(template_dir, f)
                      for f in listdir(template_dir)
                      if path.isfile(path.join(template_dir, f))
                      and path.splitext(f)[-1] in extensions
                      and check_basename_ending(
-                                template_type,
-                                path.splitext(f)[0])]
+                        template_type,
+                        path.splitext(f)[0])]
     return filenames
 
 
     return filenames
 
 
diff --git a/ice_validator/tests/structures.py b/ice_validator/tests/structures.py
new file mode 100644 (file)
index 0000000..705e35f
--- /dev/null
@@ -0,0 +1,126 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+#
+
+'''structures
+'''
+
+import os
+
+import yaml
+
+from .utils import nested_dict
+
+VERSION = '1.4.0'
+
+
+class Heat(object):
+    """A Heat template.
+    filepath - absolute path to template file.
+    envpath - absolute path to environmnt file.
+    """
+    def __init__(self, filepath=None, envpath=None):
+        self.filepath = None
+        self.basename = None
+        self.dirname = None
+        self.yml = None
+        self.heat_template_version = None
+        self.description = None
+        self.parameter_groups = None
+        self.parameters = None
+        self.resources = None
+        self.outputs = None
+        self.conditions = None
+        if filepath:
+            self.load(filepath)
+        self.env = None
+        if envpath:
+            self.load_env(envpath)
+
+    def load(self, filepath):
+        """Load the Heat template given a filepath.
+        """
+        self.filepath = filepath
+        self.basename = os.path.basename(self.filepath)
+        self.dirname = os.path.dirname(self.filepath)
+        with open(self.filepath) as fi:
+            self.yml = yaml.load(fi)
+        self.heat_template_version = self.yml.get('heat_template_version',
+                                                  None)
+        self.description = self.yml.get('description', '')
+        self.parameter_groups = self.yml.get('parameter_groups', {})
+        self.parameters = self.yml.get('parameters', {})
+        self.resources = self.yml.get('resources', {})
+        self.outputs = self.yml.get('outputs', {})
+        self.conditions = self.yml.get('conditions', {})
+
+    def load_env(self, envpath):
+        """Load the Environment template given a envpath.
+        """
+        self.env = Env(filepath=envpath)
+
+    @staticmethod
+    def nested_get(dic, *keys):
+        """make utils.nested_dict.get available as a class method.
+        """
+        return nested_dict.get(dic, *keys)
+
+
+class Env(Heat):
+    """An Environment file
+    """
+    pass
+
+
+class Resource(object):
+    """A Resource
+    """
+    def __init__(self, resource_id=None, resource=None):
+        self.resource_id = resource_id or ''
+        self.resource = resource or {}
+
+    @staticmethod
+    def get_index_var(resource):
+        """Return the index_var for this resource.
+        """
+        index_var = nested_dict.get(
+                resource,
+                'properties',
+                'index_var') or 'index'
+        return index_var
index fd5b967..39247bf 100644 (file)
@@ -1,12 +1,12 @@
 # -*- coding: utf8 -*-
 # -*- coding: utf8 -*-
-# ============LICENSE_START=======================================================
+# ============LICENSE_START====================================================
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
-# under the Apache License, Version 2.0 (the “License”);
+# under the Apache License, Version 2.0 (the "License");
 # 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
 #
@@ -21,7 +21,7 @@
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
-# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 # 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
 #
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
 
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
 
+'''test_all_referenced_resources_exists
+'''
+
 import pytest
 import yaml
 import pytest
 import yaml
+
 from .utils.nested_iterables import find_all_get_resource_in_yml
 
 from .utils.nested_iterables import find_all_get_resource_in_yml
 
+VERSION = '1.0.0'
+
+# pylint: disable=invalid-name
+
 
 def test_all_referenced_resources_exists(yaml_file):
     '''
 
 def test_all_referenced_resources_exists(yaml_file):
     '''
@@ -58,9 +66,11 @@ def test_all_referenced_resources_exists(yaml_file):
     resource_ids = yml['resources'].keys()
     referenced_resource_ids = find_all_get_resource_in_yml(yml)
 
     resource_ids = yml['resources'].keys()
     referenced_resource_ids = find_all_get_resource_in_yml(yml)
 
-    missing_referenced_resources = []
+    missing_referenced_resources = set()
     for referenced_resource_id in referenced_resource_ids:
         if referenced_resource_id not in resource_ids:
     for referenced_resource_id in referenced_resource_ids:
         if referenced_resource_id not in resource_ids:
-            missing_referenced_resources.append(referenced_resource_id)
+            missing_referenced_resources.add(referenced_resource_id)
 
 
-    assert not set(missing_referenced_resources)
+    assert not missing_referenced_resources, (
+            'missing referenced resources %s' % list(
+                    missing_referenced_resources))
index 683d560..721d5c9 100644 (file)
@@ -1,12 +1,12 @@
 # -*- coding: utf8 -*-
 # -*- coding: utf8 -*-
-# ============LICENSE_START=======================================================
+# ============LICENSE_START====================================================
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
-# under the Apache License, Version 2.0 (the “License”);
+# under the Apache License, Version 2.0 (the "License");
 # 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
 #
@@ -21,7 +21,7 @@
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
-# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 # 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
 #
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
 
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
 
+'''
+test_allowed_address_pairs_format
+'''
+
+import re
+
 import pytest
 import yaml
 import pytest
 import yaml
-from .utils.network_roles import get_network_role_from_port,\
-                                 property_uses_get_resource
-import re
+
+from .utils.network_roles import get_network_role_from_port, \
+    property_uses_get_resource
+
+VERSION = '1.0.0'
+
+# pylint: disable=invalid-name
 
 
 def test_allowed_address_pairs_format(heat_template):
 
 
 def test_allowed_address_pairs_format(heat_template):
@@ -88,46 +98,38 @@ def test_allowed_address_pairs_format(heat_template):
     invalid_allowed_address_pairs = []
 
     for v1 in yml["resources"].values():
     invalid_allowed_address_pairs = []
 
     for v1 in yml["resources"].values():
-        if not isinstance(v1, dict):
-            continue
-        if "properties" not in v1:
-            continue
-        if v1.get("type") != "OS::Neutron::Port":
-            continue
-        if property_uses_get_resource(v1, "network"):
+        if (not isinstance(v1, dict)
+                or "properties" not in v1
+                or v1.get("type") != "OS::Neutron::Port"
+                or property_uses_get_resource(v1, "network")):
             continue
         network_role = get_network_role_from_port(v1)
 
             continue
         network_role = get_network_role_from_port(v1)
 
-        for k2, v2 in v1["properties"].items():
-            if k2 != "allowed_address_pairs":
+        v2 = v1["properties"].get("allowed_address_pairs", {})
+        for v3 in v2:
+            if ("ip_address" not in v3
+                    or "get_param" not in v3["ip_address"]):
                 continue
                 continue
-            for v3 in v2:
-                if "ip_address" not in v3:
-                    continue
-                if "get_param" not in v3["ip_address"]:
-                    continue
-
-                valid_allowed_address_pair = False
-                for v4 in allowed_formats:
-                    param = v3["ip_address"]["get_param"]
-                    if isinstance(param, list):
-                        param = param[0]
-
-                    # check if pattern matches
-                    m = v4[3].match(param)
-                    if m:
-                        if v4[2] == "internal" and\
-                            len(m.groups()) > 1 and\
-                                m.group(2) == network_role:
-                                valid_allowed_address_pair = True
-                                break
-                        elif v4[2] == "external" and\
-                                len(m.groups()) > 0 and\
-                                m.group(1).endswith("_" + network_role):
-                                    valid_allowed_address_pair = True
-                                    break
-
-                if not valid_allowed_address_pair:
-                    invalid_allowed_address_pairs.append(param)
-
-    assert not set(invalid_allowed_address_pairs)
+
+            param = v3["ip_address"]["get_param"]
+            if isinstance(param, list):
+                param = param[0]
+
+            for v4 in allowed_formats:
+                # check if pattern matches
+                m = v4[3].match(param)
+                if m:
+                    if (v4[2] == "internal"
+                            and len(m.groups()) > 1
+                            and m.group(2) == network_role):
+                        break
+                    elif (v4[2] == "external"
+                            and len(m.groups()) > 0
+                            and m.group(1).endswith("_" + network_role)):
+                        break
+            else:
+                invalid_allowed_address_pairs.append(param)
+
+    assert not set(invalid_allowed_address_pairs), (
+            'invalid_allowed_address_pairs %s' % list(
+                    set(invalid_allowed_address_pairs)))
index d4fdb36..cd2e50f 100644 (file)
@@ -1,12 +1,12 @@
 # -*- coding: utf8 -*-
 # -*- coding: utf8 -*-
-# ============LICENSE_START=======================================================
+# ============LICENSE_START====================================================
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
-# under the Apache License, Version 2.0 (the “License”);
+# under the Apache License, Version 2.0 (the "License");
 # 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
 #
@@ -21,7 +21,7 @@
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
-# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 # 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
 #
 #
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
 #
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
-from .helpers import validates
+
+'''
+test_allowed_address_pairs_include_vm_type_network_role
+'''
 
 import pytest
 import yaml
 
 import pytest
 import yaml
+
+from .helpers import validates
 from .utils.ports import get_invalid_ip_addresses
 
 from .utils.ports import get_invalid_ip_addresses
 
+VERSION = '1.0.0'
+
+# pylint: disable=invalid-name
+
 
 @validates('R-41492',
            'R-35735')
 
 @validates('R-41492',
            'R-35735')
@@ -62,4 +71,6 @@ def test_allowed_address_pairs_include_vm_type_network_role(heat_template):
     invalid_ip_addresses = get_invalid_ip_addresses(yml['resources'],
                                                     "allowed_address_pairs")
 
     invalid_ip_addresses = get_invalid_ip_addresses(yml['resources'],
                                                     "allowed_address_pairs")
 
-    assert not set(invalid_ip_addresses)
+    assert not set(invalid_ip_addresses), (
+            'invalid ip addresses allowed address pairs %s' % list(
+                    set(invalid_ip_addresses)))
index 77f1c56..6e0de32 100644 (file)
@@ -1,12 +1,12 @@
 # -*- coding: utf8 -*-
 # -*- coding: utf8 -*-
-# ============LICENSE_START=======================================================
+# ============LICENSE_START====================================================
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
-# under the Apache License, Version 2.0 (the “License”);
+# under the Apache License, Version 2.0 (the "License");
 # 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
 #
@@ -21,7 +21,7 @@
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
-# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 # 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
 #
 #
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
 #
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
-from .helpers import validates
+"""test
+"""
+
+import re
 
 import pytest
 import yaml
 
 import pytest
 import yaml
-import re
+
+from .helpers import validates
+
+VERSION = '1.1.0'
 
 
 @validates('R-98450')
 
 
 @validates('R-98450')
@@ -57,9 +63,9 @@ def test_availability_zone_naming(heat_template):
     if "resources" not in yml:
         pytest.skip("No resources specified in the heat template")
 
     if "resources" not in yml:
         pytest.skip("No resources specified in the heat template")
 
-    invalid_availability_zones = []
+    invalid_availability_zones = set()
 
 
-    for k1, v1 in yml["resources"].items():
+    for v1 in yml["resources"].values():
         if not isinstance(v1, dict):
             continue
         if "properties" not in v1:
         if not isinstance(v1, dict):
             continue
         if "properties" not in v1:
@@ -71,8 +77,11 @@ def test_availability_zone_naming(heat_template):
             for k2, v2 in v1["properties"].items():
                 if k2 != 'availability_zone':
                     continue
             for k2, v2 in v1["properties"].items():
                 if k2 != 'availability_zone':
                     continue
-
+                if 'str_replace' in v2:
+                    continue
                 if not re.match(r'availability_zone_\d+', v2["get_param"]):
                 if not re.match(r'availability_zone_\d+', v2["get_param"]):
-                    invalid_availability_zones.append(v2["get_param"])
+                    invalid_availability_zones.add(v2["get_param"])
 
 
-    assert not set(invalid_availability_zones)
+    assert not invalid_availability_zones, (
+            'invalid availability zones %s' % list(
+                    invalid_availability_zones))
index cc7ab0b..40452ae 100644 (file)
@@ -1,12 +1,12 @@
 # -*- coding: utf8 -*-
 # -*- coding: utf8 -*-
-# ============LICENSE_START=======================================================
+# ============LICENSE_START====================================================
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
-# under the Apache License, Version 2.0 (the “License”);
+# under the Apache License, Version 2.0 (the "License");
 # 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
 #
@@ -21,7 +21,7 @@
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
-# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 # 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
 #
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
 
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
 
+"""base template names
+"""
+
 from os import listdir
 from os import path
 import re
 from os import listdir
 from os import path
 import re
+
 from .helpers import check_basename_ending
 from .helpers import validates
 
 from .helpers import check_basename_ending
 from .helpers import validates
 
+VERSION = '1.2.0'
+
 # is 'base', starts with 'base_', contains '_base_', ends with '_base'
 RE_BASE = re.compile(r'(^base$)|(^base_)|(_base_)|(_base$)')
 
 # is 'base', starts with 'base_', contains '_base_', ends with '_base'
 RE_BASE = re.compile(r'(^base$)|(^base_)|(_base_)|(_base$)')
 
@@ -66,4 +72,7 @@ def test_base_template_names(template_dir):
 
         if RE_BASE.search(filename):
             base_template_count += 1
 
         if RE_BASE.search(filename):
             base_template_count += 1
-    assert base_template_count == 1
+    assert base_template_count == 1, (
+            'must be 1 "*_base_*" in %s not %d' % (
+                    filenames,
+                    base_template_count))
index bec40f2..fc1edc1 100644 (file)
@@ -1,12 +1,12 @@
 # -*- coding: utf8 -*-
 # -*- coding: utf8 -*-
-# ============LICENSE_START=======================================================
+# ============LICENSE_START====================================================
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
-# under the Apache License, Version 2.0 (the “License”);
+# under the Apache License, Version 2.0 (the "License");
 # 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
 #
@@ -21,7 +21,7 @@
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
-# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 # 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
 #
 #
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
 #
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
-from .helpers import validates
+
+'''
+test_base_template_outputs_consumed
+'''
+
 from os import path, sep
 from os import path, sep
-import yaml
+
 import pytest
 import pytest
+import yaml
+
+from .helpers import validates
+
+VERSION = '1.0.0'
+
+# pylint: disable=invalid-name
 
 
 @validates('R-52753')
 
 
 @validates('R-52753')
@@ -56,11 +67,11 @@ def test_base_template_outputs_consumed(heat_templates):
         with open(heat_template) as fh:
             yml = yaml.load(fh)
         basename = path.splitext(heat_template)[0].rsplit(sep, 1)[1]
         with open(heat_template) as fh:
             yml = yaml.load(fh)
         basename = path.splitext(heat_template)[0].rsplit(sep, 1)[1]
-        if (basename.endswith("_base") or
-                basename.startswith("base_") or
-                basename.find("_base_") > 0):
-                base_template = heat_template
-                base_template_yml = yml
+        if (basename.endswith("_base")
+                or basename.startswith("base_")
+                or basename.find("_base_") > 0):
+            base_template = heat_template
+            base_template_yml = yml
 
     # get the base template outputs
     if "outputs" not in base_template_yml:
 
     # get the base template outputs
     if "outputs" not in base_template_yml:
@@ -83,4 +94,6 @@ def test_base_template_outputs_consumed(heat_templates):
         parameters = yml["parameters"].keys()
         non_base_parameters.extend(parameters)
 
         parameters = yml["parameters"].keys()
         non_base_parameters.extend(parameters)
 
-    assert base_outputs <= set(non_base_parameters)
+    assert base_outputs <= set(non_base_parameters), (
+            'unconsumed outputs %s' % list(
+                    base_outputs - set(non_base_parameters)))
diff --git a/ice_validator/tests/test_cloud_config_resource_id.py b/ice_validator/tests/test_cloud_config_resource_id.py
new file mode 100644 (file)
index 0000000..bd04e37
--- /dev/null
@@ -0,0 +1,87 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+#
+
+'''
+A VNF's Heat Orchestration Template's Resource ``OS::Heat::CloudConfig``
+Resource ID **MUST** contain the ``{vm-type}``.
+'''
+
+import pytest
+
+from .structures import Heat
+from .helpers import validates
+from .utils import vm_types
+
+VERSION = '1.0.0'
+
+
+@validates('R-04747')
+def test_cloud_config(heat_template):
+    '''validate resource ids
+    '''
+    h = Heat(filepath=heat_template)
+    if not h.resources:
+        pytest.skip('No resources in this template')
+
+    cloud_configs = get_cloud_configs(h)
+    if not cloud_configs:
+        pytest.skip('No CloudConfig resources in this template')
+
+    resource_vm_types = vm_types.get_vm_types(h.resources)
+    if not resource_vm_types:
+        pytest.skip('No resources with {vm-type} in this template')
+
+    bad = set()
+    for rid in cloud_configs:
+        for vm_type in resource_vm_types:
+            if vm_type in rid:
+                break
+        else:
+            bad.add(rid)
+    assert not bad, 'CloudConfigs %s have {vm-type} not in %s' % (
+            list(bad),
+            list(resource_vm_types))
+
+
+def get_cloud_configs(heat):
+    """Return list of resource_id whose type is OS::Heat::CloudConfig.
+    """
+    return [rid for rid, resource in heat.resources.items()
+            if heat.nested_get(resource, 'type') == 'OS::Heat::CloudConfig']
index 86270fd..865845a 100644 (file)
@@ -1,12 +1,12 @@
 # -*- coding: utf8 -*-
 # -*- coding: utf8 -*-
-# ============LICENSE_START=======================================================
+# ============LICENSE_START====================================================
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
-# under the Apache License, Version 2.0 (the “License”);
+# under the Apache License, Version 2.0 (the "License");
 # 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
 #
@@ -21,7 +21,7 @@
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
-# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 # 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
 #
 #
 from .helpers import validates
 
 #
 from .helpers import validates
 
+'''test_env_and_yaml_same_name
+'''
 from os import listdir
 from os import path
 
 from os import listdir
 from os import path
 
+VERSION = '1.0.0'
+
 
 @validates('R-67205', 'R-35727', 'R-22656')
 def test_env_and_yaml_same_name(template_dir):
 
 @validates('R-67205', 'R-35727', 'R-22656')
 def test_env_and_yaml_same_name(template_dir):
@@ -55,7 +59,11 @@ def test_env_and_yaml_same_name(template_dir):
                  if path.splitext(f)[-1] == ".env"]
     yaml_files = [f for f in files
                   if path.splitext(f)[-1] in ['.yml', '.yaml']]
                  if path.splitext(f)[-1] == ".env"]
     yaml_files = [f for f in files
                   if path.splitext(f)[-1] in ['.yml', '.yaml']]
+    unmatched = []
     for filename in env_files:
         basename = path.splitext(filename)[0]
     for filename in env_files:
         basename = path.splitext(filename)[0]
-        assert basename + '.yaml' in yaml_files or \
-            basename + '.yml' in yaml_files
+        if (basename + '.yaml' not in yaml_files
+                and basename + '.yml' not in yaml_files):
+            unmatched.append(filename)
+    assert not unmatched, (
+            'files with no corresponding .y[a]ml %s' % unmatched)
index 285f200..d784d20 100644 (file)
@@ -1,12 +1,12 @@
 # -*- coding: utf8 -*-
 # -*- coding: utf8 -*-
-# ============LICENSE_START=======================================================
+# ============LICENSE_START====================================================
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
-# under the Apache License, Version 2.0 (the “License”);
+# under the Apache License, Version 2.0 (the "License");
 # 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
 #
@@ -21,7 +21,7 @@
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
-# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 # 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
 #
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
 
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
 
+'''
+test_env_files_provided
+'''
+
+VERSION = '1.0.0'
+
 
 def test_env_files_provided(env_files):
     '''
     Make sure environment files have been provided
     '''
 
 def test_env_files_provided(env_files):
     '''
     Make sure environment files have been provided
     '''
-    assert len(env_files) > 0
+    assert len(env_files) > 0, '"*.env" not found'
index 7213e3b..b50629e 100644 (file)
@@ -1,12 +1,12 @@
 # -*- coding: utf8 -*-
 # -*- coding: utf8 -*-
-# ============LICENSE_START=======================================================
+# ============LICENSE_START====================================================
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
-# under the Apache License, Version 2.0 (the “License”);
+# under the Apache License, Version 2.0 (the "License");
 # 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
 #
@@ -21,7 +21,7 @@
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
-# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 # 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
 #
 #
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
 #
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
-from .helpers import validates
+
+""" environment file structure
+"""
+
 import yaml
 import pytest
 
 import yaml
 import pytest
 
+from .helpers import validates
+
+VERSION = '1.0.0'
+
+# pylint: disable=invalid-name
+
 
 def test_environment_structure(env_file):
     '''
 
 def test_environment_structure(env_file):
     '''
@@ -51,7 +60,10 @@ def test_environment_structure(env_file):
 
     with open(env_file) as fh:
         yml = yaml.load(fh)
 
     with open(env_file) as fh:
         yml = yaml.load(fh)
-    assert any(map(lambda v: v in yml, key_values))
+    assert [k for k in key_values if k in yml], (
+            '%s missing any of %s' % (
+                    env_file,
+                    key_values))
 
 
 @validates('R-03324')
 
 
 @validates('R-03324')
@@ -59,11 +71,12 @@ def test_environment_file_contains_required_sections(env_file):
     '''
     Check that all environments files only have the allowed sections
     '''
     '''
     Check that all environments files only have the allowed sections
     '''
-    required_key_values = ["parameters"]
+    required_keys = ["parameters"]
 
     with open(env_file) as fh:
         yml = yaml.load(fh)
 
     with open(env_file) as fh:
         yml = yaml.load(fh)
-    assert any(map(lambda v: v in yml, required_key_values))
+    missing_keys = [v for v in required_keys if v not in yml]
+    assert not missing_keys, '%s missing %s' % (env_file, missing_keys)
 
 
 def test_environment_file_sections_have_the_right_format(env_file):
 
 
 def test_environment_file_sections_have_the_right_format(env_file):
@@ -71,29 +84,30 @@ def test_environment_file_sections_have_the_right_format(env_file):
     Check that all environment files have sections of the right format.
     Do note that it only tests for dicts or not dicts currently.
     '''
     Check that all environment files have sections of the right format.
     Do note that it only tests for dicts or not dicts currently.
     '''
-    key_values = ["parameters", "event_sinks", "encrypted_parameters",
-                  "parameter_merge_strategies"]
-    key_values_not_dicts = ["event_sinks"]
+    dict_keys = [
+            "parameters",
+            "encrypted_parameters",
+            "parameter_merge_strategies"]
+    not_dict_keys = [
+            "event_sinks"]
 
     with open(env_file) as fh:
         yml = yaml.load(fh)
 
 
     with open(env_file) as fh:
         yml = yaml.load(fh)
 
-    if not any(map(lambda v: v in yml, key_values)):
+    if not [k for k in dict_keys + not_dict_keys if k in yml]:
         pytest.skip('The fixture is not applicable for this test')
 
         pytest.skip('The fixture is not applicable for this test')
 
-    is_dict = 0
-    should_be_dict = 0
-    is_not_dict = 0
-    should_not_be_dict = 0
-    for key_value in key_values:
-        if key_value in yml:
-            if isinstance(yml[key_value], dict):
-                is_dict += 1
-                if key_value not in key_values_not_dicts:
-                    should_be_dict += 1
-            elif not isinstance(yml[key_value], list):
-                is_not_dict += 1
-                if key_value in key_values_not_dicts:
-                    should_not_be_dict += 1
-    assert (is_dict == should_be_dict and
-            is_not_dict == should_not_be_dict)
+    bad_dict_keys = [k for k in dict_keys
+                     if k in yml
+                     and not isinstance(yml[k], dict)]
+    bad_not_dict_keys = [k for k in not_dict_keys
+                         if k in yml
+                         and isinstance(yml[k], dict)]
+    errors = []
+    if bad_dict_keys:
+        errors.append('must be dict %s' % bad_dict_keys)
+    if bad_not_dict_keys:
+        errors.append('must not be dict %s' % bad_not_dict_keys)
+    assert not errors, '%s errors:\n    %s' % (
+            env_file,
+            '\n    '.join(errors))
diff --git a/ice_validator/tests/test_multipart_mime_resource_id.py b/ice_validator/tests/test_multipart_mime_resource_id.py
new file mode 100644 (file)
index 0000000..58023a5
--- /dev/null
@@ -0,0 +1,87 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+#
+
+'''
+A VNF's Heat Orchestration Template's Resource ``OS::Heat::MultipartMime``
+Resource ID **MUST** contain the ``{vm-type}``.
+'''
+
+import pytest
+
+from .structures import Heat
+from .helpers import validates
+from .utils import vm_types
+
+VERSION = '1.0.1'
+
+
+@validates('R-30804')
+def test_multipart_mime(heat_template):
+    '''validate resource ids
+    '''
+    h = Heat(filepath=heat_template)
+    if not h.resources:
+        pytest.skip('No resources in this template')
+
+    multipart_mimes = get_multipart_mimes(h)
+    if not multipart_mimes:
+        pytest.skip('No MultipartMime resources in this template')
+
+    resource_vm_types = vm_types.get_vm_types(h.resources)
+    if not resource_vm_types:
+        pytest.skip('No resources with {vm-type} in this template')
+
+    bad = set()
+    for rid in multipart_mimes:
+        for vm_type in resource_vm_types:
+            if vm_type in rid:
+                break
+        else:
+            bad.add(rid)
+    assert not bad, 'MultipartMime %s have {vm-type} not in %s' % (
+            list(bad),
+            list(resource_vm_types))
+
+
+def get_multipart_mimes(heat):
+    """Return list of resource_id whose type is OS::Heat::MultipartMime.
+    """
+    return [rid for rid, resource in heat.resources.items()
+            if heat.nested_get(resource, 'type') == 'OS::Heat::MultipartMime']
diff --git a/ice_validator/tests/test_nova_servers_index.py b/ice_validator/tests/test_nova_servers_index.py
new file mode 100644 (file)
index 0000000..3ca99a0
--- /dev/null
@@ -0,0 +1,119 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+#
+
+'''
+Ensure that if a resource_id has an {index}, then all resources of
+the same vm-type have an index, the indices are consecutive and start
+with 0.
+'''
+
+import collections
+import re
+
+import pytest
+
+from .structures import Heat
+from .helpers import validates
+from .utils import vm_types
+
+VERSION = '1.1.0'
+
+RE_INDEXED_RESOURCE_ID = re.compile(r'\w+_(?P<index>\d+)$')
+
+
+@validates('R-11690')
+def test_indices(heat_templates):
+    '''validate indices
+    '''
+    indexed_resource_ids = {}
+    resources = {}
+    for heat_template in heat_templates:
+        h = Heat(filepath=heat_template)
+        if h.resources:
+            indexed_resource_ids.update(get_indexed_resource_ids(h.resources))
+            resources.update(h.resources)
+    if not resources:
+        pytest.skip('No resources found')
+
+    if not indexed_resource_ids:
+        pytest.skip('No resources with {index} found')
+
+    types = get_types(resources, indexed_resource_ids)
+    if not types:
+        pytest.skip('No resources with {vm-type} found')
+
+    indices = collections.defaultdict(list)
+    for resource_id, vm_type in types.items():
+        indices[vm_type].append(indexed_resource_ids[resource_id])
+    bad = {}
+    for vm_type, index_list in indices.items():
+        for i in range(len(index_list)):
+            if i not in index_list:
+                bad[vm_type] = index_list
+                break
+    assert not bad, (
+            'vm-type indices must be consecutive, unique,'
+            ' and start at 0.\n    %s' % (
+                    '\n    '.join(['Resource ID %s: VM Type: %s' % (x, y)
+                                   for x, y in types.items() if y in bad])))
+
+
+def get_indexed_resource_ids(resources):
+    """Return dict. keys are resource_ids which end in an index.
+    values are the integer index parsed from the resource_id.
+    """
+    indexed_resource_ids = {}
+    for resource in resources:
+        match = RE_INDEXED_RESOURCE_ID.match(resource)
+        if match:
+            indexed_resource_ids[resource] = int(match.groupdict()['index'])
+    return indexed_resource_ids
+
+
+def get_types(resources, indexed_resource_ids):
+    """Return dict. keys are resource_ids from indexed_resource_ids.
+    values are the vm-type extracted from the resource.
+    """
+    all_vm_types = {}
+    for rid in indexed_resource_ids:
+        x = vm_types.get_vm_types_for_resource(resources[rid])
+        if x and len(x) == 1:
+            all_vm_types[rid] = list(x)[0]  # x is a set.
+    return all_vm_types
diff --git a/ice_validator/tests/test_vm_type_resource_id.py b/ice_validator/tests/test_vm_type_resource_id.py
new file mode 100644 (file)
index 0000000..9a47656
--- /dev/null
@@ -0,0 +1,74 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+#
+
+'''vm-type resource_id
+'''
+
+import pytest
+
+from .structures import Heat
+from .helpers import validates
+from .utils import vm_types as utils_vm_types
+
+VERSION = '1.1.0'
+
+
+@validates('R-46839')
+def test_vm_type_resource_id(heat_template):
+    '''
+    A VNF's Heat Orchestration Template's use of ``{vm-type}``
+    in all Resource IDs **MUST** be the same case.
+    '''
+    bad = {}
+    h = Heat(filepath=heat_template)
+    if not h.resources:
+        pytest.skip("No resources specified in the heat template")
+    vm_types = {v + '_': v.lower() + '_'
+                for v in utils_vm_types.get_vm_types(h.resources)}
+    if not vm_types:
+        pytest.skip("No {vm-type} specified in the heat template")
+
+    for rid in h.resources:
+        lower_rid = rid.lower()
+        for vm_type, lower_vm_type in vm_types.items():
+            if (lower_rid.startswith(lower_vm_type)
+               and not rid.startswith(vm_type)):
+                    bad[rid] = vm_type
+    assert not bad, 'resource_id which do not match their vm-type %s' % bad
diff --git a/ice_validator/tests/test_vm_type_syntax.py b/ice_validator/tests/test_vm_type_syntax.py
new file mode 100644 (file)
index 0000000..b44118b
--- /dev/null
@@ -0,0 +1,74 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+#
+
+'''vm-type syntax
+'''
+
+import re
+
+import pytest
+
+from .structures import Heat
+from .helpers import validates
+from .utils import vm_types
+
+VERSION = '1.0.0'
+
+RE_VM_TYPE = re.compile(r'[\w\d_]+$')
+RE_VM_TYPE_NG = re.compile(r'.*_int|_?int_.*$')
+
+
+@validates('R-98407')
+def test_vm_type_syntax(heat_template):
+    '''
+    A VNF's Heat Orchestration Template's ``{vm-type}``
+    **MUST** contain only
+    alphanumeric characters and/or underscores '_' and **MUST NOT**
+    contain any of the following strings:
+    ``_int`` or ``int_`` or ``_int_``.
+    '''
+    v = Heat(filepath=heat_template)
+    if not v.resources:
+        pytest.skip("No resources")
+    t = set()
+    t.update(*[vm_types.get_vm_types_for_resource(r)
+               for r in v.resources.values()])
+    bad = [x for x in t if not RE_VM_TYPE.match(x) or RE_VM_TYPE_NG.match(x)]
+    assert not bad, 'bad vm-types %s' % bad
diff --git a/ice_validator/tests/utils/nested_dict.py b/ice_validator/tests/utils/nested_dict.py
new file mode 100644 (file)
index 0000000..9bc3e99
--- /dev/null
@@ -0,0 +1,64 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START====================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#             https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+#
+
+'''nested_dict.get
+'''
+
+VERSION = '1.0.0'
+
+
+def get(dic, *keys):
+    '''Return the value of the last key given a (nested) dict
+    and list of keys.  If any key is missing, or if the value
+    of any key except the last is not a dict, then None is returned.
+    '''
+    d = dic
+    for key in keys:
+        if hasattr(d, 'get'):
+            d = d.get(key)
+        else:
+            return None
+    return d
+
+
+def is_dict_has_key(obj, key):
+    '''return True/False `obj` is a dict and has `key`
+    '''
+    return isinstance(obj, dict) and key in obj
index e2c9ed3..39306eb 100644 (file)
@@ -2,11 +2,11 @@
 # ============LICENSE_START====================================================
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # ============LICENSE_START====================================================
 # org.onap.vvp/validation-scripts
 # ===================================================================
-# Copyright Â© 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
-# under the Apache License, Version 2.0 (the â€œLicenseâ€\9d);
+# under the Apache License, Version 2.0 (the "License");
 # 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
 #
@@ -21,7 +21,7 @@
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
-# under the Creative Commons License, Attribution 4.0 Intl. (the License);
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 # 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
 #
index eea6e19..b6deaba 100644 (file)
@@ -6,7 +6,7 @@
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
-# under the Apache License, Version 2.0 (the “License”);
+# under the Apache License, Version 2.0 (the "License");
 # 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
 #
@@ -21,7 +21,7 @@
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
-# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 # 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
 #
index fbe6dce..3f8d6b8 100644 (file)
@@ -6,7 +6,7 @@
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
-# under the Apache License, Version 2.0 (the “License”);
+# under the Apache License, Version 2.0 (the "License");
 # 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
 #
@@ -21,7 +21,7 @@
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
-# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 # 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
 #
index 4d0b4ca..c9d4be9 100644 (file)
@@ -6,7 +6,7 @@
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
-# under the Apache License, Version 2.0 (the “License”);
+# under the Apache License, Version 2.0 (the "License");
 # 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
 #
@@ -21,7 +21,7 @@
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
-# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 # 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
 #
index 5bd447b..41da7d9 100644 (file)
@@ -6,7 +6,7 @@
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
-# under the Apache License, Version 2.0 (the “License”);
+# under the Apache License, Version 2.0 (the "License");
 # 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
 #
@@ -21,7 +21,7 @@
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
-# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 # 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
 #
old mode 100755 (executable)
new mode 100644 (file)
index 7cdd147..c64c0ee
@@ -1,12 +1,12 @@
 # -*- coding: utf8 -*-
 # -*- coding: utf8 -*-
-# ============LICENSE_START=======================================================
+# ============LICENSE_START====================================================
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
 # org.onap.vvp/validation-scripts
 # ===================================================================
 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
-# under the Apache License, Version 2.0 (the “License”);
+# under the Apache License, Version 2.0 (the "License");
 # 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
 #
@@ -21,7 +21,7 @@
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
-# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 # 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
 #
@@ -38,6 +38,9 @@
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
 
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
 
+"""volume resources
+"""
+
 from os import path
 import yaml
 
 from os import path
 import yaml
 
index 0d292fe..8a5006c 100644 (file)
@@ -6,7 +6,7 @@
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
-# under the Apache License, Version 2.0 (the “License”);
+# under the Apache License, Version 2.0 (the "License");
 # 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
 #
@@ -21,7 +21,7 @@
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
 #
 #
 # Unless otherwise specified, all documentation contained herein is licensed
-# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 # 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
 #