From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 6 Dec 2006 18:38:57 -0000 Subject: [Cluster-devel] conga/luci cluster/form-chooser cluster/form-m ... Message-ID: <20061206183857.24454.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-06 18:38:55 Modified files: luci/cluster : form-chooser form-macros luci/site/luci/Extensions: cluster_adapters.py conga_constants.py Log message: The service delete option was doing nothing. Make it work, but only when the service is not running. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-chooser.diff?cvsroot=cluster&r1=1.13&r2=1.14 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.121&r2=1.122 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.172&r2=1.173 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_constants.py.diff?cvsroot=cluster&r1=1.27&r2=1.28 --- conga/luci/cluster/form-chooser 2006/11/10 19:44:57 1.13 +++ conga/luci/cluster/form-chooser 2006/12/06 18:38:53 1.14 @@ -80,6 +80,9 @@
+ +
+
--- conga/luci/cluster/form-macros 2006/12/05 23:32:34 1.121 +++ conga/luci/cluster/form-macros 2006/12/06 18:38:54 1.122 @@ -2775,9 +2775,31 @@
@@ -3047,14 +3069,15 @@ - - + @@ -3152,6 +3175,11 @@

Service Process Form

+
+

Service Delete Form

+ +
+

Resources Form

--- conga/luci/site/luci/Extensions/cluster_adapters.py 2006/12/05 23:32:35 1.172 +++ conga/luci/site/luci/Extensions/cluster_adapters.py 2006/12/06 18:38:54 1.173 @@ -404,7 +404,6 @@ 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.']}) @@ -1920,6 +1919,7 @@ itemmap['nodename'] = item['nodename'] itemmap['autostart'] = item['autostart'] itemmap['cfgurl'] = baseurl + "?" + "clustername=" + cluname + "&servicename=" + item['name'] + "&pagetype=" + SERVICE + itemmap['delurl'] = baseurl + "?" + "clustername=" + cluname + "&servicename=" + item['name'] + "&pagetype=" + SERVICE_DELETE svc = modelb.retrieveServiceByName(item['name']) dom = svc.getAttribute("domain") @@ -1980,6 +1980,8 @@ innermap['current'] = "This service is currently running on %s" % nodename innermap['disableurl'] = baseurl + "?" + "clustername=" + cluname +"&servicename=" + servicename + "&pagetype=" + SERVICE_STOP innermap['restarturl'] = baseurl + "?" + "clustername=" + cluname +"&servicename=" + servicename + "&pagetype=" + SERVICE_RESTART + innermap['delurl'] = baseurl + "?" + "clustername=" + cluname +"&servicename=" + servicename + "&pagetype=" + SERVICE_DELETE + nodes = modelb.getNodes() for node in nodes: starturl = {} @@ -2026,16 +2028,18 @@ if parent is not None: rc_map['parent'] = parent rc_map['name'] = child.getName() + + #Note: Final version needs all resource attrs if child.isRefObject() == True: rc_map['ref_object'] = True rc_map['type'] = child.getObj().getResourceType() + rc_map['attrs'] = child.getObj().getAttributes() else: rc_map['type'] = child.getResourceType() + rc_map['attrs'] = child.getAttributes() rc_map['indent_ctr'] = indent_ctr - #Note: Final version needs all resource attrs - rc_map['attrs'] = child.getAttributes() rc_map['uuid'] = make_uuid('resource') rc_map['parent_uuid'] = parent_uuid @@ -3985,6 +3989,82 @@ except: continue +def delService(self, request): + errstr = 'An error occurred while attempting to set the new cluster.conf' + + try: + modelb = request.SESSION.get('model') + except Exception, e: + luci_log.debug_verbose('delService0: no model: %s' % str(e)) + return (False, {'errors': [ errstr ] }) + + name = None + try: + name = request['servicename'] + except: + try: + name = request.form['servicename'] + except: + pass + + if name is None: + luci_log.debug_verbose('delService1: no service name') + return (False, {'errors': [ '%s: no service name was provided.' % errstr ]}) + + clustername = None + try: + clustername = request['clustername'] + except: + try: + clustername = request.form['clustername'] + except: + pass + + if clustername is None: + luci_log.debug_verbose('delService2: no cluster name for %s' % name) + return (False, {'errors': [ '%s: no cluster name was provided.' % errstr ]}) + + rc = getRicciAgent(self, clustername) + if not rc: + luci_log.debug_verbose('delService3: unable to get ricci agent for cluster %s' % clustername) + return (False, {'errors': [ '%s: unable to find a Ricci agent for this cluster.' % errstr ]}) + + try: + ragent = rc.hostname() + if not ragent: + raise Exception, 'unable to determine the hostname of the ricci agent' + except Exception, e: + luci_log.debug_verbose('delService4: %s: %s' % (errstr, str(e))) + return (False, {'errors': [ '%s: unable to find a Ricci agent for this cluster.' % errstr ]}) + + try: + modelb.deleteService(name) + except Exception, e: + luci_log.debug_verbose('delService5: Unable to find a service named %s for cluster %s' % (name, clustername)) + return (False, {'errors': [ '%s: error removing service %s.' % (errstr, name) ]}) + + try: + conf = modelb.exportModelAsString() + if not conf: + raise Exception, 'model string is blank' + except Exception, e: + luci_log.debug_verbose('delService6: exportModelAsString failed: %s' \ + % str(e)) + return (False, {'errors': [ '%s: error removing service %s.' % (errstr, name) ]}) + + batch_number, result = setClusterConf(rc, str(conf)) + if batch_number is None or result is None: + luci_log.debug_verbose('delService7: missing batch and/or result') + return (False, {'errors': [ '%s: error removing service %s.' % (errstr, name) ]}) + + try: + set_node_flag(self, clustername, ragent, str(batch_number), SERVICE_DELETE, "Removing service \'%s\'" % name) + except Exception, e: + luci_log.debug_verbose('delService8: failed to set flags: %s' % str(e)) + + response = request.RESPONSE + response.redirect(request['URL'] + "?pagetype=" + SERVICES + "&clustername=" + clustername + '&busyfirst=true') + def delResource(self, rc, request): errstr = 'An error occurred while attempting to set the new cluster.conf' @@ -4068,9 +4148,6 @@ 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 --- conga/luci/site/luci/Extensions/conga_constants.py 2006/11/27 20:06:53 1.27 +++ conga/luci/site/luci/Extensions/conga_constants.py 2006/12/06 18:38:55 1.28 @@ -43,6 +43,7 @@ FENCEDEV_CONFIG="53" FENCEDEV="54" CLUSTER_DAEMON="55" +SERVICE_DELETE = '56' #Cluster tasks CLUSTER_STOP = '1000'