← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~gz/maas/store_lshw_in_node into lp:maas

 

Martin Packman has proposed merging lp:~gz/maas/store_lshw_in_node into lp:maas with lp:~gz/maas/add_node_hardware_details as a prerequisite.

Requested reviews:
  MAAS Maintainers (maas-maintainers)

For more details, see:
https://code.launchpad.net/~gz/maas/store_lshw_in_node/+merge/125699

Special cases the lshw output and updates the Node's hardware_details instead of inserting into the generic file storage.

The api possibly wants to catch DatabaseError if there's a problem with the lshw data and log or report it somehow, though what the commissioned node could actually do about it I don't know.
-- 
https://code.launchpad.net/~gz/maas/store_lshw_in_node/+merge/125699
Your team MAAS Maintainers is requested to review the proposed merge of lp:~gz/maas/store_lshw_in_node into lp:maas.
=== modified file 'src/metadataserver/api.py'
--- src/metadataserver/api.py	2012-08-24 10:28:29 +0000
+++ src/metadataserver/api.py	2012-09-21 12:55:25 +0000
@@ -180,8 +180,11 @@
     def _store_commissioning_results(self, node, request):
         """Store commissioning result files for `node`."""
         for name, uploaded_file in request.FILES.items():
-            contents = uploaded_file.read().decode('utf-8')
-            NodeCommissionResult.objects.store_data(node, name, contents)
+            if name == "01-lshw.out":
+                node.set_hardware_details(uploaded_file.read())
+            else:
+                contents = uploaded_file.read().decode('utf-8')
+                NodeCommissionResult.objects.store_data(node, name, contents)
 
     @api_exported('POST')
     def signal(self, request, version=None, mac=None):

=== modified file 'src/metadataserver/tests/test_api.py'
--- src/metadataserver/tests/test_api.py	2012-08-16 10:34:56 +0000
+++ src/metadataserver/tests/test_api.py	2012-09-21 12:55:25 +0000
@@ -494,6 +494,15 @@
             node, 'output.txt')
         self.assertEqual(size_limit, len(stored_data))
 
+    def test_signal_stores_lshw_file_on_node(self):
+        node = factory.make_node(status=NODE_STATUS.COMMISSIONING)
+        client = self.make_node_client(node=node)
+        xmlbytes = "<t\xe9st/>".encode("utf-8")
+        response = self.call_signal(client, files={'01-lshw.out': xmlbytes})
+        self.assertEqual(httplib.OK, response.status_code)
+        node = reload_object(node)
+        self.assertEqual(xmlbytes, node.hardware_details)
+
     def test_api_retrieves_node_metadata_by_mac(self):
         mac = factory.make_mac_address()
         url = reverse(