30
30
compose_curtin_network_preseed_for,
31
31
extract_mac_string,
32
32
extract_network_interfaces,
33
find_macs_for_automatic_interfaces,
34
33
generate_dns_server_entry,
35
34
generate_ethernet_link_entry,
36
35
generate_network_entry,
37
36
generate_networking_config,
38
37
generate_route_entries,
38
get_mac_for_automatic_interfaces,
723
723
mapping[mac.mac_address])
726
class TestFindMACsForAutomaticInterfaces(MAASServerTestCase):
728
def test__returns_netboot_interface_in_simple_case(self):
729
node = factory.make_node_with_mac_attached_to_nodegroupinterface()
730
mac = node.get_primary_mac().mac_address
732
[normalise_mac(unicode(mac))],
733
find_macs_for_automatic_interfaces(node))
735
def test__returns_only_macs_on_managed_networks_if_connected(self):
736
node = factory.make_node_with_mac_attached_to_nodegroupinterface()
737
boot_mac = node.get_primary_mac().mac_address
738
factory.make_MACAddress(
740
cluster_interface=factory.make_NodeGroupInterface(
742
management=NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED))
744
[normalise_mac(unicode(boot_mac))],
745
find_macs_for_automatic_interfaces(node))
747
def test__returns_all_macs_if_no_managed_networks_connected(self):
748
node = factory.make_node_with_mac_attached_to_nodegroupinterface(
749
management=NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED)
750
mac1 = node.get_primary_mac().mac_address
751
other_mac = factory.make_MACAddress(
753
cluster_interface=factory.make_NodeGroupInterface(
755
management=NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED))
756
mac2 = other_mac.mac_address
757
self.assertItemsEqual(
758
[normalise_mac(unicode(mac1)), normalise_mac(unicode(mac2))],
759
find_macs_for_automatic_interfaces(node))
726
class TestGetMACForAutomaticInterfaces(MAASServerTestCase):
728
def test__uses_pxe_mac(self):
729
node = factory.make_node_with_mac_attached_to_nodegroupinterface()
730
mac = node.get_primary_mac()
732
result = get_mac_for_automatic_interfaces(node)
733
self.assertEqual(result, extract_mac_string(mac))
762
736
class TestComposeCurtinNetworkPreseedFor(MAASServerTestCase):
801
775
networking_preseed, 'compose_curtin_network_preseed')
802
776
preseed_data = {factory.make_name('key'): factory.make_name('value')}
803
777
fake.return_value = [preseed_data]
804
node = factory.make_Node()
778
node = factory.make_Node(mac=True)
806
780
preseed = compose_curtin_network_preseed_for(node)