← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/maas/maas-nodes-states into lp:maas

 

Raphaël Badin has proposed merging lp:~rvb/maas/maas-nodes-states into lp:maas.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~rvb/maas/maas-nodes-states/+merge/93019

Update node states.  Fairly mechanical change.

COMMISSIONED => READY
DEPLOYED => ALLOCATED

I've changed 3 sentences to avoid mentioning "the MaaS" or "the Maas owner".:
- "the MaaS can't contact the node." => "The node can't be contacted."
- "MaaS is aware of the node and has assigned it a system ID, but has done nothing else to it." => "The node has been created and has a system ID assigned to it."
- "The node has been removed from service manually until the MaaS owner overrides the retirement." => "The node has been removed from service manually until an admin overrides the retirement."
-- 
https://code.launchpad.net/~rvb/maas/maas-nodes-states/+merge/93019
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/maas-nodes-states into lp:maas.
=== modified file 'src/maasserver/models.py'
--- src/maasserver/models.py	2012-02-14 15:10:38 +0000
+++ src/maasserver/models.py	2012-02-14 16:09:32 +0000
@@ -62,27 +62,36 @@
 
 class NODE_STATUS:
     """The vocabulary of a `Node`'s possible statuses."""
-# TODO: document this when it's stabilized.
-    #:
     DEFAULT_STATUS = 0
-    #:
-    NEW = 0
-    #:
-    READY = 1
-    #:
-    DEPLOYED = 2
-    #:
-    COMMISSIONED = 3
-    #:
-    DECOMMISSIONED = 4
+    #: The node has been created and has a system ID assigned to it.
+    DECLARED = 0
+    #: Testing and other commissioning steps are taking place.
+    COMMISSIONING = 1
+    #: Smoke or burn-in testing has a found a problem.
+    FAILED_TESTS = 2
+    #: The node can't be contacted.
+    MISSING = 3
+    #: The node is in the general pool ready to be deployed.
+    READY = 4
+    #: The node is ready for named deployment.
+    RESERVED = 5
+    #: The node is powering a service from a charm or is ready for use with
+    #: a fresh Ubuntu install.
+    ALLOCATED = 6
+    #: The node has been removed from service manually until an admin
+    #: overrides the retirement.
+    RETIRED = 7
 
 
 NODE_STATUS_CHOICES = (
-    (NODE_STATUS.NEW, u'New'),
-    (NODE_STATUS.READY, u'Ready to Commission'),
-    (NODE_STATUS.DEPLOYED, u'Deployed'),
-    (NODE_STATUS.COMMISSIONED, u'Commissioned'),
-    (NODE_STATUS.DECOMMISSIONED, u'Decommissioned'),
+    (NODE_STATUS.DECLARED, "Declared"),
+    (NODE_STATUS.COMMISSIONING, "Commissioning"),
+    (NODE_STATUS.FAILED_TESTS, "Failed tests"),
+    (NODE_STATUS.MISSING, "Missing"),
+    (NODE_STATUS.READY, "Ready"),
+    (NODE_STATUS.RESERVED, "Reserved"),
+    (NODE_STATUS.ALLOCATED, "Allocated"),
+    (NODE_STATUS.RETIRED, "Retired"),
 )
 
 
@@ -225,7 +234,7 @@
         """
         available_nodes = (
             self.get_visible_nodes(for_user)
-                .filter(status=NODE_STATUS.COMMISSIONED))
+                .filter(status=NODE_STATUS.READY))
         available_nodes = list(available_nodes[:1])
         if len(available_nodes) == 0:
             return None
@@ -344,9 +353,9 @@
 
     def acquire(self, by_user):
         """Mark commissioned node as acquired by the given user."""
-        assert self.status == NODE_STATUS.COMMISSIONED
+        assert self.status == NODE_STATUS.READY
         assert self.owner is None
-        self.status = NODE_STATUS.DEPLOYED
+        self.status = NODE_STATUS.ALLOCATED
         self.owner = by_user
 
 

=== modified file 'src/maasserver/tests/test_api.py'
--- src/maasserver/tests/test_api.py	2012-02-14 15:10:38 +0000
+++ src/maasserver/tests/test_api.py	2012-02-14 16:09:32 +0000
@@ -148,7 +148,7 @@
         # The request to fetch a single node is denied if the node isn't
         # visible by the user.
         other_node = factory.make_node(
-            status=NODE_STATUS.DEPLOYED, owner=factory.make_user())
+            status=NODE_STATUS.ALLOCATED, owner=factory.make_user())
 
         response = self.client.get(self.get_uri(other_node))
 
@@ -239,7 +239,7 @@
         # The request to update a single node is denied if the node isn't
         # visible by the user.
         other_node = factory.make_node(
-            status=NODE_STATUS.DEPLOYED, owner=factory.make_user())
+            status=NODE_STATUS.ALLOCATED, owner=factory.make_user())
 
         response = self.client.put(self.get_uri(other_node))
 
@@ -265,7 +265,7 @@
         # The request to delete a single node is denied if the node isn't
         # visible by the user.
         other_node = factory.make_node(
-            status=NODE_STATUS.DEPLOYED, owner=factory.make_user())
+            status=NODE_STATUS.ALLOCATED, owner=factory.make_user())
 
         response = self.client.delete(self.get_uri(other_node))
 
@@ -286,7 +286,7 @@
         # The api allows for fetching the list of Nodes.
         node1 = factory.make_node()
         node2 = factory.make_node(
-            set_hostname=True, status=NODE_STATUS.DEPLOYED,
+            set_hostname=True, status=NODE_STATUS.ALLOCATED,
             owner=self.logged_in_user)
         response = self.client.get('/api/nodes/', {'op': 'list'})
         parsed_result = json.loads(response.content)
@@ -432,7 +432,7 @@
 
     def test_POST_returns_available_node(self):
         # The "acquire" operation returns an available node.
-        available_status = NODE_STATUS.COMMISSIONED
+        available_status = NODE_STATUS.READY
         node = factory.make_node(status=available_status, owner=None)
         response = self.client.post('/api/nodes/', {'op': 'acquire'})
         self.assertEqual(200, response.status_code)
@@ -441,7 +441,7 @@
 
     def test_POST_acquire_allocates_node(self):
         # The "acquire" operation allocates the node it returns.
-        available_status = NODE_STATUS.COMMISSIONED
+        available_status = NODE_STATUS.READY
         node = factory.make_node(status=available_status, owner=None)
         self.client.post('/api/nodes/', {'op': 'acquire'})
         node = Node.objects.get(system_id=node.system_id)
@@ -479,7 +479,7 @@
         # When fetching MAC Addresses, the api returns a 'Forbidden' (403)
         # error if the node is not visible to the logged-in user.
         other_node = factory.make_node(
-            status=NODE_STATUS.DEPLOYED, owner=factory.make_user())
+            status=NODE_STATUS.ALLOCATED, owner=factory.make_user())
         response = self.client.get(
             '/api/nodes/%s/macs/' % other_node.system_id)
 
@@ -504,7 +504,7 @@
         # When fetching a MAC Address, the api returns a 'Forbidden' (403)
         # error if the node is not visible to the logged-in user.
         other_node = factory.make_node(
-            status=NODE_STATUS.DEPLOYED, owner=factory.make_user())
+            status=NODE_STATUS.ALLOCATED, owner=factory.make_user())
         response = self.client.get(
             '/api/nodes/%s/macs/0-aa-22-cc-44-dd/' % other_node.system_id)
 
@@ -562,7 +562,7 @@
         # When deleting a MAC Address, the api returns a 'Forbidden' (403)
         # error if the node is not visible to the logged-in user.
         other_node = factory.make_node(
-            status=NODE_STATUS.DEPLOYED, owner=factory.make_user())
+            status=NODE_STATUS.ALLOCATED, owner=factory.make_user())
         response = self.client.delete(
             '/api/nodes/%s/macs/%s/' % (
                 other_node.system_id, self.mac1.mac_address))

=== modified file 'src/maasserver/tests/test_auth.py'
--- src/maasserver/tests/test_auth.py	2012-01-24 18:15:21 +0000
+++ src/maasserver/tests/test_auth.py	2012-02-14 16:09:32 +0000
@@ -60,9 +60,9 @@
         self.user1 = factory.make_user(username='user1')
         self.user2 = factory.make_user(username='user2')
         self.node_user1 = factory.make_node(
-            owner=self.user1, status=NODE_STATUS.DEPLOYED)
+            owner=self.user1, status=NODE_STATUS.ALLOCATED)
         self.node_user2 = factory.make_node(
-            owner=self.user2, status=NODE_STATUS.DEPLOYED)
+            owner=self.user2, status=NODE_STATUS.ALLOCATED)
         self.not_owned_node = factory.make_node()
 
 

=== modified file 'src/maasserver/tests/test_models.py'
--- src/maasserver/tests/test_models.py	2012-02-14 15:10:38 +0000
+++ src/maasserver/tests/test_models.py	2012-02-14 16:09:32 +0000
@@ -49,7 +49,9 @@
 
     def test_display_status(self):
         node = factory.make_node()
-        self.assertEqual('New', node.display_status())
+        self.assertEqual(
+            NODE_STATUS_CHOICES_DICT[NODE_STATUS.DECLARED],
+            node.display_status())
 
     def test_add_mac_address(self):
         node = factory.make_node()
@@ -67,11 +69,11 @@
         self.assertEqual(0, macs)
 
     def test_acquire(self):
-        node = factory.make_node(status=NODE_STATUS.COMMISSIONED)
+        node = factory.make_node(status=NODE_STATUS.READY)
         user = factory.make_user()
         node.acquire(user)
         self.assertEqual(user, node.owner)
-        self.assertEqual(NODE_STATUS.DEPLOYED, node.status)
+        self.assertEqual(NODE_STATUS.ALLOCATED, node.status)
 
 
 class NodeManagerTest(TestCase):
@@ -79,9 +81,9 @@
     def make_node(self, user=None):
         """Create a node, allocated to `user` if given."""
         if user is None:
-            status = NODE_STATUS.COMMISSIONED
+            status = NODE_STATUS.READY
         else:
-            status = NODE_STATUS.DEPLOYED
+            status = NODE_STATUS.ALLOCATED
         return factory.make_node(set_hostname=True, status=status, owner=user)
 
     def test_filter_by_ids_filters_nodes_by_ids(self):
@@ -191,7 +193,7 @@
 
     def test_get_available_node_for_acquisition_ignores_taken_nodes(self):
         user = factory.make_user()
-        available_status = NODE_STATUS.COMMISSIONED
+        available_status = NODE_STATUS.READY
         unavailable_statuses = (
             set(NODE_STATUS_CHOICES_DICT.keys()) - set([available_status]))
         for status in unavailable_statuses: