Merge lp:~jtv/maas/add-curtin-network-preseed-to-osystems-rpc-layer 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: 3173
Proposed branch: lp:~jtv/maas/add-curtin-network-preseed-to-osystems-rpc-layer
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 119 lines (+48/-12)
3 files modified
src/maasserver/clusterrpc/osystems.py (+26/-0)
src/maasserver/clusterrpc/tests/test_osystems.py (+21/-0)
src/provisioningserver/rpc/cluster.py (+1/-12)
To merge this branch: bzr merge lp:~jtv/maas/add-curtin-network-preseed-to-osystems-rpc-layer
Reviewer Review Type Date Requested Status
Raphaël Badin (community) Approve
Review via email: mp+236811@code.launchpad.net

Commit message

Add a missing piece to the RPC layercake for the compose_curtin_network_preseed call: a wrapper in maasserver.clusterrpc.osystems.

Description of the change

This follows the patterns I see in the other OS-related RPC code. It looks like this is also where the documentation for parameters goes, so I moved it from the definition of the call itself (where none of the other definitions had this documentation).

Jeroen

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

Looks good.

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

All done. Thanks for the review. It's hateful how many places need this documentation copied around, or go undocumented, all for *one* call site passing through the whole chain...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/clusterrpc/osystems.py'
2--- src/maasserver/clusterrpc/osystems.py 2014-09-27 12:55:30 +0000
3+++ src/maasserver/clusterrpc/osystems.py 2014-10-02 04:17:00 +0000
4@@ -13,6 +13,7 @@
5
6 __metaclass__ = type
7 __all__ = [
8+ "compose_curtin_network_preseed",
9 "gen_all_known_operating_systems",
10 "get_preseed_data",
11 "validate_license_key",
12@@ -32,6 +33,7 @@
13 from maasserver.utils import async
14 from maasserver.utils.orm import get_one
15 from provisioningserver.rpc.cluster import (
16+ ComposeCurtinNetworkPreseed,
17 GetOSReleaseTitle,
18 GetPreseedData,
19 ListOperatingSystems,
20@@ -135,6 +137,30 @@
21
22
23 @synchronous
24+def compose_curtin_network_preseed(node, config):
25+ """Generate a Curtin network preseed for a node.
26+
27+ :param node: A `Node`.
28+ :param config: A dict detailing the network configuration:
29+ `interfaces` maps to a list of pairs of interface name and MAC address.
30+ `auto_interfaces` maps to a list of MAC addresses for those network
31+ interfaces that should come up automatically on node boot.
32+ `ips_mapping` maps to a dict which maps MAC addresses to lists of
33+ IP addresses (at most one IPv4 and one IPv6 each) to be assigned to the
34+ corresponding network interfaces.
35+ `gateways_mapping` maps to a dict which maps MAC addresses to lists of
36+ gateway IP addresses (at most one IPv4 and one IPv6) to be used by the
37+ corresponding network interfaces.
38+ :param disable_ipv4: Should IPv4 networking be disabled on the node?
39+ """
40+ client = getClientFor(node.nodegroup.uuid)
41+ call = client(
42+ ComposeCurtinNetworkPreseed, osystem=node.get_osystem(), config=config,
43+ disable_ipv4=node.disable_ipv4)
44+ return call.wait(30).get("data")
45+
46+
47+@synchronous
48 def validate_license_key_for(nodegroup, osystem, release, key):
49 """Validate license key for the given nodegroup, OS, and release.
50
51
52=== modified file 'src/maasserver/clusterrpc/tests/test_osystems.py'
53--- src/maasserver/clusterrpc/tests/test_osystems.py 2014-09-27 04:40:39 +0000
54+++ src/maasserver/clusterrpc/tests/test_osystems.py 2014-10-02 04:17:00 +0000
55@@ -20,6 +20,7 @@
56 )
57
58 from maasserver.clusterrpc.osystems import (
59+ compose_curtin_network_preseed,
60 gen_all_known_operating_systems,
61 get_os_release_title,
62 get_preseed_data,
63@@ -242,6 +243,26 @@
64 metadata_url=factory.make_url())
65
66
67+class TestComposeCurtinPreseedData(MAASServerTestCase):
68+
69+ def make_config(self):
70+ mac = factory.make_mac_address()
71+ return {
72+ 'interfaces': [(factory.make_name('eth'), mac)],
73+ 'auto_interfaces': [mac],
74+ 'ips_mapping': {},
75+ 'gateways_mapping': {mac: [factory.make_ipv6_address()]},
76+ }
77+
78+ def test__returns_preseed_data(self):
79+ node = factory.make_Node()
80+ node.nodegroup.accept()
81+ self.useFixture(RunningClusterRPCFixture())
82+ config = self.make_config()
83+ preseed = compose_curtin_network_preseed(node, config)
84+ self.assertIsInstance(preseed, list)
85+
86+
87 class TestValidateLicenseKeyFor(MAASServerTestCase):
88 """Tests for `validate_license_key_for`."""
89
90
91=== modified file 'src/provisioningserver/rpc/cluster.py'
92--- src/provisioningserver/rpc/cluster.py 2014-10-01 03:58:43 +0000
93+++ src/provisioningserver/rpc/cluster.py 2014-10-02 04:17:00 +0000
94@@ -16,6 +16,7 @@
95
96 __metaclass__ = type
97 __all__ = [
98+ "ComposeCurtinNetworkPreseed",
99 "ConfigureDHCPv4",
100 "ConfigureDHCPv6",
101 "CreateHostMaps",
102@@ -188,18 +189,6 @@
103 class ComposeCurtinNetworkPreseed(amp.Command):
104 """Generate Curtin network preseed for a node.
105
106- :param osystem: Operating system identifier, e.g. `ubuntu`.
107- :param config: A dict detailing the network configuration:
108- `interfaces` maps to a list of pairs of interface name and MAC address.
109- `auto_interfaces` maps to a list of MAC addresses for those network
110- interfaces that should come up automatically on node boot.
111- `ips_mapping` maps to a dict which maps MAC addresses to lists of
112- IP addresses (at most one IPv4 and one IPv6 each) to be assigned to the
113- corresponding network interfaces.
114- `gateways_mapping` maps to a dict which maps MAC addresses to lists of
115- gateway IP addresses (at most one IPv4 and one IPv6) to be used by the
116- corresponding network interfaces.
117- :param disable_ipv4: Should IPv4 networking be disabled on the node?
118 :since: 1.7
119 """
120