← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/maas/bug-1177879 into lp:maas

 

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

Commit message:
Add the display of the cluster_name of a nodegroup.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1177879 in MAAS: "The cluster's information cannot be read via the API/CLI"
  https://bugs.launchpad.net/maas/+bug/1177879

For more details, see:
https://code.launchpad.net/~rvb/maas/bug-1177879/+merge/163070

The main change here is the addition of 'cluster_name" to DISPLAYED_NODEGROUP_FIELDS.
I also fixed the unfortunate reuse of DISPLAYED_NODEGROUP_FIELDS for the list of the nodegroupinterface fields. It worked so far because DISPLAYED_NODEGROUP_FIELDS was defined with the list of the nodegroup fields, then used for that, then redefined with the list of the nodegroupinterface fields then used for that. 
-- 
https://code.launchpad.net/~rvb/maas/bug-1177879/+merge/163070
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/bug-1177879 into lp:maas.
=== modified file 'src/maasserver/api.py'
--- src/maasserver/api.py	2013-04-24 17:42:35 +0000
+++ src/maasserver/api.py	2013-05-08 23:07:30 +0000
@@ -972,7 +972,7 @@
     }
 
 
-DISPLAYED_NODEGROUP_FIELDS = ('uuid', 'status', 'name')
+DISPLAYED_NODEGROUP_FIELDS = ('uuid', 'status', 'name', 'cluster_name')
 
 
 class AnonNodeGroupsHandler(AnonymousOperationsHandler):
@@ -1297,7 +1297,7 @@
             json.dumps(list(value_list)), content_type='application/json')
 
 
-DISPLAYED_NODEGROUP_FIELDS = (
+DISPLAYED_NODEGROUPINTERFACE_FIELDS = (
     'ip', 'management', 'interface', 'subnet_mask',
     'broadcast_ip', 'ip_range_low', 'ip_range_high')
 
@@ -1309,7 +1309,7 @@
     controller, with its network properties.
     """
     create = read = update = delete = None
-    fields = DISPLAYED_NODEGROUP_FIELDS
+    fields = DISPLAYED_NODEGROUPINTERFACE_FIELDS
 
     @operation(idempotent=True)
     def list(self, request, uuid):
@@ -1362,7 +1362,7 @@
     the name of the network interface it represents: "eth0" for example.
     """
     create = delete = None
-    fields = DISPLAYED_NODEGROUP_FIELDS
+    fields = DISPLAYED_NODEGROUPINTERFACE_FIELDS
 
     def read(self, request, uuid, interface):
         """List of NodeGroupInterfaces of a NodeGroup."""

=== modified file 'src/maasserver/tests/test_api.py'
--- src/maasserver/tests/test_api.py	2013-04-24 13:33:00 +0000
+++ src/maasserver/tests/test_api.py	2013-05-08 23:07:30 +0000
@@ -58,7 +58,7 @@
     )
 from maasserver.api import (
     describe,
-    DISPLAYED_NODEGROUP_FIELDS,
+    DISPLAYED_NODEGROUPINTERFACE_FIELDS,
     extract_constraints,
     find_nodegroup_for_pxeconfig_request,
     store_node_power_parameters,
@@ -3845,6 +3845,7 @@
                 'uuid': nodegroup.uuid,
                 'status': nodegroup.status,
                 'name': nodegroup.name,
+                'cluster_name': nodegroup.cluster_name,
             }],
             json.loads(response.content))
 
@@ -4211,7 +4212,8 @@
         self.assertEqual(httplib.OK, response.status_code)
         self.assertEqual(
             [
-                dict_subset(interface, DISPLAYED_NODEGROUP_FIELDS)
+                dict_subset(
+                    interface, DISPLAYED_NODEGROUPINTERFACE_FIELDS)
                 for interface in nodegroup.nodegroupinterface_set.all()
             ],
             json.loads(response.content))
@@ -4274,7 +4276,8 @@
                 args=[nodegroup.uuid, interface.interface]))
         self.assertEqual(httplib.OK, response.status_code)
         self.assertEqual(
-            dict_subset(interface, DISPLAYED_NODEGROUP_FIELDS),
+            dict_subset(
+                interface, DISPLAYED_NODEGROUPINTERFACE_FIELDS),
             json.loads(response.content))
 
     def test_update_interface(self):