From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 12 Oct 2006 19:40:46 -0000 Subject: [Cluster-devel] conga/luci/site/luci/Extensions cluster_adapte ... Message-ID: <20061012194046.4424.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-10-12 19:40:44 Modified files: luci/site/luci/Extensions: cluster_adapters.py conga_constants.py homebase_adapters.py Log message: - save the cluster OS in the database so that we can compare it against nodes that are added after the cluster is initially deployed. - move some constants into the conga_constants.py file Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.103&r2=1.104 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_constants.py.diff?cvsroot=cluster&r1=1.14&r2=1.15 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.28&r2=1.29 --- conga/luci/site/luci/Extensions/cluster_adapters.py 2006/10/12 17:27:26 1.103 +++ conga/luci/site/luci/Extensions/cluster_adapters.py 2006/10/12 19:40:44 1.104 @@ -247,7 +247,7 @@ sessionData = None if 'clusterName' in request.form: - clusterName = request.form['clusterName'] + clusterName = str(request.form['clusterName']) else: return (False, {'errors': [ 'Cluster name is missing'], 'requestResults': requestResults }) @@ -285,7 +285,24 @@ raise except: errors.append('You must specify at least one valid node to add to the cluster') - + + try: + clusterObj = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName) + cluster_os = clusterObj.manage_getProperty('cluster_os') + if not cluster_os: + raise Exception, 'no cluster OS was found.' + try: + if len(filter(lambda x: x['os'] != cluster_os, nodeList)) > 0: + raise Exception, 'different operating systems were detected.' + except: + nodeUnauth(nodeList) + cluster_properties['isComplete'] = False + errors.append('Cluster nodes must be running compatible operating systems.') + except: + nodeUnauth(nodeList) + cluster_properties['isComplete'] = False + errors.append('Unable to determine the cluster OS for the ' + clusterName + ' cluster.') + if not cluster_properties['isComplete']: return (False, {'errors': errors, 'requestResults': cluster_properties}) --- conga/luci/site/luci/Extensions/conga_constants.py 2006/10/12 15:45:49 1.14 +++ conga/luci/site/luci/Extensions/conga_constants.py 2006/10/12 19:40:44 1.15 @@ -90,3 +90,14 @@ POSSIBLE_REBOOT_MESSAGE="This node is not currently responding and is probably
rebooting as planned. This state should persist for 5 minutes or so..." + + +HOMEBASE_ADD_USER="1" +HOMEBASE_ADD_SYSTEM="2" +HOMEBASE_PERMS="3" +HOMEBASE_DEL_USER="4" +HOMEBASE_DEL_SYSTEM="5" +HOMEBASE_ADD_CLUSTER="6" +HOMEBASE_ADD_CLUSTER_INITIAL="7" + +PLONE_ROOT='luci' --- conga/luci/site/luci/Extensions/homebase_adapters.py 2006/10/11 21:48:04 1.28 +++ conga/luci/site/luci/Extensions/homebase_adapters.py 2006/10/12 19:40:44 1.29 @@ -11,16 +11,7 @@ from ricci_communicator import RicciCommunicator from ricci_communicator import CERTS_DIR_PATH from clusterOS import resolveOSType - -HOMEBASE_ADD_USER="1" -HOMEBASE_ADD_SYSTEM="2" -HOMEBASE_PERMS="3" -HOMEBASE_DEL_USER="4" -HOMEBASE_DEL_SYSTEM="5" -HOMEBASE_ADD_CLUSTER="6" -HOMEBASE_ADD_CLUSTER_INITIAL="7" - -PLONE_ROOT='luci' +from conga_constants import * class InCluster(Exception): pass @@ -959,6 +950,19 @@ pass return 'Unable to set permissions on new cluster \"' + clusterName + '\"-- Cluster creation failed' + # 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: + cluster_os = 'rhel5' + + try: + newCluster.manage_addProperty('cluster_os', cluster_os, 'string') + except: + pass # we were unable to set the OS property string on this cluster + for i in nodeList: if 'ricci_host' in i: host = str(i['ricci_host'])