Merge lp:~jtv/maas/identify-auto-interfaces into lp:~maas-committers/maas/trunk

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: no longer in the source branch.
Merged at revision: 3158
Proposed branch: lp:~jtv/maas/identify-auto-interfaces
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 76 lines (+54/-0)
2 files modified
src/maasserver/networking_preseed.py (+17/-0)
src/maasserver/tests/test_networking_preseed.py (+37/-0)
To merge this branch: bzr merge lp:~jtv/maas/identify-auto-interfaces
Reviewer Review Type Date Requested Status
Graham Binns (community) Approve
Review via email: mp+236688@code.launchpad.net

Commit message

Select network interfaces on a node that should be brought up automatically on boot. This is part of the work for writing its /etc/network/interfaces (assuming it's installed with a Debian-like OS). That code is not active yet, but is now very close to completion (and has been tested in a spike).

We chose the selection behaviour as being the closest to existing behaviour, not as the ideal behaviour as we would without the time constraints. In the normal situation where a node has one network interface on a network where MAAS manages DHCP, it is identical to what happens in the current code. If the node has multiple network interfaces on one or more MAAS-managed networks, they will all come up; the existing code will only bring up the interface from which the node netbooted, and some people seem to run into problems in this situation. And finally, if the node is not connected to any MAAS-managed DHCP, we have no knowledge of how the machine netbooted, so we bring up all interfaces.

Description of the change

Dimiter agrees that this seems like a sensible approach. In the future we'll work on ways for users to customise nodes' networking setup in more detail, not as an excuse for avoiding this question ourselves, but to extend the portion of networking that MAAS can manage for you.

Jeroen

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) wrote :

Approved with one minor comment. Nice work :).

review: Approve
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Good point. Done.

Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (18.4 KiB)

The attempt to merge lp:~jtv/maas/identify-auto-interfaces into lp:maas failed. Below is the output from the failed tests.

Ign http://nova.clouds.archive.ubuntu.com trusty InRelease
Ign http://security.ubuntu.com trusty-security InRelease
Get:1 http://security.ubuntu.com trusty-security Release.gpg [933 B]
Ign http://nova.clouds.archive.ubuntu.com trusty-updates InRelease
Get:2 http://security.ubuntu.com trusty-security Release [59.7 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty Release.gpg
Get:3 http://nova.clouds.archive.ubuntu.com trusty-updates Release.gpg [933 B]
Hit http://nova.clouds.archive.ubuntu.com trusty Release
Get:4 http://nova.clouds.archive.ubuntu.com trusty-updates Release [59.7 kB]
Get:5 http://security.ubuntu.com trusty-security/main Sources [46.3 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty/main Sources
Get:6 http://security.ubuntu.com trusty-security/universe Sources [10.8 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Sources
Get:7 http://security.ubuntu.com trusty-security/main amd64 Packages [146 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en
Get:8 http://security.ubuntu.com trusty-security/universe amd64 Packages [49.0 kB]
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Ign http://nova.clouds.archive.ubuntu.com trusty/main Translation-en_US
Ign http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en_US
Get:9 http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources [125 kB]
Get:10 http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources [86.2 kB]
Get:11 http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages [337 kB]
Get:12 http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages [208 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Translation-en
Fetched 1,129 kB in 0s (1,655 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
     --no-install-recommends install apache2 authbind bind9 bind9utils build-essential bzr-builddeb curl daemontools debhelper dh-apport distro-info dnsutils firefox freeipmi-tools ipython isc-dhcp-common libjs-raphael libjs-yui3-full libjs-yui3-min libpq-dev make pep8 postgresql pyflakes python-amqplib python-bzrlib python-celery python-convoy python-crochet python-cssselect python-curtin python-dev python-distro-info python-django python-django-piston python-django-south python-djorm-ext-pgarray python-docutils python-extras python-fixtures python-flake8 python-formencode python-hivex python-httplib2 python-jinja2 python-jsonschema python-lockfile python-lxml python-mimeparse python-mock python-netaddr python-netifaces python-nose python-oauth python-oops python-oops-amqp python-oops-datedir-repo python-oops-twisted python-oops-wsgi python-open...

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Spurious test failure. I get it in trunk too, about 1% of the times I eexecute that test.

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-01 04:43:44 +0000
3+++ src/maasserver/networking_preseed.py 2014-10-01 14:28:34 +0000
4@@ -297,3 +297,20 @@
5 if cluster_interface.manages_static_range():
6 add_ip_to_mapping(mapping, mac, cluster_interface.router_ip)
7 return mapping
8+
9+
10+def find_macs_for_automatic_interfaces(node):
11+ """Return those MAC addresses for `node` that should come up on boot.
12+
13+ These are the MACs for the network interfaces that should be enabled when
14+ a node boots. If the node has `MACAddress` entries on managed networks,
15+ these will be returned; if it doesn't, all of its `MACAddress` enries will
16+ be returned.
17+
18+ :param node: A `Node`.
19+ :return: A list of normalised MAC address strings.
20+ """
21+ macs = node.mac_addresses_on_managed_interfaces()
22+ if len(macs) == 0:
23+ macs = node.macaddress_set.all()
24+ return [normalise_mac(unicode(mac.mac_address)) for mac in macs]
25
26=== modified file 'src/maasserver/tests/test_networking_preseed.py'
27--- src/maasserver/tests/test_networking_preseed.py 2014-10-01 04:43:44 +0000
28+++ src/maasserver/tests/test_networking_preseed.py 2014-10-01 14:28:34 +0000
29@@ -28,6 +28,7 @@
30 add_ip_to_mapping,
31 extract_mac_string,
32 extract_network_interfaces,
33+ find_macs_for_automatic_interfaces,
34 generate_dns_server_entry,
35 generate_ethernet_link_entry,
36 generate_network_entry,
37@@ -711,3 +712,39 @@
38 },
39 },
40 map_gateways(node))
41+
42+
43+class TestFindMACsForAutomaticInterfaces(MAASServerTestCase):
44+
45+ def test__returns_netboot_interface_in_simple_case(self):
46+ node = factory.make_node_with_mac_attached_to_nodegroupinterface()
47+ mac = node.get_primary_mac().mac_address
48+ self.assertEqual(
49+ [normalise_mac(unicode(mac))],
50+ find_macs_for_automatic_interfaces(node))
51+
52+ def test__returns_only_macs_on_managed_networks_if_connected(self):
53+ node = factory.make_node_with_mac_attached_to_nodegroupinterface()
54+ boot_mac = node.get_primary_mac().mac_address
55+ factory.make_MACAddress(
56+ node=node,
57+ cluster_interface=factory.make_NodeGroupInterface(
58+ node.nodegroup,
59+ management=NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED))
60+ self.assertEqual(
61+ [normalise_mac(unicode(boot_mac))],
62+ find_macs_for_automatic_interfaces(node))
63+
64+ def test__returns_all_macs_if_no_managed_networks_connected(self):
65+ node = factory.make_node_with_mac_attached_to_nodegroupinterface(
66+ management=NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED)
67+ mac1 = node.get_primary_mac().mac_address
68+ other_mac = factory.make_MACAddress(
69+ node=node,
70+ cluster_interface=factory.make_NodeGroupInterface(
71+ node.nodegroup,
72+ management=NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED))
73+ mac2 = other_mac.mac_address
74+ self.assertItemsEqual(
75+ [normalise_mac(unicode(mac1)), normalise_mac(unicode(mac2))],
76+ find_macs_for_automatic_interfaces(node))