All of lore.kernel.org
 help / color / mirror / Atom feed
From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci/site/luci/Extensions LuciClusterInf ...
Date: 3 Jul 2007 17:06:01 -0000	[thread overview]
Message-ID: <20070703170601.7894.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-07-03 17:06:00

Modified files:
	luci/site/luci/Extensions: LuciClusterInfo.py PropsObject.py 
	                           cluster_adapters.py 
	luci/site/luci/Extensions/ClusterModel: ModelBuilder.py 
Removed files:
	luci/site/luci/Extensions/ClusterModel: GeneralError.py 

Log message:
	More cleanup.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciClusterInfo.py.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/PropsObject.py.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.259&r2=1.260
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/GeneralError.py.diff?cvsroot=cluster&r1=1.2&r2=NONE

--- conga/luci/site/luci/Extensions/LuciClusterInfo.py	2007/06/28 19:31:45	1.4
+++ conga/luci/site/luci/Extensions/LuciClusterInfo.py	2007/07/03 17:05:59	1.5
@@ -6,7 +6,6 @@
 # Free Software Foundation.
 
 from Products.Archetypes.utils import make_uuid
-from ClusterModel.GeneralError import GeneralError
 from ClusterModel.ModelBuilder import ModelBuilder
 import RicciQueries as rq
 from ricci_communicator import RicciCommunicator
@@ -1146,7 +1145,7 @@
 	# is returned.
 	try:
 		node = model.retrieveNodeByName(nodename)
-	except GeneralError, e:
+	except Exception, e:
 		if LUCI_DEBUG_MODE is True:
 			luci_log.debug_verbose('getFenceInfo3: unable to find node name "%s" in current node list: %r %s' % (str(nodename), e, str(e)))
 		return {}
--- conga/luci/site/luci/Extensions/PropsObject.py	2007/06/25 16:03:38	1.3
+++ conga/luci/site/luci/Extensions/PropsObject.py	2007/07/03 17:05:59	1.4
@@ -7,8 +7,7 @@
 
 from Variable import parse_variable
 from ricci_defines import PROPS_TAG
-import xml
-import xml.dom
+from xml.dom.Node import ELEMENT_NODE
 
 class PropsObject:
 
@@ -36,7 +35,7 @@
     def import_xml(self, parent_node):
         props = None
         for node in parent_node.childNodes:
-            if node.nodeType == xml.dom.Node.ELEMENT_NODE:
+            if node.nodeType == ELEMENT_NODE:
                 if node.nodeName == str(PROPS_TAG):
                     props = node
         if props is None:
@@ -48,4 +47,3 @@
             except:
                 continue
         return self
-
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2007/06/28 19:31:45	1.259
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2007/07/03 17:05:59	1.260
@@ -19,7 +19,6 @@
 from ClusterModel.Heuristic import Heuristic
 from ClusterModel.Fence import Fence
 from ClusterModel.Method import Method
-from ClusterModel.GeneralError import GeneralError
 
 import RicciQueries as rq
 from HelperFunctions import resolveOSType
@@ -708,32 +707,28 @@
 		return (False, { 'errors': errors, 'messages': messages })
 
 	buildClusterCreateFlags(self, batch_id_map, clustername)
-
 	response = request.RESPONSE
 	response.redirect('%s?pagetype=%s&clustername=%s&busyfirst=true' \
 		% (request['URL'], CLUSTER_CONFIG, clustername))
 
 def validateServiceAdd(self, request):
 	errors = list()
+	fvar = GetReqVars(request, [ 'form_xml', 'clustername', 'domain', 'recovery', 'svc_name', 'action', 'URL' ])
 
-	try:
-		form_xml = request['form_xml'].strip()
-		if not form_xml:
-			raise KeyError, 'form_xml must not be blank'
-	except Exception, e:
+	baseurl = fvar['URL'] or LUCI_CLUSTER_BASE_URL
+	clustername = fvar['clustername']
+
+	form_xml = fvar['form_xml']
+	if form_xml is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('vSA0: no form_xml: %r %s' \
-				% (e, str(e)))
+			luci_log.debug_verbose('vSA0: no form_xml')
 		return (False, { 'errors': [ 'No resource data was supplied for this service' ]})
 
-	try:
-		model = request.SESSION.get('model')
-		if not model:
-			raise Exception, 'model is None'
-	except Exception, e:
+	model = LuciExtractCluModel(self, request, clustername)
+	if model is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('vSA0a: %r %s' % (e, str(e)))
-		return (False, { 'errors': [ 'The cluster model is missing from the session object' ]})
+			luci_log.debug_verbose('vSA1: no model')
+		return (False, {'errors': ['No cluster model was found']})
 
 	try:
 		doc = minidom.parseString(form_xml)
@@ -816,32 +811,17 @@
 	if len(errors) > 0:
 		return (False, {'errors': errors})
 
-	fdom = None
-	try:
-		fdom = request.form['domain'].strip()
-		if not fdom:
-			raise Exception, 'blank'
-	except:
-		fdom = None
+	fdom = fvar['domain']
 
-	recovery = None
-	try:
-		recovery = request.form['recovery'].strip()
-		if not recovery:
-			recovery = None
-		else:
-			if recovery != 'restart' and recovery != 'relocate' and recovery != 'disable':
-				errors.append('You entered an invalid recovery option: "%s" Valid options are "restart" "relocate" and "disable."')
-	except:
-		recovery = None
+	recovery = fvar['recovery']
+	if recovery is not None and recovery != 'restart' and recovery != 'relocate' and recovery != 'disable':
+		errors.append('You entered an invalid recovery option: "%s" Valid options are "restart" "relocate" and "disable."')
 
-	try:
-		service_name = request.form['svc_name'].strip()
-	except Exception, e:
+	service_name = fvar['svc_name']
+	if service_name is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('vSA5: no service name: %r %s' \
-				% (e, str(e)))
-		return (False, { 'errors': [ 'No service name was given' ]})
+			luci_log.debug_verbose('vSA5: no service name')
+		errors.append('No service name was given')
 
 	autostart = '1'
 	try:
@@ -864,34 +844,28 @@
 
 	try:
 		cur_service = model.retrieveServiceByName(service_name)
-	except GeneralError, e:
-		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('vSA5b: no service named %s found: %r %s' \
-				% (service_name, e, str(e)))
-		cur_service = None
 	except Exception, e:
 		if LUCI_DEBUG_MODE is True:
 			luci_log.debug_verbose('vSA5c: no service named %s found: %r %s' \
 				% (service_name, e, str(e)))
 		cur_service = None
 
-	try:
-		if request.form['action'] == 'edit':
-			if cur_service is None:
-				return (False, {'errors': [ 'The service %s could not be found for editing' % service_name ]})
-			model.deleteService(service_name)
-		elif request.form['action'] == 'add':
-			if cur_service is not None:
-				return (False, {'errors': [ 'A service with the name %s already exists' % service_name ]})
-		else:
-			if LUCI_DEBUG_MODE is True:
-				luci_log.debug_verbose('vSA4a: unknown action %s' \
-					% request.form['action'])
-			return (False, {'errors': [ 'An unknown action was specified' ]})
-	except Exception, e:
-		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('vSA5: no action type: %r %s' \
-				% (e, str(e)))
+	action = fvar['action']
+	if action is None:
+		return (False, {'errors': [ 'No action was given for service %s' % service_name ] })
+
+	if action == 'edit':
+		if cur_service is None:
+			return (False, {'errors': [ 'The service %s could not be found for editing' % service_name ]})
+		model.deleteService(service_name)
+	elif action == 'add':
+		if cur_service is not None:
+			return (False, {'errors': [ 'A service with the name %s already exists' % service_name ]})
+	else:
+		if LUCI_DEBUG_MODE is True:
+			luci_log.debug_verbose('vSA4a: unknown action %s' \
+				% request.form['action'])
+		return (False, {'errors': [ 'An unknown action was specified' ]})
 
 	def buildSvcTree(parent, child_id_list):
 		for i in child_id_list:
@@ -921,7 +895,7 @@
 	model.resourcemanager_ptr.addChild(new_service)
 	model.setModified(True)
 
-	if request.form['action'].strip().lower() == 'edit':
+	if action == 'edit':
 		action_type = SERVICE_CONFIG
 		action_msg = 'Configuring service "%s"'
 	else:
@@ -935,7 +909,7 @@
 
 	response = request.RESPONSE
 	response.redirect('%s?pagetype=%s&clustername=%s&busyfirst=true' \
-		% (request['URL'], SERVICES, model.getClusterName()))
+		% (baseurl, SERVICES, model.getClusterName()))
 
 def validateResourceAdd(self, request):
 	try:
@@ -972,15 +946,12 @@
 			luci_log.debug_verbose('resource error: %r %s' % (e, str(e)))
 		return (False, { 'errors': errors})
 
-
 	return (True, { 'messages': [ 'Resource added successfully' ]})
 
-
 ## Cluster properties form validation routines
 
 # rhel5 cluster version
 def validateMCastConfig(model, form):
-	import socket
 	try:
 		gulm_ptr = model.getGULMPtr()
 		if gulm_ptr:
@@ -1002,6 +973,7 @@
 		return (False, {'errors': errors})
 
 	if mcast_manual is True:
+		import socket
 		try:
 			addr_str = form['mcast_address'].strip()
 			socket.inet_pton(socket.AF_INET, addr_str)
@@ -1264,13 +1236,13 @@
 		errors.append(str(e))
 
 	try:
-		token_retransmits_before_loss_const = form['token_retransmits_before_loss_const'].strip()
-		if not token_retransmits_before_loss_const:
+		trblc = form['token_retransmits_before_loss_const'].strip()
+		if not trblc:
 			raise KeyError, 'token_retransmits_before_loss_const'
-		token_retransmits_before_loss_const = int(token_retransmits_before_loss_const)
-		if token_retransmits_before_loss_const < 1:
-			raise ValueError, '%d is an invalid value for number of token retransmits before loss' % token_retransmits_before_loss_const
-		totem.addAttribute('token_retransmits_before_loss_const', str(token_retransmits_before_loss_const))
+		trblc = int(trblc)
+		if trblc < 1:
+			raise ValueError, '%d is an invalid value for number of token retransmits before loss' % trblc
+		totem.addAttribute('token_retransmits_before_loss_const', str(trblc))
 	except KeyError, e:
 		try:
 			totem.removeAttribute('token_retransmits_before_loss_const')
@@ -1377,7 +1349,7 @@
 		return (False, {'errors': [ 'This cluster appears not to be using GULM locking' ]})
 
 	node_list = map(lambda x: x.getName(), gulm_ptr.getChildren())
-	for i in map(lambda x: x.getName(), model.getNodes()):
+	for i in model.getNodeNames():
 		if not i in node_list:
 			node_list.append(i)
 
@@ -1498,35 +1470,28 @@
 
 def validateFenceAdd(self, request):
 	errors = list()
+	fvar = GetReqVars(request, [ 'clustername', 'URL' ])
 
-	model = LuciExtractCluModel(self, request)
+	baseurl = fvar['URL'] or LUCI_CLUSTER_BASE_URL
+	clustername = fvar['clustername']
 
+	model = LuciExtractCluModel(self, request, clustername)
 	if not model:
 		if LUCI_DEBUG_MODE is True:
 			luci_log.debug_verbose('VFE0: no model')
-		return (False, [ 'No cluster model was found' ])
-
-	if not request.form:
-		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('VFE: no form was submitted')
-		return (False, [ 'No form was submitted' ])
+		return (False, { 'errors': [ 'No cluster model was found' ] })
 
 	ret_code, ret_obj = validateNewFenceDevice(request.form, model)
 	if ret_code != FD_VAL_SUCCESS:
 		errors.extend(ret_obj)
-		return (False, errors)
+		return (False, { 'errors': errors })
 
-	try:
-		conf_str = str(model.exportModelAsString())
-		if not conf_str:
-			raise Exception, 'conf_str is none'
-	except Exception, e:
-		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('VFE: export model as string failed: %r %s' \
-				% (e, str(e)))
-		errors.append('Unable to store the new cluster configuration')
+	ret = propagateClusterConfAsync(self, model, None,
+			CLUSTER_CONFIG, 'Creating fence device "%s"' % ret_obj)
+	if ret[0] is not True:
+		return ret
 
-	request.RESPONSE.redirect('%s?pagetype=%s&clustername=%s&fencename=%s&busyfirst=true' % (request['URL'], FENCEDEV, model.getClusterName(), ret_obj))
+	request.RESPONSE.redirect('%s?pagetype=%s&clustername=%s&fencename=%s&busyfirst=true' % (baseurl, FENCEDEV, clustername, ret_obj))
 
 def validateFenceEdit(self, request):
 	errors = list()
@@ -2217,9 +2182,7 @@
 				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))
+				model.setModified(True)
 				msg_list.append('DONE\n')
 
 				msg_list.append('Propagating the new cluster.conf')
@@ -2282,9 +2245,8 @@
 		return formValidators[pagetype](self, request)
 
 def getClusterURL(self, request, model):
-	
 	try:
-		clustername = request.clustername
+		clustername = request['clustername'].strip()
 		if not clustername:
 			raise Exception, 'cluster name from request is blank'
 	except:
--- conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py	2007/06/27 08:14:13	1.3
+++ conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py	2007/07/03 17:06:00	1.4
@@ -48,7 +48,6 @@
 from FailoverDomains import FailoverDomains
 from FailoverDomainNode import FailoverDomainNode
 from Rm import Rm
-from GeneralError import GeneralError
 
 DLM_TYPE	= 0
 GULM_TYPE	= 1
@@ -563,7 +562,7 @@
       if svc.getName() == name:
         return svc
 
-    raise GeneralError('FATAL', "Couldn't find service name in current list")
+    raise KeyError, 'Couldn\'t find service name %s in current list' % name
 
   def retrieveVMsByName(self, name):
     vms = self.getVMs()
@@ -571,7 +570,7 @@
       if v.getName() == name:
         return v
 
-    raise GeneralError('FATAL', "Couldn't find VM name %s in current list" % name)
+    raise KeyError, 'Couldn\'t find VM name %s in current list' % name
 
   def del_totem(self):
     if self.TOTEM_ptr is not None:



             reply	other threads:[~2007-07-03 17:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-03 17:06 rmccabe [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-09-21 16:06 [Cluster-devel] conga/luci/site/luci/Extensions LuciClusterInf rmccabe
2007-07-26  5:52 rmccabe
2007-07-16 21:35 rmccabe
2007-06-28 19:31 rmccabe
2007-06-08 18:27 rmccabe
2007-05-30 22:06 rmccabe
2007-05-16 21:27 rmccabe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070703170601.7894.qmail@sourceware.org \
    --to=rmccabe@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.