1038
1038
alloc_type=IPADDRESS_TYPE.DISCOVERED, subnet=subnet_list[i],
1039
1039
ip=str(IPNetwork(cidr_list[i]).ip)))
1041
def test__links_interface_to_vlan_on_existing_subnet_with_logging(self):
1042
ng = factory.make_NodeGroup()
1043
fabric2 = factory.make_Fabric()
1044
fabric3 = factory.make_Fabric()
1045
ngi1 = factory.make_NodeGroupInterface(ng)
1046
ngi2 = factory.make_NodeGroupInterface(ng, fabric=fabric2)
1047
ngi3 = factory.make_NodeGroupInterface(ng, fabric=fabric3)
1048
interface1 = factory.make_Interface(INTERFACE_TYPE.PHYSICAL)
1049
interface2 = factory.make_Interface(INTERFACE_TYPE.PHYSICAL)
1050
interface3 = factory.make_Interface(INTERFACE_TYPE.PHYSICAL)
1051
vlan1 = ngi1.subnet.vlan
1052
vlan2 = ngi2.subnet.vlan
1053
vlan3 = ngi3.subnet.vlan
1054
maaslog = self.patch_autospec(interface_module, "maaslog")
1055
interface1.update_ip_addresses([ngi1.subnet.cidr])
1056
interface2.update_ip_addresses([ngi2.subnet.cidr])
1057
interface3.update_ip_addresses([ngi3.subnet.cidr])
1058
self.assertThat(interface1.vlan, Equals(vlan1))
1059
self.assertThat(interface2.vlan, Equals(vlan2))
1060
self.assertThat(interface3.vlan, Equals(vlan3))
1061
self.assertThat(maaslog.info, MockCallsMatch(
1062
call(("%s: Observed connected to %s via %s." % (
1063
interface1.get_log_string(), interface1.vlan.fabric.get_name(),
1064
ngi1.subnet.cidr))),
1065
call(("%s: Observed connected to %s via %s." % (
1066
interface2.get_log_string(), interface2.vlan.fabric.get_name(),
1067
ngi2.subnet.cidr))),
1068
call(("%s: Observed connected to %s via %s." % (
1069
interface3.get_log_string(), interface3.vlan.fabric.get_name(),
1070
ngi3.subnet.cidr))),
1041
1073
def test__deletes_old_discovered_ip_addresses_on_interface(self):
1042
1074
interface = factory.make_Interface(INTERFACE_TYPE.PHYSICAL)
1043
1075
# Create existing DISCOVERED IP address on the interface. These should