Merge lp:~jtv/maas/use-get_osystem-not-osystem 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: 3085
Proposed branch: lp:~jtv/maas/use-get_osystem-not-osystem
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 64 lines (+17/-4)
4 files modified
src/maasserver/preseed.py (+1/-1)
src/maasserver/tests/test_preseed.py (+5/-2)
src/maasserver/views/nodes.py (+1/-1)
src/maasserver/views/tests/test_nodes.py (+10/-0)
To merge this branch: bzr merge lp:~jtv/maas/use-get_osystem-not-osystem
Reviewer Review Type Date Requested Status
Raphaël Badin (community) Approve
Review via email: mp+235895@code.launchpad.net

Commit message

Use Node.get_osystem(), not Node.osystem, to obtain a node's operating system.

Description of the change

The affected code will probably end up in the OS registry.

Jeroen

To post a comment you must log in.
Revision history for this message
Raphaël Badin (rvb) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/preseed.py'
2--- src/maasserver/preseed.py 2014-09-24 13:27:46 +0000
3+++ src/maasserver/preseed.py 2014-09-25 04:28:42 +0000
4@@ -145,7 +145,7 @@
5 the `maas_configure_interfaces` script to the node during installation, and
6 running it.
7 """
8- if node.osystem not in OS_WITH_IPv6_SUPPORT:
9+ if node.get_osystem() not in OS_WITH_IPv6_SUPPORT:
10 # Don't configure networking on this node. It breaks.
11 return []
12
13
14=== modified file 'src/maasserver/tests/test_preseed.py'
15--- src/maasserver/tests/test_preseed.py 2014-09-24 13:27:46 +0000
16+++ src/maasserver/tests/test_preseed.py 2014-09-25 04:28:42 +0000
17@@ -806,8 +806,11 @@
18 self.expectThat(file_spec['content'], Equals(read_text_file(script)))
19
20 def test__runs_script_if_supported_OS(self):
21- [_, late_commands_yaml] = compose_curtin_network_preseed(
22- factory.make_Node(osystem='ubuntu'))
23+ node = factory.make_Node()
24+ # Let the node default to Ubuntu, which is supported for IPv6.
25+ node.osystem = ''
26+ node.save()
27+ [_, late_commands_yaml] = compose_curtin_network_preseed(node)
28 late_commands = yaml.safe_load(late_commands_yaml)
29 command = (
30 late_commands['late_commands']['90_maas_configure_interfaces'])
31
32=== modified file 'src/maasserver/views/nodes.py'
33--- src/maasserver/views/nodes.py 2014-09-24 02:34:07 +0000
34+++ src/maasserver/views/nodes.py 2014-09-25 04:28:42 +0000
35@@ -551,7 +551,7 @@
36
37 :return: Bool: should the UI show this warning?
38 """
39- supported_os = (node.osystem in OS_WITH_IPv6_SUPPORT)
40+ supported_os = (node.get_osystem() in OS_WITH_IPv6_SUPPORT)
41 if supported_os and node.boot_type == NODE_BOOT.FASTPATH:
42 # MAAS knows how to configure IPv6 addresses on an Ubuntu node
43 # installed with the fast installer. No warning needed.
44
45=== modified file 'src/maasserver/views/tests/test_nodes.py'
46--- src/maasserver/views/tests/test_nodes.py 2014-09-23 09:46:02 +0000
47+++ src/maasserver/views/tests/test_nodes.py 2014-09-25 04:28:42 +0000
48@@ -1349,6 +1349,16 @@
49 ip=factory.pick_ip_in_network(network), mac=node.get_primary_mac())
50 self.assertFalse(NodeView().warn_unconfigured_ip_addresses(node))
51
52+ def test__does_not_warn_for_default_ubuntu_with_fast_installer(self):
53+ network = factory.make_ipv6_network()
54+ node = factory.make_node_with_mac_attached_to_nodegroupinterface(
55+ osystem='ubuntu', network=network, boot_type=NODE_BOOT.FASTPATH)
56+ node.osystem = ''
57+ node.save()
58+ factory.make_StaticIPAddress(
59+ ip=factory.pick_ip_in_network(network), mac=node.get_primary_mac())
60+ self.assertFalse(NodeView().warn_unconfigured_ip_addresses(node))
61+
62 def test__does_not_warn_for_just_IPv4_address(self):
63 network = factory.make_ipv4_network()
64 osystem = choice(['windows', 'centos', 'suse'])