From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci cluster/form-macros cluster/validat ...
Date: 24 Feb 2007 07:02:43 -0000 [thread overview]
Message-ID: <20070224070243.23909.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2007-02-24 07:02:42
Modified files:
luci/cluster : form-macros validate_sys_svc.js
luci/site/luci/Extensions: ricci_bridge.py system_adapters.py
Log message:
Cleanups to the system services management interface
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.193&r2=1.194
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_sys_svc.js.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_bridge.py.diff?cvsroot=cluster&r1=1.59&r2=1.60
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/system_adapters.py.diff?cvsroot=cluster&r1=1.1&r2=1.2
--- conga/luci/cluster/form-macros 2007/02/23 22:07:45 1.193
+++ conga/luci/cluster/form-macros 2007/02/24 07:02:42 1.194
@@ -5062,7 +5062,7 @@
<td class="systemsTable">
<span
tal:content="s/state |string:[unknown]"
- tal:attributes="id python: '__STATUS__:' + s['name']" />
+ tal:attributes="id python: '__STATUS__' + s['name']" />
</td>
<td class="systemsTable">
--- conga/luci/cluster/validate_sys_svc.js 2007/02/23 22:07:45 1.1
+++ conga/luci/cluster/validate_sys_svc.js 2007/02/24 07:02:42 1.2
@@ -3,16 +3,45 @@
if (xmlHttp_object.status == 200) {
var response = xmlHttp_object.responseXML;
if (response) {
- req_status = response.getAttribute('success');
- req_op = response.getAttribute('operation');
- req_svc = response.getAttribute('service');
- req_msg = response.getAttribute('message');
- //alert(req_msg + ' / ' + req_status + ' / ' + req_op + ' / ' + req_svc);
+ var result = response.getElementsByTagName('result')[0];
+ var req_status = result.getAttribute('success');
+ var req_op = result.getAttribute('operation');
+ var req_svc = result.getAttribute('service');
+ var req_msg = result.getAttribute('message');
+
+ if (req_status != '0') {
+ var op_str = null;
+ if (req_op == 'stop')
+ op_str = 'stopped';
+ else
+ op_str = req_op + 'ed';
+
+ alert('Service ' + req_svc + ' was successfully ' + op_str);
+
+ var status_elem = document.getElementById('__STATUS__' + req_svc);
+ var start_elem = document.getElementById('__START__' + req_svc);
+ var restart_elem = document.getElementById('__RESTART__' + req_svc);
+ var stop_elem = document.getElementById('__STOP__' + req_svc);
+
+ if (req_op == 'stop') {
+ stop_elem.disabled = 'disabled';
+ restart_elem.disabled = 'disabled';
+ start_elem.disabled = '';
+ status_elem.innerHTML = 'Stopped';
+ } else {
+ stop_elem.disabled = '';
+ restart_elem.disabled = '';
+ start_elem.disabled = 'disabled';
+ status_elem.innerHTML = 'Running';
+ }
+ } else {
+ alert('An error occurred while attempting to ' + req_op + ' service ' + req_svc + ': ' + req_msg);
+ }
} else {
- alert(xmlHttp_object.responseText);
+ alert('Error retrieving data from server');
}
} else {
- //alert('Error retrieving data from server: ' + xmlHttp_object.status);
+ alert('Error retrieving data from server: ' + xmlHttp_object.status);
}
}
}
--- conga/luci/site/luci/Extensions/ricci_bridge.py 2007/02/23 22:07:45 1.59
+++ conga/luci/site/luci/Extensions/ricci_bridge.py 2007/02/24 07:02:42 1.60
@@ -491,16 +491,15 @@
doc = minidom.Document()
elem = doc.createElement('result')
+ elem.setAttribute('success', '0')
if not servicename:
elem.setAttribute('service', 'No service name was specified.')
elem.setAttribute('message', 'No service name was specified.')
- elem.setAttribute('success', '0')
if not op:
elem.setAttribute('operation', 'No operation was specified.')
elem.setAttribute('message', 'No operation was specified.')
- elem.setAttribute('success', '0')
if not servicename or not op:
doc.appendChild(elem)
@@ -517,8 +516,7 @@
else:
raise Exception, op
except Exception, e:
- elem.setAttribute('success', '0');
- elem.setAttribute('message', 'Unknown operation')
+ elem.setAttribute('message', 'Unknown operation: %s' % str(e))
doc.appendChild(elem)
return doc
@@ -526,14 +524,31 @@
ricci_xml = rc.batch_run(batch_str, async=False)
if not ricci_xml or not ricci_xml.firstChild:
- luci_log.debug_verbose('SVCM0: None returned')
- elem.setAttribute('success', '0')
elem.setAttribute('message', 'operation failed')
doc.appendChild(elem)
return doc
- elem.setAttribute('success', '0')
- elem.setAttribute('message', str(ricci_xml.toxml()))
+ try:
+ mod_elem = ricci_xml.getElementsByTagName('module')
+ status_code = int(mod_elem[0].getAttribute('status'))
+ if status_code == 0:
+ var_elem = mod_elem[0].getElementsByTagName('var')
+ for i in var_elem:
+ name = i.getAttribute('name').lower()
+ if name == 'success':
+ success = i.getAttribute('value').lower()
+ if success == 'true':
+ elem.setAttribute('success', '1')
+ elem.setAttribute('message', 'success')
+ else:
+ elem.setAttribute('message', 'operation failed')
+ break
+ else:
+ err_msg = mod_elem[0].childNodes[1].getAttribute('description')
+ elem.setAttribute('message', err_msg)
+ except Exception, e:
+ elem.setAttribute('message', 'operation failed')
+
doc.appendChild(elem)
return doc
--- conga/luci/site/luci/Extensions/system_adapters.py 2007/02/23 22:07:45 1.1
+++ conga/luci/site/luci/Extensions/system_adapters.py 2007/02/24 07:02:42 1.2
@@ -1,6 +1,7 @@
from ricci_communicator import RicciCommunicator
from ricci_bridge import list_services, updateServices, svc_manage
from LuciSyslog import LuciSyslog
+from xml.dom import minidom
try:
luci_log = LuciSyslog()
@@ -104,31 +105,45 @@
request.RESPONSE.redirect(request['URL'] + '?pagetype=90&systemname=' + hostname)
def validate_manage_svc(self, request):
+ ret = minidom.Document()
+
+ result = ret.createElement('result')
+ result.setAttribute('success', '0')
+
+ servicename = None
try:
- hostname = request['systemname'].strip()
+ servicename = request['svcname'].strip()
+ result.setAttribute('service', servicename)
except:
- return None
+ result.setAttribute('service', 'this service')
- servicename = None
op = None
try:
- servicename = request['svcname'].strip()
op = request['operation'].strip()
except:
- pass
+ result.setAttribute('operation', 'manage')
try:
- rc = RicciCommunicator(hostname)
- if not rc:
- raise Exception, 'none'
+ hostname = request['systemname'].strip()
+ if not hostname:
+ raise Exception, 'blank'
except Exception, e:
- return None
+ hostname = None
+ result.setAttribute('message', 'No system was specified')
+ ret.appendChild(result)
- ret = None
- try:
- ret = svc_manage(rc, hostname, servicename, op)
- luci_log.debug_verbose('VMC0: returning %s' % str(ret.toxml()))
- except:
- pass
-
- return ret
+ if hostname and op and servicename:
+ try:
+ rc = RicciCommunicator(hostname)
+ if not rc:
+ raise Exception, 'none'
+ ret = svc_manage(rc, hostname, servicename, op)
+ except Exception, e:
+ result.setAttribute('message', str(e))
+ ret.appendChild(result)
+ else:
+ ret.appendChild(result)
+
+ request.RESPONSE.setHeader('Content-Type', 'text/xml; charset=UTF-8')
+ request.RESPONSE.setHeader('Cache-Control', 'no-cache, no-store, private')
+ request.RESPONSE.write(str(ret.toxml()))
next reply other threads:[~2007-02-24 7:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-24 7:02 rmccabe [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-08-24 22:01 [Cluster-devel] conga/luci cluster/form-macros cluster/validat rmccabe
2007-08-24 21:55 rmccabe
2007-08-24 18:42 rmccabe
2007-08-24 18:40 rmccabe
2007-08-09 4:37 rmccabe
2007-08-09 4:34 rmccabe
2007-02-16 5:29 rmccabe
2007-02-16 5:26 rmccabe
2007-02-12 23:28 rmccabe
2007-02-12 23:26 rmccabe
2007-02-09 18:32 rmccabe
2007-02-09 18:30 rmccabe
2007-02-08 3:43 rmccabe
2007-02-08 2:34 rmccabe
2007-02-01 23:48 rmccabe
2007-01-25 19:55 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=20070224070243.23909.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).