From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci cluster/form-macros site/luci/Exten ...
Date: 13 Nov 2006 21:40:58 -0000 [thread overview]
Message-ID: <20061113214058.4271.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2006-11-13 21:40:55
Modified files:
luci/cluster : form-macros
luci/site/luci/Extensions: cluster_adapters.py
conga_constants.py ricci_bridge.py
Log message:
fix for bz# 215034 (Cannot change daemon properties via luci web app)
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.104&r2=1.105
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.162&r2=1.163
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_constants.py.diff?cvsroot=cluster&r1=1.25&r2=1.26
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_bridge.py.diff?cvsroot=cluster&r1=1.42&r2=1.43
--- conga/luci/cluster/form-macros 2006/11/12 02:10:52 1.104
+++ conga/luci/cluster/form-macros 2006/11/13 21:40:55 1.105
@@ -1791,7 +1791,7 @@
tal:condition="python: nodeinfo['nodestate'] == '0' or nodeinfo['nodestate'] == '1'">
<h3>Cluster daemons running on this node</h3>
- <form name="daemon_form">
+ <form name="daemon_form" method="post">
<table class="systemsTable">
<thead>
<tr class="systemsTable">
@@ -1803,23 +1803,38 @@
<tfoot class="systemsTable">
<tr class="systemsTable"><td class="systemsTable" colspan="3">
<div class="systemsTableEnd">
- <input type="button" value="Update node daemon properties" />
+ <input type="Submit" value="Update node daemon properties" />
</div>
</td></tr>
</tfoot>
<tbody class="systemsTable">
<tr class="systemsTable" tal:repeat="demon nodeinfo/d_states">
<td class="systemsTable"><span tal:replace="demon/name"/></td>
- <td class="systemsTable"><span tal:replace="python: demon['running'] and 'yes' or 'no'" /></td>
+ <td class="systemsTable"><span tal:replace="python: demon['running'] == 'true' and 'yes' or 'no'" /></td>
<td class="systemsTable">
- <input type="checkbox"
- tal:attributes="
- name python: nodeinfo['nodename'] + ':' + demon['name'];
- checked python: demon['enabled'] and 'checked'" />
+ <input type="hidden" tal:attributes="
+ name python: '__daemon__:' + demon['name'] + ':';
+ value demon/name" />
+
+ <input type="hidden" tal:attributes="
+ name python: '__daemon__:' + demon['name'] + ':';
+ value python: demon['enabled'] == 'true' and '1' or '0'" />
+
+ <input type="checkbox" tal:attributes="
+ name python: '__daemon__:' + demon['name'] + ':';
+ checked python: demon['enabled'] == 'true' and 'checked'" />
</td>
</tr>
</tbody>
</table>
+
+ <input type="hidden" name="nodename"
+ tal:attributes="value nodeinfo/nodename | request/nodename | nothing" />
+
+ <input type="hidden" name="clustername"
+ tal:attributes="value request/clustername | nothing" />
+
+ <input type="hidden" name="pagetype" value="55" />
</form>
<hr/>
</tal:block>
--- conga/luci/site/luci/Extensions/cluster_adapters.py 2006/11/12 02:10:53 1.162
+++ conga/luci/site/luci/Extensions/cluster_adapters.py 2006/11/13 21:40:55 1.163
@@ -815,7 +815,7 @@
except Exception, e:
luci_log.debug_verbose('VCC4: export model as string failed: %s' \
% str(e))
- errors.append('unable to store the new cluster configuration')
+ errors.append('Unable to store the new cluster configuration')
try:
clustername = model.getClusterName()
@@ -823,7 +823,7 @@
raise Exception, 'cluster name from modelb.getClusterName() is blank'
except Exception, e:
luci_log.debug_verbose('VCC5: error: getClusterName: %s' % str(e))
- errors.append('unable to determine cluster name from model')
+ errors.append('Unable to determine cluster name from model')
if len(errors) > 0:
return (retcode, {'errors': errors, 'messages': messages})
@@ -832,14 +832,14 @@
rc = getRicciAgent(self, clustername)
if not rc:
luci_log.debug_verbose('VCC6: unable to find a ricci agent for the %s cluster' % clustername)
- errors.append('unable to contact a ricci agent for cluster %s' \
+ errors.append('Unable to contact a ricci agent for cluster %s' \
% clustername)
if rc:
batch_id, result = setClusterConf(rc, str(conf_str))
if batch_id is None or result is None:
luci_log.debug_verbose('VCC7: setCluserConf: batchid or result is None')
- errors.append('unable to propagate the new cluster configuration for %s' \
+ errors.append('Unable to propagate the new cluster configuration for %s' \
% clustername)
else:
try:
@@ -862,6 +862,89 @@
def validateFenceEdit(self, request):
return (True, {})
+def validateDaemonProperties(self, request):
+ errors = list()
+
+ form = None
+ try:
+ response = request.response
+ form = request.form
+ if not form:
+ form = None
+ raise Exception, 'no form was submitted'
+ except:
+ pass
+
+ if form is None:
+ luci_log.debug_verbose('VDP0: no form was submitted')
+ return (False, {'errors': ['No form was submitted']})
+
+ try:
+ nodename = form['nodename'].strip()
+ if not nodename:
+ raise Exception, 'nodename is blank'
+ except Exception, e:
+ errors.append('Unable to determine the current node name')
+ luci_log.debug_verbose('VDP1: no nodename: %s' % str(e))
+
+ try:
+ clustername = form['clustername'].strip()
+ if not clustername:
+ raise Exception, 'clustername is blank'
+ except Exception, e:
+ errors.append('Unable to determine the current cluster name')
+ luci_log.debug_verbose('VDP2: no clustername: %s' % str(e))
+
+ disable_list = list()
+ enable_list = list()
+ for i in form.items():
+ try:
+ if i[0][:11] == '__daemon__:':
+ daemon_prop = i[1]
+ if len(daemon_prop) == 2:
+ if daemon_prop[1] == '1':
+ disable_list.append(daemon_prop[0])
+ else:
+ if daemon_prop[1] == '0' and daemon_prop[2] == 'on':
+ enable_list.append(daemon_prop[0])
+ except Exception, e:
+ luci_log.debug_verbose('VDP3: error: %s' % str(i))
+
+ if len(enable_list) < 1 and len(disable_list) < 1:
+ luci_log.debug_verbose('VDP4: no changes made')
+ response.redirect(request['URL'] + "?pagetype=" + NODE + "&clustername=" + clustername + '&nodename=' + nodename)
+
+ nodename_resolved = resolve_nodename(self, clustername, nodename)
+ try:
+ rc = RicciCommunicator(nodename_resolved)
+ if not rc:
+ raise Exception, 'rc is None'
+ except Exception, e:
+ luci_log.debug_verbose('VDP5: RC %s: %s' % (nodename_resolved, str(e)))
+ errors.append('Unable to connect to the ricci agent on %s to update cluster daemon properties' % nodename_resolved)
+ return (False, {'errors': errors})
+
+ batch_id, result = updateServices(rc, enable_list, disable_list)
+ if batch_id is None or result is None:
+ luci_log.debug_verbose('VDP6: setCluserConf: batchid or result is None')
+ errors.append('Unable to update the cluster daemon properties on node %s' % nodename_resolved)
+ return (False, {'errors': errors})
+
+ try:
+ status_msg = 'Updating %s daemon properties:' % nodename_resolved
+ if len(enable_list) > 0:
+ status_msg += ' enabling %s' % str(enable_list)[1:-1]
+ if len(disable_list) > 0:
+ status_msg += ' disabling %s' % str(disable_list)[1:-1]
+ set_node_flag(self, clustername, rc.hostname(), batch_id, CLUSTER_DAEMON, status_msg)
+ except:
+ pass
+
+ if len(errors) > 0:
+ return (False, {'errors': errors})
+
+ response.redirect(request['URL'] + "?pagetype=" + NODE + "&clustername=" + clustername + '&nodename=' + nodename + '&busyfirst=true')
+
formValidators = {
6: validateCreateCluster,
7: validateConfigCluster,
@@ -872,11 +955,18 @@
33: validateResourceAdd,
51: validateFenceAdd,
50: validateFenceEdit,
+ 55: validateDaemonProperties
}
def validatePost(self, request):
- pagetype = int(request.form['pagetype'])
+ try:
+ pagetype = int(request.form['pagetype'])
+ except Exception, e:
+ luci_log.debug_verbose('VP0: error: %s' % str(e))
+ return None
+
if not pagetype in formValidators:
+ luci_log.debug_verbose('VP1: no handler for page type %d' % pagetype)
return None
else:
return formValidators[pagetype](self, request)
--- conga/luci/site/luci/Extensions/conga_constants.py 2006/11/12 02:10:53 1.25
+++ conga/luci/site/luci/Extensions/conga_constants.py 2006/11/13 21:40:55 1.26
@@ -42,6 +42,7 @@
FENCEDEV_LIST="52"
FENCEDEV_CONFIG="53"
FENCEDEV="54"
+CLUSTER_DAEMON="55"
#Cluster tasks
CLUSTER_STOP = '1000'
--- conga/luci/site/luci/Extensions/ricci_bridge.py 2006/11/12 02:10:53 1.42
+++ conga/luci/site/luci/Extensions/ricci_bridge.py 2006/11/13 21:40:55 1.43
@@ -18,7 +18,7 @@
return False
try:
- batchid = batch.getAttribute('batch_id')
+ dummy = batch.getAttribute('batch_id')
result = batch.getAttribute('status')
except:
return False
@@ -471,6 +471,26 @@
ricci_xml = rc.batch_run(batch_str)
return batchAttemptResult(ricci_xml)
+def updateServices(rc, enable_list, disable_list):
+ batch = ''
+
+ if enable_list and len(enable_list) > 0:
+ batch += '<module name="service"><request API_version="1.0"><function_call name="enable"><var mutable="false" name="services" type="list_xml">'
+ for i in enable_list:
+ batch += '<service name="%s"/>' % str(i)
+ batch += '</var></function_call></request></module>'
+
+ if disable_list and len(disable_list) > 0:
+ batch += '<module name="service"><request API_version="1.0"><function_call name="disable"><var mutable="false" name="services" type="list_xml">'
+ for i in disable_list:
+ batch += '<service name="%s"/>' % str(i)
+ batch += '</var></function_call></request></module>'
+
+ if batch == '':
+ return None
+ ricci_xml = rc.batch_run(batch)
+ return batchAttemptResult(ricci_xml)
+
def restartService(rc, servicename):
batch_str = '<module name="cluster"><request API_version="1.0"><function_call name="restart_service"><var mutable="false" name="servicename" type="string" value=\"' + servicename + '\"/></function_call></request></module>'
next reply other threads:[~2006-11-13 21:40 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-13 21:40 rmccabe [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-09-21 3:11 [Cluster-devel] conga/luci cluster/form-macros site/luci/Exten rmccabe
2007-06-19 15:54 rmccabe
2007-05-03 20:16 rmccabe
2007-03-15 16:41 rmccabe
2007-03-14 22:38 rmccabe
2007-03-14 22:37 rmccabe
2007-03-05 16:50 rmccabe
2007-03-05 16:50 rmccabe
2007-03-05 16:49 rmccabe
2007-02-15 22:44 rmccabe
2007-02-08 3:46 rmccabe
2007-02-07 17:02 rmccabe
2007-02-07 16:55 rmccabe
2007-02-02 4:34 rmccabe
2007-02-02 0:11 rmccabe
2007-02-01 20:49 rmccabe
2007-01-31 23:36 rmccabe
2007-01-31 5:26 rmccabe
2007-01-23 13:53 rmccabe
2007-01-15 18:21 rmccabe
2007-01-11 19:11 rmccabe
2007-01-10 21:40 rmccabe
2007-01-06 3:29 rmccabe
2006-12-14 23:14 rmccabe
2006-12-14 18:22 rmccabe
2006-12-11 22:42 rmccabe
2006-12-11 21:51 rmccabe
2006-12-06 22:11 rmccabe
2006-12-06 21:16 rmccabe
2006-11-12 2:10 rmccabe
2006-11-09 20:32 rmccabe
2006-11-03 22:48 rmccabe
2006-10-25 1:53 rmccabe
2006-10-25 1:11 rmccabe
2006-10-13 21:25 rmccabe
2006-08-03 18:36 shuennek
2006-07-21 14:49 rmccabe
2006-07-20 16:59 rmccabe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061113214058.4271.qmail@sourceware.org \
--to=rmccabe@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.