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
1=== modified file 'src/maasserver/networking_preseed.py'
2--- src/maasserver/networking_preseed.py 2014-10-06 10:07:01 +0000
3+++ src/maasserver/networking_preseed.py 2014-10-09 09:47:08 +0000
4@@ -32,6 +32,7 @@
5 import json
6
7 from lxml import etree
8+from maasserver import logger
9 from maasserver.clusterrpc.osystems import compose_curtin_network_preseed
10 from maasserver.dns.zonegenerator import get_dns_server_address
11 from maasserver.exceptions import UnresolvableHost
12@@ -317,9 +318,16 @@
13 :param node: A `Node`.
14 :return: A list of normalised MAC address strings.
15 """
16- macs = node.mac_addresses_on_managed_interfaces()
17- if len(macs) == 0:
18+ pxe_mac = node.pxe_mac
19+ if pxe_mac is None:
20+ # XXX jtv 2014-10-09, bug=1379209: Replace this with an error once we
21+ # have the code to populate Node.pxe_mac. It's just here to facilitate
22+ # the transition on development/testing systems.
23+ logger.warn(
24+ "Node %s has no known PXE-boot MAC address.", node.hostname)
25 macs = node.macaddress_set.all()
26+ else:
27+ macs = [pxe_mac]
28 return [normalise_mac(unicode(mac.mac_address)) for mac in macs]
29
30
31
32=== modified file 'src/maasserver/tests/test_networking_preseed.py'
33--- src/maasserver/tests/test_networking_preseed.py 2014-10-08 08:51:09 +0000
34+++ src/maasserver/tests/test_networking_preseed.py 2014-10-09 09:47:08 +0000
35@@ -725,37 +725,31 @@
36
37 class TestFindMACsForAutomaticInterfaces(MAASServerTestCase):
38
39- def test__returns_netboot_interface_in_simple_case(self):
40- node = factory.make_node_with_mac_attached_to_nodegroupinterface()
41- mac = node.get_primary_mac().mac_address
42- self.assertEqual(
43- [normalise_mac(unicode(mac))],
44- find_macs_for_automatic_interfaces(node))
45-
46- def test__returns_only_macs_on_managed_networks_if_connected(self):
47- node = factory.make_node_with_mac_attached_to_nodegroupinterface()
48- boot_mac = node.get_primary_mac().mac_address
49- factory.make_MACAddress(
50- node=node,
51- cluster_interface=factory.make_NodeGroupInterface(
52- node.nodegroup,
53- management=NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED))
54- self.assertEqual(
55- [normalise_mac(unicode(boot_mac))],
56- find_macs_for_automatic_interfaces(node))
57-
58- def test__returns_all_macs_if_no_managed_networks_connected(self):
59- node = factory.make_node_with_mac_attached_to_nodegroupinterface(
60- management=NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED)
61- mac1 = node.get_primary_mac().mac_address
62- other_mac = factory.make_MACAddress(
63- node=node,
64- cluster_interface=factory.make_NodeGroupInterface(
65- node.nodegroup,
66- management=NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED))
67- mac2 = other_mac.mac_address
68+ def test__returns_pxe_mac_if_known(self):
69+ node = factory.make_node_with_mac_attached_to_nodegroupinterface()
70+ mac = node.get_primary_mac()
71+ node.pxe_mac = mac
72+ self.assertEqual(
73+ [extract_mac_string(mac)],
74+ find_macs_for_automatic_interfaces(node))
75+
76+ def test__ignores_other_interfaces_if_pxe_mac_known(self):
77+ node = factory.make_Node()
78+ macs = [factory.make_MACAddress(node=node) for _ in range(3)]
79+ pxe_mac = macs[1]
80+ node.pxe_mac = pxe_mac
81+ self.assertEqual(
82+ [extract_mac_string(pxe_mac)],
83+ find_macs_for_automatic_interfaces(node))
84+
85+ def test__returns_all_macs_if_no_pxe_mac_known(self):
86+ # XXX jtv 2014-10-09, bug=1379209: Once the code to populate
87+ # Node.pxe_mac has landed, this situation should no longer occur.
88+ node = factory.make_Node()
89+ node.pxe_mac = None
90+ macs = [factory.make_MACAddress(node=node) for _ in range(2)]
91 self.assertItemsEqual(
92- [normalise_mac(unicode(mac1)), normalise_mac(unicode(mac2))],
93+ [extract_mac_string(mac) for mac in macs],
94 find_macs_for_automatic_interfaces(node))
95
96