From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 10 Jan 2007 16:00:42 -0000 Subject: [Cluster-devel] conga/luci homebase/luci_homebase.css site/luc ... Message-ID: <20070110160042.21469.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 2007-01-10 16:00:42 Modified files: luci/homebase : luci_homebase.css luci/site/luci/Extensions: cluster_adapters.py Log message: node fence updates Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/luci_homebase.css.diff?cvsroot=cluster&r1=1.32&r2=1.33 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.195&r2=1.196 --- conga/luci/homebase/luci_homebase.css 2007/01/08 21:58:33 1.32 +++ conga/luci/homebase/luci_homebase.css 2007/01/10 16:00:41 1.33 @@ -14,6 +14,10 @@ background: #dee7ec; } +input.pad_left { + margin-left: +.3333em; +} + div.fence { max-width: 700px; padding: .5em; --- conga/luci/site/luci/Extensions/cluster_adapters.py 2007/01/06 03:29:16 1.195 +++ conga/luci/site/luci/Extensions/cluster_adapters.py 2007/01/10 16:00:42 1.196 @@ -23,6 +23,9 @@ from QuorumD import QuorumD from Heuristic import Heuristic from clusterOS import resolveOSType +from Method import Method +from FenceDevice import FenceDevice +from Device import Device from FenceHandler import validateNewFenceDevice, FENCE_OPTS, validateFenceDevice from GeneralError import GeneralError from homebase_adapters import manageCluster, createClusterSystems, havePermCreateCluster, setNodeFlag, delNodeFlag, userAuthenticated, getStorageNode, getClusterNode, delCluster, parseHostForm @@ -1443,14 +1446,54 @@ return (False, {'errors': ['No fence data was supplied.']}) try: + fence_level = int(request.form['fence_level'].strip()) + except Exception, e: + luci_log.debug_verbose('vNFC0a: no fence level: %s' % str(e)) + return (False, {'errors': ['No fence level was supplied.']}) + + try: + nodename = request['nodename'] + if not nodename: + raise Exception, 'nodename is blank' + except Exception, e: + luci_log.debug_verbose('vNFC1: no nodename: %s' % str(e)) + return (False, {'errors': ['No node name was given.']}) + + try: + clustername = request['clustername'] + if not clustername: + raise Exception, 'clustername is blank' + except Exception, e: + luci_log.debug_verbose('vNFC2: no clustername: %s' % str(e)) + return (False, {'errors': ['No cluster name was given.']}) + + try: + model = request.SESSION.get('model') + if not model: + raise Exception, 'model is none' + except Exception, e: + model = None + try: + model = getModelForCluster(self, clustername) + except: + model = None + + if model is None: + luci_log.debug_verbose('vNFC2a: unable to get model for cluster %s' % clustername) + return (False, {'errors': ['No cluster model was found.']}) + + try: doc = minidom.parseString(form_xml) forms = doc.getElementsByTagName('form') if len(forms) < 1: raise except Exception, e: - luci_log.debug_verbose('vNFC1: error: %s' % str(e)) + luci_log.debug_verbose('vNFC2b: error: %s' % str(e)) return (False, {'errors': ['The fence data submitted is not properly formed.']}) + fence_method = Method() + fence_method.addAttribute('name', str(fence_level)) + form_hash = {} for i in forms: form_id = i.getAttribute('name') @@ -1465,19 +1508,126 @@ for i in ielems: try: input_type = str(i.getAttribute('type')) - except: + except Exception, e: + luci_log.debug_verbose('vNFC4: input type: %s' % str(e)) continue + if not input_type or input_type == 'button': continue + try: dummy_form[str(i.getAttribute('name'))] = str(i.getAttribute('value')) except Exception, e: - luci_log.debug_verbose('vNFC2: parsing XML: %s' % str(e)) + luci_log.debug_verbose('vNFC5: parsing XML: %s' % str(e)) + + if len(dummy_form) < 1: + continue + + if 'instance' in dummy_form: + try: + parent = dummy_form['parent_fencedev'] + parent_form = form_hash[parent][1].append(dummy_form) + except: + luci_log.debug_verbose('vNFC6: no parent for instance: %s' \ + % dummy_form['name']) + raise Exception, 'instance has no owner' + else: + form_hash[form_id] = (dummy_form, list()) + + for i in form_hash: + fencedev_name = None + fencedev_unknown = False + fencedev_obj = None + + try: + fence_form, instance_list = form_hash[i] + except Exception, e: + luci_log.debug_verbose('vNFC7: %s' % str(e)) + continue + + try: + fence_type = fence_form['fence_type'] + if not fence_type: + raise Exception, 'fence type is blank' + fence_form['agent'] = fence_type + except Exception, e: + luci_log.debug_verbose('vNFC8: %s' % str(e)) + fence_type = None + + try: + del fence_form['fence_type'] + except: + pass + + fencedev_name = fence_form['name'] + if 'existing_device' in fence_form: + del fence_form['existing_device'] + + if fence_type is None: + # An unknown device. Pull the data out of + # the model and persist it and all instances. + # All we care about is its name. + fencedev_unknown = True + else: + if 'sharable' in fence_form: + # If it's a shared fence device that already exists, the + # user could not have edited it (without playing dirty + # games), so it's safe to pull the existing entry from + # the model. All we need is the device name. + pass + else: + # An existing non-shared device; build up the device + # from scratch since the user could have edited it. + try: + old_name = fence_form['old_name'] + if not old_name: + raise Exception, 'old name is blank' + del fence_form['old_name'] + except Exception, e: + luci_log.debug_verbose('vNFC8: no old name for %s %s' \ + % (fence_form['name'], str(e))) + + fencedev_obj = FenceDevice() + for k in fence_form.keys(): + fencedev_obj.addAttribute(k, fence_form[k]) + else: + # The user created a new fence device. + fencedev_name = fence_form['name'] + fencedev_obj = FenceDevice() + for k in fence_form.keys(): + fencedev_obj.addAttribute(k, fence_form[k]) + + if fencedev_obj is not None: + # If a device with this name exists in the model + # already, replace it with the current object. If + # this block is not executed, we don't need to make + # any changes to the fencedevices block for this + # device + pass + + if fencedev_unknown is True: + # Save any instances for this fence device. + pass + + for inst in instance_list: + new_instance = not 'existing_instance' in inst + try: + del inst['new_instance'] + del inst['parent_fencedev'] + del inst['existing_instance'] + del inst['name'] + except: pass - form_hash[form_id] = dummy_form - luci_log.debug_verbose('vNFC3: got xml: %s' % doc.toxml()) - return (False, { 'errors': [ doc.toxml() ]}) + device_obj = Device() + device_obj.setAgentType(fence_type) + device_obj.addAttribute('name', fencedev_name) + for k in new_instance.keys(): + device_obj.addAttribute(k, inst[k]) + fence_method.addChild(device_obj) + + luci_log.debug_verbose('vNFC7: got xml: %s' % doc.toprettyxml()) + return (False, { 'errors': [ doc.toprettyxml() ]}) def deleteFenceDevice(self, request): errors = list()