From: Lovett, Trevor Date: Mon, 15 Apr 2019 16:47:25 +0000 (-0500) Subject: [VVP] Updated network param validations per reqts X-Git-Tag: 5.0.0~47 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=vvp%2Fvalidation-scripts.git;a=commitdiff_plain;h=e5d7862c7c6c02847b8b4f95d2af0c5e9a454828 [VVP] Updated network param validations per reqts Change-Id: Idb0e051d6063cd94b733ed68093989d527592c9f Issue-ID: VVP-193 Signed-off-by: Lovett, Trevor Signed-off-by: Lovett, Trevor (tl2972) --- diff --git a/ice_validator/tests/fixtures/test_network_format_use_get_param_or_get_resource/fail/get_param_not_used_for_network.yaml b/ice_validator/tests/fixtures/test_network_format_use_get_param_or_get_resource/fail/get_param_not_used_for_network.yaml deleted file mode 100644 index ecb500e..0000000 --- a/ice_validator/tests/fixtures/test_network_format_use_get_param_or_get_resource/fail/get_param_not_used_for_network.yaml +++ /dev/null @@ -1,75 +0,0 @@ -# -*- 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============================================ -# -# ---- -resources: - vm_type_1_int_intranet_0_port: - type: OS::Neutron::Port - properties: - network: { int_intranet_net_name } - - vm_type_1_int_vpnnet_0_port: - type: OS::Neutron::Port - properties: - network: { get_param: int_vpnnet_net_id } - - vm_type_1_external_net_0_port: - type: OS::Neutron::Port - properties: - network: { get_param: external_net_name } - - vm_type_1_extnet_0_port: - type: OS::Neutron::Port - properties: - network: { get_param: extnet_net_id } - - int_network: - type: OS::Neutron::Net - properties: - name: - str_replace: - template: $PREFIX_int_network - params: - $PREFIX: { get_param: vnf_name } - admin_state_up: True - shared: False - - vm_type_0_int_network_0_port: - type: OS::Neutron::Port - properties: - network: { get_resource: int_network } diff --git a/ice_validator/tests/fixtures/test_network_format_use_get_param_or_get_resource/pass/valid_heat_template.yaml b/ice_validator/tests/fixtures/test_network_format_use_get_param_or_get_resource/pass/valid_heat_template.yaml deleted file mode 100644 index eb4c8f2..0000000 --- a/ice_validator/tests/fixtures/test_network_format_use_get_param_or_get_resource/pass/valid_heat_template.yaml +++ /dev/null @@ -1,75 +0,0 @@ -# -*- 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============================================ -# -# ---- -resources: - vm_type_1_int_intranet_0_port: - type: OS::Neutron::Port - properties: - network: { get_param: int_intranet_net_name } - - vm_type_1_int_vpnnet_0_port: - type: OS::Neutron::Port - properties: - network: { get_param: int_vpnnet_net_id } - - vm_type_1_external_net_0_port: - type: OS::Neutron::Port - properties: - network: { get_param: external_net_name } - - vm_type_1_extnet_0_port: - type: OS::Neutron::Port - properties: - network: { get_param: extnet_net_id } - - int_network: - type: OS::Neutron::Net - properties: - name: - str_replace: - template: $PREFIX_int_network - params: - $PREFIX: { get_param: vnf_name } - admin_state_up: True - shared: False - - vm_type_0_int_network_0_port: - type: OS::Neutron::Port - properties: - network: { get_resource: int_network } diff --git a/ice_validator/tests/fixtures/test_neutron_port_internal_network/fail/fail0.yaml b/ice_validator/tests/fixtures/test_neutron_port_internal_network/fail/fail0.yaml deleted file mode 100644 index 2309104..0000000 --- a/ice_validator/tests/fixtures/test_neutron_port_internal_network/fail/fail0.yaml +++ /dev/null @@ -1,99 +0,0 @@ -# -*- 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============================================ -# -# -# VERSION: '1.0.0' - ---- -parameters: - - vm_typeX_bialy_vlan_filter: - type: comma_delimited_list - vm_typeX_bialy_public_vlans: - type: comma_delimited_list - vm_typeX_bialy_private_vlans: - type: comma_delimited_list - vm_typeX_bialy_guest_vlans: - type: comma_delimited_list - subnet_param: - type: string - subnet_id_param: - type: string - int_extnet_net_id: - type: string - int_intranet_net_name: - type: string -resources: - - vm_typeX_0_intranet_port_2: - type: OS::Neutron::Port - properties: - network: { get_param: int_intranet_net_name } - fixed_ips: - - ip_address: { get_param: lb_1_int_intranet_floating_ip } - subnet: { get_param: subnet_param } - subnet_id: { get_param: subnet_id_param } - binding:vnic_type: direct - value_specs: - vlan_filter: {get_param: vm_typeX_bialy_vlan_filter} - public_vlans: {get_param: vm_typeX_bialy_public_vlans} - private_vlans: {get_param: vm_typeX_bialy_private_vlans} - guest_vlans: {get_param: vm_typeX_bialy_guest_vlans} - vlan_mirror: - ATT_FABRIC_CONFIGURATION_REQUIRED: true - metadata: - port_type: SR-IOV_Trunk - - vm_typeX_3_extnet_port_2: - type: OS::Neutron::Port - properties: - network: { get_param: int_extnet_net_id } - fixed_ips: - - ip_address: { get_param: lb_2_extnet_floating_v6_ip } - subnet: { get_param: subnet_param } - subnet_id: { get_param: subnet_id_param } - binding:vnic_type: direct - value_specs: - vlan_filter: {get_param: vm_typeX_bialy_vlan_filter} - public_vlans: {get_param: vm_typeX_bialy_public_vlans} - private_vlans: {get_param: vm_typeX_bialy_private_vlans} - guest_vlans: {get_param: vm_typeX_bialy_guest_vlans} - vlan_mirror: - ATT_FABRIC_CONFIGURATION_REQUIRED: true - metadata: - port_type: SR-IOV_Mirrored_Trunk - diff --git a/ice_validator/tests/fixtures/test_neutron_port_internal_network/pass/pass0.yaml b/ice_validator/tests/fixtures/test_neutron_port_internal_network/pass/pass0.yaml deleted file mode 100644 index 6983f7c..0000000 --- a/ice_validator/tests/fixtures/test_neutron_port_internal_network/pass/pass0.yaml +++ /dev/null @@ -1,105 +0,0 @@ -# -*- coding: utf8 -*- -# ============LICENSE_START==================================================== -# org.onap.vvp/validation-scripts -# =================================================================== -# Copyright © 2019 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============================================ - -parameters: - - vm_typeX_bialy_vlan_filter: - type: comma_delimited_list - vm_typeX_bialy_public_vlans: - type: comma_delimited_list - vm_typeX_bialy_private_vlans: - type: comma_delimited_list - vm_typeX_bialy_guest_vlans: - type: comma_delimited_list - subnet_param: - type: string - subnet_id_param: - type: string - int_intranet_net_id: - type: string - -resources: - - vm_typeX_0_intranet_port_2: - type: OS::Neutron::Port - properties: - network: { get_param: int_intranet_net_id } - fixed_ips: - - ip_address: { get_param: lb_1_int_intranet_floating_ip } - subnet: { get_param: subnet_param } - subnet_id: { get_param: subnet_id_param } - binding:vnic_type: direct - value_specs: - vlan_filter: {get_param: vm_typeX_bialy_vlan_filter} - public_vlans: {get_param: vm_typeX_bialy_public_vlans} - private_vlans: {get_param: vm_typeX_bialy_private_vlans} - guest_vlans: {get_param: vm_typeX_bialy_guest_vlans} - vlan_mirror: - ATT_FABRIC_CONFIGURATION_REQUIRED: true - metadata: - port_type: SR-IOV_Trunk - - vm_typeX_3_extnet_port_2: - type: OS::Neutron::Port - properties: - network: { get_param: int_intranet_net_id } - fixed_ips: - - ip_address: { get_param: lb_2_extnet_floating_v6_ip } - subnet: { get_param: subnet_param } - subnet_id: { get_param: subnet_id_param } - binding:vnic_type: direct - value_specs: - vlan_filter: {get_param: vm_typeX_bialy_vlan_filter} - public_vlans: {get_param: vm_typeX_bialy_public_vlans} - private_vlans: {get_param: vm_typeX_bialy_private_vlans} - guest_vlans: {get_param: vm_typeX_bialy_guest_vlans} - vlan_mirror: - ATT_FABRIC_CONFIGURATION_REQUIRED: true - metadata: - port_type: SR-IOV_Mirrored_Trunk - - int_special_network: - type: OS::Neutron::Net - - vm_typeX_3_extnet_port_3: - type: nested.yaml - properties: - int_special_net_id: { get_resource: int_special_network } - - - - diff --git a/ice_validator/tests/fixtures/test_network_format_use_get_param_or_get_resource/fail/get_resource_used_for_external_network.yaml b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_external_get_param_with_list/vnf_base.yaml similarity index 70% rename from ice_validator/tests/fixtures/test_network_format_use_get_param_or_get_resource/fail/get_resource_used_for_external_network.yaml rename to ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_external_get_param_with_list/vnf_base.yaml index 8268b66..8f9ff53 100644 --- a/ice_validator/tests/fixtures/test_network_format_use_get_param_or_get_resource/fail/get_resource_used_for_external_network.yaml +++ b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_external_get_param_with_list/vnf_base.yaml @@ -1,5 +1,5 @@ # -*- coding: utf8 -*- -# ============LICENSE_START======================================================= +# ============LICENSE_START==================================================== # org.onap.vvp/validation-scripts # =================================================================== # Copyright © 2017 AT&T Intellectual Property. All rights reserved. @@ -36,29 +36,18 @@ # ============LICENSE_END============================================ # # ---- -resources: - vm_type_1_int_intranet_0_port: - type: OS::Neutron::Port - properties: - network: { get_param: int_intranet_net_name } +# VERSION: '1.0.0' - vm_type_1_int_vpnnet_0_port: - type: OS::Neutron::Port - properties: - network: { get_param: int_vpnnet_net_id } +parameters: + external_net_id: + type: string - vm_type_1_external_net_0_port: - type: OS::Neutron::Port - properties: - network: { get_param: external_net_name } + external_net_name: + type: string - vm_type_1_extnet_0_port: - type: OS::Neutron::Port - properties: - network: { get_param: extnet_net_id } +resources: - vm_type_0_extnet_0_port: - type: OS::Neutron::Port - properties: - network: { get_resource: extnet_net_id } + vmtype_0_external_port_0: + type: OS::Neutron::Port + properties: + network: { get_param: [ {get_param: external_net_id}, 0 ]} diff --git a/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_external_invalid_param_format/vnf_base.yaml b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_external_invalid_param_format/vnf_base.yaml new file mode 100644 index 0000000..42c81c0 --- /dev/null +++ b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_external_invalid_param_format/vnf_base.yaml @@ -0,0 +1,50 @@ +# -*- 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============================================ +# +# +# VERSION: '1.0.0' + +parameters: + external_net: + type: string + +resources: + + vmtype_0_external_port_0: + type: OS::Neutron::Port + properties: + network: { get_param: external_net } diff --git a/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_external_network_role_mismatch/vnf_base.yaml b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_external_network_role_mismatch/vnf_base.yaml new file mode 100644 index 0000000..3375480 --- /dev/null +++ b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_external_network_role_mismatch/vnf_base.yaml @@ -0,0 +1,50 @@ +# -*- 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============================================ +# +# +# VERSION: '1.0.0' + +parameters: + external_net_id: + type: string + +resources: + + vmtype_0_other_port_0: + type: OS::Neutron::Port + properties: + network: { get_param: external_net_id } diff --git a/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_external_no_get_param/vnf_base.yaml b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_external_no_get_param/vnf_base.yaml new file mode 100644 index 0000000..8954e32 --- /dev/null +++ b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_external_no_get_param/vnf_base.yaml @@ -0,0 +1,53 @@ +# -*- 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============================================ +# +# +# VERSION: '1.0.0' + +parameters: + external_net_id: + type: string + + external_net_name: + type: string + +resources: + + vmtype_0_external_port_0: + type: OS::Neutron::Port + properties: + network: 123 diff --git a/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_incorrect_naming_convention/module1.yaml b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_incorrect_naming_convention/module1.yaml new file mode 100644 index 0000000..bbab87d --- /dev/null +++ b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_incorrect_naming_convention/module1.yaml @@ -0,0 +1,49 @@ +# -*- coding: utf8 -*- +# ============LICENSE_START==================================================== +# org.onap.vvp/validation-scripts +# =================================================================== +# Copyright © 2019 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============================================ + +parameters: + + int_intranet_net: + type: string + + +resources: + + vmtype_0_int_intranet_port_0: + type: OS::Neutron::Port + properties: + network: { get_param: int_intranet_net } diff --git a/ice_validator/tests/fixtures/test_neutron_port_internal_network/fail/fail0_base.yaml b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_incorrect_naming_convention/vnf_base.yaml similarity index 85% rename from ice_validator/tests/fixtures/test_neutron_port_internal_network/fail/fail0_base.yaml rename to ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_incorrect_naming_convention/vnf_base.yaml index 0a2af73..bb0b819 100644 --- a/ice_validator/tests/fixtures/test_neutron_port_internal_network/fail/fail0_base.yaml +++ b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_incorrect_naming_convention/vnf_base.yaml @@ -38,25 +38,17 @@ # # VERSION: '1.0.0' ---- -outputs: - - #int_extnet_net_id: - # value: { get_resource: int_extnet_net_id } - #int_intranet_net_name: - # value: { get_param: int_intranet_net_name } - - resources: - int_intranet_net_name: + int_intranet_network: type: OS::Neutron::Net properties: - name: { get_param: int_intranet_net_name } + name: network_name - int_extnet_net_id: - type: OS::Neutron::Net +outputs: + + int_intranet_net: + value: { get_resource: int_intranet_network } -parameters: int_intranet_net_name: - type: string + value: { get_attr: int_intranet_network } diff --git a/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_internal_no_matching_network_base/module1.yaml b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_internal_no_matching_network_base/module1.yaml new file mode 100644 index 0000000..25d8d15 --- /dev/null +++ b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_internal_no_matching_network_base/module1.yaml @@ -0,0 +1,49 @@ +# -*- coding: utf8 -*- +# ============LICENSE_START==================================================== +# org.onap.vvp/validation-scripts +# =================================================================== +# Copyright © 2019 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============================================ + +parameters: + + int_intranet_net_id: + type: string + + +resources: + + vmtype_0_int_intranet_port_0: + type: OS::Neutron::Port + properties: + network: { get_param: int_intranet_net_id } diff --git a/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_internal_no_matching_network_base/nested.yaml b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_internal_no_matching_network_base/nested.yaml new file mode 100644 index 0000000..456702c --- /dev/null +++ b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_internal_no_matching_network_base/nested.yaml @@ -0,0 +1,46 @@ +# -*- coding: utf8 -*- +# ============LICENSE_START==================================================== +# org.onap.vvp/validation-scripts +# =================================================================== +# Copyright © 2019 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============================================ + +parameters: + + int_special_net: + type: string + +resources: + + int_special_RVN: + type: OS::ContrailV2::VirtualNetwork diff --git a/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_internal_no_matching_network_base/vnf_base.yaml b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_internal_no_matching_network_base/vnf_base.yaml new file mode 100644 index 0000000..7f7d616 --- /dev/null +++ b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_internal_no_matching_network_base/vnf_base.yaml @@ -0,0 +1,53 @@ +# -*- 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============================================ +# +# +# VERSION: '1.0.0' + +resources: + + int_other_network: + type: OS::Neutron::Net + properties: + name: network_name + + nested_resource: + type: nested.yaml + +outputs: + int_intranet_net_id: + value: { get_resource: int_other_network } \ No newline at end of file diff --git a/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_module_not_using_base/module1.yaml b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_module_not_using_base/module1.yaml new file mode 100644 index 0000000..f415e46 --- /dev/null +++ b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_module_not_using_base/module1.yaml @@ -0,0 +1,56 @@ +# -*- coding: utf8 -*- +# ============LICENSE_START==================================================== +# org.onap.vvp/validation-scripts +# =================================================================== +# Copyright © 2019 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============================================ + +parameters: + + int_intranet_net_id: + type: string + + + int_intranet_net_name: + type: string + + other_net_name: + type: string + + +resources: + + vmtype_0_int_intranet_port_0: + type: OS::Neutron::Port + properties: + network: 123 diff --git a/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_module_not_using_base/vnf_base.yaml b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_module_not_using_base/vnf_base.yaml new file mode 100644 index 0000000..7c6e4df --- /dev/null +++ b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_module_not_using_base/vnf_base.yaml @@ -0,0 +1,54 @@ +# -*- 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============================================ +# +# +# VERSION: '1.0.0' + +resources: + + int_intranet_network: + type: OS::Neutron::Net + properties: + name: network_name + +outputs: + + int_intranet_net_id: + value: { get_resource: int_intranet_network } + + int_intranet_net_name: + value: { get_attr: int_intranet_network } diff --git a/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_network_role_mismatch/module1.yaml b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_network_role_mismatch/module1.yaml new file mode 100644 index 0000000..fa81355 --- /dev/null +++ b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_network_role_mismatch/module1.yaml @@ -0,0 +1,49 @@ +# -*- coding: utf8 -*- +# ============LICENSE_START==================================================== +# org.onap.vvp/validation-scripts +# =================================================================== +# Copyright © 2019 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============================================ + +parameters: + + int_intranet_net_id: + type: string + + +resources: + + vmtype_0_int_internal_port_0: + type: OS::Neutron::Port + properties: + network: { get_param: int_intranet_net_id } diff --git a/ice_validator/tests/fixtures/test_neutron_port_internal_network/pass/pass0_base.yaml b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_network_role_mismatch/vnf_base.yaml similarity index 97% rename from ice_validator/tests/fixtures/test_neutron_port_internal_network/pass/pass0_base.yaml rename to ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_network_role_mismatch/vnf_base.yaml index 248f780..13d96a3 100644 --- a/ice_validator/tests/fixtures/test_neutron_port_internal_network/pass/pass0_base.yaml +++ b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_network_role_mismatch/vnf_base.yaml @@ -38,15 +38,12 @@ # # VERSION: '1.0.0' - -parameters: - int_intranet_net_name: - type: string - resources: int_intranet_network: type: OS::Neutron::Net + properties: + name: network_name outputs: diff --git a/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_not_in_outputs/module1.yaml b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_not_in_outputs/module1.yaml new file mode 100644 index 0000000..25d8d15 --- /dev/null +++ b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_not_in_outputs/module1.yaml @@ -0,0 +1,49 @@ +# -*- coding: utf8 -*- +# ============LICENSE_START==================================================== +# org.onap.vvp/validation-scripts +# =================================================================== +# Copyright © 2019 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============================================ + +parameters: + + int_intranet_net_id: + type: string + + +resources: + + vmtype_0_int_intranet_port_0: + type: OS::Neutron::Port + properties: + network: { get_param: int_intranet_net_id } diff --git a/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_not_in_outputs/vnf_base.yaml b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_not_in_outputs/vnf_base.yaml new file mode 100644 index 0000000..bb15eb9 --- /dev/null +++ b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/fail/fail_not_in_outputs/vnf_base.yaml @@ -0,0 +1,46 @@ +# -*- 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============================================ +# +# +# VERSION: '1.0.0' + +resources: + + int_intranet_network: + type: OS::Neutron::Net + properties: + name: network_name \ No newline at end of file diff --git a/ice_validator/tests/fixtures/test_neutron_port_internal_network/pass/nested.yaml b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/pass/nested.yaml similarity index 96% rename from ice_validator/tests/fixtures/test_neutron_port_internal_network/pass/nested.yaml rename to ice_validator/tests/fixtures/test_neutron_port_network_attachment/pass/nested.yaml index 882a757..3deba7c 100644 --- a/ice_validator/tests/fixtures/test_neutron_port_internal_network/pass/nested.yaml +++ b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/pass/nested.yaml @@ -37,7 +37,7 @@ parameters: - int_special_net_id: + int_special_net: type: string resources: @@ -45,5 +45,5 @@ resources: vm_typeX_0_intranet_port_3: type: OS::Neutron::Port properties: - network: { get_param: int_special_net_id } + network: { get_param: int_special_net } diff --git a/ice_validator/tests/fixtures/test_neutron_port_network_attachment/pass/pass0.yaml b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/pass/pass0.yaml new file mode 100644 index 0000000..e9e6b91 --- /dev/null +++ b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/pass/pass0.yaml @@ -0,0 +1,79 @@ +# -*- coding: utf8 -*- +# ============LICENSE_START==================================================== +# org.onap.vvp/validation-scripts +# =================================================================== +# Copyright © 2019 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============================================ + +parameters: + + int_intranet_net_id: + type: string + + + int_intranet_net_name: + type: string + + other_net_name: + type: string + + +resources: + + vmtype_0_int_intranet_port_0: + type: OS::Neutron::Port + properties: + network: { get_param: int_intranet_net_id } + + vmtype_0_int_intranet_port_1: + type: OS::Neutron::Port + properties: + network: { get_param: int_intranet_net_name } + + vmtype_0_other_port_0: + type: OS::Neutron::Port + properties: + network: { get_param: other_net_name } + + int_module_network: + type: OS::Neutron::Net + properties: + name: network_name + + vmtype_1_int_module_port_0: + type: OS::Neutron::Port + properties: + network: { get_resource: int_module_network } + + nested_resource: + type: nested.yaml diff --git a/ice_validator/tests/fixtures/test_neutron_port_network_attachment/pass/pass0_base.yaml b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/pass/pass0_base.yaml new file mode 100644 index 0000000..7c6e4df --- /dev/null +++ b/ice_validator/tests/fixtures/test_neutron_port_network_attachment/pass/pass0_base.yaml @@ -0,0 +1,54 @@ +# -*- 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============================================ +# +# +# VERSION: '1.0.0' + +resources: + + int_intranet_network: + type: OS::Neutron::Net + properties: + name: network_name + +outputs: + + int_intranet_net_id: + value: { get_resource: int_intranet_network } + + int_intranet_net_name: + value: { get_attr: int_intranet_network } diff --git a/ice_validator/tests/test_network_format.py b/ice_validator/tests/test_network_format.py index 9d3062a..f146f75 100644 --- a/ice_validator/tests/test_network_format.py +++ b/ice_validator/tests/test_network_format.py @@ -43,7 +43,7 @@ import re from tests import cached_yaml as yaml from .helpers import validates -from .utils.network_roles import get_network_role_from_port, property_uses_get_resource +from .utils.network_roles import property_uses_get_resource RE_INTERNAL_NETWORK_RID = re.compile( # match pattern r"int_(?P.+)_network$" @@ -51,40 +51,6 @@ RE_INTERNAL_NETWORK_RID = re.compile( # match pattern NETWORK_RESOURCE_TYPES = ["OS::Neutron::Net", "OS::ContrailV2::VirtualNetwork"] -@validates("R-62983", "R-86182") -def test_network_format(yaml_file): - """ - Make sure all network properties use the allowed naming - conventions - """ - with open(yaml_file) as fh: - yml = yaml.load(fh) - - # skip if resources are not defined - if "resources" not in yml: - pytest.skip("No resources specified in the heat template") - - invalid_ports = [] - for k, v in yml["resources"].items(): - if not isinstance(v, dict): - continue - if "properties" not in v: - continue - if property_uses_get_resource(v, "network"): - continue - if v.get("type") != "OS::Neutron::Port": - continue - if not get_network_role_from_port(v): - invalid_ports.append(k) - - assert not set(invalid_ports), ( - "Missing 'network' property or improperly " - "formatted network parameter name on the " - "following OS::Neutron::Ports: " - "{}".format(", ".join(invalid_ports)) - ) - - @validates("R-16968", "R-35666") def test_network_resource_id_format(yaml_file): """ diff --git a/ice_validator/tests/test_network_format_use_get_param_or_get_resource.py b/ice_validator/tests/test_network_format_use_get_param_or_get_resource.py deleted file mode 100644 index e10e873..0000000 --- a/ice_validator/tests/test_network_format_use_get_param_or_get_resource.py +++ /dev/null @@ -1,101 +0,0 @@ -# -*- 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============================================ -# -# - -import pytest -from tests import cached_yaml as yaml - -from .helpers import validates - - -@validates("R-93177") -def test_network_format_use_get_param_or_get_resource(yaml_file): - """ - Make sure all network properties only use get_param - or get_resource of an internal network - """ - - with open(yaml_file) as fh: - yml = yaml.load(fh) - - # skip if resources are not defined - if "resources" not in yml: - pytest.skip("No resources specified in the heat template") - - invalid_get_resource = [] - invalid_get_param = [] - for k1, v1 in yml["resources"].items(): - if not isinstance(v1, dict): - continue - if "properties" not in v1: - continue - if v1.get("type") != "OS::Neutron::Port": - continue - - for k2, v2 in v1["properties"].items(): - if k2 != "network": - continue - if not isinstance(v2, dict): - invalid_get_param.append(k1) - elif "get_resource" in v2: - if not v2["get_resource"].startswith("int_"): - invalid_get_resource.append(k1) - elif "get_param" not in v2: - invalid_get_param.append(k1) - # TODO: I don't think this test needs to check get_param as that is - # already covered by another test. - - msg = ( - "A OS::Neutron::Port must connect to an internal network using " - "get_resource (network created in same template) or get_param " - "(network created in a different template)." - ) - if invalid_get_resource: - msg = ( - msg - + " These resources use get_resource to connect to a " - + "non-internal network: {}" - ).format(", ".join(invalid_get_resource)) - if invalid_get_param: - msg = ( - msg - + " These resources do not use get_resource or get_param " - + "to connect to a network: {}" - ).format(", ".join(invalid_get_param)) - - assert not (invalid_get_param or invalid_get_resource), msg diff --git a/ice_validator/tests/test_neutron_port_internal_network.py b/ice_validator/tests/test_neutron_port_internal_network.py deleted file mode 100644 index e90f87c..0000000 --- a/ice_validator/tests/test_neutron_port_internal_network.py +++ /dev/null @@ -1,85 +0,0 @@ -# -*- coding: utf8 -*- -# ============LICENSE_START==================================================== -# org.onap.vvp/validation-scripts -# =================================================================== -# Copyright © 2019 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============================================ -# - -from tests.parametrizers import get_nested_files -from tests.utils.network_roles import get_network_type_from_port -from .structures import Heat -from .helpers import validates, load_yaml, get_base_template_from_yaml_files - - -@validates("R-22688") -def test_neutron_port_internal_network_v2(yaml_files): - base_path = get_base_template_from_yaml_files(yaml_files) - nested_template_paths = get_nested_files(yaml_files) - errors = [] - for yaml_file in yaml_files: - if yaml_file == base_path or yaml_file in nested_template_paths: - continue # Only applies to incremental modules - heat = Heat(filepath=yaml_file) - internal_ports = { - r_id: p - for r_id, p in heat.neutron_port_resources.items() - if get_network_type_from_port(p) == "internal" - } - for r_id, port in internal_ports.items(): - props = port.get("properties") or {} - network_value = props.get("network") or {} - if not isinstance(network_value, dict): - continue - if "get_param" not in network_value: - continue # Not connecting to network outside the template - param = network_value.get("get_param") - base_heat = load_yaml(base_path) - base_outputs = base_heat.get("outputs") or {} - if not param.endswith("_net_id"): - errors.append( - ( - "Internal network {} is attached to port {}, but the " - "network must be attached via UUID of the network not " - "the name (ex: int_{{network-role}}_net_id)." - ).format(param, r_id) - ) - if param not in base_outputs: - errors.append( - ( - "Internal network {} is attached to port {}, but network " - "is not defined as an output in the base module ({})." - ).format(param, r_id, base_path) - ) - - assert not errors, " ".join(errors) diff --git a/ice_validator/tests/test_neutron_port_network_attachment.py b/ice_validator/tests/test_neutron_port_network_attachment.py new file mode 100644 index 0000000..001d453 --- /dev/null +++ b/ice_validator/tests/test_neutron_port_network_attachment.py @@ -0,0 +1,159 @@ +import os +import re + +import pytest + +from tests.helpers import validates, get_base_template_from_yaml_files +from tests.parametrizers import get_nested_files +from tests.structures import Heat + +INTERNAL_UUID_PATTERN = re.compile(r"^int_(?P.+?)_net_id$") +INTERNAL_NAME_PATTERN = re.compile(r"^int_(?P.+?)_net_name$") +INTERNAL_PORT = re.compile(r"^(?P.+)_(?P\d+)_int_" + r"(?P.+)_port_(?P\d+)$") + +EXTERNAL_PORT = re.compile(r"^(?P.+)_(?P\d+)_(?!int_)" + r"(?P.+)_port_(?P\d+)$") + +EXTERNAL_UUID_PATTERN = re.compile(r"^(?!int_)(?P.+?)_net_id$") +EXTERNAL_NAME_PATTERN = re.compile(r"^(?!int_)(?P.+?)_net_name$") + +INTERNAL_NETWORK_PATTERN = re.compile(r"^int_(?P.+?)" + r"_(network|RVN)$") + + +def is_incremental_module(yaml_file, base_path, nested_paths): + return yaml_file != base_path and yaml_file not in nested_paths + + +def get_param(prop_val): + if not isinstance(prop_val, dict): + return None + param = prop_val.get("get_param") + return param if isinstance(param, str) else None + + +@validates("R-86182", "R-22688") +def test_internal_network_parameters(yaml_files): + base_path = get_base_template_from_yaml_files(yaml_files) + if not base_path: + pytest.skip("No base module found") + base_heat = Heat(filepath=base_path) + nested_paths = get_nested_files(yaml_files) + incremental_modules = [f for f in yaml_files + if is_incremental_module(f, base_path, nested_paths)] + errors = [] + for module in incremental_modules: + heat = Heat(filepath=module) + for rid, port in heat.neutron_port_resources.items(): + rid_match = INTERNAL_PORT.match(rid) + if not rid_match: + continue + + network = (port.get("properties") or {}).get("network") or {} + if isinstance(network, dict) and ( + "get_resource" in network or "get_attr" in network): + continue + + param = get_param(network) + if not param: + errors.append(( + "The internal port ({}) must either connect to a network " + "in the base module using get_param or to a network " + "created in this module ({})" + ).format(rid, os.path.split(module)[1])) + continue + + param_match = ( + INTERNAL_UUID_PATTERN.match(param) + or INTERNAL_NAME_PATTERN.match(param) + ) + if not param_match: + errors.append(( + "The internal port ({}) network parameter ({}) does not " + "match one of the required naming conventions of " + "int_{{network-role}}_net_id or " + "int_{{network-role}}_net_name " + "for connecting to an internal network. " + "If this is not an internal port, then change the resource " + "ID to adhere to the external port naming convention." + ).format(rid, param)) + continue + + if param not in base_heat.yml.get("outputs", {}): + base_module = os.path.split(base_path)[1] + errors.append(( + "The internal network parameter ({}) attached to port ({}) " + "must be defined in the output section of the base module ({})." + ).format(param, rid, base_module)) + continue + + param_network_role = param_match.groupdict().get("network_role") + rid_network_role = rid_match.groupdict().get("network_role") + if param_network_role != rid_network_role: + errors.append(( + "The network role ({}) extracted from the resource ID ({}) " + "does not match network role ({}) extracted from the " + "network parameter ({})" + ).format(rid_network_role, rid, param_network_role, param)) + + resources = base_heat.get_all_resources(os.path.split(base_path)[0]) + networks = {rid: resource for rid, resource in resources.items() + if resource.get("type") + in {"OS::Neutron::Net", + "OS::ContrailV2::VirtualNetwork"}} + matches = (INTERNAL_NETWORK_PATTERN.match(n) for n in networks) + roles = {m.groupdict()["network_role"] for m in matches if m} + if param_network_role not in roles: + errors.append(( + "No internal network with a network role of {} was " + "found in the base modules networks: {}" + ).format(param_network_role, ", ".join(networks))) + + assert not errors, ". ".join(errors) + + +@validates("R-62983") +def test_external_network_parameter(heat_template): + heat = Heat(filepath=heat_template) + errors = [] + for rid, port in heat.neutron_port_resources.items(): + rid_match = EXTERNAL_PORT.match(rid) + if not rid_match: + continue # only test external ports + network = (port.get("properties") or {}).get("network") or {} + if not isinstance(network, dict) or "get_param" not in network: + errors.append(( + "The external port ({}) must assign the network property " + "using get_param. If this port is for an internal network, " + "then change the resource ID format to the external format." + ).format(rid)) + continue + param = get_param(network) + if not param: + errors.append(( + "The get_param function on the network property of port ({}) " + "must only take a single, string parameter." + ).format(rid)) + continue + + param_match = ( + EXTERNAL_NAME_PATTERN.match(param) + or EXTERNAL_UUID_PATTERN.match(param) + ) + if not param_match: + errors.append(( + "The network parameter ({}) on port ({}) does not match one of " + "{{network-role}}_net_id or {{network-role}}_net_name." + ).format(param, rid)) + continue + rid_network_role = rid_match.groupdict()["network_role"] + param_network_role = param_match.groupdict()["network_role"] + if rid_network_role != param_network_role: + errors.append(( + "The network role ({}) extracted from the resource ID ({}) " + "does not match network role ({}) extracted from the " + "network parameter ({})" + ).format(rid_network_role, rid, param_network_role, param)) + + assert not errors, ". ".join(errors)