From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 6 Aug 2010 21:57:44 -0000 Subject: [Cluster-devel] conga/luci cluster/fdom-macros cluster/fence-m ... Message-ID: <20100806215744.11904.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 2010-08-06 21:57:43 Modified files: luci/cluster : fdom-macros fence-macros luci/site/luci/Extensions: LuciValidation.py cluster_adapters.py conga_constants.py luci/site/luci/Extensions/ClusterModel: ModelBuilder.py Log message: Fix rhbz#555862 - Luci does not have an option to delete failover domain Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/fdom-macros.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.2.2.1&r2=1.2.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/fence-macros.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.2.2.15&r2=1.2.2.16 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciValidation.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.6.2.14&r2=1.6.2.15 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.49&r2=1.120.2.50 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_constants.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.19.2.17&r2=1.19.2.18 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.4.13&r2=1.1.4.14 --- conga/luci/cluster/fdom-macros 2008/01/23 04:44:30 1.2.2.1 +++ conga/luci/cluster/fdom-macros 2010/08/06 21:57:42 1.2.2.2 @@ -105,6 +105,7 @@ src="/luci/cluster/validate_fdom.js"> +
@@ -155,10 +156,8 @@ -
- -
+ @@ -191,8 +190,24 @@ -
+ + + + + +
+
+ + + + +
+
+
@@ -213,6 +228,9 @@
+

Failover Domain Form

--- conga/luci/cluster/fence-macros 2010/08/05 19:14:10 1.2.2.15 +++ conga/luci/cluster/fence-macros 2010/08/06 21:57:43 1.2.2.16 @@ -1213,34 +1213,36 @@ value cur_fencedev/passwd_script | nothing" /> - - - VMware ESX Management Login - - - - - - VMware ESX Management Password - - + + VMware Type + + - VMware ESX Management Password Script (optional) + VMware Datacenter (ESX only) - + value cur_fencedev/vmware_datacenter | nothing" /> --- conga/luci/site/luci/Extensions/LuciValidation.py 2010/08/05 19:32:58 1.6.2.14 +++ conga/luci/site/luci/Extensions/LuciValidation.py 2010/08/06 21:57:43 1.6.2.15 @@ -16,7 +16,7 @@ from ClusterModel.Lockserver import Lockserver from ClusterModel.Vm import Vm -from conga_constants import LUCI_DEBUG_MODE, FDOM, FDOM_ADD, SERVICE_CONFIG, SERVICE_ADD, VM_CONFIG, VM_ADD +from conga_constants import LUCI_DEBUG_MODE, FDOM, FDOM_ADD, FDOM_DELETE, SERVICE_CONFIG, SERVICE_ADD, VM_CONFIG, VM_ADD from FenceHandler import validateFenceDevice, validateNewFenceDevice, validate_fenceinstance, FD_VAL_SUCCESS from LuciSyslog import get_logger @@ -524,6 +524,38 @@ return (False, { 'errors': [ 'Error configuring resource %s %s: ' % (resname, str(e)) ] }) return (True, { 'res_name': resname }) +def validate_fdom_delete(model, name): + errors = list() + + fdom = model.getFailoverDomainByName(name) + if fdom is None: + if LUCI_DEBUG_MODE is True: + luci_log.debug_verbose('validateFdomdel1: No fdom named %s exists' % name) + errors.append('No failover domain named "%s" exists' % name) + + svc_list = model.getServicesForFdom(name) + if svc_list and len(svc_list) != 0: + errors.append('Unable to delete failover domain "%s" because it is in use by %s %s' % (name, len(svc_list) == 1 and 'service' or 'services', ', '.join(map(lambda x: x.getName(), svc_list)))) + + if len(errors) > 0: + return (False, { 'errors': errors }) + + try: + fdom_ptr = model.getFailoverDomainPtr() + fdom_ptr.removeChild(fdom) + except: + if LUCI_DEBUG_MODE is True: + luci_log.debug_verbose('validateFdomdel2: unable to fdom remove %s' % name) + errors.append('Unable to remove failover domain "%s"' % name) + + if len(errors) > 0: + return (False, { 'errors': errors }) + + action = FDOM_DELETE + status_msg = 'Deleting failover domain "%s"' % name + + return (True, { 'msg': status_msg, 'action': action }) + def validate_fdom(model, request): errors = list() fvar = GetReqVars(request, [ 'clustername', 'name', 'oldname' ]) --- conga/luci/site/luci/Extensions/cluster_adapters.py 2010/08/06 20:17:21 1.120.2.49 +++ conga/luci/site/luci/Extensions/cluster_adapters.py 2010/08/06 21:57:43 1.120.2.50 @@ -30,7 +30,7 @@ NODE_FENCE, NODE_FORCE_DELETE, NODE_JOIN_CLUSTER, NODE_LEAVE_CLUSTER, \ NODE_REBOOT, NODES, POSSIBLE_REBOOT_MESSAGE, PRE_CFG, PRE_INSTALL, \ PRE_JOIN, REBOOT_TASK, REDIRECT_MSG, RESOURCES, RICCI_CONNECT_FAILURE, \ - RICCI_CONNECT_FAILURE_MSG, SEND_CONF, \ + RICCI_CONNECT_FAILURE_MSG, SEND_CONF, FDOMS, \ SERVICE_LIST, SERVICES, START_NODE, TASKTYPE, \ REDIRECT_SEC, LUCI_CLUSTER_BASE_URL, FENCE_XVM_KEY_CREATE @@ -967,6 +967,36 @@ request.RESPONSE.redirect('%s?pagetype=%s&clustername=%s&nodename=%s&busyfirst=true' % (baseurl, NODE, clustername, nodename)) +def deleteFdom(self, request): + from LuciValidation import validate_fdom_delete + + fvar = GetReqVars(request, [ 'clustername', 'name', 'oldname', 'URL' ]) + baseurl = fvar['URL'] or LUCI_CLUSTER_BASE_URL + + name = fvar['name'] + clustername = fvar['clustername'] + if clustername is None: + if LUCI_DEBUG_MODE is True: + luci_log.debug_verbose('VFE0: No cluster name') + return (False, {'errors': ['No cluster name was given']}) + + model = LuciExtractCluModel(self, request, clustername) + if model is None: + if LUCI_DEBUG_MODE is True: + luci_log.debug_verbose('validateFdomdel0: no model') + return (False, { 'errors': [ 'Unable to retrieve the cluster configuration for %s. The configuration XML may contain errors' % clustername ]}) + + ret = validate_fdom_delete(model, name) + if ret[0] is not True: + return ret + + ret = propagateClusterConfAsync(self, model, None, + ret[1]['action'], ret[1]['msg']) + if ret[0] is not True: + return ret + + request.RESPONSE.redirect('%s?pagetype=%s&clustername=%s&busyfirst=true' % (baseurl, FDOMS, clustername)) + def validateFdom(self, request): from LuciValidation import validate_fdom @@ -1175,6 +1205,7 @@ 33: validateResourceAdd, 41: validateFdom, 44: validateFdom, + 46: deleteFdom, 51: validateFenceAdd, 54: validateFenceEdit, 55: validateDaemonProperties, --- conga/luci/site/luci/Extensions/conga_constants.py 2008/03/12 15:13:13 1.19.2.17 +++ conga/luci/site/luci/Extensions/conga_constants.py 2010/08/06 21:57:43 1.19.2.18 @@ -44,6 +44,7 @@ FDOM_LIST = '42' FDOM_CONFIG = '43' FDOM = '44' +FDOM_DELETE = '46' FENCEDEVS = '50' FENCEDEV_ADD = '51' FENCEDEV_LIST = '52' --- conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py 2010/01/07 18:08:35 1.1.4.13 +++ conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py 2010/08/06 21:57:43 1.1.4.14 @@ -600,6 +600,9 @@ raise KeyError, 'Couldn\'t find service name %s in current list' % name + def getServicesForFdom(self, name): + return filter(lambda x: x.getAttribute('domain') == name, self.getServices()) + def retrieveVMsByName(self, name): vms = self.getVMs() for v in vms: