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
=== modified file 'src/maasserver/api.py'
--- src/maasserver/api.py 2012-09-19 14:04:30 +0000
+++ src/maasserver/api.py 2012-09-19 14:04:31 +0000
@@ -518,14 +518,23 @@
518 The user_data parameter, if set in the POST data, is taken as518 The user_data parameter, if set in the POST data, is taken as
519 base64-encoded binary data.519 base64-encoded binary data.
520520
521 The distro_series parameter, if set in the POST data, is taken as
522 clear text. This parameter specifies the Ubuntu Release the node
523 will use.
524
521 Ideally we'd have MIME multipart and content-transfer-encoding etc.525 Ideally we'd have MIME multipart and content-transfer-encoding etc.
522 deal with the encapsulation of binary data, but couldn't make it work526 deal with the encapsulation of binary data, but couldn't make it work
523 with the framework in reasonable time so went for a dumb, manual527 with the framework in reasonable time so went for a dumb, manual
524 encoding instead.528 encoding instead.
525 """529 """
526 user_data = request.POST.get('user_data', None)530 user_data = request.POST.get('user_data', None)
531 series = request.POST.get('distro_series', None)
527 if user_data is not None:532 if user_data is not None:
528 user_data = b64decode(user_data)533 user_data = b64decode(user_data)
534 if series is not None:
535 node = Node.objects.get_node_or_404(
536 system_id=system_id, user=request.user, perm=NODE_PERMISSION.EDIT)
537 node.set_distro_series(series=series)
529 nodes = Node.objects.start_nodes(538 nodes = Node.objects.start_nodes(
530 [system_id], request.user, user_data=user_data)539 [system_id], request.user, user_data=user_data)
531 if len(nodes) == 0:540 if len(nodes) == 0:
@@ -538,6 +547,7 @@
538 """Release a node. Opposite of `NodesHandler.acquire`."""547 """Release a node. Opposite of `NodesHandler.acquire`."""
539 node = Node.objects.get_node_or_404(548 node = Node.objects.get_node_or_404(
540 system_id=system_id, user=request.user, perm=NODE_PERMISSION.EDIT)549 system_id=system_id, user=request.user, perm=NODE_PERMISSION.EDIT)
550 node.set_distro_series(series='')
541 if node.status == NODE_STATUS.READY:551 if node.status == NODE_STATUS.READY:
542 # Nothing to do. This may be a redundant retry, and the552 # Nothing to do. This may be a redundant retry, and the
543 # postcondition is achieved, so call this success.553 # postcondition is achieved, so call this success.
544554
=== modified file 'src/maasserver/models/node.py'
--- src/maasserver/models/node.py 2012-09-19 14:04:30 +0000
+++ src/maasserver/models/node.py 2012-09-19 14:04:31 +0000
@@ -567,6 +567,11 @@
567 else:567 else:
568 return self.distro_series568 return self.distro_series
569569
570 def set_distro_series(self, series=''):
571 """Set the distro series to install that node."""
572 self.distro_series = series
573 self.save()
574
570 def get_effective_power_parameters(self):575 def get_effective_power_parameters(self):
571 """Return effective power parameters, including any defaults."""576 """Return effective power parameters, including any defaults."""
572 if self.power_parameters:577 if self.power_parameters: