sts-sponsors team mailing list archive
-
sts-sponsors team
-
Mailing list archive
-
Message #04067
[Merge] ~ack/maas:machine-fields-list-to-get into maas:master
Alberto Donato has proposed merging ~ack/maas:machine-fields-list-to-get into maas:master.
Commit message:
Exclude some unused fields from machine details when in list mode
This also removes the numa_node_count and sriov_support search/filter for server-side filtering.
Those are not exposed and can't be populated anymore since we're not including that info in the listing queryset.
Requested reviews:
MAAS Maintainers (maas-maintainers)
For more details, see:
https://code.launchpad.net/~ack/maas/+git/maas/+merge/434549
--
Your team MAAS Committers is subscribed to branch maas:master.
diff --git a/src/maasserver/node_constraint_filter_forms.py b/src/maasserver/node_constraint_filter_forms.py
index 12dce7f..5128c1f 100644
--- a/src/maasserver/node_constraint_filter_forms.py
+++ b/src/maasserver/node_constraint_filter_forms.py
@@ -13,7 +13,6 @@ import attr
from django import forms
from django.core.exceptions import ValidationError
from django.db.models import Model, Q
-from django.forms import NullBooleanField
from django.forms.fields import Field
from netaddr import IPAddress
@@ -634,7 +633,6 @@ STATIC_FILTER_FIELDS = (
"power_state",
"simple_status",
"status",
- "sriov_support",
)
@@ -1546,30 +1544,6 @@ class FreeTextFilterNodeForm(ReadNodesForm):
},
)
- numa_nodes_count = UnconstrainedTypedMultipleChoiceField(
- label="NUMA nodes Count",
- coerce=int,
- required=False,
- error_messages={
- "invalid_choice": "Invalid number: number of NUMA nodes required."
- },
- )
-
- not_numa_nodes_count = UnconstrainedTypedMultipleChoiceField(
- label="NUMA nodes Count",
- coerce=int,
- required=False,
- error_messages={
- "invalid_choice": "Invalid number: number of NUMA nodes required."
- },
- )
-
- sriov_support = NullBooleanField(
- label="SR-IOV support",
- required=False,
- help_text="Whether the machine support SR-IOV",
- )
-
not_physical_disk_count = UnconstrainedTypedMultipleChoiceField(
label="Physical disk Count",
coerce=int,
@@ -1947,8 +1921,5 @@ class FreeTextFilterNodeForm(ReadNodesForm):
def _apply_filters(self, nodes):
nodes = super()._apply_filters(nodes)
- sriov = self.cleaned_data.get("sriov_support", None)
- if sriov is not None:
- nodes = nodes.filter(sriov_support=sriov)
nodes = self._free_text_search(nodes)
return nodes.distinct()
diff --git a/src/maasserver/tests/test_node_constraint_filter_forms.py b/src/maasserver/tests/test_node_constraint_filter_forms.py
index 1222323..f5dde8e 100644
--- a/src/maasserver/tests/test_node_constraint_filter_forms.py
+++ b/src/maasserver/tests/test_node_constraint_filter_forms.py
@@ -1911,41 +1911,6 @@ class TestFreeTextFilterNodeForm(MAASServerTestCase):
}
self.assertConstrainedNodes([node1], constraints)
- def test_srvio(self):
- node1 = factory.make_Machine()
- node2 = factory.make_Machine(interface=True)
- factory.make_Interface(sriov_max_vf=2, node=node1)
- self.assertConstrainedNodes(
- [node1],
- {
- "sriov_support": True,
- },
- )
- self.assertConstrainedNodes(
- [node2],
- {
- "sriov_support": False,
- },
- )
-
- def test_numa_nodes_count(self):
- node1 = factory.make_Machine()
- factory.make_NUMANode(node=node1)
- node2 = factory.make_Machine()
- self.assertConstrainedNodes(
- [node1],
- {
- "numa_nodes_count": [2],
- },
- )
- # default NUMA node
- self.assertConstrainedNodes(
- [node2],
- {
- "numa_nodes_count": [1],
- },
- )
-
def test_substring_description_filter(self):
desc = factory.make_unicode_string(size=30, spaces=True)
node1 = factory.make_Node(description=desc)
diff --git a/src/maasserver/websockets/handlers/machine.py b/src/maasserver/websockets/handlers/machine.py
index 26407c6..a938436 100644
--- a/src/maasserver/websockets/handlers/machine.py
+++ b/src/maasserver/websockets/handlers/machine.py
@@ -9,16 +9,7 @@ import logging
from operator import itemgetter
from django.core.exceptions import ObjectDoesNotExist, ValidationError
-from django.db.models import (
- Case,
- CharField,
- Count,
- Exists,
- F,
- OuterRef,
- Subquery,
- Sum,
-)
+from django.db.models import Case, CharField, Count, F, OuterRef, Subquery, Sum
from django.db.models import Value as V
from django.db.models import When
from django.db.models.functions import Concat
@@ -171,12 +162,6 @@ class MachineHandler(NodeHandler):
output_field=CharField(),
),
simple_status=_build_simple_status_q(),
- numa_nodes_count=Count("numanode", distinct=True),
- sriov_support=Exists(
- Interface.objects.filter(
- node_config__node=OuterRef("pk"), sriov_max_vf__gt=0
- )
- ),
)
.annotate(
status_event_type_description=Subquery(
@@ -193,8 +178,6 @@ class MachineHandler(NodeHandler):
.order_by("-created", "-id")
.values("description")[:1]
),
- numa_nodes_count=F("numa_nodes_count"),
- sriov_support=F("sriov_support"),
physical_disk_count=F("physical_disk_count"),
total_storage=F("storage"),
pxe_mac=F("pxe_mac"),
@@ -323,7 +306,6 @@ class MachineHandler(NodeHandler):
def dehydrate(self, obj, data, for_list=False):
"""Add extra fields to `data`."""
data = super().dehydrate(obj, data, for_list=for_list)
- data["workload_annotations"] = OwnerData.objects.get_owner_data(obj)
data["parent"] = getattr(obj.parent, "system_id", None)
# Try to use the annotated event description so its loaded in the same
# query as loading the machines. Otherwise fallback to the method on
@@ -401,36 +383,38 @@ class MachineHandler(NodeHandler):
storage_script_results
)
- interface_script_results = [
- script_result
- for script_result in self._script_results.get(obj.id, {}).get(
- HARDWARE_TYPE.NETWORK, []
- )
- if script_result.script_set.result_type == RESULT_TYPE.TESTING
- ]
- data["interface_test_status"] = self.dehydrate_test_statuses(
- interface_script_results
- )
-
- node_script_results = [
- script_result
- for script_result in self._script_results.get(obj.id, {}).get(
- HARDWARE_TYPE.NODE, []
- )
- if script_result.script_set.result_type == RESULT_TYPE.TESTING
- ]
- data["other_test_status"] = self.dehydrate_test_statuses(
- node_script_results
- )
-
if not for_list:
# Add info specific to a machine.
+ data["workload_annotations"] = OwnerData.objects.get_owner_data(
+ obj
+ )
data["show_os_info"] = self.dehydrate_show_os_info(obj)
devices = [
self.dehydrate_device(device) for device in obj.children.all()
]
data["devices"] = sorted(devices, key=itemgetter("fqdn"))
+ interface_script_results = [
+ script_result
+ for script_result in self._script_results.get(obj.id, {}).get(
+ HARDWARE_TYPE.NETWORK, []
+ )
+ if script_result.script_set.result_type == RESULT_TYPE.TESTING
+ ]
+ data["interface_test_status"] = self.dehydrate_test_statuses(
+ interface_script_results
+ )
+ node_script_results = [
+ script_result
+ for script_result in self._script_results.get(obj.id, {}).get(
+ HARDWARE_TYPE.NODE, []
+ )
+ if script_result.script_set.result_type == RESULT_TYPE.TESTING
+ ]
+ data["other_test_status"] = self.dehydrate_test_statuses(
+ node_script_results
+ )
+
# include certificate info if present
certificate = obj.get_power_parameters().get("certificate")
key = obj.get_power_parameters().get("key")
diff --git a/src/maasserver/websockets/handlers/node.py b/src/maasserver/websockets/handlers/node.py
index 9d6c548..0e8bbb7 100644
--- a/src/maasserver/websockets/handlers/node.py
+++ b/src/maasserver/websockets/handlers/node.py
@@ -268,7 +268,6 @@ class NodeHandler(TimestampedModelHandler):
"""Add extra fields to `data`."""
data["fqdn"] = obj.fqdn
data["actions"] = list(compile_node_actions(obj, self.user).keys())
- data["node_type_display"] = obj.get_node_type_display()
data["link_type"] = NODE_TYPE_TO_LINK_TYPE[obj.node_type]
data["tags"] = [tag.id for tag in obj.tags.all()]
if obj.node_type == NODE_TYPE.MACHINE or (
@@ -300,7 +299,8 @@ class NodeHandler(TimestampedModelHandler):
/ (1000**3),
1,
)
- data["storage_tags"] = self.get_all_storage_tags(blockdevices)
+ if not for_list:
+ data["storage_tags"] = self.get_all_storage_tags(blockdevices)
commissioning_script_results = []
testing_script_results = []
commissioning_start_time = None
@@ -359,9 +359,10 @@ class NodeHandler(TimestampedModelHandler):
data["installation_start_time"] = dehydrate_datetime(
installation_start_time
)
- data["has_logs"] = (
- log_results.difference(script_output_nsmap.keys()) == set()
- )
+ if not for_list:
+ data["has_logs"] = (
+ log_results.difference(script_output_nsmap.keys()) == set()
+ )
else:
blockdevices = []
@@ -401,26 +402,27 @@ class NodeHandler(TimestampedModelHandler):
if not obj.is_controller:
# For filters
subnets = self.get_all_subnets(obj)
- data["subnets"] = sorted(subnet.cidr for subnet in subnets)
data["fabrics"] = sorted(self.get_all_fabric_names(obj, subnets))
data["spaces"] = sorted(self.get_all_space_names(subnets))
data["extra_macs"] = sorted(
"%s" % mac_address for mac_address in obj.get_extra_macs()
)
- data["link_speeds"] = sorted(
- {
- interface.link_speed
- for interface in obj.current_config.interface_set.all()
- if interface.link_speed > 0
- }
- )
+ if not for_list:
+ data["subnets"] = sorted(subnet.cidr for subnet in subnets)
+ data["link_speeds"] = sorted(
+ {
+ interface.link_speed
+ for interface in obj.current_config.interface_set.all()
+ if interface.link_speed > 0
+ }
+ )
- if for_list:
+ if not for_list:
for attr in ("numa_nodes_count", "sriov_support"):
value = getattr(obj, attr, None)
if value is not None:
data[attr] = value
- else:
+ data["node_type_display"] = obj.get_node_type_display()
data["on_network"] = obj.on_network()
if obj.node_type != NODE_TYPE.DEVICE:
data["numa_nodes"] = [
diff --git a/src/maasserver/websockets/handlers/tests/test_device.py b/src/maasserver/websockets/handlers/tests/test_device.py
index 871f0c7..eb595d7 100644
--- a/src/maasserver/websockets/handlers/tests/test_device.py
+++ b/src/maasserver/websockets/handlers/tests/test_device.py
@@ -194,12 +194,9 @@ class TestDeviceHandler(MAASTransactionServerTestCase):
"ip_address",
"ip_assignment",
"link_type",
- "node_type_display",
"permissions",
"primary_mac",
"spaces",
- "subnets",
- "link_speeds",
"tags",
"interface_speed",
"link_connected",
diff --git a/src/maasserver/websockets/handlers/tests/test_machine.py b/src/maasserver/websockets/handlers/tests/test_machine.py
index 08afc62..0c026ae 100644
--- a/src/maasserver/websockets/handlers/tests/test_machine.py
+++ b/src/maasserver/websockets/handlers/tests/test_machine.py
@@ -411,16 +411,12 @@ class TestMachineHandler(MAASServerTestCase):
"dhcp_on",
"distro_series",
"extra_macs",
- "link_speeds",
"fabrics",
"fqdn",
- "has_logs",
"installation_start_time",
"ip_addresses",
"link_type",
"metadata",
- "node_type_display",
- "numa_nodes_count",
"osystem",
"permissions",
"physical_disk_count",
@@ -428,20 +424,16 @@ class TestMachineHandler(MAASServerTestCase):
"pxe_mac",
"pxe_mac_vendor",
"spaces",
- "sriov_support",
"simple_status",
"status",
"status_code",
"status_message",
"storage",
- "storage_tags",
- "subnets",
"tags",
"testing_script_count",
"testing_start_time",
"testing_status",
"vlan",
- "workload_annotations",
}
)
for key in list(data):
@@ -506,27 +498,28 @@ class TestMachineHandler(MAASServerTestCase):
storage_script_results
)
- interface_script_results = [
- script_result
- for script_result in handler._script_results.get(node.id, {}).get(
- HARDWARE_TYPE.NETWORK, []
+ if not for_list:
+ interface_script_results = [
+ script_result
+ for script_result in handler._script_results.get(
+ node.id, {}
+ ).get(HARDWARE_TYPE.NETWORK, [])
+ if script_result.script_set.result_type == RESULT_TYPE.TESTING
+ ]
+ data["interface_test_status"] = handler.dehydrate_test_statuses(
+ interface_script_results
)
- if script_result.script_set.result_type == RESULT_TYPE.TESTING
- ]
- data["interface_test_status"] = handler.dehydrate_test_statuses(
- interface_script_results
- )
- node_script_results = [
- script_result
- for script_result in handler._script_results.get(node.id, {}).get(
- HARDWARE_TYPE.NODE, []
+ node_script_results = [
+ script_result
+ for script_result in handler._script_results.get(
+ node.id, {}
+ ).get(HARDWARE_TYPE.NODE, [])
+ if script_result.script_set.result_type == RESULT_TYPE.TESTING
+ ]
+ data["other_test_status"] = handler.dehydrate_test_statuses(
+ node_script_results
)
- if script_result.script_set.result_type == RESULT_TYPE.TESTING
- ]
- data["other_test_status"] = handler.dehydrate_test_statuses(
- node_script_results
- )
if node.enable_hw_sync:
data.update(
@@ -2412,29 +2405,6 @@ class TestMachineHandler(MAASServerTestCase):
[self.dehydrate_node(node, handler, for_list=True)], list_items
)
- def test_list_includes_numa_node_info(self):
- user = factory.make_User()
- machine = factory.make_Machine(owner=user)
- memory_cores = ((512, [0, 1]), (1024, [2, 3]), (2048, [4, 5]))
- for memory, cores in memory_cores:
- factory.make_NUMANode(node=machine, memory=memory, cores=cores)
- handler = MachineHandler(user, {}, None)
- list_results = handler.list({})
- [list_item] = list_results["groups"][0]["items"]
- self.assertEqual(list_item["numa_nodes_count"], 4)
- # the listing is not included in the result
- self.assertNotIn("numa_nodes", list_item)
-
- def test_list_includes_sriov_support_flag(self):
- user = factory.make_User()
- machine = factory.make_Machine(owner=user)
- factory.make_Interface(node=machine)
- factory.make_Interface(node=machine, sriov_max_vf=16)
- handler = MachineHandler(user, {}, None)
- list_results = handler.list({})
- [list_item] = list_results["groups"][0]["items"]
- self.assertTrue(list_item["sriov_support"])
-
def test_list_ignores_devices(self):
owner = factory.make_User()
handler = MachineHandler(owner, {}, None)
@@ -6605,27 +6575,6 @@ class TestMachineHandlerNewSchema(MAASServerTestCase):
"dynamic": True,
"for_grouping": True,
},
- {
- "key": "numa_nodes_count",
- "label": "NUMA nodes Count",
- "type": "list[int]",
- "dynamic": True,
- "for_grouping": False,
- },
- {
- "key": "not_numa_nodes_count",
- "label": "NUMA nodes Count",
- "type": "list[int]",
- "dynamic": True,
- "for_grouping": False,
- },
- {
- "key": "sriov_support",
- "label": "SR-IOV support",
- "type": "bool",
- "dynamic": False,
- "for_grouping": False,
- },
],
handler.filter_groups({}),
)
@@ -6815,27 +6764,6 @@ class TestMachineHandlerNewSchema(MAASServerTestCase):
[choice[1] for choice in SIMPLIFIED_NODE_STATUS_CHOICES],
)
- def test_filter_options_sriov(self):
- user = factory.make_User()
- handler = MachineHandler(user, {}, None)
- result = handler.filter_options({"group_key": "sriov_support"})
- self.assertCountEqual(
- [v["label"] for v in result],
- ["True", "False"],
- )
-
- def test_filter_options_numa_nodes_count(self):
- user = factory.make_User()
- factory.make_Machine()
- node1 = factory.make_Machine()
- factory.make_NUMANode(node=node1)
- handler = MachineHandler(user, {}, None)
- result = handler.filter_options({"group_key": "numa_nodes_count"})
- self.assertCountEqual(
- [v["label"] for v in result],
- ["1", "2"],
- )
-
def test_filter_options_interfaces_unique_values(self):
user = factory.make_User()
tags = [factory.make_name("tag") for _ in range(3)]
Follow ups