← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/maas/maas-add-node-form into lp:maas

 

Raphaël Badin has proposed merging lp:~rvb/maas/maas-add-node-form into lp:maas with lp:~rvb/maas/maas-add-node-api as a prerequisite.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~rvb/maas/maas-add-node-form/+merge/90851

This branch adds a new choice field to Node (after_commissioning_action) to store the action to be performed after commissioning (!).  Note that I did not update the sampledata so the default value will be used for Nodes created using the sampledata.
-- 
https://code.launchpad.net/~rvb/maas/maas-add-node-form/+merge/90851
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/maas-add-node-form into lp:maas.
=== modified file 'src/maasserver/forms.py'
--- src/maasserver/forms.py	2012-01-31 10:53:47 +0000
+++ src/maasserver/forms.py	2012-01-31 10:53:47 +0000
@@ -30,7 +30,7 @@
 
     class Meta:
         model = Node
-        fields = ('hostname', 'system_id')
+        fields = ('hostname', 'system_id', 'after_commissioning_action')
 
 
 class MACAddressForm(ModelForm):

=== modified file 'src/maasserver/models.py'
--- src/maasserver/models.py	2012-01-27 14:30:12 +0000
+++ src/maasserver/models.py	2012-01-31 10:53:47 +0000
@@ -68,6 +68,36 @@
 NODE_STATUS_CHOICES_DICT = dict(NODE_STATUS_CHOICES)
 
 
+class NODE_AFTER_COMMISSIONING_ACTION:
+    DEFAULT = 0
+    QUEUE = 0
+    CHECK = 1
+    DEPLOY_12_04 = 2
+    DEPLOY_11_10 = 3
+    DEPLOY_11_04 = 4
+    DEPLOY_10_10 = 5
+
+
+NODE_AFTER_COMMISSIONING_ACTION_CHOICES = (
+    (NODE_AFTER_COMMISSIONING_ACTION.QUEUE,
+        "Queue for dynamic allocation to services"),
+    (NODE_AFTER_COMMISSIONING_ACTION.CHECK,
+        "Check compatibility and hold for future decision"),
+    (NODE_AFTER_COMMISSIONING_ACTION.DEPLOY_12_04,
+        "Deploy with Ubuntu 12.04 LTS"),
+    (NODE_AFTER_COMMISSIONING_ACTION.DEPLOY_11_10,
+        "Deploy with Ubuntu 11.10"),
+    (NODE_AFTER_COMMISSIONING_ACTION.DEPLOY_11_04,
+        "Deploy with Ubuntu 11.04"),
+    (NODE_AFTER_COMMISSIONING_ACTION.DEPLOY_10_10,
+        "Deploy with Ubuntu 10.10"),
+)
+
+
+NODE_AFTER_COMMISSIONING_ACTION_CHOICES_DICT = dict(
+    NODE_AFTER_COMMISSIONING_ACTION_CHOICES)
+
+
 class NodeManager(models.Manager):
     """A utility to manage collections of Nodes."""
 
@@ -114,6 +144,9 @@
         default=NODE_STATUS.DEFAULT_STATUS)
     owner = models.ForeignKey(
         User, default=None, blank=True, null=True, editable=False)
+    after_commissioning_action = models.IntegerField(
+        choices=NODE_AFTER_COMMISSIONING_ACTION_CHOICES,
+        default=NODE_AFTER_COMMISSIONING_ACTION.DEFAULT)
 
     objects = NodeManager()
 

=== modified file 'src/maasserver/tests/test_api.py'
--- src/maasserver/tests/test_api.py	2012-01-31 10:53:47 +0000
+++ src/maasserver/tests/test_api.py	2012-01-31 10:53:47 +0000
@@ -113,6 +113,7 @@
                 {
                     'op': 'new',
                     'hostname': 'diane',
+                    'after_commissioning_action': '2',
                     'mac_addresses': ['aa:bb:cc:dd:ee:ff', '22:bb:cc:dd:ee:ff']
                 })
         parsed_result = json.loads(response.content)
@@ -122,6 +123,7 @@
         self.assertEqual(41, len(parsed_result.get('system_id')))
         self.assertEqual(1, Node.objects.filter(hostname='diane').count())
         node = Node.objects.get(hostname='diane')
+        self.assertEqual(2, node.after_commissioning_action)
         self.assertSequenceEqual(
             ['aa:bb:cc:dd:ee:ff', '22:bb:cc:dd:ee:ff'],
             [mac.mac_address for mac in node.macaddress_set.all()])