Follow up to I44336423194eed99f026c44b6390030a94ed0522
Allow using IPv6 address in the provisioning network. IP address based pxe config may not be used actually, in that case we can remove it and saving a few neutron interaction. Change-Id: Ideef57674550270a87513e039cd030f0bcc1c10e
This commit is contained in:
parent
06094e1658
commit
82a2fe4f7f
|
@ -297,6 +297,10 @@ class InvalidIPv4Address(IronicException):
|
|||
_msg_fmt = _("Invalid IPv4 address %(ip_address)s.")
|
||||
|
||||
|
||||
class InvalidIPAddress(IronicException):
|
||||
_msg_fmt = _("Invalid IP address %(ip_address)s.")
|
||||
|
||||
|
||||
class FailedToUpdateMacOnPort(IronicException):
|
||||
_msg_fmt = _("Update MAC address on port: %(port_id)s failed.")
|
||||
|
||||
|
|
|
@ -187,18 +187,19 @@ class NeutronDHCPApi(base.BaseDHCP):
|
|||
|
||||
if ip_address:
|
||||
try:
|
||||
if ipaddress.ip_address(ip_address).version == 4:
|
||||
if (ipaddress.ip_address(ip_address).version == 4
|
||||
or ipaddress.ip_address(ip_address).version == 6):
|
||||
return ip_address
|
||||
else:
|
||||
LOG.error("Neutron returned invalid IPv4 "
|
||||
LOG.error("Neutron returned invalid IP "
|
||||
"address %(ip_address)s on port %(port_uuid)s.",
|
||||
{'ip_address': ip_address,
|
||||
'port_uuid': port_uuid})
|
||||
raise exception.InvalidIPv4Address(ip_address=ip_address)
|
||||
raise exception.InvalidIPAddress(ip_address=ip_address)
|
||||
except ValueError as exc:
|
||||
LOG.error("An Invalid IP address was supplied and failed "
|
||||
"basic validation: %s", exc)
|
||||
raise exception.InvalidIPv4Address(ip_address=ip_address)
|
||||
raise exception.InvalidIPAddress(ip_address=ip_address)
|
||||
else:
|
||||
LOG.error("No IP address assigned to Neutron port %s.",
|
||||
port_uuid)
|
||||
|
|
|
@ -267,6 +267,30 @@ class TestNeutron(db_base.DbTestCase):
|
|||
self.assertEqual(expected, result)
|
||||
fake_client.show_port.assert_called_once_with(port_id)
|
||||
|
||||
def test__get_fixed_ip_address_ipv6(self):
|
||||
port_id = 'fake-port-id'
|
||||
expected = "2001:dead:beef::1234"
|
||||
api = dhcp_factory.DHCPFactory().provider
|
||||
port_data = {
|
||||
"id": port_id,
|
||||
"network_id": "3cb9bc59-5699-4588-a4b1-b87f96708bc6",
|
||||
"admin_state_up": True,
|
||||
"status": "ACTIVE",
|
||||
"mac_address": "fa:16:3e:4c:2c:30",
|
||||
"fixed_ips": [
|
||||
{
|
||||
"ip_address": "2001:dead:beef::1234",
|
||||
"subnet_id": "f8a6e8f8-c2ec-497c-9f23-da9616de54ef"
|
||||
}
|
||||
],
|
||||
"device_id": 'bece68a3-2f8b-4e66-9092-244493d6aba7',
|
||||
}
|
||||
fake_client = mock.Mock()
|
||||
fake_client.show_port.return_value = {'port': port_data}
|
||||
result = api._get_fixed_ip_address(port_id, fake_client)
|
||||
self.assertEqual(expected, result)
|
||||
fake_client.show_port.assert_called_once_with(port_id)
|
||||
|
||||
def test__get_fixed_ip_address_invalid_ip(self):
|
||||
port_id = 'fake-port-id'
|
||||
api = dhcp_factory.DHCPFactory().provider
|
||||
|
@ -286,7 +310,7 @@ class TestNeutron(db_base.DbTestCase):
|
|||
}
|
||||
fake_client = mock.Mock()
|
||||
fake_client.show_port.return_value = {'port': port_data}
|
||||
self.assertRaises(exception.InvalidIPv4Address,
|
||||
self.assertRaises(exception.InvalidIPAddress,
|
||||
api._get_fixed_ip_address,
|
||||
port_id, fake_client)
|
||||
fake_client.show_port.assert_called_once_with(port_id)
|
||||
|
|
Loading…
Reference in New Issue