From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 30 May 2007 22:06:26 -0000 Subject: [Cluster-devel] conga/luci/site/luci/Extensions LuciClusterInf ... Message-ID: <20070530220626.12529.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: EXPERIMENTAL Changes by: rmccabe at sourceware.org 2007-05-30 22:06:24 Modified files: luci/site/luci/Extensions: LuciClusterInfo.py LuciDB.py LuciZope.py LuciZopeExternal.py Variable.py cluster_adapters.py storage_adapters.py Added files: luci/site/luci/Extensions: LuciZopeClusterPortal.py Log message: More cleanup and refactor Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZopeClusterPortal.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciClusterInfo.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.6&r2=1.1.2.7 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciDB.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.13&r2=1.1.2.14 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZope.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.7&r2=1.1.2.8 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZopeExternal.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.3&r2=1.1.2.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/Variable.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.4.8.3&r2=1.4.8.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.255.2.11&r2=1.255.2.12 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/storage_adapters.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.9.4.3&r2=1.9.4.4 --- conga/luci/site/luci/Extensions/Attic/LuciClusterInfo.py 2007/05/18 05:23:55 1.1.2.6 +++ conga/luci/site/luci/Extensions/Attic/LuciClusterInfo.py 2007/05/30 22:06:24 1.1.2.7 @@ -1585,3 +1585,25 @@ return None return model + +def getClusterOS(self, rc): + from HelperFunctions import resolveOSType + + clu_map = {} + + try: + os_str = resolveOSType(rc.os()) + clu_map['os'] = os_str + clu_map['isVirtualized'] = rc.dom0() + except: + # default to rhel5 if something crazy happened. + try: + if LUCI_DEBUG_MODE is True: + luci_log.debug('An error occurred while attempting to get OS/Virt info for %s -- defaulting to rhel5/False' % rc.hostname()) + except: + # this can throw an exception if the original exception + # is caused by rc being None or stale. + pass + clu_map['os'] = 'rhel5' + clu_map['isVirtualized'] = False + return clu_map --- conga/luci/site/luci/Extensions/Attic/LuciDB.py 2007/05/30 05:54:02 1.1.2.13 +++ conga/luci/site/luci/Extensions/Attic/LuciDB.py 2007/05/30 22:06:24 1.1.2.14 @@ -864,6 +864,38 @@ return [] return nodelist +def getClusterDBVersion(cluster_folder): + try: + cluster_os = str(cluster_folder.getProperty('cluster_os')) + if not cluster_os: + raise Exception, 'cluster os is blank' + except Exception, e: + if LUCI_DEBUG_MODE is True: + luci_log.debug_verbose('GCDBV0: %s: %r %s' \ + % (cluster_folder.getId(), e, str(e))) + cluster_os = None + return cluster_os + +def setClusterDBVersion(cluster_folder, version_str): + if cluster_folder.getProperty('cluster_os') is None: + try: + cluster_folder.manage_addProperty('cluster_os', + version_str, 'string') + except Exception, e: + if LUCI_DEBUG_MODE is True: + luci_log.debug_verbose('SCDBV0: %s: %r %s' \ + % (cluster_folder.getId(), e, str(e))) + return None + else: + try: + cluster_folder.manage_changeProperties({'cluster_os': version_str }) + except Exception, e: + if LUCI_DEBUG_MODE is True: + luci_log.debug_verbose('SCDBV1: %s: %r %s' \ + % (cluster_folder.getId(), e, str(e))) + return None + return True + def getClusterFlags(self, cluname): try: path = '%s%s' % (CLUSTER_FOLDER_PATH, cluname) --- conga/luci/site/luci/Extensions/Attic/LuciZope.py 2007/05/18 05:23:55 1.1.2.7 +++ conga/luci/site/luci/Extensions/Attic/LuciZope.py 2007/05/30 22:06:24 1.1.2.8 @@ -124,3 +124,19 @@ luci_log.debug_verbose('Appending model to request failed: %r %s' \ % (e, str(e))) return 'An error occurred while storing the cluster model' + +def GetReqVars(req, varlist): + ret = {} + for i in varlist: + pval = None + if req.has_key(i): + pval = req[i].strip() + if not pval: + pval = None + if pval is None: + if req.form and req.form.has_key(i): + pval = req.form[i].strip() + if not pval: + pval = None + ret[i] = pval + return ret --- conga/luci/site/luci/Extensions/Attic/LuciZopeExternal.py 2007/05/30 05:54:02 1.1.2.3 +++ conga/luci/site/luci/Extensions/Attic/LuciZopeExternal.py 2007/05/30 22:06:24 1.1.2.4 @@ -13,10 +13,9 @@ from homebase_adapters import getUserPerms, homebaseControl, \ getDefaultUser -from cluster_adapters import clusterTaskProcess, resourceAdd, \ - resourceDelete, \ - createCluChooser, createCluConfigTree, serviceDelete, \ - getClusterOS, getClusterURL, getSystemLogs, getRicciAgentForCluster, \ +from cluster_adapters import clusterTaskProcess, \ + resourceAdd, resourceDelete, serviceDelete, \ + getClusterURL, getSystemLogs, getRicciAgentForCluster, \ isClusterBusy, nodeTaskProcess, process_cluster_conf_editor, \ serviceMigrate, serviceRestart, serviceStart, serviceStop @@ -26,7 +25,7 @@ getClustersInfo, getClusterStatus, getFdomInfo, get_fdom_names, \ getFdomsInfo, getFence, getFenceInfo, getFencesInfo, getModelBuilder, \ getNodeInfo, getnodes, getNodesInfo, getResourceInfo, getResourcesInfo, \ - getServiceInfo, getServicesInfo, getVMInfo + getServiceInfo, getServicesInfo, getVMInfo, getClusterOS from LuciDB import access_to_host_allowed, allowed_systems, \ check_clusters, getRicciAgent, getSystems, getClusters, \ @@ -35,6 +34,8 @@ from LuciZope import appendModel, bytes_to_value_prefunits, \ set_persistent_var, strFilter, getTabs, siteIsSetup +from LuciZopeClusterPortal import createCluChooser, createCluConfigTree + from LuciZopePerm import isAdmin, userAuthenticated from ricci_communicator import get_ricci_communicator @@ -42,7 +43,7 @@ from storage_adapters import createStorageChooser, \ createStorageConfigTree, getStorageURL -from StorageReport import apply, cache_storage_report, \ +from StorageReport import apply_storage_changes, cache_storage_report, \ get_bd_data, get_mapper_data, get_mappers_data, get_mapper_template_data, \ get_mappings_info, get_storage_batch_result, get_storage_report, \ group_systems_by_cluster, is_storage_report_cached, validate, \ --- conga/luci/site/luci/Extensions/Variable.py 2007/05/15 21:42:21 1.4.8.3 +++ conga/luci/site/luci/Extensions/Variable.py 2007/05/30 22:06:24 1.4.8.4 @@ -91,6 +91,8 @@ def __init__(self, name, value, mods={}): self.__name = str(name) self.__mods = mods + self.__value = None + self.__type = None self.set_value(value) def get_name(self): --- conga/luci/site/luci/Extensions/cluster_adapters.py 2007/05/30 05:54:02 1.255.2.11 +++ conga/luci/site/luci/Extensions/cluster_adapters.py 2007/05/30 22:06:24 1.255.2.12 @@ -29,20 +29,17 @@ from homebase_adapters import parseHostForm from LuciClusterInfo import getClusterInfo, getModelBuilder, getModelForCluster -from conga_constants import BATCH_ID, CLUNAME, CLUNODE_CREATE_ERRORS, \ - CLUSTER, CLUSTER_ADD, CLUSTER_CONFIG, CLUSTER_DAEMON, CLUSTER_DELETE, \ - CLUSTER_FOLDER_PATH, CLUSTERLIST, CLUSTER_RESTART, CLUSTERS, \ - CLUSTER_START, CLUSTER_STOP, DISABLE_SVC_TASK, ENABLE_SVC_TASK, \ - FDOM, FDOM_ADD, FDOM_CONFIG, FDOMS, FENCEDEV, FENCEDEV_ADD, \ - FENCEDEV_CONFIG, FENCEDEV_NODE_CONFIG, FENCEDEVS, FLAG_DESC, \ - INSTALL_TASK, LAST_STATUS, LUCI_DEBUG_MODE, NODE, NODE_ADD, \ - NODE_CONFIG, NODE_DELETE, NODE_FENCE, NODE_GRID, NODE_JOIN_CLUSTER, \ - NODE_LEAVE_CLUSTER, NODE_LIST, NODE_REBOOT, NODES, PAGETYPE, \ - POSSIBLE_REBOOT_MESSAGE, PRE_CFG, PRE_INSTALL, PRE_JOIN, \ - REBOOT_TASK, REDIRECT_MSG, RESOURCE, RESOURCE_ADD, RESOURCE_CONFIG, \ - RESOURCES, RICCI_CONNECT_FAILURE, RICCI_CONNECT_FAILURE_MSG, \ - SEND_CONF, SERVICE, SERVICE_ADD, SERVICE_CONFIG, SERVICE_LIST, \ - SERVICES, START_NODE, TASKTYPE, VM_ADD, VM_CONFIG +from conga_constants import BATCH_ID, CLUNODE_CREATE_ERRORS, \ + CLUSTER_ADD, CLUSTER_CONFIG, CLUSTER_DAEMON, CLUSTER_DELETE, \ + CLUSTER_FOLDER_PATH, CLUSTER_RESTART, CLUSTER_START, CLUSTER_STOP, \ + DISABLE_SVC_TASK, ENABLE_SVC_TASK, FDOM, FDOM_ADD, FENCEDEV, \ + FENCEDEV_NODE_CONFIG, FENCEDEVS, FLAG_DESC, INSTALL_TASK, \ + LAST_STATUS, LUCI_DEBUG_MODE, NODE, NODE_ADD, NODE_DELETE, \ + NODE_FENCE, 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, SERVICE_ADD, SERVICE_CONFIG, \ + SERVICE_LIST, SERVICES, START_NODE, TASKTYPE, VM_ADD, VM_CONFIG from FenceHandler import validateNewFenceDevice, \ validateFenceDevice, validate_fenceinstance, \ @@ -57,7 +54,7 @@ resolve_nodename, set_node_flag, getRicciAgent, \ CLUSTER_NODE_NEED_AUTH -from LuciZopePerm import havePermCreateCluster +from LuciZope import GetReqVars luci_log = get_logger() @@ -341,7 +338,7 @@ check_certs = False try: - check_certs = 'check_certs' in request.form + check_certs = request.form.has_key('check_certs') except: check_certs = False @@ -1552,29 +1549,15 @@ response.redirect('%s?pagetype=%s&clustername=%s&busyfirst=true' \ % (request['URL'], CLUSTER_CONFIG, clustername)) -def LuciExtractCluName(self, request): - cluname = None - - try: - if request.form.has_key('clustername'): - cluname = request.form['clustername'].strip() - if not cluname and request.has_key('clustername'): - cluname = request['clustername'].strip() - except Exception, e: - pass - - if not cluname: - if LUCI_DEBUG_MODE is True: - luci_log.debug_verbose('LECN0: no cluster name') - return cluname - def LuciExtractCluModel(self, request, cluster_name=None): - model = None if not cluster_name: - cluster_name = LuciExtractCluName(self, request) - if not cluster_name: + fvar = GetReqVars(request, [ 'clustername' ]) + cluster_name = fvar['clustername'] + if cluster_name is None: if LUCI_DEBUG_MODE is True: luci_log.debug_verbose('LECM0: no cluster name') + + model = None try: model = request.SESSION.get('model') if not model: @@ -2565,6 +2548,63 @@ response.redirect('%s?pagetype=%s&clustername=%s&busyfirst=true' \ % (request['URL'], SERVICES, clustername)) +def process_cluster_conf_editor(self, req): + clustername = req['clustername'] + msg_list = list(('\n')) + cc = '' + if 'new_cluster_conf' in req: + cc = req['new_cluster_conf'] + msg_list.append('Checking if valid XML - ') + cc_xml = None + try: + cc_xml = minidom.parseString(cc) + except: + pass + if cc_xml is None: + msg_list.append('FAILED\n') + msg_list.append('Fix the error and try again:\n') + else: + msg_list.append('PASSED\n') + + msg_list.append('Making sure no cluster name change has occurred - ') + new_name = cc_xml.firstChild.getAttribute('name') + if new_name != clustername: + msg_list.append('FAILED\n') + msg_list.append('Fix the error and try again:\n') + else: + msg_list.append('PASSED\n') + + msg_list.append('Incrementing the cluster version number - ') + version = cc_xml.firstChild.getAttribute('config_version') + version = int(version) + 1 + cc_xml.firstChild.setAttribute('config_version', str(version)) + msg_list.append('DONE\n') + + msg_list.append('Propagating the new cluster.conf') + rc = getRicciAgent(self, clustername) + if not rc: + if LUCI_DEBUG_MODE is True: + luci_log.debug_verbose('VFA0: unable to find a ricci agent for the %s cluster' % clustername) + msg_list.append('\nUnable to contact a ricci agent for cluster "%s"\n\n' % clustername) + else: + batch_id, result = rq.setClusterConf(rc, cc_xml.toxml()) + if batch_id is None or result is None: + if LUCI_DEBUG_MODE is True: + luci_log.debug_verbose('VFA1: setClusterConf: batchid or result is None') + msg_list.append('\nUnable to propagate the new cluster configuration for cluster "%s"\n\n' % clustername) + else: + msg_list.append(' - DONE\n') + cc = cc_xml.toxml() + msg_list.append('\n\nALL DONE\n\n') + else: + if getClusterInfo(self, None, req) == {}: + msg_list.append('invalid cluster') + else: + model = req.SESSION.get('model') + cc = model.exportModelAsString() + + return { 'msg': ''.join(msg_list), 'cluster_conf': cc } + formValidators = { 6: validateCreateCluster, 7: validateConfigCluster, @@ -2600,542 +2640,8 @@ else: return formValidators[pagetype](self, request) - -# Policy for showing the cluster chooser menu: -# 1) If there are no clusters in the ManagedClusterSystems -# folder, then only the admin user may see this menu, and -# the configure option should not be displayed. -# 2)If there are clusters in the ManagedClusterSystems, -# then only display chooser if the current user has -# permissions on at least one. If the user is admin, show ALL clusters - -def createCluChooser(self, request, systems): - dummynode = {} - - if request.REQUEST_METHOD == 'POST': - ret = validatePost(self, request) - try: - request.SESSION.set('checkRet', ret[1]) - except: - request.SESSION.set('checkRet', {}) - else: - try: - request.SESSION.set('checkRet', {}) - except: - pass - - # First, see if a cluster is chosen, then - # check that the current user can access that system - cname = None - try: - cname = request[CLUNAME] - except: - cname = '' - - try: - url = request['URL'] - except: - url = "/luci/cluster/index_html" - - try: - pagetype = request[PAGETYPE] - except: - pagetype = '3' - - cldata = {} - cldata['Title'] = "Cluster List" - cldata['cfg_type'] = "clusters" - cldata['absolute_url'] = '%s?pagetype=%s' % (url, CLUSTERLIST) - cldata['Description'] = "Clusters available for configuration" - if pagetype == CLUSTERLIST: - cldata['currentItem'] = True - else: - cldata['currentItem'] = False - - UserHasPerms = havePermCreateCluster(self) - if UserHasPerms: - cladd = {} - cladd['Title'] = "Create a New Cluster" - cladd['cfg_type'] = "clusteradd" - cladd['absolute_url'] = '%s?pagetype=%s' % (url, CLUSTER_ADD) - cladd['Description'] = "Create a Cluster" - if pagetype == CLUSTER_ADD: - cladd['currentItem'] = True - else: - cladd['currentItem'] = False - - clcfg = {} - clcfg['Title'] = "Configure" - clcfg['cfg_type'] = "clustercfg" - clcfg['absolute_url'] = '%s?pagetype=%s' % (url, CLUSTERS) - clcfg['Description'] = "Configure a cluster" - if pagetype == CLUSTERS: - clcfg['currentItem'] = True - else: - clcfg['currentItem'] = False - - #test... - #clcfg['show_children'] = True - #Add all cluster type pages here: - if pagetype == CLUSTER or pagetype == CLUSTER_CONFIG: - clcfg['show_children'] = True - else: - clcfg['show_children'] = False - - #loop through all clusters - syslist = list() - for system in systems: - clsys = {} - clsys['Title'] = system[0] - clsys['cfg_type'] = "cluster" - clsys['absolute_url'] = '%s?pagetype=%s&clustername=%s' % (url, CLUSTER, system[0]) - clsys['Description'] = "Configure this cluster" - - if pagetype == CLUSTER or pagetype == CLUSTER_CONFIG: - if cname == system[0]: - clsys['currentItem'] = True - else: - clsys['currentItem'] = False - else: - clsys['currentItem'] = False - syslist.append(clsys) - - clcfg['children'] = syslist - - mylist = list() - mylist.append(cldata) - if UserHasPerms: - mylist.append(cladd) - mylist.append(clcfg) - dummynode['children'] = mylist - - return dummynode - -def createCluConfigTree(self, request, model): - dummynode = {} - - if not model: - return {} - - # There should be a positive page type - try: - pagetype = request[PAGETYPE] - except: - pagetype = '3' - - try: - url = request['URL'] - except: - url = "/luci/cluster/index_html" - - # The only way this method can run is if there exists - # a clustername query var - cluname = request['clustername'] - - nd = {} - nd['Title'] = "Nodes" - nd['cfg_type'] = "nodes" - nd['absolute_url'] = '%s?pagetype=%s&clustername=%s' % (url, NODES, cluname) - nd['Description'] = "Node configuration for this cluster" - if pagetype == NODES or pagetype == NODE_GRID or pagetype == NODE_LIST or pagetype == NODE_CONFIG or pagetype == NODE_ADD or pagetype == NODE: - nd['show_children'] = True - else: - nd['show_children'] = False - if pagetype == '0': - nd['show_children'] = False - - if pagetype == NODES: - nd['currentItem'] = True - else: - nd['currentItem'] = False - - - ndadd = {} - ndadd['Title'] = "Add a Node" - ndadd['cfg_type'] = "nodeadd" - ndadd['absolute_url'] = '%s?pagetype=%s&clustername=%s' % (url, NODE_ADD, cluname) - ndadd['Description'] = "Add a node to this cluster" - if pagetype == NODE_ADD: - ndadd['currentItem'] = True - else: - ndadd['currentItem'] = False - - ndcfg = {} - ndcfg['Title'] = "Configure" - ndcfg['cfg_type'] = "nodecfg" - ndcfg['absolute_url'] = '%s?pagetype=%s&clustername=%s' % (url, NODE_CONFIG, cluname) - ndcfg['Description'] = "Configure cluster nodes" - if pagetype == NODE_CONFIG or pagetype == NODE or pagetype == NODES or pagetype == NODE_LIST or pagetype == NODE_GRID or pagetype == NODE_ADD: - ndcfg['show_children'] = True - else: - ndcfg['show_children'] = False - if pagetype == NODE_CONFIG: - ndcfg['currentItem'] = True - else: - ndcfg['currentItem'] = False - - nodes = model.getNodes() - nodenames = list() - for node in nodes: - nodenames.append(node.getName()) - - cfgablenodes = list() - for nodename in nodenames: - cfg = {} - cfg['Title'] = nodename - cfg['cfg_type'] = "node" - cfg['absolute_url'] = '%s?pagetype=%s&nodename=%s&clustername=%s' % (url, NODE, nodename, cluname) - cfg['Description'] = "Configure this cluster node" - if pagetype == NODE: - try: - nname = request['nodename'] - except KeyError, e: - nname = '' - if nodename == nname: - cfg['currentItem'] = True - else: - cfg['currentItem'] = False - else: - cfg['currentItem'] = False - - cfgablenodes.append(cfg) - - #Now add nodename structs as children of the config element - ndcfg['children'] = cfgablenodes - - ndkids = list() - ndkids.append(ndadd) - ndkids.append(ndcfg) - - nd['children'] = ndkids - - ################################################################## - sv = {} - sv['Title'] = "Services" - sv['cfg_type'] = "services" - sv['absolute_url'] = '%s?pagetype=%s&clustername=%s' % (url, SERVICES, cluname) - sv['Description'] = "Service configuration for this cluster" - if pagetype == SERVICES or pagetype == SERVICE_CONFIG or pagetype == SERVICE_ADD or pagetype == SERVICE or pagetype == SERVICE_LIST or pagetype == VM_ADD or pagetype == VM_CONFIG: - sv['show_children'] = True - else: - sv['show_children'] = False - if pagetype == SERVICES or pagetype == SERVICE_LIST: - sv['currentItem'] = True - else: - sv['currentItem'] = False - - svadd = {} - svadd['Title'] = "Add a Service" - svadd['cfg_type'] = "serviceadd" - svadd['absolute_url'] = '%s?pagetype=%s&clustername=%s' % (url, SERVICE_ADD, cluname) - svadd['Description'] = "Add a Service to this cluster" - if pagetype == SERVICE_ADD: - svadd['currentItem'] = True - else: - svadd['currentItem'] = False - - if model.getIsVirtualized() is True: - vmadd = {} - vmadd['Title'] = "Add a Virtual Service" - vmadd['cfg_type'] = "vmadd" - vmadd['absolute_url'] = '%s?pagetype=%s&clustername=%s' % (url, VM_ADD, cluname) - vmadd['Description'] = "Add a Virtual Service to this cluster" - if pagetype == VM_ADD: - vmadd['currentItem'] = True - else: - vmadd['currentItem'] = False - - svcfg = {} - svcfg['Title'] = "Configure a Service" - svcfg['cfg_type'] = "servicecfg" - svcfg['absolute_url'] = '%s?pagetype=%s&clustername=%s' % (url, SERVICE_CONFIG, cluname) - svcfg['Description'] = "Configure a Service for this cluster" - if pagetype == SERVICE_CONFIG or pagetype == SERVICE or pagetype == VM_CONFIG: - svcfg['show_children'] = True - else: - svcfg['show_children'] = False - if pagetype == SERVICE_CONFIG or pagetype == VM_CONFIG: - svcfg['currentItem'] = True - else: - svcfg['currentItem'] = False - - services = model.getServices() - serviceable = list() - - for service in services: - servicename = service.getName() - svc = {} - svc['Title'] = servicename - svc['cfg_type'] = "service" - svc['absolute_url'] = '%s?pagetype=%s&servicename=%s&clustername=%s' % (url, SERVICE, servicename, cluname) - svc['Description'] = "Configure this service" - if pagetype == SERVICE: - try: - sname = request['servicename'] - except KeyError, e: - sname = '' - if servicename == sname: - svc['currentItem'] = True - else: - svc['currentItem'] = False - else: - svc['currentItem'] = False - - serviceable.append(svc) - - vms = model.getVMs() - for vm in vms: - name = vm.getName() - svc = {} - svc['Title'] = name - svc['cfg_type'] = "vm" - svc['absolute_url'] = '%s?pagetype=%s&servicename=%s&clustername=%s' % (url, VM_CONFIG, name, cluname) - svc['Description'] = "Configure this Virtual Service" - if pagetype == VM_CONFIG: - try: - xname = request['servicename'] - except KeyError, e: - xname = '' - if name == xname: - svc['currentItem'] = True - else: - svc['currentItem'] = False - else: - svc['currentItem'] = False - - serviceable.append(svc) - - svcfg['children'] = serviceable - - - - kids = list() - kids.append(svadd) - if model.getIsVirtualized() is True: - kids.append(vmadd) - kids.append(svcfg) - sv['children'] = kids -############################################################# - rv = {} - rv['Title'] = "Resources" - rv['cfg_type'] = "resources" - rv['absolute_url'] = '%s?pagetype=%s&clustername=%s' % (url, RESOURCES, cluname) - rv['Description'] = "Resource configuration for this cluster" - if pagetype == RESOURCES or pagetype == RESOURCE_CONFIG or pagetype == RESOURCE_ADD or pagetype == RESOURCE: - rv['show_children'] = True - else: - rv['show_children'] = False - if pagetype == RESOURCES: - rv['currentItem'] = True - else: - rv['currentItem'] = False - - rvadd = {} - rvadd['Title'] = "Add a Resource" - rvadd['cfg_type'] = "resourceadd" - rvadd['absolute_url'] = '%s?pagetype=%s&clustername=%s' % (url, RESOURCE_ADD, cluname) - rvadd['Description'] = "Add a Resource to this cluster" - if pagetype == RESOURCE_ADD: - rvadd['currentItem'] = True - else: - rvadd['currentItem'] = False - - rvcfg = {} - rvcfg['Title'] = "Configure a Resource" - rvcfg['cfg_type'] = "resourcecfg" - rvcfg['absolute_url'] = '%s?pagetype=%s&clustername=%s' % (url, RESOURCE_CONFIG, cluname) - rvcfg['Description'] = "Configure a Resource for this cluster" - if pagetype == RESOURCE_CONFIG or pagetype == RESOURCE: - rvcfg['show_children'] = True - else: - rvcfg['show_children'] = False - if pagetype == RESOURCE_CONFIG: - rvcfg['currentItem'] = True - else: - rvcfg['currentItem'] = False - - resources = model.getResources() - resourceable = list() - for resource in resources: - resourcename = resource.getName() - rvc = {} - rvc['Title'] = resourcename - rvc['cfg_type'] = "resource" - rvc['absolute_url'] = '%s?pagetype=%s&resourcename=%s&clustername=%s' % (url, RESOURCES, resourcename, cluname) - rvc['Description'] = "Configure this resource" - if pagetype == RESOURCE: - try: - rname = request['resourcename'] - except KeyError, e: - rname = '' - if resourcename == rname: - rvc['currentItem'] = True - else: - rvc['currentItem'] = False - else: - rvc['currentItem'] = False - - resourceable.append(rvc) - rvcfg['children'] = resourceable - - - - kids = list() - kids.append(rvadd) - kids.append(rvcfg) - rv['children'] = kids - ################################################################ - fd = {} - fd['Title'] = "Failover Domains" - fd['cfg_type'] = "failoverdomains" - fd['absolute_url'] = '%s?pagetype=%s&clustername=%s' % (url, FDOMS, cluname) - fd['Description'] = "Failover domain configuration for this cluster" - if pagetype == FDOMS or pagetype == FDOM_CONFIG or pagetype == FDOM_ADD or pagetype == FDOM: - fd['show_children'] = True - else: - fd['show_children'] = False - if pagetype == FDOMS: - fd['currentItem'] = True - else: - fd['currentItem'] = False - - fdadd = {} - fdadd['Title'] = "Add a Failover Domain" - fdadd['cfg_type'] = "failoverdomainadd" - fdadd['absolute_url'] = '%s?pagetype=%s&clustername=%s' % (url, FDOM_ADD, cluname) - fdadd['Description'] = "Add a Failover Domain to this cluster" - if pagetype == FDOM_ADD: - fdadd['currentItem'] = True - else: - fdadd['currentItem'] = False - - fdcfg = {} - fdcfg['Title'] = "Configure a Failover Domain" - fdcfg['cfg_type'] = "failoverdomaincfg" - fdcfg['absolute_url'] = '%s?pagetype=%s&clustername=%s' % (url, FDOM_CONFIG, cluname) - fdcfg['Description'] = "Configure a Failover Domain for this cluster" - if pagetype == FDOM_CONFIG or pagetype == FDOM: - fdcfg['show_children'] = True - else: - fdcfg['show_children'] = False - if pagetype == FDOM_CONFIG: - fdcfg['currentItem'] = True - else: - fdcfg['currentItem'] = False - - fdoms = model.getFailoverDomains() - fdomable = list() - for fdom in fdoms: - fdomname = fdom.getName() - fdc = {} - fdc['Title'] = fdomname - fdc['cfg_type'] = "fdom" - fdc['absolute_url'] = '%s?pagetype=%s&fdomname=%s&clustername=%s' % (url, FDOM, fdomname, cluname) - fdc['Description'] = "Configure this Failover Domain" - if pagetype == FDOM: - try: - fname = request['fdomname'] - except KeyError, e: - fname = '' - if fdomname == fname: - fdc['currentItem'] = True - else: - fdc['currentItem'] = False - else: - fdc['currentItem'] = False - - fdomable.append(fdc) - fdcfg['children'] = fdomable - - - - kids = list() - kids.append(fdadd) - kids.append(fdcfg) - fd['children'] = kids -############################################################# - fen = {} - fen['Title'] = "Shared Fence Devices" - fen['cfg_type'] = "fencedevicess" - fen['absolute_url'] = '%s?pagetype=%s&clustername=%s' % (url, FENCEDEVS, cluname) - fen['Description'] = "Fence Device configuration for this cluster" - if pagetype == FENCEDEVS or pagetype == FENCEDEV_CONFIG or pagetype == FENCEDEV_ADD or pagetype == FENCEDEV: - fen['show_children'] = True - else: - fen['show_children'] = False - if pagetype == FENCEDEVS: - fen['currentItem'] = True - else: - fen['currentItem'] = False - - fenadd = {} - fenadd['Title'] = "Add a Fence Device" - fenadd['cfg_type'] = "fencedeviceadd" - fenadd['absolute_url'] = '%s?pagetype=%s&clustername=%s' % (url, FENCEDEV_ADD, cluname) - fenadd['Description'] = "Add a Fence Device to this cluster" - if pagetype == FENCEDEV_ADD: - fenadd['currentItem'] = True - else: - fenadd['currentItem'] = False - - fencfg = {} - fencfg['Title'] = "Configure a Fence Device" - fencfg['cfg_type'] = "fencedevicecfg" - fencfg['absolute_url'] = '%s?pagetype=%s&clustername=%s' % (url, FENCEDEV_CONFIG, cluname) - fencfg['Description'] = "Configure a Fence Device for this cluster" - if pagetype == FENCEDEV_CONFIG or pagetype == FENCEDEV: - fencfg['show_children'] = True - else: - fencfg['show_children'] = False - if pagetype == FENCEDEV_CONFIG: - fencfg['currentItem'] = True - else: - fencfg['currentItem'] = False - - fences = model.getFenceDevices() - fenceable = list() - for fence in fences: - fencename = fence.getName() - fenc = {} - fenc['Title'] = fencename - fenc['cfg_type'] = "fencedevice" - fenc['absolute_url'] = '%s?pagetype=%s&fencename=%s&clustername=%s' % (url, FENCEDEV, fencename, cluname) - fenc['Description'] = "Configure this Fence Device" - if pagetype == FENCEDEV: - try: - fenname = request['fencename'] - except KeyError, e: - fenname = '' - if fencename == fenname: - fenc['currentItem'] = True - else: - fenc['currentItem'] = False - else: - fenc['currentItem'] = False - - fenceable.append(fenc) - fencfg['children'] = fenceable - - - - kids = list() - kids.append(fenadd) - kids.append(fencfg) - fen['children'] = kids -############################################################# - - mylist = list() - mylist.append(nd) - mylist.append(sv) - mylist.append(rv) - mylist.append(fd) - mylist.append(fen) - - dummynode['children'] = mylist - - return dummynode - def getClusterURL(self, request, model): + try: clustername = request.clustername if not clustername: @@ -3648,83 +3154,7 @@ busy_map['refreshurl'] = '5; url=/luci/cluster?pagetype=3' return busy_map -def getClusterOS(self, rc): - clu_map = {} - - try: - os_str = resolveOSType(rc.os()) - clu_map['os'] = os_str - clu_map['isVirtualized'] = rc.dom0() - except: - # default to rhel5 if something crazy happened. - try: - if LUCI_DEBUG_MODE is True: - luci_log.debug('An error occurred while attempting to get OS/Virt info for %s -- defaulting to rhel5/False' % rc.hostname()) - except: - # this can throw an exception if the original exception - # is caused by rc being None or stale. - pass - clu_map['os'] = 'rhel5' - clu_map['isVirtualized'] = False - return clu_map - -def process_cluster_conf_editor(self, req): - clustername = req['clustername'] - msg_list = list(('\n')) - cc = '' - if 'new_cluster_conf' in req: - cc = req['new_cluster_conf'] - msg_list.append('Checking if valid XML - ') - cc_xml = None - try: - cc_xml = minidom.parseString(cc) - except: - pass - if cc_xml is None: - msg_list.append('FAILED\n') - msg_list.append('Fix the error and try again:\n') - else: - msg_list.append('PASSED\n') - - msg_list.append('Making sure no cluster name change has occurred - ') - new_name = cc_xml.firstChild.getAttribute('name') - if new_name != clustername: - msg_list.append('FAILED\n') - msg_list.append('Fix the error and try again:\n') - else: - msg_list.append('PASSED\n') - - msg_list.append('Incrementing the cluster version number - ') - version = cc_xml.firstChild.getAttribute('config_version') - version = int(version) + 1 - cc_xml.firstChild.setAttribute('config_version', str(version)) - msg_list.append('DONE\n') - - msg_list.append('Propagating the new cluster.conf') - rc = getRicciAgent(self, clustername) - if not rc: - if LUCI_DEBUG_MODE is True: - luci_log.debug_verbose('VFA0: unable to find a ricci agent for the %s cluster' % clustername) - msg_list.append('\nUnable to contact a ricci agent for cluster "%s"\n\n' % clustername) - else: - batch_id, result = rq.setClusterConf(rc, cc_xml.toxml()) - if batch_id is None or result is None: - if LUCI_DEBUG_MODE is True: - luci_log.debug_verbose('VFA1: setClusterConf: batchid or result is None') - msg_list.append('\nUnable to propagate the new cluster configuration for cluster "%s"\n\n' % clustername) - else: - msg_list.append(' - DONE\n') - cc = cc_xml.toxml() - msg_list.append('\n\nALL DONE\n\n') - else: - if getClusterInfo(self, None, req) == {}: - msg_list.append('invalid cluster') - else: - model = req.SESSION.get('model') - cc = model.exportModelAsString() - - return { 'msg': ''.join(msg_list), 'cluster_conf': cc } - +# These are called from external methods. def getResourceInfo(model, request): fvars = GetReqVars(request, [ 'resourcename', 'type', 'value', 'clustername', 'URL' ]) @@ -3750,23 +3180,6 @@ #CALL return {} -def GetReqVars(req, varlist): - ret = {} - for i in varlist: - pval = None - if req.has_key(i): - pval = req[i].strip() - if not pval: - pval = None - if pval is None: - if req.form and req.form.has_key(i): - pval = req.form[i].strip() - if not pval: - pval = None - ret[i] = pval - return ret - -# These are called from external methods. def serviceRestart(self, rc, req): from LuciClusterActions import RestartCluSvc --- conga/luci/site/luci/Extensions/storage_adapters.py 2007/05/15 21:42:21 1.9.4.3 +++ conga/luci/site/luci/Extensions/storage_adapters.py 2007/05/30 22:06:24 1.9.4.4 @@ -357,8 +357,6 @@ return dummynode - - def getStorageURL(self, request, hostname): # return URL to manage this storage system try: