Merge "Handle Name and MAC field when parse config with IPV6"
This commit is contained in:
@@ -146,13 +146,15 @@ class NetworkConfigPlugin(plugin_base.BasePlugin):
|
|||||||
name = osutils.get_network_adapter_name_by_mac_address(mac)
|
name = osutils.get_network_adapter_name_by_mac_address(mac)
|
||||||
LOG.info("Configuring network adapter: %s", name)
|
LOG.info("Configuring network adapter: %s", name)
|
||||||
|
|
||||||
reboot = osutils.set_static_network_config(
|
# In v6 only case, nic.address and nic.netmask could be unset
|
||||||
name,
|
if nic.address and nic.netmask:
|
||||||
nic.address,
|
reboot = osutils.set_static_network_config(
|
||||||
nic.netmask,
|
name,
|
||||||
nic.gateway,
|
nic.address,
|
||||||
nic.dnsnameservers
|
nic.netmask,
|
||||||
)
|
nic.gateway,
|
||||||
|
nic.dnsnameservers
|
||||||
|
)
|
||||||
reboot_required = reboot or reboot_required
|
reboot_required = reboot or reboot_required
|
||||||
# Set v6 info too if available.
|
# Set v6 info too if available.
|
||||||
if nic.address6 and nic.netmask6:
|
if nic.address6 and nic.netmask6:
|
||||||
|
|||||||
@@ -26,12 +26,22 @@ DNSNS0 = "208.67.220.220 208.67.222.222"
|
|||||||
|
|
||||||
NAME1 = "eth1"
|
NAME1 = "eth1"
|
||||||
ADDRESS1 = "10.1.0.2"
|
ADDRESS1 = "10.1.0.2"
|
||||||
ADDRESS61 = "::ffff:a00:1"
|
ADDRESS61 = None
|
||||||
NETMASK1 = "255.255.255.0"
|
NETMASK1 = "255.255.255.0"
|
||||||
NETMASK61 = None
|
NETMASK61 = None
|
||||||
BROADCAST1 = "10.1.0.255"
|
BROADCAST1 = "10.1.0.255"
|
||||||
GATEWAY1 = "10.1.0.1"
|
GATEWAY1 = "10.1.0.1"
|
||||||
GATEWAY61 = "2001::ffff:a00:1b"
|
GATEWAY61 = None
|
||||||
|
|
||||||
|
NAME2 = "eth2"
|
||||||
|
MAC2 = None
|
||||||
|
ADDRESS2 = "::ffff:a00:1"
|
||||||
|
ADDRESS62 = None
|
||||||
|
NETMASK2 = None
|
||||||
|
NETMASK62 = None
|
||||||
|
BROADCAST2 = None
|
||||||
|
GATEWAY2 = "2001::ffff:a00:1b"
|
||||||
|
GATEWAY62 = None
|
||||||
|
|
||||||
|
|
||||||
def get_fake_metadata_json(version):
|
def get_fake_metadata_json(version):
|
||||||
@@ -158,9 +168,9 @@ iface {name1} inet static
|
|||||||
broadcast {broadcast1}
|
broadcast {broadcast1}
|
||||||
gateway {gateway1}
|
gateway {gateway1}
|
||||||
iface eth2 inet6 static
|
iface eth2 inet6 static
|
||||||
address {address61}
|
address {address2}
|
||||||
netmask {netmask61}
|
netmask {netmask2}
|
||||||
gateway {gateway61}
|
gateway {gateway2}
|
||||||
""").format(name0=NAME0, # eth0 (IPv4/6)
|
""").format(name0=NAME0, # eth0 (IPv4/6)
|
||||||
mac0=MAC0,
|
mac0=MAC0,
|
||||||
address0=ADDRESS0,
|
address0=ADDRESS0,
|
||||||
@@ -179,7 +189,17 @@ iface eth2 inet6 static
|
|||||||
gateway1=GATEWAY1,
|
gateway1=GATEWAY1,
|
||||||
address61=ADDRESS61,
|
address61=ADDRESS61,
|
||||||
netmask61=NETMASK61,
|
netmask61=NETMASK61,
|
||||||
gateway61=GATEWAY61
|
gateway61=GATEWAY61,
|
||||||
|
# eth2 (IPv6)
|
||||||
|
name2=NAME1,
|
||||||
|
mac2=MAC2,
|
||||||
|
address2=ADDRESS2,
|
||||||
|
broadcast2=BROADCAST2,
|
||||||
|
netmask2=NETMASK2,
|
||||||
|
gateway2=GATEWAY2,
|
||||||
|
address62=ADDRESS62,
|
||||||
|
netmask62=NETMASK62,
|
||||||
|
gateway62=GATEWAY62
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,7 +245,19 @@ class TestBaseOpenStackService(unittest.TestCase):
|
|||||||
fake_json_response.GATEWAY61,
|
fake_json_response.GATEWAY61,
|
||||||
None
|
None
|
||||||
)
|
)
|
||||||
self.assertEqual([nic0, nic1], ret)
|
nic2 = network_model.NetworkDetails(
|
||||||
|
fake_json_response.NAME2,
|
||||||
|
None,
|
||||||
|
fake_json_response.ADDRESS2,
|
||||||
|
fake_json_response.ADDRESS62,
|
||||||
|
fake_json_response.NETMASK2,
|
||||||
|
fake_json_response.NETMASK62,
|
||||||
|
fake_json_response.BROADCAST2,
|
||||||
|
fake_json_response.GATEWAY2,
|
||||||
|
fake_json_response.GATEWAY62,
|
||||||
|
None
|
||||||
|
)
|
||||||
|
self.assertEqual([nic0, nic1, nic2], ret)
|
||||||
|
|
||||||
def test_get_network_details_no_config(self):
|
def test_get_network_details_no_config(self):
|
||||||
self._partial_test_get_network_details(
|
self._partial_test_get_network_details(
|
||||||
|
|||||||
@@ -92,7 +92,8 @@ class TestNetworkConfigPlugin(unittest.TestCase):
|
|||||||
nic.gateway6,
|
nic.gateway6,
|
||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
calls.append(call)
|
if nic.address and nic.netmask:
|
||||||
|
calls.append(call)
|
||||||
if nic.address6 and nic.netmask6:
|
if nic.address6 and nic.netmask6:
|
||||||
calls.append(call6)
|
calls.append(call6)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
|||||||
@@ -63,7 +63,19 @@ class TestInterfacesParser(unittest.TestCase):
|
|||||||
fake_json_response.GATEWAY61,
|
fake_json_response.GATEWAY61,
|
||||||
None
|
None
|
||||||
)
|
)
|
||||||
self.assertEqual([nic0, nic1], nics)
|
nic2 = network_model.NetworkDetails(
|
||||||
|
fake_json_response.NAME2,
|
||||||
|
None,
|
||||||
|
fake_json_response.ADDRESS2,
|
||||||
|
fake_json_response.ADDRESS62,
|
||||||
|
fake_json_response.NETMASK2,
|
||||||
|
fake_json_response.NETMASK62,
|
||||||
|
fake_json_response.BROADCAST2,
|
||||||
|
fake_json_response.GATEWAY2,
|
||||||
|
fake_json_response.GATEWAY62,
|
||||||
|
None
|
||||||
|
)
|
||||||
|
self.assertEqual([nic0, nic1, nic2], nics)
|
||||||
|
|
||||||
def test_nothing_to_parse(self):
|
def test_nothing_to_parse(self):
|
||||||
invalid = [None, "", 324242, ("dasd", "dsa")]
|
invalid = [None, "", 324242, ("dasd", "dsa")]
|
||||||
|
|||||||
@@ -60,7 +60,9 @@ IFACE_TEMPLATE = dict.fromkeys(FIELDS.keys())
|
|||||||
V6_PROXY = {
|
V6_PROXY = {
|
||||||
ADDRESS: ADDRESS6,
|
ADDRESS: ADDRESS6,
|
||||||
NETMASK: NETMASK6,
|
NETMASK: NETMASK6,
|
||||||
GATEWAY: GATEWAY6
|
GATEWAY: GATEWAY6,
|
||||||
|
NAME: NAME,
|
||||||
|
MAC: MAC,
|
||||||
}
|
}
|
||||||
DETAIL_PREPROCESS = {
|
DETAIL_PREPROCESS = {
|
||||||
MAC: lambda value: value.upper(),
|
MAC: lambda value: value.upper(),
|
||||||
@@ -79,7 +81,6 @@ def _get_iface_blocks(data):
|
|||||||
if "iface" in line:
|
if "iface" in line:
|
||||||
if "inet6" in line:
|
if "inet6" in line:
|
||||||
crt_lines = lines6
|
crt_lines = lines6
|
||||||
continue
|
|
||||||
if lines:
|
if lines:
|
||||||
yield lines, lines6
|
yield lines, lines6
|
||||||
lines[:] = []
|
lines[:] = []
|
||||||
|
|||||||
Reference in New Issue
Block a user