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
=== modified file 'src/maasserver/networking_preseed.py'
--- src/maasserver/networking_preseed.py 2014-10-01 04:43:44 +0000
+++ src/maasserver/networking_preseed.py 2014-10-01 14:28:34 +0000
@@ -297,3 +297,20 @@
297 if cluster_interface.manages_static_range():297 if cluster_interface.manages_static_range():
298 add_ip_to_mapping(mapping, mac, cluster_interface.router_ip)298 add_ip_to_mapping(mapping, mac, cluster_interface.router_ip)
299 return mapping299 return mapping
300
301
302def find_macs_for_automatic_interfaces(node):
303 """Return those MAC addresses for `node` that should come up on boot.
304
305 These are the MACs for the network interfaces that should be enabled when
306 a node boots. If the node has `MACAddress` entries on managed networks,
307 these will be returned; if it doesn't, all of its `MACAddress` enries will
308 be returned.
309
310 :param node: A `Node`.
311 :return: A list of normalised MAC address strings.
312 """
313 macs = node.mac_addresses_on_managed_interfaces()
314 if len(macs) == 0:
315 macs = node.macaddress_set.all()
316 return [normalise_mac(unicode(mac.mac_address)) for mac in macs]
300317
=== modified file 'src/maasserver/tests/test_networking_preseed.py'
--- src/maasserver/tests/test_networking_preseed.py 2014-10-01 04:43:44 +0000
+++ src/maasserver/tests/test_networking_preseed.py 2014-10-01 14:28:34 +0000
@@ -28,6 +28,7 @@
28 add_ip_to_mapping,28 add_ip_to_mapping,
29 extract_mac_string,29 extract_mac_string,
30 extract_network_interfaces,30 extract_network_interfaces,
31 find_macs_for_automatic_interfaces,
31 generate_dns_server_entry,32 generate_dns_server_entry,
32 generate_ethernet_link_entry,33 generate_ethernet_link_entry,
33 generate_network_entry,34 generate_network_entry,
@@ -711,3 +712,39 @@
711 },712 },
712 },713 },
713 map_gateways(node))714 map_gateways(node))
715
716
717class TestFindMACsForAutomaticInterfaces(MAASServerTestCase):
718
719 def test__returns_netboot_interface_in_simple_case(self):
720 node = factory.make_node_with_mac_attached_to_nodegroupinterface()
721 mac = node.get_primary_mac().mac_address
722 self.assertEqual(
723 [normalise_mac(unicode(mac))],
724 find_macs_for_automatic_interfaces(node))
725
726 def test__returns_only_macs_on_managed_networks_if_connected(self):
727 node = factory.make_node_with_mac_attached_to_nodegroupinterface()
728 boot_mac = node.get_primary_mac().mac_address
729 factory.make_MACAddress(
730 node=node,
731 cluster_interface=factory.make_NodeGroupInterface(
732 node.nodegroup,
733 management=NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED))
734 self.assertEqual(
735 [normalise_mac(unicode(boot_mac))],
736 find_macs_for_automatic_interfaces(node))
737
738 def test__returns_all_macs_if_no_managed_networks_connected(self):
739 node = factory.make_node_with_mac_attached_to_nodegroupinterface(
740 management=NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED)
741 mac1 = node.get_primary_mac().mac_address
742 other_mac = factory.make_MACAddress(
743 node=node,
744 cluster_interface=factory.make_NodeGroupInterface(
745 node.nodegroup,
746 management=NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED))
747 mac2 = other_mac.mac_address
748 self.assertItemsEqual(
749 [normalise_mac(unicode(mac1)), normalise_mac(unicode(mac2))],
750 find_macs_for_automatic_interfaces(node))