Merge ~adam-collard/maas:remove-unused-machine-list-fields into maas:master

Proposed by Adam Collard
Status: Merged
Approved by: Adam Collard
Approved revision: 7ebf4bc1f81e54859f594dc9c15d8df9a112dcbb
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~adam-collard/maas:remove-unused-machine-list-fields
Merge into: maas:master
Diff against target: 166 lines (+61/-51)
3 files modified
src/maasserver/websockets/handlers/machine.py (+4/-1)
src/maasserver/websockets/handlers/node.py (+7/-6)
src/maasserver/websockets/handlers/tests/test_machine.py (+50/-44)
Reviewer Review Type Date Requested Status
Alexsander de Souza Approve
MAAS Lander unittests Pending
Review via email: mp+416302@code.launchpad.net

Commit message

Remove unused fields from machine list
- cpu_speed
- commissioning_start_time
- commissioning_status

To post a comment you must log in.
Revision history for this message
Alexsander de Souza (alexsander-souza) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/maasserver/websockets/handlers/machine.py b/src/maasserver/websockets/handlers/machine.py
index b625225..77f9167 100644
--- a/src/maasserver/websockets/handlers/machine.py
+++ b/src/maasserver/websockets/handlers/machine.py
@@ -238,7 +238,6 @@ class MachineHandler(NodeHandler):
238 "locked",238 "locked",
239 "owner",239 "owner",
240 "cpu_count",240 "cpu_count",
241 "cpu_speed",
242 "description",241 "description",
243 "error_description",242 "error_description",
244 "memory",243 "memory",
@@ -247,6 +246,10 @@ class MachineHandler(NodeHandler):
247 "pool",246 "pool",
248 "zone",247 "zone",
249 ]248 ]
249 list_exclude = [
250 "commissioning_start_time",
251 "commissioning_status",
252 ] + exclude
250 listen_channels = ["machine"]253 listen_channels = ["machine"]
251 create_permission = NodePermission.admin254 create_permission = NodePermission.admin
252 view_permission = NodePermission.view255 view_permission = NodePermission.view
diff --git a/src/maasserver/websockets/handlers/node.py b/src/maasserver/websockets/handlers/node.py
index a5d1f06..8877140 100644
--- a/src/maasserver/websockets/handlers/node.py
+++ b/src/maasserver/websockets/handlers/node.py
@@ -284,15 +284,16 @@ class NodeHandler(TimestampedModelHandler):
284 and script_result.started < testing_start_time284 and script_result.started < testing_start_time
285 ):285 ):
286 testing_start_time = script_result.started286 testing_start_time = script_result.started
287 data["commissioning_status"] = self.dehydrate_test_statuses(287 if not for_list:
288 commissioning_script_results288 data["commissioning_status"] = self.dehydrate_test_statuses(
289 )289 commissioning_script_results
290 )
291 data["commissioning_start_time"] = dehydrate_datetime(
292 commissioning_start_time
293 )
290 data["testing_status"] = self.dehydrate_test_statuses(294 data["testing_status"] = self.dehydrate_test_statuses(
291 testing_script_results295 testing_script_results
292 )296 )
293 data["commissioning_start_time"] = dehydrate_datetime(
294 commissioning_start_time
295 )
296 data["testing_start_time"] = dehydrate_datetime(testing_start_time)297 data["testing_start_time"] = dehydrate_datetime(testing_start_time)
297 data["installation_start_time"] = dehydrate_datetime(298 data["installation_start_time"] = dehydrate_datetime(
298 installation_start_time299 installation_start_time
diff --git a/src/maasserver/websockets/handlers/tests/test_machine.py b/src/maasserver/websockets/handlers/tests/test_machine.py
index 9b29ceb..16b94fb 100644
--- a/src/maasserver/websockets/handlers/tests/test_machine.py
+++ b/src/maasserver/websockets/handlers/tests/test_machine.py
@@ -388,46 +388,49 @@ class TestMachineHandler(MAASServerTestCase):
388 data["sriov_support"] = any(388 data["sriov_support"] = any(
389 iface["sriov_max_vf"] > 0 for iface in data["interfaces"]389 iface["sriov_max_vf"] > 0 for iface in data["interfaces"]
390 )390 )
391 allowed_fields = MachineHandler.Meta.list_fields + [391 list_fields = set(MachineHandler.Meta.list_fields) - set(
392 "actions",392 MachineHandler.Meta.list_exclude
393 "architecture",393 )
394 "commissioning_script_count",394 allowed_fields = list_fields.union(
395 "commissioning_start_time",395 {
396 "commissioning_status",396 "actions",
397 "dhcp_on",397 "architecture",
398 "distro_series",398 "commissioning_script_count",
399 "extra_macs",399 "dhcp_on",
400 "link_speeds",400 "distro_series",
401 "fabrics",401 "extra_macs",
402 "fqdn",402 "link_speeds",
403 "has_logs",403 "fabrics",
404 "installation_start_time",404 "fqdn",
405 "ip_addresses",405 "has_logs",
406 "link_type",406 "installation_start_time",
407 "metadata",407 "ip_addresses",
408 "node_type_display",408 "link_type",
409 "numa_nodes_count",409 "metadata",
410 "osystem",410 "node_type_display",
411 "permissions",411 "numa_nodes_count",
412 "physical_disk_count",412 "osystem",
413 "pod",413 "permissions",
414 "pxe_mac",414 "physical_disk_count",
415 "pxe_mac_vendor",415 "pod",
416 "spaces",416 "pxe_mac",
417 "sriov_support",417 "pxe_mac_vendor",
418 "status",418 "spaces",
419 "status_code",419 "sriov_support",
420 "status_message",420 "status",
421 "storage",421 "status_code",
422 "storage_tags",422 "status_message",
423 "subnets",423 "storage",
424 "tags",424 "storage_tags",
425 "testing_script_count",425 "subnets",
426 "testing_start_time",426 "tags",
427 "testing_status",427 "testing_script_count",
428 "vlan",428 "testing_start_time",
429 "workload_annotations",429 "testing_status",
430 ]430 "vlan",
431 "workload_annotations",
432 }
433 )
431 for key in list(data):434 for key in list(data):
432 if key not in allowed_fields:435 if key not in allowed_fields:
433 del data[key]436 del data[key]
@@ -2249,14 +2252,17 @@ class TestMachineHandler(MAASServerTestCase):
2249 handler = MachineHandler(user, {}, None)2252 handler = MachineHandler(user, {}, None)
2250 factory.make_PhysicalBlockDevice(node=node)2253 factory.make_PhysicalBlockDevice(node=node)
2251 self.assertNotIn(node.id, handler._script_results.keys())2254 self.assertNotIn(node.id, handler._script_results.keys())
2252 self.assertCountEqual(2255 list_results = handler.list({})
2253 [self.dehydrate_node(node, handler, for_list=True)],
2254 handler.list({}),
2255 )
2256 self.assertDictEqual(2256 self.assertDictEqual(
2257 {node.id: {script_result.script.hardware_type: [script_result]}},2257 {node.id: {script_result.script.hardware_type: [script_result]}},
2258 handler._script_results,2258 handler._script_results,
2259 )2259 )
2260 self.assertNotIn("commissioning_status", list_results[0])
2261 self.assertNotIn("commissioning_start_time", list_results[0])
2262 self.assertNotIn("cpu_speed", list_results[0])
2263 self.assertCountEqual(
2264 [self.dehydrate_node(node, handler, for_list=True)], list_results
2265 )
22602266
2261 def test_list_includes_numa_node_info(self):2267 def test_list_includes_numa_node_info(self):
2262 user = factory.make_User()2268 user = factory.make_User()

Subscribers

People subscribed via source and target branches