From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
Date: 1 Nov 2006 20:34:03 -0000 [thread overview]
Message-ID: <20061101203403.15921.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2006-11-01 20:34:02
Modified files:
luci/site/luci/Extensions: homebase_adapters.py ricci_bridge.py
ricci_communicator.py
Log message:
fixes for bz# 213504
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.37&r2=1.38
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_bridge.py.diff?cvsroot=cluster&r1=1.39&r2=1.40
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_communicator.py.diff?cvsroot=cluster&r1=1.16&r2=1.17
--- conga/luci/site/luci/Extensions/homebase_adapters.py 2006/10/30 20:42:03 1.37
+++ conga/luci/site/luci/Extensions/homebase_adapters.py 2006/11/01 20:34:02 1.38
@@ -13,6 +13,12 @@
from ricci_communicator import CERTS_DIR_PATH
from clusterOS import resolveOSType
from conga_constants import *
+from LuciSyslog import LuciSyslog, LuciSyslogError
+
+try:
+ luci_log = LuciSyslog()
+except LuciSyslogError, e:
+ pass
def siteIsSetup(self):
try:
@@ -136,20 +142,27 @@
pass
def nodeAuth(cluster, host, passwd):
+ messages = list()
systemName = host
os_str = 'rhel5'
try:
rc = RicciCommunicator(host)
if not rc:
- raise
- systemName = rc.system_name()
- except:
- error = 'Unable to establish a connection to the ricci agent on \"' + host + '\"'
- return { 'host': host, 'ricci_host': systemName, 'errors': error, 'cur_auth': False, 'os': os_str }
+ luci_log.debug_verbose('nodeAuth0: rc is None')
+ raise Exception, 'unknown error'
+ except Exception, e:
+ try:
+ error = 'Ricci connection to %s failed: %s' % (host, str(e))
+ except:
+ error = 'Ricci connection to %s failed' % host
+ luci_log.debug_verbose('nodeAuth1: rc failed: %s' % error)
+
+ return { 'host': host, 'ricci_host': host, 'errors': error, 'cur_auth': False, 'os': os_str }
if rc.authed():
prevAuth = True
+ messages.append('Luci is already authenticated to %s -- not checking password' % host)
else:
prevAuth = False
if not passwd:
@@ -157,11 +170,15 @@
else:
try:
rc.auth(passwd)
- except: pass
+ except:
+ pass
if rc.authed():
- os_str = resolveOSType(rc.os())
- if not os_str:
+ try:
+ os_str = resolveOSType(rc.os())
+ if not os_str:
+ raise
+ except:
os_str = "rhel5" #Backup plan in case all is almost lost...
systemName = rc.system_name()
@@ -183,6 +200,7 @@
def validateAddClusterInitial(self, request, must_complete=True):
errors = list()
+ messages = list()
newNodeList = list()
nodeHash = {}
rnodeHash = {}
@@ -196,8 +214,10 @@
try:
rc = RicciCommunicator(sysData[0])
- except:
- return (False, { 'errors': [ 'Unable to establish a connection to the Ricci agent on \"' + sysData[0] + '\"' ] })
+ if not rc:
+ raise Exception, 'unknown error'
+ except Exception, e:
+ return (False, { 'errors': [ 'Unable to establish a connection to the Ricci agent on %s: %s' % (sysData[0], str(e)) ] })
prevAuth = 0
if not rc.authed():
@@ -241,7 +261,7 @@
if systemName[:9] == 'localhost':
systemName = sysData[0]
- node = { 'host': sysData[0], 'ricci_host': systemName, 'prev_auth': prevAuth, 'cur_auth': rc.authed(), 'os': os_str }
+ node = { 'host': rc.hostname(), 'ricci_host': systemName, 'prev_auth': prevAuth, 'cur_auth': rc.authed(), 'os': os_str }
nodeHash[sysData[0]] = node
rnodeHash[systemName] = node
newNodeList.append(node)
@@ -253,6 +273,8 @@
for i in nodeList:
node = nodeAuth(clusterName, i, passwd)
+ if 'messages' in node:
+ messages.extend(node['messages'])
if node['host'] in nodeHash or node['ricci_host'] in rnodeHash:
continue
nodeHash[node['host']] = node
@@ -281,11 +303,11 @@
'isComplete': len(filter(dfn, newNodeList)) == 0
}
- if len(errors) < 1:
+ if len(errors) < len(nodeList):
cluster_properties['redirect'] = HOMEBASE_ADD_CLUSTER
return (len(errors) < 1,
- {'errors': errors, 'requestResults': cluster_properties })
+ {'messages': messages, 'errors': errors, 'requestResults': cluster_properties })
def validateAddCluster(self, request, must_complete=True):
errors = list()
@@ -296,7 +318,8 @@
try:
sessionData = request.SESSION.get('checkRet')
requestResults = sessionData['requestResults']
- except:
+ except Exception, e:
+ luci_log.debug_verbose('VAC0: error getting session obj: %s' % str(e))
try:
clusterName = request.form['clusterName']
except:
@@ -304,24 +327,27 @@
try:
nodeList = requestResults['nodeList']
+ luci_log.debug_verbose('VAC1: unauth to node list')
nodeUnauth(nodeList)
except:
pass
- return (False, { 'errors': [ 'A data integrity error has occurred. Please attempt adding the cluster again.' ], 'requestResults': { 'clusterName': clusterName, 'isComplete': False, 'nodeList': [] } })
+ return (False, { 'errors': [ 'A data integrity error has occurred. Please attempt adding the cluster again.' ], 'requestResults': { 'clusterName': clusterName, 'isComplete': False, 'nodeList': [], 'redirect': HOMEBASE_ADD_CLUSTER_INITIAL } })
try:
clusterName = request.form['clusterName']
if not clusterName:
- raise
- except:
+ raise Exception, 'no cluster name was found'
+ except Exception, e:
+ luci_log.debug_verbose('VAC2: no cluser name found: %s', str(e))
return (False, { 'errors': ['No cluster name was given.'], 'requestResults': requestResults })
try:
nodeList = requestResults['nodeList']
if not nodeList or len(nodeList) < 1:
- raise
- except:
+ raise Exception, 'no node list found'
+ except Exception, e:
+ luci_log.debug_verbose('VAC3: no nodeList found: %s', str(e))
return (False, { 'errors': ['No cluster nodes were given.'], 'requestResults': requestResults })
try:
@@ -338,13 +364,15 @@
try:
numStorage = int(request.form['numStorage'])
if numStorage != len(nodeList):
- raise
- except:
- nodeUnauth(nodeList)
+ raise Exception, 'numstorage != len(nodelist)'
+ except Exception, e:
try:
requestResults['isComplete'] = False
+ luci_log.debug_verbose('VAC4: error: %s' % str(e))
except:
pass
+
+ nodeUnauth(nodeList)
return (False, {
'errors': [ 'Unknown number of nodes entered' ],
'requestResults': requestResults })
@@ -372,8 +400,9 @@
oldNode = rnodeHash[k]
if not oldNode:
+ luci_log.debug_verbose('VAC5: node %s not found', sysData[0])
nodeUnauth(nodeList)
- return (False, { 'errors': [ 'A data integrity error has occurred. Please attempt adding the cluster again.' ], 'requestResults': { 'clusterName': clusterName, 'nodeList': nodeList, 'isComplete': False } })
+ return (False, { 'errors': [ 'A data integrity error has occurred. Please attempt adding the cluster again.' ], 'requestResults': { 'clusterName': clusterName, 'nodeList': nodeList, 'isComplete': False, 'redirect': HOMEBASE_ADD_CLUSTER_INITIAL } })
if oldNode['host'] != node['host']:
del nodeHash[oldNode['host']]
@@ -587,8 +616,11 @@
try:
rc = RicciCommunicator(sysData[0])
- except:
- errors.append('Unable to contact the ricci agent for ' + host)
+ if rc is None:
+ raise Exception, 'unknown error'
+ except Exception, e:
+ errors.append('Unable to contact the ricci agent for %s: %s' \
+ % (sysData[0], str(e)))
i += 1
continue
@@ -658,20 +690,23 @@
except:
sessionData = None
- try:
- request.SESSION.delete('checkRet')
- except:
- pass
-
if 'ACTUAL_URL' in request:
url = request['ACTUAL_URL']
else:
url = '.'
- try:
+ if 'pagetype' in request.form:
pagetype = int(request.form['pagetype'])
+ else:
+ try: request.SESSION.set('checkRet', {})
+ except: pass
+ return homebasePortal(self, request, '.', '0')
+
+ try:
validatorFn = formValidators[pagetype - 1]
except:
+ try: request.SESSION.set('checkRet', {})
+ except: pass
return homebasePortal(self, request, '.', '0')
if validatorFn == validateAddClusterInitial or validatorFn == validateAddCluster:
@@ -699,7 +734,7 @@
return homebaseControlPost(self, request)
try:
- request.SESSION.delete('checkRet')
+ request.SESSION.set('checkRet', {})
except:
pass
@@ -948,8 +983,11 @@
try:
rc = RicciCommunicator(host)
- except:
- return 'Unable to establish a connection to the ricci agent on \"' + host + '\"'
+ if rc is None:
+ raise Exception, 'unknown error'
+ except Exception, e:
+ return 'Unable to establish a connection to the ricci agent on %s: %s' \
+ % (host, str(e))
try:
if not rc.authed():
@@ -977,20 +1015,20 @@
try:
ssystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/')
- except:
- return 'Unable to create storage system \"' + host + '\"'
+ except Exception, e:
+ return 'Unable to create storage system %s: %s' % (host, str(e))
try:
ssystem.manage_addFolder(host, '__luci__:system')
newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/' + host)
- except:
- return 'Unable to create storage system \"' + host + '\"'
+ except Exception, e:
+ return 'Unable to create storage system %s: %s' % (host, str(e))
try:
newSystem.manage_acquiredPermissions([])
newSystem.manage_role('View', ['Access contents information','View'])
- except:
- return 'Unable to set permissions on new system \"' + host + '\"'
+ except Exception, e:
+ return 'Unable to set permissions on storage system %s: %s' % (host, str(e))
return None
@@ -1003,11 +1041,12 @@
def manageCluster(self, clusterName, nodeList):
clusterName = str(clusterName)
+ luci_log.debug_verbose('manageCluster for %s' % clusterName)
try:
clusters = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/')
if not clusters:
- raise
+ raise Exception, 'cannot find the cluster entry in the DB'
except:
nodeUnauth(nodeList)
return 'Unable to create cluster \"' + clusterName + '\": the cluster directory is missing.'
@@ -1024,28 +1063,29 @@
clusters.manage_addFolder(clusterName, '__luci__:cluster')
newCluster = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName)
if not newCluster:
- raise
- except:
+ raise Exception, 'unable to find cluster folder for %s' % clusterName
+ except Exception, e:
nodeUnauth(nodeList)
- return 'Unable to create cluster \"' + clusterName + '\"'
+ return 'Unable to create cluster %s: %s' % (clusterName, str(e))
try:
newCluster.manage_acquiredPermissions([])
newCluster.manage_role('View', ['Access Contents Information','View'])
- except:
+ except Exception, e:
nodeUnauth(nodeList)
try:
clusters.manage_delObjects([clusterName])
except:
pass
- return 'Unable to set permissions on new cluster \"' + clusterName + '\"-- Cluster creation failed'
+ return 'Unable to set permissions on new cluster: %s: %s' % (clusterName, str(e))
- # XXX this needs to be improved.
try:
cluster_os = nodeList[0]['os']
if not cluster_os:
raise KeyError, 'Cluster OS is blank'
except KeyError, e:
+ luci_log.debug_verbose('Warning adding cluster %s: %s' \
+ % (clusterName, str(e)))
cluster_os = 'rhel5'
try:
@@ -1063,23 +1103,24 @@
newCluster.manage_addFolder(host, '__luci__:csystem:' + clusterName)
newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName + '/' + host)
if not newSystem:
- raise 'not there'
+ raise Exception, 'unable to create cluster system DB entry'
newSystem.manage_acquiredPermissions([])
newSystem.manage_role('View', [ 'Access contents information' , 'View' ])
- except:
+ except Exception, e:
nodeUnauth(nodeList)
try:
clusters.manage_delObjects([clusterName])
except:
pass
- return 'Unable to create cluster node \"' + host + '\" for cluster \"' + clusterName + '\" -- Cluster creation failed."'
+ return 'Unable to create cluster node %s for cluster %s: %s' \
+ % (host, clusterName, str(e))
try:
ssystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/')
if not ssystem:
- raise
- except:
- return 'The storage directory is missing.'
+ raise Exception, 'The storage DB entry is missing'
+ except Exception, e:
+ return 'Error adding storage node %s: %s' % (host, str(e))
# Only add storage systems if the cluster and cluster node DB
# objects were added successfully.
@@ -1106,7 +1147,7 @@
try:
clusterObj = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName)
if not clusterObj:
- raise
+ raise Exception, 'cluster %s DB entry is missing' % clusterName
except:
nodeUnauth(nodeList)
return 'No cluster named \"' + clusterName + '\" is managed by Luci'
@@ -1121,18 +1162,22 @@
clusterObj.manage_addFolder(host, '__luci__:csystem:' + clusterName)
newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName + '/' + host)
if not newSystem:
- raise
+ raise Exception, 'cluster node DB entry for %s disappeared from under us' % host
+
newSystem.manage_acquiredPermissions([])
newSystem.manage_role('View', [ 'Access contents information' , 'View' ])
- except:
+ except Exception, e:
nodeUnauth(nodeList)
- return 'Unable to create cluster node \"' + host + '\" for cluster \"' + clusterName + '\"'
+ return 'Unable to create cluster node %s for cluster %s: %s' \
+ % (host, clusterName, str(e))
try:
ssystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/')
if not ssystem:
- raise
- except:
+ raise Exception, 'storage DB entry is missing'
+ except Exception, e:
+ luci_log.debug_verbose('Error: adding storage DB node for %s: %s' \
+ % (host, str(e)))
return
# Only add storage systems if the and cluster node DB
@@ -1160,19 +1205,20 @@
try:
ssystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/')
if not ssystem:
- raise
- except:
- return 'Unable to find storage system \"' + systemName + '\"'
+ raise Exception, 'storage DB entry is missing'
+ except Exception, e:
+ return 'Unable to find storage system %s: %s' % (systemName, str(e))
try:
rc = RicciCommunicator(systemName)
- if not rc:
- raise
- except:
+ if rc is None:
+ raise Exception, 'unknown error'
+ except Exception, e:
try:
ssystem.manage_delObjects([systemName])
except:
return 'Unable to delete the storage system \"' + systemName + '\"'
+ luci_log.debug_verbose('ricci error for %s: %s' % (systemName, str(e)))
return
# Only unauthenticate if the system isn't a member of
@@ -1190,8 +1236,9 @@
try:
ssystem.manage_delObjects([systemName])
- except:
- return 'Unable to delete storage system \"' + systemName + '\"'
+ except Exception, e:
+ return 'Unable to delete storage system %s: %s' \
+ % (systemName, str(e))
def delCluster(self, clusterName):
try:
@@ -1218,25 +1265,33 @@
try:
rc = RicciCommunicator(systemName)
rc.unauth()
- except: pass
- cluster.manage_delObjects([systemName])
+ except Exception, e:
+ luci_log.debug_verbose('ricci error for %s: %s' \
+ % (systemName, str(e)))
+
+ try:
+ cluster.manage_delObjects([systemName])
+ except Exception, e:
+ err_str = 'Error deleting cluster object %s: %s' % (systemName, str(e))
+ luci_log.debug_verbose(err_str)
+ return err_str
def delClusterSystems(self, clusterName):
try:
cluster = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName)
if not cluster:
- raise
+ raise Exception, 'cluster DB entry is missing'
csystems = getClusterSystems(self, clusterName)
- except:
+ except Exception, e:
+ luci_log.debug_verbose('delCluSysterms: error for %s: %s' \
+ % (clusterName, str(e)))
return 'Unable to find any systems for cluster \"' + clusterName + '\"'
errors = ''
for i in csystems:
- try:
- delClusterSystem(self, cluster, i[0])
- except:
- errors += 'Unable to delete the cluster system \"' + i[0] + '\"\n'
-
+ err = delClusterSystem(self, cluster, i[0])
+ if err:
+ errors += 'Unable to delete the cluster system %s: %s\n' % (i[0], err)
return errors
def getDefaultUser(self, request):
--- conga/luci/site/luci/Extensions/ricci_bridge.py 2006/10/31 13:51:53 1.39
+++ conga/luci/site/luci/Extensions/ricci_bridge.py 2006/11/01 20:34:02 1.40
@@ -507,13 +507,22 @@
batch.appendChild(module)
# temporary workaround for ricci bug
- system_info = rc.system_name()
- rc = RicciCommunicator(system_info)
+ system_info = rc.hostname()
+ try:
+ rc = RicciCommunicator(system_info)
+ if rc is None:
+ raise Exception, 'unknown error'
+ except Exception, e:
+ luci_log.debug_verbose('Ricci error while connecting to %s: %s' \
+ % (system_info, str(e)))
+ return None
# end workaround
try:
ret = rc.process_batch(batch)
except Exception, e:
+ luci_log.debug_verbose('process_batch error for %s: %s' \
+ % (system_info, str(e)))
return None
if not ret:
--- conga/luci/site/luci/Extensions/ricci_communicator.py 2006/10/31 17:18:12 1.16
+++ conga/luci/site/luci/Extensions/ricci_communicator.py 2006/11/01 20:34:02 1.17
@@ -32,6 +32,10 @@
except Exception, e:
raise RicciError, 'Error connecting to %s:%d: %s' \
% (self.__hostname, self.__port, str(e))
+ except:
+ raise RicciError, 'Error connecting to %s:%d: unknown error' \
+ % (self.__hostname, self.__port)
+
luci_log.debug_verbose('Connected to %s:%d' \
% (self.__hostname, self.__port))
try:
@@ -42,6 +46,9 @@
except Exception, e:
raise RicciError, 'Error setting up SSL for connection to %s: %s' \
% (self.__hostname, str(e))
+ except:
+ raise RicciError, 'Error setting up SSL for connection to %s' \
+ % self.__hostname
# receive ricci header
hello = self.__receive()
@@ -168,6 +175,8 @@
% (doc.toxml(), self.__hostname))
raise RicciError, 'Error sending XML to host %s: %s' \
% (self.__hostname, str(e))
+ except:
+ raise RicciError, 'Error sending XML to host %s' % self.__hostname
# receive response
doc = self.__receive()
@@ -264,8 +273,11 @@
try:
pos = self.ss.write(buff)
except Exception, e:
- luci_log.debug('Error sending XML \"%s\" to %s' \
- % (buff, self.__hostname))
+ luci_log.debug('Error sending XML \"%s\" to %s: %s' \
+ % (buff, self.__hostname, str(e)))
+ raise RicciError, 'write error while sending XML to host %s' \
+ % self.__hostname
+ except:
raise RicciError, 'write error while sending XML to host %s' \
% self.__hostname
buff = buff[pos:]
@@ -294,8 +306,9 @@
except Exception, e:
luci_log.debug('Error reading data from %s: %s' \
% (self.__hostname, str(e)))
- raise RicciError, 'Error reading data from host %s' \
- % self.__hostname
+ raise RicciError, 'Error reading data from host %s' % self.__hostname
+ except:
+ raise RicciError, 'Error reading data from host %s' % self.__hostname
luci_log.debug_verbose('Received XML \"%s\" from host %s' \
% (xml_in, self.__hostname))
next reply other threads:[~2006-11-01 20:34 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-01 20:34 rmccabe [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-04-21 18:19 [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt rmccabe
2008-02-05 20:59 rmccabe
2007-06-06 15:14 rmccabe
2007-01-29 22:06 rmccabe
2007-01-08 19:49 rmccabe
2007-01-08 19:46 rmccabe
2006-11-02 21:12 rmccabe
2006-10-30 20:20 rmccabe
2006-10-26 16:57 rmccabe
2006-10-16 15:18 rmccabe
2006-10-13 17:12 rmccabe
2006-10-11 21:48 rmccabe
2006-10-11 18:44 rmccabe
2006-10-06 20:45 rmccabe
2006-10-06 18:58 rmccabe
2006-10-04 13:25 jparsons
2006-08-01 16:27 rmccabe
2006-07-27 13:37 jparsons
2006-07-26 19:50 rmccabe
2006-07-25 17:45 rmccabe
2006-07-18 19:26 rmccabe
2006-06-27 20:53 rmccabe
2006-06-27 20:47 rmccabe
2006-06-27 17:49 rmccabe
2006-06-26 20:10 rmccabe
2006-06-22 3:58 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=20061101203403.15921.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.