From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 27 Jul 2007 19:11:33 -0000 Subject: [Cluster-devel] conga/luci cluster/resource_form_handlers.js s ... Message-ID: <20070727191133.14295.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: conga Branch: RHEL5 Changes by: rmccabe at sourceware.org 2007-07-27 19:11:32 Modified files: luci/cluster : resource_form_handlers.js luci/site/luci/Extensions: cluster_adapters.py Log message: Allow the creation and modification of services with no resources Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource_form_handlers.js.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.20.2.9&r2=1.20.2.10 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.120.2.34&r2=1.120.2.35 --- conga/luci/cluster/resource_form_handlers.js 2007/07/12 04:41:39 1.20.2.9 +++ conga/luci/cluster/resource_form_handlers.js 2007/07/27 19:11:32 1.20.2.10 @@ -523,8 +523,11 @@ if (!svc_name) errors.push('No name was given for this service.'); - if (!form_xml) - errors.push('No resource information was submitted.'); + /* + ** allow creation of empty services. + ** if (!form_xml) + ** errors.push('No resource information was submitted.'); + */ if (recovery && recovery != 'relocate' && recovery != 'restart' && recovery != 'disable') { errors.push('You entered an invalid recovery option. Valid options are "relocate" "restart" and "disable"'); @@ -534,7 +537,12 @@ return (-1); /* sort this out in the backend */ - master_form.form_xml.value = '' + form_xml + ''; + if (form_xml) { + master_form.form_xml.value = '' + form_xml + ''; + } else { + /* empty service */ + master_form.form_xml.value = ' '; + } master_form.svc_name.value = svc_name; if (domain) master_form.domain.value = domain; --- conga/luci/site/luci/Extensions/cluster_adapters.py 2007/07/26 05:52:54 1.120.2.34 +++ conga/luci/site/luci/Extensions/cluster_adapters.py 2007/07/27 19:11:32 1.120.2.35 @@ -720,9 +720,10 @@ form_xml = fvar['form_xml'] if form_xml is None: + form_xml = '' if LUCI_DEBUG_MODE is True: luci_log.debug_verbose('vSA0: no form_xml') - return (False, { 'errors': [ 'No resource data was supplied for this service' ]}) + model = LuciExtractCluModel(self, request, clustername) if model is None: @@ -730,15 +731,17 @@ luci_log.debug_verbose('vSA1: no model') return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ]}) - try: - doc = minidom.parseString(form_xml) - forms = doc.getElementsByTagName('form') - if len(forms) < 1: - raise Exception, 'invalid XML' - except Exception, e: - if LUCI_DEBUG_MODE is True: - luci_log.debug_verbose('vSA1: error: %r %s' % (e, str(e))) - return (False, { 'errors': [ 'The resource data submitted for this service is not properly formed' ]}) + forms = [] + if form_xml.strip(): + try: + doc = minidom.parseString(form_xml) + forms = doc.getElementsByTagName('form') + if len(forms) < 1: + raise Exception, 'invalid XML' + except Exception, e: + if LUCI_DEBUG_MODE is True: + luci_log.debug_verbose('vSA1: error: %r %s: %r' % (e, str(e), form_xml)) + return (False, { 'errors': [ 'The resource data submitted for this service is not properly formed' ]}) form_hash = {} form_hash['toplevel'] = { 'form': None, 'kids': [] }