From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci cluster/form-macros cluster/resourc ...
Date: 5 Dec 2006 23:32:36 -0000 [thread overview]
Message-ID: <20061205233236.13429.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2006-12-05 23:32:35
Modified files:
luci/cluster : form-macros resource_form_handlers.js
luci/site/luci/Extensions: cluster_adapters.py
Log message:
service add and edit fixes
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.120&r2=1.121
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource_form_handlers.js.diff?cvsroot=cluster&r1=1.23&r2=1.24
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.171&r2=1.172
--- conga/luci/cluster/form-macros 2006/12/05 06:44:09 1.120
+++ conga/luci/cluster/form-macros 2006/12/05 23:32:34 1.121
@@ -2857,6 +2857,14 @@
<input type="text" length="20" name="service_name" value="" />
</td>
</tr>
+ <tr class="systemsTable">
+ <td class="systemsTable">
+ Automatically start this service
+ </td>
+ <td class="systemsTable">
+ <input type="checkbox" name="autostart" checked="checked" />
+ </td>
+ </tr>
</table>
</form>
</div>
@@ -2880,6 +2888,7 @@
<input type="hidden" name="parent_uuid" value="_toplevel" />
<input type="hidden" name="tree_level" value="-1" />
<input type="hidden" name="svc_name" value="" />
+ <input type="hidden" name="autostart" value="" />
<input type="hidden" name="form_xml" />
<input type="hidden" name="action" value="add" />
</form>
@@ -3022,7 +3031,8 @@
tal:content="sinfo/name | nothing"
tal:attributes="class python: running and 'running' or 'stopped'" />
</td>
- <td class="cluster service service_action">
+ <td class="cluster service service_action"
+ tal:condition="python: sinfo and 'innermap' in sinfo">
<form method="post" onSubmit="return dropdown(this.gourl)">
<input type="hidden" name="pagetype" tal:attributes="
value request/pagetype | request/form/pagetype | nothing" />
@@ -3090,9 +3100,16 @@
</div>
<div class="service_comp_list">
<form name="service_name_form">
+ <table class="rescfg">
+ <tr><td>
+ Automatically start this service
+ </td>
+ <td><input type="checkbox" name="autostart" tal:attributes="checked sinfo/autostart | nothing" /></td></tr>
+ </table>
<input type="hidden" name="service_name"
- tal:attributes="value sinfo/name | nothing" />
+ tal:attributes="value sinfo/name | string:1" />
</form>
+
<form name="master" method="post">
<tal:block
tal:define="global clusterinfo python: here.getClusterInfo(modelb, request)" />
@@ -3109,6 +3126,7 @@
<input type="hidden" name="parent_uuid" value="_toplevel" />
<input type="hidden" name="tree_level" value="-1" />
<input type="hidden" name="svc_name" value="" />
+ <input type="hidden" name="autostart" value="" />
<input type="hidden" name="form_xml" />
<input type="hidden" name="action" value="edit" />
</form>
--- conga/luci/cluster/resource_form_handlers.js 2006/12/05 06:44:09 1.23
+++ conga/luci/cluster/resource_form_handlers.js 2006/12/05 23:32:34 1.24
@@ -381,6 +381,7 @@
var errors = new Array();
var form_xml = '';
var svc_name = null;
+ var autostart = 1;
var form = document.getElementsByTagName('form');
for (var i = 0 ; i < form.length ; i++) {
@@ -393,17 +394,40 @@
clr_form_err(form[i].service_name);
svc_name = form[i].service_name.value;
}
+ if (!form[i].autostart.checked)
+ autostart = 0;
continue;
}
if (form[i].name == 'master' || !form[i].uuid || !form[i].uuid.value)
continue;
+
var err = check_form(form[i]);
if (err)
errors = errors.concat(err);
- var temp = form[i].innerHTML.match(/<input [^>]+>/ig).toString().replace(/>(,|$)/g, '/>');
- if (!temp)
- continue;
+ var temp = '';
+
+ var input_elem = form[i].getElementsByTagName('input');
+ for (var j = 0 ; j < input_elem.length ; j++) {
+ var res_type = input_elem[j].type;
+ if (res_type == 'hidden' || res_type == 'text' ||
+ res_type == 'password')
+ {
+ temp += '<input type="' + res_type + '" name="' + input_elem[j].name + '" value="' + input_elem[j].value + '" />';
+ } else if (res_type == 'checkbox' || res_type == 'radio') {
+ if (input_elem[j].checked)
+ temp += '<input type="' + res_type + '" name="' + input_elem[j].name + '" checked="checked"';
+ if (res_type == 'radio')
+ temp += ' value="' + input_elem[j].value + '"';
+ temp += ' />';
+ }
+ }
+
+ var select_elem = form[i].getElementsByTagName('select');
+ for (var j = 0 ; j < select_elem.length ; j++) {
+ temp += '<input type="text" name="' + select_elem[j].name + '" value="' + select_elem[j].options[select_elem[j].options.selectedIndex].value + '" />';
+ }
+
form_xml += '<form id="' + form[i].uuid.value + '" parent="' +
form[i].parent_uuid.value + '">' + temp + '</form>';
}
@@ -420,6 +444,7 @@
/* sort this out in the backend */
master_form.form_xml.value = '<formlist>' + form_xml + '</formlist>';
master_form.svc_name.value = svc_name;
+ master_form.autostart = autostart;
var confirm_msg = null;
if (master_form.action.value == 'add')
--- conga/luci/site/luci/Extensions/cluster_adapters.py 2006/12/05 06:44:10 1.171
+++ conga/luci/site/luci/Extensions/cluster_adapters.py 2006/12/05 23:32:35 1.172
@@ -12,8 +12,10 @@
from Ip import Ip
from Clusterfs import Clusterfs
from Fs import Fs
+from RefObject import RefObject
from NFSClient import NFSClient
from NFSExport import NFSExport
+from Service import Service
from Netfs import Netfs
from Vm import Vm
from Script import Script
@@ -396,15 +398,26 @@
response.redirect(request['URL'] + "?pagetype=" + CLUSTER_CONFIG + "&clustername=" + clusterName + '&busyfirst=true')
def validateServiceAdd(self, request):
+ errors = list()
+
try:
form_xml = request['form_xml']
if not form_xml:
raise KeyError, 'form_xml must not be blank'
+ luci_log.debug_verbose('VSAXML DUMP: %s' % form_xml)
except Exception, e:
luci_log.debug_verbose('vSA0: no form_xml: %s' % str(e))
return (False, {'errors': ['No resource data was supplied for this service.']})
try:
+ model = request.SESSION.get('model')
+ if not model:
+ raise Exception, 'model is None'
+ except Exception, e:
+ luci_log.debug_verbose('vSA0a: %s' % str(e))
+ return (False, {'errors': [ 'The cluster model is missing from the session object.' ]})
+
+ try:
doc = minidom.parseString(form_xml)
forms = doc.getElementsByTagName('form')
if len(forms) < 1:
@@ -447,20 +460,21 @@
try:
res_type = dummy_form['type'].strip()
- if not res_type or not res_type in resourceAddHandler:
+ if not res_type:
+ raise Exception, 'no resource type was given'
+ if not res_type in resourceAddHandler:
raise Exception, 'invalid resource type: %s' % res_type
except Exception, e:
luci_log.debug_verbose('vSA3: %s' % str(e))
- return (False, {'errors': ['An invalid resource type was specified: ' + res_type]})
+ return (False, {'errors': [ 'An invalid resource type was specified' ]})
try:
if dummy_form.has_key('immutable'):
- model = request.SESSION.get('model')
- if not model:
- raise Exception, 'model is None'
- resObj = getResource(model, dummy_form['resourceName'])
+ newRes = getResource(model, dummy_form['resourceName'])
+ resObj = RefObject(newRes)
+ resObj.setRef(newRes.getName())
else:
- resObj = resourceAddHandler[res_type](request, dummy_form)
+ resObj = resourceAddHandler[res_type](request, dummy_form)[0]
except Exception, e:
resObj = None
luci_log.debug_verbose('vSA4: type %s: %s' % (res_type, str(e)))
@@ -468,8 +482,109 @@
if resObj is None:
return (False, {'errors': [ 'An error occurred while adding %s' % res_type ]})
form_hash[form_id]['obj'] = resObj
-
- return (True, {'messages': ['This service has been updated.']})
+
+ if len(errors) > 0:
+ return (False, {'errors': errors})
+
+ try:
+ service_name = request.form['svc_name'].strip()
+ except Exception, e:
+ luci_log.debug_verbose('vSA5: no service name: %s' % str(e))
+ return (False, {'errors': [ 'No service name was given.' ]})
+
+ autostart = "1"
+ try:
+ if not request.form.has_key('autostart'):
+ autostart = "0"
+ except:
+ pass
+
+ try:
+ cur_service = model.retrieveServiceByName(service_name)
+ except GeneralError, e:
+ luci_log.debug_verbose('vSA5a: no service named %s found' % service_name)
+ cur_service = None
+ except Exception, e:
+ luci_log.debug_verbose('vSA5a: no service named %s found: %s' % (service_name, str(e)))
+ cur_service = None
+
+ try:
+ if request.form['action'] == 'edit':
+ if cur_service is None:
+ return (False, {'errors': [ 'The service %s could not be found for editing.' % service_name ]})
+ model.deleteService(service_name)
+ elif request.form['action'] == 'add':
+ if cur_service is not None:
+ return (False, {'errors': [ 'A service with the name %s already exists.' % service_name ]})
+ else:
+ luci_log.debug_verbose('vSA4a: unknown action %s' % request.form['action'])
+ return (False, {'errors': [ 'An unknown action was specified.' ]})
+ except Exception, e:
+ luci_log.debug_verbose('vSA5: no action type: %s' % str(e))
+
+ def buildSvcTree(parent, child_id_list):
+ for i in child_id_list:
+ try:
+ child = form_hash[i]['obj']
+ if not child:
+ raise Exception, 'No object for %s' % i
+ except Exception, e:
+ luci_log.debug_verbose('bST0: %s' % str(e))
+ continue
+ parent.addChild(child)
+ if 'kids' in form_hash[i]:
+ buildSvcTree(child, form_hash[i]['kids'])
+
+ new_service = Service()
+ new_service.addAttribute('name', service_name)
+ new_service.attr_hash['autostart'] = autostart
+
+ buildSvcTree(new_service, form_hash['toplevel']['kids'])
+ model.resourcemanager_ptr.addChild(new_service)
+
+ clustername = model.getClusterName()
+ if not clustername:
+ luci_log.debug_verbose('vAS6: no cluname from mb')
+ return (False, {'errors': [ 'Unable to determine cluster name' ]})
+
+ try:
+ conf = model.exportModelAsString()
+ if not conf:
+ raise Exception, 'model string for %s is blank' % clustername
+ except Exception, e:
+ luci_log.debug_verbose('vAS6a: exportModelAsString : %s' \
+ % str(e))
+ return (False, {'errors': [ 'An error occurred while adding this service.' ]})
+
+ rc = getRicciAgent(self, clustername)
+ if not rc:
+ luci_log.debug_verbose('vAS6b: unable to find a ricci agent for cluster %s' % clustername)
+ return 'Unable to find a ricci agent for the %s cluster' % clustername
+
+ try:
+ ragent = rc.hostname()
+ if not ragent:
+ luci_log.debug_verbose('vAS7: missing ricci hostname')
+ raise Exception, 'unknown ricci agent hostname'
+
+ batch_number, result = setClusterConf(rc, str(conf))
+ if batch_number is None or result is None:
+ luci_log.debug_verbose('vAS8: missing batch_number or result')
+ raise Exception, 'unable to save the new cluster configuration.'
+ except Exception, e:
+ luci_log.debug_verbose('vAS9: %s' % str(e))
+ return 'An error occurred while propagating the new cluster.conf: %s' % str(e)
+
+ try:
+ if request.form['action'] == 'edit':
+ set_node_flag(self, clustername, ragent, str(batch_number), SERVICE_CONFIG, "Configuring service \'%s\'" % service_name)
+ else:
+ set_node_flag(self, clustername, ragent, str(batch_number), SERVICE_ADD, "Adding new service \'%s\'" % service_name)
+ except Exception, e:
+ luci_log.debug_verbose('vAS10: failed to set flags: %s' % str(e))
+
+ response = request.RESPONSE
+ response.redirect(request['URL'] + "?pagetype=" + SERVICES + "&clustername=" + clustername + '&busyfirst=true')
def validateResourceAdd(self, request):
try:
@@ -1856,6 +1971,7 @@
if item['name'] == servicename:
hmap['name'] = servicename
starturls = list()
+ hmap['autostart'] = item['autostart']
if item['running'] == "true":
hmap['running'] = "true"
#In this case, determine where it can run...
@@ -3952,6 +4068,9 @@
if form is None:
form = request.form
+ if form is not None:
+ luci_log.debug_verbose('addIp DUMP: %s' % str(form.items()))
+
if not form:
luci_log.debug_verbose('addIp error: form is missing')
return None
@@ -4526,7 +4645,7 @@
'gfs': addGfs,
'nfsm': addNfsm,
'nfsx': addNfsx,
- 'nfsc': addNfsx,
+ 'nfsc': addNfsc,
'scr': addScr,
'smb': addSmb
}
next reply other threads:[~2006-12-05 23:32 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-05 23:32 rmccabe [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-05-30 5:54 [Cluster-devel] conga/luci cluster/form-macros cluster/resourc rmccabe
2007-02-16 2:12 rmccabe
2007-02-16 2:06 rmccabe
2007-02-08 16:00 rmccabe
2007-02-08 15:59 rmccabe
2007-02-08 5:05 rmccabe
2007-01-26 17:56 rmccabe
2007-01-20 4:50 rmccabe
2006-12-06 22:44 rmccabe
2006-12-05 6:44 rmccabe
2006-09-23 4:04 rmccabe
2006-09-14 21:24 rmccabe
2006-09-13 17:50 rmccabe
2006-09-11 22:22 rmccabe
2006-09-05 21:25 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=20061205233236.13429.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.