From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 26 Jun 2006 20:10:16 -0000 Subject: [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ... Message-ID: <20060626201016.9929.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 2006-06-26 20:10:15 Modified files: luci/site/luci/Extensions: homebase_adapters.py Log message: Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.5&r2=1.6 --- conga/luci/site/luci/Extensions/homebase_adapters.py 2006/06/22 03:58:41 1.5 +++ conga/luci/site/luci/Extensions/homebase_adapters.py 2006/06/26 20:10:15 1.6 @@ -18,6 +18,9 @@ PLONE_ROOT='luci' +class InCluster(Exception): + pass + from ricci_communicator import CERTS_DIR_PATH def siteIsSetup(self): try: @@ -122,7 +125,7 @@ return (False, {'errors': ['The passwords do not match']}) try: - self.portal_registration.addMember(user, passwd, properties={ 'username': user, 'password': passwd, 'confirm': passwd, 'roles': ['Member'], 'domains':[], 'email': user + '@example.com'}) + self.portal_registration.addMember(user, passwd, properties = { 'username': user, 'password': passwd, 'confirm': passwd, 'roles': ['Member'], 'domains':[], 'email': user + '@example.com' }) except: return (False, {'errors': [ 'Unable to add new user \"' + user + '\"' ] }) @@ -163,11 +166,7 @@ break if len(sysData) == 2 and sysData[0] != '' and sysData[1] != '': - try: - csResult = createClusterSystem(self, clusterName, sysData[0], sysData[1]) - except string, e: - dialog_str = 'The system \"' + sysData[0] + '\" is a member of the cluster \"' + e + '\"\nDo you want to manage the whole cluster?' - return (True, {'dialog': dialog_str }) + csResult = createClusterSystem(self, clusterName, sysData[0], sysData[1]) if csResult: errors.append(csResult) else: @@ -198,7 +197,25 @@ break if len(sysData) == 2 and sysData[0] != '' and sysData[1] != '': - csResult = createSystem(self, sysData[0], sysData[1]) + try: + csResult = createSystem(self, sysData[0], sysData[1]) + except InCluster, e: + csResult = None + host = str(e) + rc = RicciCommunicator(e) + if not rc.authed(): + rc.auth(sysData[1]) + try: + cluConf = getClusterConf(rc) + if cluConf: + nodeList = getClusterConfNodes(cluConf) + if NodeList: + pass + # XXX fix this + #print "other nodes in",cluster_info[0],"::",nodeList + except: + pass + if csResult: errors.append(csResult) else: @@ -584,7 +601,8 @@ return 'Unable to establish a connection to the ricci agent on \"' + host + '\"' try: - rc.auth(passwd) + if not rc.authed(): + rc.auth(passwd) except: return 'Unable to communicate with the ricci agent on \"' + host + '\" for authentication' @@ -593,6 +611,16 @@ except: return 'Unable to authenticate to the ricci agent on \"' + host + '\"' + rhost = rc.system_name() + if rhost and rhost != host: + host = rhost + + try: + exists = self.restrictedTraverse(PLONE_ROOT +'/systems/storage/' + host) + return 'Storage system \"' + host + '\" is already managed.' + except: + pass + if i != True: return 'Authentication for storage system \"' + host + '\" failed' @@ -613,15 +641,10 @@ except: return 'Unable to set permissions on new system \"' + host + '\"' -# sys.stdout = sys.stderr -# cluster_info = rc.cluster_info() -# if cluster_info[0] != '': -# cluConf = getClusterConf(rc) -# if cluConf: -# print cluConf.toxml() -# nodeList = getClusterConfNodes(cluConf) -# sys.stdout = sys.stderr -# print "other nodes in",cluster_info[0],"::",nodeList + cluster_info = rc.cluster_info() + if cluster_info[0] != '': + raise InCluster, host + def createCluster(self, clusterName): try: @@ -630,6 +653,11 @@ return 'Unable to create cluster \"' + clusterName + '\"' try: + newCluster = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName) + if newCluster: + return 'Cluster \"' + clusterName + '\" is already managed by Luci' + + try: clusters.manage_addFolder(clusterName, '__luci__:cluster') newCluster = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName) except: @@ -648,7 +676,8 @@ return 'Unable to establish connection to the ricci agent on \"' + host + '\"' try: - rc.auth(passwd) + if not rc.authed(): + rc.auth(passwd) except: return 'Unable to communicate with the ricci agent on \"' + host + '\" for authentication' @@ -660,6 +689,10 @@ if i != True: return 'Authentication for host \"' + host + '\" failed' + rhost = rc.system_name() + if rhost and rhost != host: + host = rhost + cluster_info = rc.cluster_info() if len(cluster_info) > 0 and cluster_info[0] != '' and cluster_info[0] != cluster: return 'The host \"' + host + '\" is already a member of the cluster \"' + cluster_info[0] + '\"' @@ -688,6 +721,13 @@ return 'Unable to create storage system \"' + host + '\"' try: + newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/' + host) + # It's already there. + return None + except: + pass + + try: ssystem.manage_addFolder(host, '__luci__:system') except: pass