From: elumalai Date: Tue, 25 Apr 2023 10:52:56 +0000 (+0530) Subject: Feature 10979: Static IPv6 Dual Stack Assignment X-Git-Tag: release-v14.0-start~8 X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FRO.git;a=commitdiff_plain;h=370e36bafdcb90f212e289b87290f39be141b3d4 Feature 10979: Static IPv6 Dual Stack Assignment Added support for static dual stack IP assignment Change-Id: Ief10ae955fb870a3417f68e1c5f7bda570cb6470 Signed-off-by: elumalai --- diff --git a/RO-VIM-openstack/osm_rovim_openstack/tests/test_vimconn_openstack.py b/RO-VIM-openstack/osm_rovim_openstack/tests/test_vimconn_openstack.py index 118251b7..b6fff180 100644 --- a/RO-VIM-openstack/osm_rovim_openstack/tests/test_vimconn_openstack.py +++ b/RO-VIM-openstack/osm_rovim_openstack/tests/test_vimconn_openstack.py @@ -359,7 +359,7 @@ class TestNewVmInstance(unittest.TestCase): self.vimconn._prepare_port_dict_mac_ip_addr(net, port_dict) self.assertDictEqual(port_dict, result_dict) - def test_prepare_port_dict_mac_ip_addr_no_mac_and_ip(self): + def test_prepare_port_dict_mac_ip_addr_empty_net(self): """mac address and ip address does not exist.""" net = {} port_dict = {} @@ -367,6 +367,67 @@ class TestNewVmInstance(unittest.TestCase): self.vimconn._prepare_port_dict_mac_ip_addr(net, port_dict) self.assertDictEqual(port_dict, result_dict) + def test_prepare_port_dict_mac_ip_addr_dual(self): + """mac address, ipv4 and ipv6 addresses exist.""" + net = { + "mac_address": mac_address, + "ip_address": ["10.0.1.5", "2345:0425:2CA1:0000:0000:0567:5673:23b5"], + } + port_dict = {} + result_dict = { + "mac_address": mac_address, + "fixed_ips": [ + {"ip_address": "10.0.1.5"}, + {"ip_address": "2345:0425:2CA1:0000:0000:0567:5673:23b5"}, + ], + } + self.vimconn._prepare_port_dict_mac_ip_addr(net, port_dict) + self.assertDictEqual(port_dict, result_dict) + + def test_prepare_port_dict_mac_ip_addr_dual_ip_addr_is_not_list(self): + """mac address, ipv4 and ipv6 addresses exist.""" + net = { + "mac_address": mac_address, + "ip_address": "10.0.1.5", + } + port_dict = {} + result_dict = { + "mac_address": mac_address, + "fixed_ips": [ + {"ip_address": "10.0.1.5"}, + ], + } + self.vimconn._prepare_port_dict_mac_ip_addr(net, port_dict) + self.assertDictEqual(port_dict, result_dict) + + def test_prepare_port_dict_mac_ip_addr_dual_net_without_ip_addr(self): + """mac address, ipv4 and ipv6 addresses exist.""" + net = { + "mac_address": mac_address, + "ip_address": [], + } + port_dict = {} + result_dict = { + "mac_address": mac_address, + } + self.vimconn._prepare_port_dict_mac_ip_addr(net, port_dict) + self.assertDictEqual(port_dict, result_dict) + + def test_prepare_port_dict_mac_ip_addr_dual_net_without_mac_addr(self): + """mac address, ipv4 and ipv6 addresses exist.""" + net = { + "ip_address": ["10.0.1.5", "2345:0425:2CA1:0000:0000:0567:5673:23b5"], + } + port_dict = {} + result_dict = { + "fixed_ips": [ + {"ip_address": "10.0.1.5"}, + {"ip_address": "2345:0425:2CA1:0000:0000:0567:5673:23b5"}, + ], + } + self.vimconn._prepare_port_dict_mac_ip_addr(net, port_dict) + self.assertDictEqual(port_dict, result_dict) + def test_create_new_port(self): """new port has id and mac address.""" new_port = { diff --git a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py index f118cf1b..f1df8a73 100644 --- a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py +++ b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py @@ -1946,8 +1946,14 @@ class vimconnector(vimconn.VimConnector): if net.get("mac_address"): port_dict["mac_address"] = net["mac_address"] - if net.get("ip_address"): - port_dict["fixed_ips"] = [{"ip_address": net["ip_address"]}] + ip_dual_list = [] + if ip_list := net.get("ip_address"): + if not isinstance(ip_list, list): + ip_list = [ip_list] + for ip in ip_list: + ip_dict = {"ip_address": ip} + ip_dual_list.append(ip_dict) + port_dict["fixed_ips"] = ip_dual_list # TODO add "subnet_id": def _create_new_port(self, port_dict: dict, created_items: dict, net: dict) -> Dict: diff --git a/releasenotes/notes/feature_10979_Static_IPv6_Dual_Stack_Assignment-e8c5220b85890a37.yaml b/releasenotes/notes/feature_10979_Static_IPv6_Dual_Stack_Assignment-e8c5220b85890a37.yaml new file mode 100644 index 00000000..00cbd2f1 --- /dev/null +++ b/releasenotes/notes/feature_10979_Static_IPv6_Dual_Stack_Assignment-e8c5220b85890a37.yaml @@ -0,0 +1,22 @@ +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file 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. +####################################################################################### +--- +features: + - | + Feature 10979 - Static IPv6 Dual Stack IP Assignment for Openstack VIM + This feature enables assigning static IPv6 assignment to VNFs to enable + dual stack IP assignment.