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 = {}
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 = {
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": <subnet_id>
def _create_new_port(self, port_dict: dict, created_items: dict, net: dict) -> Dict:
--- /dev/null
+#######################################################################################
+# 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.