summaryrefslogtreecommitdiff
path: root/tuskar_ui
diff options
context:
space:
mode:
authorTzu-Mainn Chen <tzumainn@redhat.com>2014-04-03 21:01:49 +0200
committerTzu-Mainn Chen <tzumainn@redhat.com>2014-04-03 21:02:39 +0200
commit5703c85736b600a101ea48a7adde168b0dbcbd32 (patch)
treec019c962d16210c416bc90c906dbc00117604263 /tuskar_ui
parentbebb039eabae6cb8a4fe9186d1663c0fecccfacf (diff)
downloadtuskar-ui-5703c85736b600a101ea48a7adde168b0dbcbd32.tar.gz
Add node filter
Closes-Bug: #1302022 Change-Id: I09127cbc689f4f0dab9a03dcf939a067828ceaa2
Diffstat (limited to 'tuskar_ui')
-rw-r--r--tuskar_ui/infrastructure/nodes/tables.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/tuskar_ui/infrastructure/nodes/tables.py b/tuskar_ui/infrastructure/nodes/tables.py
index edd5c5bc..a40b6579 100644
--- a/tuskar_ui/infrastructure/nodes/tables.py
+++ b/tuskar_ui/infrastructure/nodes/tables.py
@@ -35,6 +35,21 @@ class DeleteNode(tables.BatchAction):
api.Node.delete(request, obj_id)
+class NodeFilterAction(tables.FilterAction):
+ def filter(self, table, nodes, filter_string):
+ """Really naive case-insensitive search."""
+ q = filter_string.lower()
+
+ def comp(node):
+ return any(q in attr for attr in
+ (node.ip_address,
+ node.properties['cpu'],
+ node.properties['ram'],
+ node.properties['local_disk'],))
+
+ return filter(comp, nodes)
+
+
class NodesTable(tables.DataTable):
node = tables.Column(lambda node: node.driver_info['ip_address'],
link="horizon:infrastructure:nodes:detail",
@@ -88,7 +103,8 @@ class FreeNodesTable(NodesTable):
class Meta:
name = "free_nodes"
verbose_name = _("Free Nodes")
- table_actions = (DeleteNode,)
+ table_actions = (DeleteNode,
+ NodeFilterAction,)
row_actions = (DeleteNode,)
@@ -109,7 +125,7 @@ class DeployedNodesTable(NodesTable):
class Meta:
name = "deployed_nodes"
verbose_name = _("Deployed Nodes")
- table_actions = ()
+ table_actions = (NodeFilterAction,)
row_actions = ()
columns = ('node', 'deployment_role', 'capacity', 'architecture',
'cpu', 'ram', 'local_disk', 'health', 'power_state')