aboutsummaryrefslogtreecommitdiffstats
path: root/ice_validator/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ice_validator/tests')
-rw-r--r--ice_validator/tests/fixtures/test_neutron_port_addresses/fail/fail0.yaml85
-rw-r--r--ice_validator/tests/fixtures/test_neutron_port_addresses/fail/fail1.yaml85
-rw-r--r--ice_validator/tests/fixtures/test_neutron_port_addresses/fail/fail2.yaml85
-rw-r--r--ice_validator/tests/fixtures/test_neutron_port_addresses/fail/fail3.yaml85
-rw-r--r--ice_validator/tests/fixtures/test_neutron_port_addresses/fail/other0.yaml52
-rw-r--r--ice_validator/tests/fixtures/test_neutron_port_addresses/pass/other0.yaml54
-rw-r--r--ice_validator/tests/fixtures/test_neutron_port_addresses/pass/pass0.yaml85
-rw-r--r--ice_validator/tests/test_allowed_address_pairs_include_vm_type_network_role.py6
-rw-r--r--ice_validator/tests/test_neutron_port_addresses.py133
-rw-r--r--ice_validator/tests/utils/ports.py53
10 files changed, 36 insertions, 687 deletions
diff --git a/ice_validator/tests/fixtures/test_neutron_port_addresses/fail/fail0.yaml b/ice_validator/tests/fixtures/test_neutron_port_addresses/fail/fail0.yaml
deleted file mode 100644
index 836a45d..0000000
--- a/ice_validator/tests/fixtures/test_neutron_port_addresses/fail/fail0.yaml
+++ /dev/null
@@ -1,85 +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'
-
----
-resources:
-
- vm_typeX_0_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- allowed_address_pairs:
- - ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
- mac_and_cheese: 0
- - ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
- mac_and_cheese: 1
-
- vm_typeX_1_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- allowed_address_pairs:
- - ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
- mac_and_cheese: 0
- - ip_address: { get_param: my_ip_1 }
- v6_ip_address: { get_param: my_v6_ip_1 }
- mac_and_cheese: 1
-
- vm_typeX_2_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- allowed_address_pairs:
- - ip_address: { get_parm: my_ip }
- v6_ip_address: { get_parm: my_v6_ip }
-
- vm_typeX_3_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- allowed_address_pairs:
- - ip_address
-
- vm_typeX_4_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- allowed_address_pairs:
- ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
-
diff --git a/ice_validator/tests/fixtures/test_neutron_port_addresses/fail/fail1.yaml b/ice_validator/tests/fixtures/test_neutron_port_addresses/fail/fail1.yaml
deleted file mode 100644
index 3a56ce7..0000000
--- a/ice_validator/tests/fixtures/test_neutron_port_addresses/fail/fail1.yaml
+++ /dev/null
@@ -1,85 +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'
-
----
-resources:
-
- vm_typeX_0_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- allowed_address_pairs:
- - ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
- mac_and_cheese: 0
- - ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
- mac_and_cheese: 1
-
- vm_typeX_1_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- xallowed_address_pairs:
- - ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
- mac_and_cheese: 0
- - ip_address: { get_param: my_ip_1 }
- v6_ip_address: { get_param: my_v6_ip_1 }
- mac_and_cheese: 1
-
- vm_typeX_2_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- allowed_address_pairs:
- - ip_address: { get_parm: my_ip }
- v6_ip_address: { get_parm: my_v6_ip }
-
- vm_typeX_3_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- allowed_address_pairs:
- - ip_address
-
- vm_typeX_4_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- allowed_address_pairs:
- ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
-
diff --git a/ice_validator/tests/fixtures/test_neutron_port_addresses/fail/fail2.yaml b/ice_validator/tests/fixtures/test_neutron_port_addresses/fail/fail2.yaml
deleted file mode 100644
index 7a4dbfd..0000000
--- a/ice_validator/tests/fixtures/test_neutron_port_addresses/fail/fail2.yaml
+++ /dev/null
@@ -1,85 +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'
-
----
-resources:
-
- vm_typeX_0_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- allowed_address_pairs:
- - ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
- mac_and_cheese: 0
- - ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
- mac_and_cheese: 1
-
- vm_typeX_1_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- xallowed_address_pairs:
- - ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
- mac_and_cheese: 0
- - ip_address: { get_param: my_ip_1 }
- v6_ip_address: { get_param: my_v6_ip_1 }
- mac_and_cheese: 1
-
- vm_typeX_2_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- allowed_address_pairs:
- - ip_address: { get_parm: my_ip }
- v6_ip_address: { get_parm: my_v6_ip }
-
- vm_typeX_3_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- xallowed_address_pairs:
- - ip_address
-
- vm_typeX_4_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- allowed_address_pairs:
- ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
-
diff --git a/ice_validator/tests/fixtures/test_neutron_port_addresses/fail/fail3.yaml b/ice_validator/tests/fixtures/test_neutron_port_addresses/fail/fail3.yaml
deleted file mode 100644
index b6c2c6c..0000000
--- a/ice_validator/tests/fixtures/test_neutron_port_addresses/fail/fail3.yaml
+++ /dev/null
@@ -1,85 +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'
-
----
-resources:
-
- vm_typeX_0_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- allowed_address_pairs:
- - ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
- mac_and_cheese: 0
- - ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
- mac_and_cheese: 1
-
- vm_typeX_1_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- xallowed_address_pairs:
- - ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
- mac_and_cheese: 0
- - ip_address: { get_param: my_ip_1 }
- v6_ip_address: { get_param: my_v6_ip_1 }
- mac_and_cheese: 1
-
- vm_typeX_2_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- xallowed_address_pairs:
- - ip_address: { get_parm: my_ip }
- v6_ip_address: { get_parm: my_v6_ip }
-
- vm_typeX_3_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- xallowed_address_pairs:
- - ip_address
-
- vm_typeX_4_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- allowed_address_pairs:
- ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
-
diff --git a/ice_validator/tests/fixtures/test_neutron_port_addresses/fail/other0.yaml b/ice_validator/tests/fixtures/test_neutron_port_addresses/fail/other0.yaml
deleted file mode 100644
index 09ca85e..0000000
--- a/ice_validator/tests/fixtures/test_neutron_port_addresses/fail/other0.yaml
+++ /dev/null
@@ -1,52 +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'
-
----
-resources:
-
- other_typeX_0_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- allowed_address_pairs:
- - ip_address: { get_param: my_ip }
- - ip_address: { get_param: my_v6_ip }
- - ip_address: { get_param: my2_ip }
- - ip_address: { get_param: my2_v6_ip }
-
diff --git a/ice_validator/tests/fixtures/test_neutron_port_addresses/pass/other0.yaml b/ice_validator/tests/fixtures/test_neutron_port_addresses/pass/other0.yaml
deleted file mode 100644
index e7fa71f..0000000
--- a/ice_validator/tests/fixtures/test_neutron_port_addresses/pass/other0.yaml
+++ /dev/null
@@ -1,54 +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'
-
----
-resources:
-
- other_typeX_0_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- allowed_address_pairs:
- - ip_address: { get_param: my_ip_1 }
- v6_ip_address: { get_param: my_v6_ip_1 }
- mac_and_cheese: 0
- - ip_address: { get_param: my_ip_1 }
- v6_ip_address: { get_param: my_v6_ip_1 }
- mac_and_cheese: 1
-
diff --git a/ice_validator/tests/fixtures/test_neutron_port_addresses/pass/pass0.yaml b/ice_validator/tests/fixtures/test_neutron_port_addresses/pass/pass0.yaml
deleted file mode 100644
index 3dcc8fa..0000000
--- a/ice_validator/tests/fixtures/test_neutron_port_addresses/pass/pass0.yaml
+++ /dev/null
@@ -1,85 +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'
-
----
-resources:
-
- vm_typeX_0_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- allowed_address_pairs:
- - ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
- mac_and_cheese: 0
- - ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
- mac_and_cheese: 1
-
- vm_typeX_1_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- allowed_address_pairs:
- - ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
- mac_and_cheese: 0
- - ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
- mac_and_cheese: 1
-
- vm_typeX_2_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- xallowed_address_pairs:
- - ip_address: { get_parm: my_ip }
- v6_ip_address: { get_parm: my_v6_ip }
-
- vm_typeX_3_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- xallowed_address_pairs:
- - ip_address
-
- vm_typeX_4_bialy_port_2:
- type: OS::Neutron::Port
- properties:
- xallowed_address_pairs:
- ip_address: { get_param: my_ip }
- v6_ip_address: { get_param: my_v6_ip }
-
diff --git a/ice_validator/tests/test_allowed_address_pairs_include_vm_type_network_role.py b/ice_validator/tests/test_allowed_address_pairs_include_vm_type_network_role.py
index 6fdb815..6b3c63c 100644
--- a/ice_validator/tests/test_allowed_address_pairs_include_vm_type_network_role.py
+++ b/ice_validator/tests/test_allowed_address_pairs_include_vm_type_network_role.py
@@ -82,7 +82,7 @@ aap_regx_dict = {
}
-@validates("R-41492", "R-35735", "R-159016", "R-91810", "R-41956")
+@validates("R-41492", "R-35735", "R-159016", "R-91810", "R-41956", "R-41493")
def test_external_aap_format(yaml_file):
check_parameter_format(
yaml_file,
@@ -91,6 +91,7 @@ def test_external_aap_format(yaml_file):
NeutronPortProcessor,
"allowed_address_pairs",
"ip_address",
+ exemptions_allowed=True,
)
@@ -106,7 +107,7 @@ def test_internal_aap_format(yaml_file):
)
-@validates("R-100280", "R-100290", "R-100310", "R-100330", "R-100350")
+@validates("R-100280", "R-100290", "R-100310", "R-100330", "R-100350", "R-41493")
def test_external_aap_format_contrail(yaml_file):
check_parameter_format(
yaml_file,
@@ -117,6 +118,7 @@ def test_external_aap_format_contrail(yaml_file):
"virtual_machine_interface_allowed_address_pairs_allowed_address_pair",
"virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip",
"virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip_ip_prefix",
+ exemptions_allowed=True,
)
diff --git a/ice_validator/tests/test_neutron_port_addresses.py b/ice_validator/tests/test_neutron_port_addresses.py
deleted file mode 100644
index ed433c2..0000000
--- a/ice_validator/tests/test_neutron_port_addresses.py
+++ /dev/null
@@ -1,133 +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============================================
-#
-#
-
-"""
-OS::Neutron::Port connecting to external network
-must have at most one ip_address and at most one v6_ip_address.
-"""
-
-import collections
-import os.path
-
-from .structures import Heat
-from .helpers import validates
-
-VERSION = "1.1.0"
-
-
-def get_neutron_ports(heat):
- """Return dict of resource_id: resource, whose type is
- OS::Neutron::Port.
- """
- return {
- rid: resource
- for rid, resource in heat.resources.items()
- if heat.nested_get(resource, "type") == "OS::Neutron::Port"
- }
-
-
-def get_port_addresses(filepath):
- """Return dict:
- key is field name, value is dict:
- key is parameter name, value is dict:
- key is filepath, value is set of rid
- """
- port_addresses = collections.defaultdict(
- lambda: collections.defaultdict(lambda: collections.defaultdict(set))
- )
- heat = Heat(filepath=filepath)
- basename = os.path.basename(filepath)
- for rid, port in get_neutron_ports(heat).items():
- allowed_address_pairs = heat.nested_get(
- port, "properties", "allowed_address_pairs"
- )
- if not isinstance(allowed_address_pairs, list):
- continue
- field = "ip_address"
- for aa_pair in allowed_address_pairs:
- param = heat.nested_get(aa_pair, field, "get_param")
- if param is None:
- continue
- else:
- param = param[0] if isinstance(param, list) else param
- port_addresses[field][param][basename].add(rid)
- return port_addresses
-
-
-def nested_update(out_dict, in_dict):
- """Recursively update out_dict from in_dict.
- """
- for key, value in in_dict.items():
- if key not in out_dict:
- out_dict[key] = value
- elif isinstance(value, dict) and isinstance(out_dict[key], dict):
- out_dict[key] = nested_update(out_dict[key], value)
- elif isinstance(value, set) and isinstance(out_dict[key], set):
- out_dict[key].update(value)
- else:
- out_dict[key] = value
- return out_dict
-
-
-@validates("R-10754")
-def test_neutron_port_floating(yaml_files):
- """
- If a VNF has two or more ports that
- attach to an external network that require a Virtual IP Address (VIP),
- and the VNF requires ONAP automation to assign the IP address,
- all the Virtual Machines using the VIP address **MUST**
- be instantiated in the same Base Module Heat Orchestration Template
- or in the same Incremental Module Heat Orchestration Template.
- """
- fields = {}
- for filepath in yaml_files:
- fields = nested_update(fields, get_port_addresses(filepath))
- bad = []
- for field, params in fields.items():
- for param, files in params.items():
- if len(files) > 1:
- error = ["{} {} assigned in multiple templates: ".format(field, param)]
- for file_name, r_ids in files.items():
- error.append(
- "In {} it's assigned to {}. ".format(
- file_name, ", ".join(r_ids)
- )
- )
- bad.append("".join(error))
- assert not bad, "; ".join(bad)
diff --git a/ice_validator/tests/utils/ports.py b/ice_validator/tests/utils/ports.py
index 93e1d48..8c25df7 100644
--- a/ice_validator/tests/utils/ports.py
+++ b/ice_validator/tests/utils/ports.py
@@ -2,7 +2,7 @@
# ============LICENSE_START=======================================================
# org.onap.vvp/validation-scripts
# ===================================================================
-# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright © 2019 AT&T Intellectual Property. All rights reserved.
# ===================================================================
#
# Unless otherwise specified, all software contained herein is licensed
@@ -41,6 +41,14 @@ from tests.helpers import parameter_type_to_heat_type, prop_iterator
from . import nested_dict
+AAP_EXEMPT_CAVEAT = (
+ "If this VNF is not able to adhere to this requirement, please consult the Heat "
+ "Orchestration Template guidelines for more information. If you are knowingly "
+ "violating this requirement after reading the guidelines, then add the parameter "
+ "to the aap_exempt list under this resources metadata to suppress this warning."
+)
+
+
def get_aap_exemptions(resource_props):
"""
Gets the list of parameters that the Heat author has exempted from following
@@ -53,13 +61,17 @@ def get_aap_exemptions(resource_props):
return metadata.get("aap_exempt") or []
-def check_parameter_format(yaml_file, regx, intext, resource_processor, *properties):
+def check_parameter_format(
+ yaml_file, regx, intext, resource_processor, *properties, exemptions_allowed=False
+):
"""
yaml_file: input file to check
regx: dictionary containing the regex to use to validate parameter
intext: internal or external
resource_processor: resource type specific helper, defined in structures.py
properties: arg list of property that is being checked
+ exemptions_allowed: If True, then parameters in the aap_exempt list are allowed to
+ not follow the rules
"""
invalid_parameters = []
@@ -89,19 +101,21 @@ def check_parameter_format(yaml_file, regx, intext, resource_processor, *propert
if not parameter:
msg = (
"Unexpected parameter format for {} {} property {}: {}. "
- + "Please consult the heat guidelines documentation for details."
+ "Please consult the heat guidelines documentation for details."
).format(resource_type, rid, properties, param)
invalid_parameters.append(msg) # should this be a failure?
continue
- # getting parameter if the get_param uses list, and getting official HEAT parameter type
+ # getting parameter if the get_param uses list, and getting official
+ # HEAT parameter type
parameter_type = parameter_type_to_heat_type(parameter)
if parameter_type == "comma_delimited_list":
parameter = parameter[0]
elif parameter_type != "string":
continue
- # checking parameter format = parameter type defined in parameters section
+ # checking parameter format = parameter type defined in parameters
+ # section
heat_parameter_type = nested_dict.get(
heat_parameters, parameter, "type"
)
@@ -119,21 +133,20 @@ def check_parameter_format(yaml_file, regx, intext, resource_processor, *propert
invalid_parameters.append(msg) # should this actually be an error?
continue
- if parameter in get_aap_exemptions(resource):
+ if exemptions_allowed and parameter in get_aap_exemptions(resource):
continue
- # if parameter type is not in regx dict, then it is not supported by automation
+ # if parameter type is not in regx dict, then it is not supported
+ # by automation
regx_dict = regx[resource_intext].get(parameter_type)
if not regx_dict:
msg = (
- "WARNING: {} {} parameter {} defined as type {} "
- "is not supported by platform automation. If this VNF is not "
- "able to adhere to this requirement, please consult the Heat "
- "Orchestration Template guidelines for alternative solutions. "
- "If you are using an alternate option and wish to suppress "
- "error, then add the parameter to the aap_exempt list "
- "under this resources metadata."
+ "{} {} parameter {} defined as type {} "
+ "which is required by platform data model for proper "
+ "assignment and inventory."
).format(resource_type, properties, parameter, parameter_type)
+ if exemptions_allowed:
+ msg = "WARNING: {} {}".format(msg, AAP_EXEMPT_CAVEAT)
invalid_parameters.append(msg)
continue
@@ -143,13 +156,9 @@ def check_parameter_format(yaml_file, regx, intext, resource_processor, *propert
match = regexp.match(parameter)
if not match:
msg = (
- "{} {} property {} parameter {} does not follow {} format {} "
- "which is required by platform automation. If this VNF is not "
- "able to adhere to this requirement, please consult the Heat "
- "Orchestration Template guidelines for alternative solutions. "
- "If you are using an alternate option and wish to suppress "
- "error, then add the parameter to the aap_exempt list "
- "under this resources metadata."
+ "{} {} property {} parameter {} does not follow {} "
+ "format {} which is required by platform data model for proper "
+ "assignment and inventory."
).format(
resource_type,
rid,
@@ -158,6 +167,8 @@ def check_parameter_format(yaml_file, regx, intext, resource_processor, *propert
resource_intext,
readable_format,
)
+ if exemptions_allowed:
+ msg = "WARNING: {} {}".format(msg, AAP_EXEMPT_CAVEAT)
invalid_parameters.append(msg)
continue