Merge lp:~andreserl/maas/add_api_parameter_for_ubuntu_series into lp:~maas-committers/maas/trunk

Proposed by Andres Rodriguez
Status: Merged
Approved by: Andres Rodriguez
Approved revision: no longer in the source branch.
Merged at revision: 1027
Proposed branch: lp:~andreserl/maas/add_api_parameter_for_ubuntu_series
Merge into: lp:~maas-committers/maas/trunk
Prerequisite: lp:~andreserl/maas/distro_series_support
Diff against target: 51 lines (+15/-0) (has conflicts)
2 files modified
src/maasserver/api.py (+10/-0)
src/maasserver/models/node.py (+5/-0)
Text conflict in src/maasserver/models/config.py
To merge this branch: bzr merge lp:~andreserl/maas/add_api_parameter_for_ubuntu_series
Reviewer Review Type Date Requested Status
John A Meinel (community) Approve
Review via email: mp+125016@code.launchpad.net

Commit message

Allows to specify the ubuntu_series (Release) a Node will be started/deployed with through the API, and then sets the value for the node. This is particularly useful as it allows juju to deploy a node with the specified series.

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

(Yet another name, 'ubuntu_series', could we use 'distro_series' there?)
Otherwise fine by me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/api.py'
2--- src/maasserver/api.py 2012-09-19 14:04:30 +0000
3+++ src/maasserver/api.py 2012-09-19 14:04:31 +0000
4@@ -518,14 +518,23 @@
5 The user_data parameter, if set in the POST data, is taken as
6 base64-encoded binary data.
7
8+ The distro_series parameter, if set in the POST data, is taken as
9+ clear text. This parameter specifies the Ubuntu Release the node
10+ will use.
11+
12 Ideally we'd have MIME multipart and content-transfer-encoding etc.
13 deal with the encapsulation of binary data, but couldn't make it work
14 with the framework in reasonable time so went for a dumb, manual
15 encoding instead.
16 """
17 user_data = request.POST.get('user_data', None)
18+ series = request.POST.get('distro_series', None)
19 if user_data is not None:
20 user_data = b64decode(user_data)
21+ if series is not None:
22+ node = Node.objects.get_node_or_404(
23+ system_id=system_id, user=request.user, perm=NODE_PERMISSION.EDIT)
24+ node.set_distro_series(series=series)
25 nodes = Node.objects.start_nodes(
26 [system_id], request.user, user_data=user_data)
27 if len(nodes) == 0:
28@@ -538,6 +547,7 @@
29 """Release a node. Opposite of `NodesHandler.acquire`."""
30 node = Node.objects.get_node_or_404(
31 system_id=system_id, user=request.user, perm=NODE_PERMISSION.EDIT)
32+ node.set_distro_series(series='')
33 if node.status == NODE_STATUS.READY:
34 # Nothing to do. This may be a redundant retry, and the
35 # postcondition is achieved, so call this success.
36
37=== modified file 'src/maasserver/models/node.py'
38--- src/maasserver/models/node.py 2012-09-19 14:04:30 +0000
39+++ src/maasserver/models/node.py 2012-09-19 14:04:31 +0000
40@@ -567,6 +567,11 @@
41 else:
42 return self.distro_series
43
44+ def set_distro_series(self, series=''):
45+ """Set the distro series to install that node."""
46+ self.distro_series = series
47+ self.save()
48+
49 def get_effective_power_parameters(self):
50 """Return effective power parameters, including any defaults."""
51 if self.power_parameters: