From 64eeb59c725efbfd4d20c078c5aaea2963ddde6c Mon Sep 17 00:00:00 2001 From: Ryan Brady Date: Tue, 11 Aug 2015 11:23:03 -0400 Subject: Add discovery on demand If node introspection fails, there is no way to re-run the process within the UI. This patch adds a button to the maintenance tab to allow a user to re-run the process. Change-Id: I16645643de83f212e89f858a85589d425474c5cd --- tuskar_ui/infrastructure/nodes/tables.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) 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" -- cgit v1.2.1