← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~allenap/maas/1.3-xpath-cpu-counter into lp:maas/1.3

 

Gavin Panella has proposed merging lp:~allenap/maas/1.3-xpath-cpu-counter into lp:maas/1.3.

Commit message:
Fix xpath expression to not take disabled cpus into account.

Requested reviews:
  Gavin Panella (allenap)
Related bugs:
  Bug #1177589 in MAAS: "Virtual machine reports a number of cpu=64 where there is only 1 cpu"
  https://bugs.launchpad.net/maas/+bug/1177589

For more details, see:
https://code.launchpad.net/~allenap/maas/1.3-xpath-cpu-counter/+merge/163066

Backport from lp:maas.
-- 
https://code.launchpad.net/~allenap/maas/1.3-xpath-cpu-counter/+merge/163066
Your team MAAS Maintainers is subscribed to branch lp:maas/1.3.
=== modified file 'src/maasserver/models/node.py'
--- src/maasserver/models/node.py	2013-02-28 02:37:57 +0000
+++ src/maasserver/models/node.py	2013-05-08 22:32:26 +0000
@@ -361,7 +361,9 @@
         return processed_nodes
 
 
-_xpath_processor_count = "count(//node[@id='core']/node[@class='processor'])"
+_xpath_processor_count = (
+    "count(//node[@id='core']/"
+        "node[@class='processor'][not(@disabled)])")
 
 # Some machines have a <size> element in their memory <node> with the total
 # amount of memory, and other machines declare the size of the memory in

=== modified file 'src/maasserver/tests/test_node.py'
--- src/maasserver/tests/test_node.py	2013-02-28 02:37:57 +0000
+++ src/maasserver/tests/test_node.py	2013-05-08 22:32:26 +0000
@@ -584,6 +584,18 @@
         node = reload_object(node)
         self.assertEqual(2, node.cpu_count)
 
+    def test_cpu_count_skips_disabled_cpus(self):
+        node = factory.make_node()
+        xmlbytes = (
+            '<node id="core">'
+                '<node id="cpu:0" class="processor"/>'
+                '<node id="cpu:1" disabled="true" class="processor"/>'
+                '<node id="cpu:2" disabled="true" class="processor"/>'
+            '</node>')
+        node.set_hardware_details(xmlbytes)
+        node = reload_object(node)
+        self.assertEqual(1, node.cpu_count)
+
     def test_hardware_updates_memory(self):
         node = factory.make_node()
         xmlbytes = (


Follow ups