~newell-jensen/maas/bug-1376888

« back to all changes in this revision

Viewing changes to src/maasserver/tests/test_networking_preseed.py

[r=rvb][bug=1379209][author=jason-hobbs] Ask curtin to only bring up the PXE MAC interface by default.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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,
39
39
    list_dns_servers,
40
40
    map_gateways,
41
41
    map_static_ips,
723
723
            mapping[mac.mac_address])
724
724
 
725
725
 
726
 
class TestFindMACsForAutomaticInterfaces(MAASServerTestCase):
727
 
 
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
731
 
        self.assertEqual(
732
 
            [normalise_mac(unicode(mac))],
733
 
            find_macs_for_automatic_interfaces(node))
734
 
 
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(
739
 
            node=node,
740
 
            cluster_interface=factory.make_NodeGroupInterface(
741
 
                node.nodegroup,
742
 
                management=NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED))
743
 
        self.assertEqual(
744
 
            [normalise_mac(unicode(boot_mac))],
745
 
            find_macs_for_automatic_interfaces(node))
746
 
 
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(
752
 
            node=node,
753
 
            cluster_interface=factory.make_NodeGroupInterface(
754
 
                node.nodegroup,
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):
 
727
 
 
728
    def test__uses_pxe_mac(self):
 
729
        node = factory.make_node_with_mac_attached_to_nodegroupinterface()
 
730
        mac = node.get_primary_mac()
 
731
        node.pxe_mac = mac
 
732
        result = get_mac_for_automatic_interfaces(node)
 
733
        self.assertEqual(result, extract_mac_string(mac))
760
734
 
761
735
 
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)
805
779
 
806
780
        preseed = compose_curtin_network_preseed_for(node)
807
781