Merge lp:~jtv/maas/bug-1378803-through-Node-pxe_mac into lp:~maas-committers/maas/trunk

Proposed by Jeroen T. Vermeulen
Status: Rejected
Rejected by: Raphaël Badin
Proposed branch: lp:~jtv/maas/bug-1378803-through-Node-pxe_mac
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 94 lines (+34/-32)
2 files modified
src/maasserver/networking_preseed.py (+10/-2)
src/maasserver/tests/test_networking_preseed.py (+24/-30)
To merge this branch: bzr merge lp:~jtv/maas/bug-1378803-through-Node-pxe_mac
Reviewer Review Type Date Requested Status
Christian Reis (community) Disapprove
Jason Hobbs (community) Approve
Review via email: mp+237745@code.launchpad.net

Commit message

Tell the OS driver to bring up only a node's PXE-booting network interface on boot.

Uses the new field Node.pxe_mac. We're not actually populating that yet, so I built in a hack to keep development systems working in the meantime (should not be long). The hack doesn't try to simulate anything like desired behaviour, because that might just end up hiding problems. It's just enough for development testing.

Description of the change

Once we populate Node.pxe_mac, we should dig up the two XXX markers and remove the hack.

Jeroen

To post a comment you must log in.
Revision history for this message
Jason Hobbs (jason-hobbs) wrote :

Looks good -- I can't find anything to comment on :)

review: Approve
Revision history for this message
Christian Reis (kiko) wrote :

Just discussed with Raphael and as this needs to be done in sync with bug 1379209, I'm rejecting this and duping the bug -- Raphael and Jason will complete this with the new get-pxe API

review: Disapprove
Revision history for this message
Raphaël Badin (rvb) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/maasserver/networking_preseed.py'
--- src/maasserver/networking_preseed.py 2014-10-06 10:07:01 +0000
+++ src/maasserver/networking_preseed.py 2014-10-09 09:47:08 +0000
@@ -32,6 +32,7 @@
32import json32import json
3333
34from lxml import etree34from lxml import etree
35from maasserver import logger
35from maasserver.clusterrpc.osystems import compose_curtin_network_preseed36from maasserver.clusterrpc.osystems import compose_curtin_network_preseed
36from maasserver.dns.zonegenerator import get_dns_server_address37from maasserver.dns.zonegenerator import get_dns_server_address
37from maasserver.exceptions import UnresolvableHost38from maasserver.exceptions import UnresolvableHost
@@ -317,9 +318,16 @@
317 :param node: A `Node`.318 :param node: A `Node`.
318 :return: A list of normalised MAC address strings.319 :return: A list of normalised MAC address strings.
319 """320 """
320 macs = node.mac_addresses_on_managed_interfaces()321 pxe_mac = node.pxe_mac
321 if len(macs) == 0:322 if pxe_mac is None:
323 # XXX jtv 2014-10-09, bug=1379209: Replace this with an error once we
324 # have the code to populate Node.pxe_mac. It's just here to facilitate
325 # the transition on development/testing systems.
326 logger.warn(
327 "Node %s has no known PXE-boot MAC address.", node.hostname)
322 macs = node.macaddress_set.all()328 macs = node.macaddress_set.all()
329 else:
330 macs = [pxe_mac]
323 return [normalise_mac(unicode(mac.mac_address)) for mac in macs]331 return [normalise_mac(unicode(mac.mac_address)) for mac in macs]
324332
325333
326334
=== modified file 'src/maasserver/tests/test_networking_preseed.py'
--- src/maasserver/tests/test_networking_preseed.py 2014-10-08 08:51:09 +0000
+++ src/maasserver/tests/test_networking_preseed.py 2014-10-09 09:47:08 +0000
@@ -725,37 +725,31 @@
725725
726class TestFindMACsForAutomaticInterfaces(MAASServerTestCase):726class TestFindMACsForAutomaticInterfaces(MAASServerTestCase):
727727
728 def test__returns_netboot_interface_in_simple_case(self):728 def test__returns_pxe_mac_if_known(self):
729 node = factory.make_node_with_mac_attached_to_nodegroupinterface()729 node = factory.make_node_with_mac_attached_to_nodegroupinterface()
730 mac = node.get_primary_mac().mac_address730 mac = node.get_primary_mac()
731 self.assertEqual(731 node.pxe_mac = mac
732 [normalise_mac(unicode(mac))],732 self.assertEqual(
733 find_macs_for_automatic_interfaces(node))733 [extract_mac_string(mac)],
734734 find_macs_for_automatic_interfaces(node))
735 def test__returns_only_macs_on_managed_networks_if_connected(self):735
736 node = factory.make_node_with_mac_attached_to_nodegroupinterface()736 def test__ignores_other_interfaces_if_pxe_mac_known(self):
737 boot_mac = node.get_primary_mac().mac_address737 node = factory.make_Node()
738 factory.make_MACAddress(738 macs = [factory.make_MACAddress(node=node) for _ in range(3)]
739 node=node,739 pxe_mac = macs[1]
740 cluster_interface=factory.make_NodeGroupInterface(740 node.pxe_mac = pxe_mac
741 node.nodegroup,741 self.assertEqual(
742 management=NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED))742 [extract_mac_string(pxe_mac)],
743 self.assertEqual(743 find_macs_for_automatic_interfaces(node))
744 [normalise_mac(unicode(boot_mac))],744
745 find_macs_for_automatic_interfaces(node))745 def test__returns_all_macs_if_no_pxe_mac_known(self):
746746 # XXX jtv 2014-10-09, bug=1379209: Once the code to populate
747 def test__returns_all_macs_if_no_managed_networks_connected(self):747 # Node.pxe_mac has landed, this situation should no longer occur.
748 node = factory.make_node_with_mac_attached_to_nodegroupinterface(748 node = factory.make_Node()
749 management=NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED)749 node.pxe_mac = None
750 mac1 = node.get_primary_mac().mac_address750 macs = [factory.make_MACAddress(node=node) for _ in range(2)]
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(751 self.assertItemsEqual(
758 [normalise_mac(unicode(mac1)), normalise_mac(unicode(mac2))],752 [extract_mac_string(mac) for mac in macs],
759 find_macs_for_automatic_interfaces(node))753 find_macs_for_automatic_interfaces(node))
760754
761755