summaryrefslogtreecommitdiff
path: root/tuskar_ui/infrastructure/nodes/tables.py
diff options
context:
space:
mode:
Diffstat (limited to 'tuskar_ui/infrastructure/nodes/tables.py')
-rw-r--r--tuskar_ui/infrastructure/nodes/tables.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/tuskar_ui/infrastructure/nodes/tables.py b/tuskar_ui/infrastructure/nodes/tables.py
index 65a5cf56..898bd76e 100644
--- a/tuskar_ui/infrastructure/nodes/tables.py
+++ b/tuskar_ui/infrastructure/nodes/tables.py
@@ -128,6 +128,27 @@ class NodeFilterAction(tables.FilterAction):
return filter(comp, nodes)
+class DiscoverNode(tables.BatchAction):
+ name = "discover_nodes"
+ action_present = _("Discover")
+ action_past = _("Discovered")
+ data_type_singular = _("Node")
+ data_type_plural = _("Nodes")
+
+ def allowed(self, request, obj=None):
+ if not obj:
+ # this is necessary because table actions use this function
+ # with obj=None
+ return True
+ return obj.state == api.node.MAINTENANCE_STATE
+
+ def action(self, request, obj_id):
+ if obj_id is None:
+ messages.error(request, _("Select some nodes to discover."))
+ return
+ api.node.Node.discover(request, [obj_id])
+
+
@memoized.memoized
def _get_role_link(role_id):
if role_id:
@@ -242,7 +263,7 @@ class MaintenanceNodesTable(BaseNodesTable):
columns = ('node', 'cpus', 'memory_mb', 'local_gb', 'power_status',
'state')
table_actions = (NodeFilterAction, ActivateNode, SetPowerStateOn,
- SetPowerStateOff, DeleteNode)
+ SetPowerStateOff, DiscoverNode, DeleteNode)
row_actions = (ActivateNode, SetPowerStateOn, SetPowerStateOff,
DeleteNode)
template = "horizon/common/_enhanced_data_table.html"