commit 0d6996f091c1341af198f0f13e2c7e2d31ca2ca4
Author: Chris Feist <cfeist(a)redhat.com>
Date: Thu Dec 17 15:27:07 2009 -0600
Added support for processing form information for failovers.
luci/controllers/cluster.py | 28 +++++++++++++++++++++++++++-
luci/templates/failover.html | 12 ++++++------
2 files changed, 33 insertions(+), 7 deletions(-)
---
diff --git a/luci/controllers/cluster.py b/luci/controllers/cluster.py
index f47cb21..6a283cc 100644
--- a/luci/controllers/cluster.py
+++ b/luci/controllers/cluster.py
@@ -145,7 +145,33 @@ class IndividualClusterController(BaseController):
failovername = args[0]
else:
failovername = None
- return dict(page='nodes',name=failovername, base_url =
'/cluster/' + self.name + '/failovers')
+ failovers_cmd = '/cluster/' + self.name + '/failovers_cmd'
+ return dict(page='nodes',name=failovername, base_url =
'/cluster/' + self.name + '/failovers',
+ failovers_cmd = failovers_cmd)
+
+ @expose("luci.templates.failover")
+ def failovers_cmd(self,command=None,**kw):
+ tmpl_context.cluster_data=data.clusters[self.name]
+ tmpl_context.cluster_name = self.name
+ tmpl_context.cluster_url = "/cluster/" + self.name + '/failovers'
+ # If we're using the checkboxes, we control multiple nodes at once
+ if "MultiAction" in kw:
+ print "MAction!"
+ kw["name"] = ""
+ nodelist = ""
+ command = kw["MultiAction"]
+ for key,element in kw.items():
+ if element == "on":
+ nodelist = nodelist + " " + key
+ if command == 'Delete':
+ flash ("Deleting Failover: " + nodelist)
+ redirect (tmpl_context.cluster_url)
+ else:
+ if command == 'Delete':
+ flash ("Deleting: " + kw["name"] + " (but not
really)")
+ if command == 'update_properties':
+ flash ("Updating Properties...")
+ redirect (tmpl_context.cluster_url + '/' + kw["name"])
@expose("luci.templates.fence")
def fences(self,*args):
diff --git a/luci/templates/failover.html b/luci/templates/failover.html
index 470b28f..c148115 100644
--- a/luci/templates/failover.html
+++ b/luci/templates/failover.html
@@ -16,10 +16,10 @@
py:with="cluster_data = tmpl_context.cluster_data;
form_utils = app_globals.form_utils">
- <form action="${tg.url('apply')}" method="post">
+ <form action="${tg.url(failovers_cmd)}" method="post">
<div class="sectionblock">
<div id="toolbar">
- <input type="submit" name="Delete"
value="${_('Delete')}" class="toolbar_button"
id="tb_delete"/>
+ <input type="submit" name="MultiAction"
value="${_('Delete')}" class="toolbar_button"
id="tb_delete"/>
<a href="${tg.url('add')}" class="toolbar_button"
id="tb_add">Add</a>
</div>
@@ -41,7 +41,7 @@
<!--! List all the failover domains. -->
<tr py:for="i, (entity_name, failover_data) in
enumerate(cluster_data.failovers.iteritems())"
py:attrs="entity_name==name and {'class': 'chosen'} or
(not i%2 and {'class': 'even'} or None)"
- py:with="identifier=form_utils.string2Id(entity_name)">
+ py:with="identifier=entity_name">
<td class="checkbox"><input type="checkbox"
name="${identifier}"/></td>
<td class="icon"></td>
<td class="main_id"><a href="${tg.url(base_url +
'/' + entity_name)}">${entity_name}</a></td>
@@ -78,15 +78,15 @@
<div id="details_header">
<h3 py:content="name">Failover name</h3>
<div id="details_header_buttons">
- <a href="${tg.url('apply?' + 'Delete' +
'&name=' + name)}" id="dh_delete"
title="delete"><span
class="hide">Delete</span></a>
+ <a href="${tg.url(failovers_cmd + '?command=Delete' +
'&name=' + name)}" id="dh_delete"
title="delete"><span
class="hide">Delete</span></a>
</div>
</div>
<!--! DETAILS - attributes section. -->
<div class="details_section">
<div class="details_inner">
- <form action="${tg.url('update_properties')}"
method="post">
- <input type="hidden" name="name"
value="${form_utils.string2Id(name)}"/>
+ <form action="${tg.url(failovers_cmd +
'?command=update_properties')}" method="post">
+ <input type="hidden" name="name"
value="${name}"/>
<input type="submit" value="Update Properties"
class="float_button"/>
<table id="fdom_tattr">
<tr>
Show replies by date