From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 5 Dec 2006 06:44:11 -0000 Subject: [Cluster-devel] conga/luci cluster/form-macros cluster/resourc ... Message-ID: <20061205064411.11960.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 Changes by: rmccabe at sourceware.org 2006-12-05 06:44:10 Modified files: luci/cluster : form-macros resource-form-macros resource_form_handlers.js luci/site/luci/Extensions: cluster_adapters.py Log message: fixes for adding and editing services Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.119&r2=1.120 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource-form-macros.diff?cvsroot=cluster&r1=1.24&r2=1.25 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource_form_handlers.js.diff?cvsroot=cluster&r1=1.22&r2=1.23 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.170&r2=1.171 --- conga/luci/cluster/form-macros 2006/12/04 22:59:56 1.119 +++ conga/luci/cluster/form-macros 2006/12/05 06:44:09 1.120 @@ -2879,7 +2879,9 @@ + + @@ -2939,30 +2941,46 @@
- - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -3071,6 +3089,10 @@
+
+ +
@@ -3086,7 +3108,9 @@ + +
--- conga/luci/cluster/resource-form-macros 2006/11/10 19:44:57 1.24 +++ conga/luci/cluster/resource-form-macros 2006/12/05 06:44:09 1.25 @@ -271,7 +271,7 @@
- +
@@ -307,7 +307,10 @@ tal:attributes="name res/parent_uuid | nothing" tal:define="editDisabled resourceIsRef | nothing"> - + + - + + - + + - + + - + + - + + - + + - + + ]+>/ig).toString().replace(/>(,|$)/g, '/>'); if (!temp) continue; @@ -395,6 +408,9 @@ form[i].parent_uuid.value + '">' + temp + ''; } + if (!svc_name) + errors.push('No name was given for this service.'); + if (!form_xml) errors.push('No resource information was submitted.'); @@ -403,7 +419,14 @@ /* sort this out in the backend */ master_form.form_xml.value = '' + form_xml + ''; - if (confirm('Save changes to this service?')) + master_form.svc_name.value = svc_name; + + var confirm_msg = null; + if (master_form.action.value == 'add') + confirm_msg = 'Create this service?'; + else + confirm_msg = 'Save changes to this service?'; + if (confirm(confirm_msg)) master_form.submit(); return (0); } --- conga/luci/site/luci/Extensions/cluster_adapters.py 2006/11/29 18:15:20 1.170 +++ conga/luci/site/luci/Extensions/cluster_adapters.py 2006/12/05 06:44:10 1.171 @@ -399,8 +399,9 @@ try: form_xml = request['form_xml'] if not form_xml: - raise KeyError('form_xml must not be blank') - except KeyError, e: + raise KeyError, 'form_xml must not be blank' + 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: @@ -408,7 +409,8 @@ forms = doc.getElementsByTagName('form') if len(forms) < 1: raise - except: + except Exception, e: + luci_log.debug_verbose('vSA1: error: %s' % str(e)) return (False, {'errors': ['The resource data submitted for this service is not properly formed.']}) form_hash = {} @@ -440,24 +442,31 @@ try: dummy_form[str(i.getAttribute('name'))] = str(i.getAttribute('value')) except Exception, e: - luci_log.debug_verbose('Error parsing service XML: %s' % str(e)) + luci_log.debug_verbose('vSA2: parsing XML: %s' % str(e)) pass try: res_type = dummy_form['type'].strip() if not res_type or not res_type in resourceAddHandler: - raise - except: + 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]}) try: - resObj = resourceAddHandler[res_type](request, dummy_form) - except: - luci_log('res type %d is invalid' % res_type) + 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']) + else: + resObj = resourceAddHandler[res_type](request, dummy_form) + except Exception, e: resObj = None + luci_log.debug_verbose('vSA4: type %s: %s' % (res_type, str(e))) if resObj is None: - return (False, {'errors': ['An error occurred while adding ' + res_type]}) + 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.']}) @@ -3798,6 +3807,7 @@ for item in modelb.getResources(): itemmap = {} itemmap['name'] = item.getName() + itemmap['attrs'] = item.attr_hash itemmap['type'] = item.resource_type itemmap['cfgurl'] = baseurl + "?" + "clustername=" + cluname + "&resourcename=" + item.getName() + "&pagetype=" + RESOURCE_CONFIG itemmap['url'] = baseurl + "?" + "clustername=" + cluname + "&resourcename=" + item.getName() + "&pagetype=" + RESOURCE @@ -4651,6 +4661,17 @@ response = request.RESPONSE response.redirect(request['URL'] + "?pagetype=" + RESOURCES + "&clustername=" + clustername + '&busyfirst=true') +def getResource(modelb, name): + resPtr = modelb.getResourcesPtr() + resources = resPtr.getChildren() + + for res in resources: + if res.getName() == name: + return res + + luci_log.debug_verbose('getResource: unable to find resource \"%s\"' % name) + raise KeyError, name + def getResourceForEdit(modelb, name): resPtr = modelb.getResourcesPtr() resources = resPtr.getChildren() @@ -4660,7 +4681,7 @@ resPtr.removeChild(res) return res - luci_log.debug_verbose('unable to find resource \"%s\"' % name) + luci_log.debug_verbose('GRFE0: unable to find resource \"%s\"' % name) raise KeyError, name def appendModel(request, model):