[Cluster-devel] conga/luci/site/luci/Extensions FenceHandler.p ...
rmccabe at sourceware.org
rmccabe at sourceware.org
Tue May 15 21:42:35 UTC 2007
CVSROOT: /cvs/cluster
Module name: conga
Branch: EXPERIMENTAL
Changes by: rmccabe at sourceware.org 2007-05-15 21:42:21
Modified files:
luci/site/luci/Extensions: FenceHandler.py HelperFunctions.py
LuciClusterActions.py
LuciClusterInfo.py LuciDB.py
LuciSyslog.py LuciZope.py
PropsObject.py ResourceHandler.py
RicciQueries.py StorageReport.py
Variable.py cluster_adapters.py
conga_constants.py conga_ssl.py
conga_storage_constants.py
homebase_adapters.py
ricci_communicator.py
ricci_defines.py storage_adapters.py
system_adapters.py
luci/site/luci/Extensions/ClusterModel: BaseResource.py
Cluster.py
ClusterNode.py
FailoverDomainNode.py
FailoverDomains.py
FenceDevice.py
ModelBuilder.py
TagObject.py
Added files:
luci/site/luci/Extensions: LuciZopePerm.py
Log message:
More cleanup and refactor.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZopePerm.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FenceHandler.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.18.2.1&r2=1.18.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/HelperFunctions.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.6.4.2&r2=1.6.4.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciClusterActions.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciClusterInfo.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciDB.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.5&r2=1.1.2.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciSyslog.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.11.4.1&r2=1.11.4.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZope.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.3&r2=1.1.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/PropsObject.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.2.8.2&r2=1.2.8.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ResourceHandler.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/RicciQueries.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/StorageReport.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.23.2.2&r2=1.23.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/Variable.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.4.8.2&r2=1.4.8.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.255.2.4&r2=1.255.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_constants.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.39.2.3&r2=1.39.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_ssl.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.2.4.1&r2=1.2.4.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_storage_constants.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.8.8.1&r2=1.8.8.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.50.2.3&r2=1.50.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_communicator.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.25.2.3&r2=1.25.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_defines.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.8.1&r2=1.1.8.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/storage_adapters.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.9.4.2&r2=1.9.4.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/system_adapters.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.2.2.2&r2=1.2.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/BaseResource.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/Cluster.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/ClusterNode.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/FailoverDomainNode.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/FailoverDomains.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/FenceDevice.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.3&r2=1.1.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/TagObject.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
--- conga/luci/site/luci/Extensions/FenceHandler.py 2007/05/03 20:16:38 1.18.2.1
+++ conga/luci/site/luci/Extensions/FenceHandler.py 2007/05/15 21:42:21 1.18.2.2
@@ -1,3 +1,10 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from ClusterModel.Device import Device
FD_VAL_FAIL = 1
--- conga/luci/site/luci/Extensions/HelperFunctions.py 2007/05/04 19:10:24 1.6.4.2
+++ conga/luci/site/luci/Extensions/HelperFunctions.py 2007/05/15 21:42:21 1.6.4.3
@@ -1,3 +1,10 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from ricci_communicator import RicciCommunicator
import threading
@@ -67,7 +74,7 @@
trusted = False
ricci = ss[hostname]
- if ricci != None:
+ if ricci is not None:
OS = ricci.os()
cluname = ricci.cluster_info()[0]
cluali = ricci.cluster_info()[1]
@@ -81,9 +88,9 @@
'hostname' : hostname,
'OS' : OS,
'cluname' : cluname,
- 'key_fp' : key_fp,
- 'clualias' : cluali,
- 'available' : ricci != None,
+ 'key_fp' : key_fp,
+ 'clualias' : cluali,
+ 'available' : ricci is not None,
'trusted' : trusted,
'authed' : authed
}
--- conga/luci/site/luci/Extensions/Attic/LuciClusterActions.py 2007/05/14 18:00:14 1.1.2.2
+++ conga/luci/site/luci/Extensions/Attic/LuciClusterActions.py 2007/05/15 21:42:21 1.1.2.3
@@ -1,3 +1,10 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
import RicciQueries as rq
from LuciDB import set_node_flag, getRicciAgent
from LuciSyslog import get_logger
--- conga/luci/site/luci/Extensions/Attic/LuciClusterInfo.py 2007/05/14 18:00:14 1.1.2.2
+++ conga/luci/site/luci/Extensions/Attic/LuciClusterInfo.py 2007/05/15 21:42:21 1.1.2.3
@@ -1,8 +1,16 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from ClusterModel.GeneralError import GeneralError
import RicciQueries as rq
from ricci_communicator import RicciCommunicator
from FenceHandler import FENCE_OPTS
from LuciSyslog import get_logger
+from LuciDB import resolve_nodename
from conga_constants import CLUNAME, CLUSTER_CONFIG, CLUSTER_DELETE, \
CLUSTER_PROCESS, CLUSTER_RESTART, CLUSTER_START, CLUSTER_STOP, \
@@ -13,7 +21,7 @@
PROP_FENCE_TAB, PROP_GENERAL_TAB, PROP_GULM_TAB, PROP_MCAST_TAB, \
PROP_QDISK_TAB, RESOURCE, RESOURCE_CONFIG, RESOURCE_REMOVE, \
SERVICE, SERVICE_DELETE, SERVICE_MIGRATE, SERVICE_RESTART, \
- SERVICE_START, SERVICE_STOP, VM_CONFIG
+ SERVICE_START, SERVICE_STOP, VM_CONFIG, LUCI_DEBUG_MODE
luci_log = get_logger()
@@ -226,7 +234,7 @@
rc_map['name'] = child.getName()
#Note: Final version needs all resource attrs
- if child.isRefObject() == True:
+ if child.isRefObject() is True:
rc_map['ref_object'] = True
rc_map['tag_name'] = child.getObj().TAG_NAME
rc_map['type'] = child.getObj().getResourceType()
@@ -369,7 +377,7 @@
try:
if int(svc.getAttribute('exclusive')):
- hmap['exclusive'] = 'true'
+ hmap['exclusive'] = 'true'
else:
hmap['exclusive'] = 'false'
except:
@@ -757,7 +765,7 @@
if (item['type'] == "node") and (item['name'] == nodename):
found = True
break
- if found == False:
+ if found is False:
luci_log.debug_verbose('getNodeInfo1: Unable to resolve node name in cluster status')
return {}
@@ -1018,7 +1026,7 @@
for item in nodes_used:
if item['nodename'] == node.getName().strip():
found_duplicate = True
- if found_duplicate == True:
+ if found_duplicate is True:
continue
baseurl = request['URL']
clustername = model.getClusterName()
@@ -1117,7 +1125,7 @@
continue
if fd is not None:
- if fd.isShared() == False: #Not a shared dev...build struct and add
+ if fd.isShared() is False: #Not a shared dev...build struct and add
fencedev = {}
try:
fencedev['prettyname'] = FENCE_OPTS[fd.getAgentType()]
@@ -1192,13 +1200,13 @@
#level1 list is complete now, but it is still necessary to build shared1
for fd in fds:
isUnique = True
- if fd.isShared() == False:
+ if fd.isShared() is False:
continue
for fdev in level1:
if fd.getName().strip() == fdev['name']:
isUnique = False
break
- if isUnique == True:
+ if isUnique is True:
shared_struct = {}
shared_struct['name'] = fd.getName().strip()
agentname = fd.getAgentType()
@@ -1225,7 +1233,7 @@
fd = None #Set to None in case last time thru loop
continue
if fd is not None:
- if fd.isShared() == False: #Not a shared dev...build struct and add
+ if fd.isShared() is False: #Not a shared dev...build struct and add
fencedev = {}
try:
fencedev['prettyname'] = FENCE_OPTS[fd.getAgentType()]
@@ -1300,13 +1308,13 @@
#level2 list is complete but like above, we need to build shared2
for fd in fds:
isUnique = True
- if fd.isShared() == False:
+ if fd.isShared() is False:
continue
for fdev in level2:
if fd.getName().strip() == fdev['name']:
isUnique = False
break
- if isUnique == True:
+ if isUnique is True:
shared_struct = {}
shared_struct['name'] = fd.getName().strip()
agentname = fd.getAgentType()
@@ -1324,7 +1332,8 @@
def getFencesInfo(self, model, request):
fences_map = {}
if not model:
- luci_log.debug_verbose('getFencesInfo0: model is None')
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('getFencesInfo0: model is None')
fences_map['fencedevs'] = list()
return fences_map
@@ -1339,7 +1348,7 @@
#create fencedev hashmap
nodes_used = list()
- if fd.isShared() == True:
+ if fd.isShared() is True:
fencedev = {}
attr_hash = fd.getAttributes()
kees = attr_hash.keys()
@@ -1369,7 +1378,7 @@
for item in nodes_used:
if item['nodename'] == node.getName().strip():
found_duplicate = True
- if found_duplicate == True:
+ if found_duplicate is True:
continue
node_hash = {}
cur_nodename = node.getName().strip()
@@ -1410,8 +1419,9 @@
try:
vm = model.retrieveVMsByName(vmname)
except:
- luci_log.debug('An error occurred while attempting to get VM %s' \
- % vmname)
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug('An error occurred while attempting to get VM %s' \
+ % vmname)
return vm_map
attrs = vm.getAttributes()
@@ -1431,14 +1441,16 @@
try:
cluname = request.form['clustername']
except:
- luci_log.debug_verbose('getResourcesInfo missing cluster name')
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('getResourcesInfo missing cluster name')
return resList
#CALL LUCICLUSTERINFO
return resList
def getResourceInfo(model, request):
if not model:
- luci_log.debug_verbose('GRI0: no model object in session')
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('GRI0: no model object in session')
return {}
name = None
@@ -1459,7 +1471,8 @@
pass
if name is None:
- luci_log.debug_verbose('getResourceInfo missing res name')
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('GRI1: missing res name')
return {}
try:
@@ -1468,13 +1481,15 @@
try:
cluname = request.form['clustername']
except:
- luci_log.debug_verbose('getResourceInfo missing cluster name')
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('GRI2: missing cluster name')
return {}
try:
baseurl = request['URL']
except:
- luci_log.debug_verbose('getResourceInfo missing URL')
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('GRI3: missing URL')
return {}
#CALL
@@ -1485,6 +1500,8 @@
def getClusterAlias(self, model):
if not model:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('GCA0: no model')
return ''
alias = model.getClusterAlias()
if not alias:
--- conga/luci/site/luci/Extensions/Attic/LuciDB.py 2007/05/14 18:00:14 1.1.2.5
+++ conga/luci/site/luci/Extensions/Attic/LuciDB.py 2007/05/15 21:42:21 1.1.2.6
@@ -1,7 +1,14 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from AccessControl import getSecurityManager
import RicciQuery as rq
from ricci_communicator import RicciCommunicator
-from LuciZope import isAdmin
+from LuciZopePerm import isAdmin
from LuciSyslog import get_logger
from conga_constants import CLUSTER_FOLDER_PATH, BATCH_ID, TASKTYPE, \
@@ -92,7 +99,7 @@
luci_log.debug_verbose(errmsg)
raise Exception, errmsg
-def noNodeStatussPresent(self, nodefolder, flagname, hostname):
+def noNodeStatusPresent(self, nodefolder, flagname, hostname):
try:
items = nodefolder.objectItems('ManagedSystem')
except Exception, e:
@@ -125,7 +132,7 @@
batch_ret = rq.checkBatch(rc, item[1].getProperty(BATCH_ID))
finished = batch_ret[0]
- if finished == True or finished == -1:
+ if finished is True or finished == -1:
if finished == -1:
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('NNFP2: batch error: %s' \
@@ -585,32 +592,6 @@
luci_log.debug_verbose('delCluSystems2: %s' % err)
return ''.join(error_list)
-# In case we want to give access to non-admin users in the future
-
-def havePermCreateCluster(self):
- return isAdmin(self)
-
-def havePermAddStorage(self):
- return isAdmin(self)
-
-def havePermAddCluster(self):
- return isAdmin(self)
-
-def havePermAddUser(self):
- return isAdmin(self)
-
-def havePermDelUser(self):
- return isAdmin(self)
-
-def havePermRemStorage(self):
- return isAdmin(self)
-
-def havePermRemCluster(self):
- return isAdmin(self)
-
-def havePermEditPerms(self):
- return isAdmin(self)
-
def getSystems(self):
storage = getStorage(self)
clusters = getClusters(self)
@@ -620,7 +601,7 @@
need_auth_hash = {}
for i in storage:
storageList.append(i[0])
- if testNodeStatus(i[1], CLUSTER_NODE_NEED_AUTH) != False:
+ if testNodeStatus(i[1], CLUSTER_NODE_NEED_AUTH) is not False:
need_auth_hash[i[0]] = i[1]
chash = {}
@@ -628,7 +609,7 @@
csystems = getClusterSystems(self, i[0])
cslist = list()
for c in csystems:
- if testNodeStatus(c[1], CLUSTER_NODE_NEED_AUTH) != False:
+ if testNodeStatus(c[1], CLUSTER_NODE_NEED_AUTH) is not False:
need_auth_hash[c[0]] = c[1]
cslist.append(c[0])
chash[i[0]] = cslist
@@ -658,7 +639,7 @@
return None
if cluster_permission_check(self, cluster):
- return cluster_nodes
+ return cluster_nodes
return None
def getClusters(self):
@@ -669,8 +650,6 @@
luci_log.debug_verbose('GC0: %r' % e)
return None
- if isAdmin(self):
- return clusters
return check_clusters(self, clusters)
def getStorage(self):
--- conga/luci/site/luci/Extensions/LuciSyslog.py 2007/05/14 18:00:14 1.11.4.1
+++ conga/luci/site/luci/Extensions/LuciSyslog.py 2007/05/15 21:42:21 1.11.4.2
@@ -1,8 +1,16 @@
-from conga_constants import LUCI_DEBUG_MODE, LUCI_DEBUG_VERBOSITY
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from syslog import openlog, closelog, syslog, \
LOG_DAEMON, LOG_PID, LOG_NDELAY, LOG_INFO, \
LOG_WARNING, LOG_AUTH, LOG_DEBUG
+from conga_constants import LUCI_DEBUG_MODE, LUCI_DEBUG_VERBOSITY
+
# Exception class for the LuciSyslog facility
class LuciSyslogError(Exception):
def __init__(self, msg):
--- conga/luci/site/luci/Extensions/Attic/LuciZope.py 2007/05/14 18:00:14 1.1.2.3
+++ conga/luci/site/luci/Extensions/Attic/LuciZope.py 2007/05/15 21:42:21 1.1.2.4
@@ -1,11 +1,17 @@
-from AccessControl import getSecurityManager
-from ricci_communicator import CERTS_DIR_PATH
-from conga_constants import PLONE_ROOT
-from LuciDB import allowed_systems
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+from LuciZopePerm import userAuthenticated
+from LuciDB import allowed_systems
def siteIsSetup(self):
import os
+ from ricci_communicator import CERTS_DIR_PATH
+
try:
return os.path.isfile('%sprivkey.pem' % CERTS_DIR_PATH) and os.path.isfile('%scacert.pem' % CERTS_DIR_PATH)
except:
@@ -16,28 +22,6 @@
import re
return re.sub(regex, replaceChar, arg)
-def userAuthenticated(self):
- try:
- if (isAdmin(self) or getSecurityManager().getUser().has_role('Authenticated', self.restrictedTraverse(PLONE_ROOT))):
- return True
- except Exception, e:
- pass
- return False
-
-def isAdmin(self):
- try:
- return getSecurityManager().getUser().has_role('Owner', self.restrictedTraverse(PLONE_ROOT))
- except Exception, e:
- pass
- return False
-
-def userIsAdmin(self, userId):
- try:
- return self.portal_membership.getMemberById(userId).has_role('Owner', self.restrictedTraverse(PLONE_ROOT))
- except Exception, e:
- pass
- return False
-
# removes systems that user is not authorized access to
def get_systems_statuses(self, systems, from_cache=False):
from HelperFunctions import get_system_info
@@ -46,7 +30,7 @@
session = self.REQUEST.SESSION
if session.has_key(CACHED_INDEX):
res = session[CACHED_INDEX]
- if res != None:
+ if res is not None:
session.set(CACHED_INDEX, None)
if from_cache:
return res
@@ -73,12 +57,13 @@
value = request.cookies[cookie_prefix + var_name]
session.set(var_name, value)
- response.setCookie(cookie_prefix + var_name, value,
+ response.setCookie(cookie_prefix + var_name, value,
expires='Tue, 30 Jun 2060 12:00:00 GMT')
return value
# returns (str(float), units) that fits best,
# takes prefered units into account
+
def bytes_to_value_prefunits(self, bytes):
from HelperFunctions import bytes_to_value_units, convert_bytes, get_units_multiplier
--- conga/luci/site/luci/Extensions/PropsObject.py 2007/05/14 18:00:14 1.2.8.2
+++ conga/luci/site/luci/Extensions/PropsObject.py 2007/05/15 21:42:21 1.2.8.3
@@ -1,14 +1,20 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from Variable import parse_variable
from ricci_defines import PROPS_TAG
import xml
import xml.dom
-
class PropsObject:
-
+
def __init__(self):
self.__vars = {}
-
+
def add_prop(self, variable):
self.__vars[variable.get_name()] = variable
def get_prop(self, name):
@@ -16,24 +22,24 @@
return self.__vars[name].get_value()
else:
return None
-
+
def get_props(self):
return self.__vars
-
+
def export_xml(self, doc, parent_node):
props = doc.createElement(str(PROPS_TAG))
parent_node.appendChild(props)
for var in self.__vars:
props.appendChild(self.__vars[var].export_xml(doc))
return props
-
+
def import_xml(self, parent_node):
props = None
for node in parent_node.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == str(PROPS_TAG):
props = node
- if props == None:
+ if props is None:
return self
for node in props.childNodes:
try:
@@ -42,4 +48,4 @@
except:
continue
return self
-
+
--- conga/luci/site/luci/Extensions/Attic/ResourceHandler.py 2007/05/14 18:00:14 1.1.2.2
+++ conga/luci/site/luci/Extensions/Attic/ResourceHandler.py 2007/05/15 21:42:21 1.1.2.3
@@ -1,3 +1,10 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from ClusterModel.Ip import Ip
from ClusterModel.Fs import Fs
from ClusterModel.Clusterfs import Clusterfs
@@ -687,7 +694,7 @@
if form.has_key('edit'):
if not form.has_key('oldname'):
raise Exception, [ 'Cannot find this resource\'s original name.' ]
-
+
oldname = form['oldname'].strip()
if not oldname:
raise Exception, [ 'Cannot find this resource\'s original name.' ]
--- conga/luci/site/luci/Extensions/Attic/RicciQueries.py 2007/05/14 18:00:14 1.1.2.2
+++ conga/luci/site/luci/Extensions/Attic/RicciQueries.py 2007/05/15 21:42:21 1.1.2.3
@@ -1,3 +1,10 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from xml.dom import minidom
from xml.dom.Node import ELEMENT_NODE
from ricci_communicator import RicciCommunicator, extract_module_status
@@ -54,7 +61,7 @@
upgrade_rpms,
gulm):
batch = list()
-
+
batch.append('<?xml version="1.0" ?>')
batch.append('<batch>')
batch.append('<module name="rpm">')
@@ -80,7 +87,7 @@
batch.append('</function_call>')
batch.append('</request>')
batch.append('</module>')
-
+
batch.append('<module name="service">')
batch.append('<request API_version="1.0">')
batch.append('<function_call name="disable">')
@@ -100,7 +107,7 @@
batch.append('</function_call>')
batch.append('</request>')
batch.append('</module>')
-
+
need_reboot = install_base or install_services or install_shared_storage or install_LVS
if need_reboot:
batch.append('<module name="reboot">')
@@ -114,7 +121,7 @@
batch.append('<function_call name="install"/>')
batch.append('</request>')
batch.append('</module>')
-
+
batch.append('<module name="cluster">')
batch.append('<request API_version="1.0">')
batch.append('<function_call name="set_cluster.conf">')
@@ -131,7 +138,7 @@
batch.append('</function_call>')
batch.append('</request>')
batch.append('</module>')
-
+
if install_shared_storage:
batch.append('<module name="storage">')
batch.append('<request API_version="1.0">')
@@ -144,7 +151,7 @@
batch.append('<function_call name="install"/>')
batch.append('</request>')
batch.append('</module>')
-
+
batch.append('<module name="cluster">')
batch.append('<request API_version="1.0">')
batch.append('<function_call name="start_node"/>')
@@ -168,7 +175,7 @@
batch = list()
batch.append('<?xml version="1.0" ?>')
batch.append('<batch>')
-
+
batch.append('<module name="rpm">')
batch.append('<request API_version="1.0">')
batch.append('<function_call name="install">')
@@ -195,7 +202,7 @@
batch.append('</function_call>')
batch.append('</request>')
batch.append('</module>')
-
+
batch.append('<module name="service">')
batch.append('<request API_version="1.0">')
batch.append('<function_call name="disable">')
@@ -215,7 +222,7 @@
batch.append('</function_call>')
batch.append('</request>')
batch.append('</module>')
-
+
need_reboot = install_base or install_services or install_shared_storage or install_LVS
if need_reboot:
batch.append('<module name="reboot">')
@@ -229,7 +236,7 @@
batch.append('<function_call name="install"/>')
batch.append('</request>')
batch.append('</module>')
-
+
batch.append('<module name="cluster">')
batch.append('<request API_version="1.0">')
batch.append('<function_call name="set_cluster.conf">')
@@ -264,7 +271,7 @@
batch.append('</function_call>')
batch.append('</request>')
batch.append('</module>')
-
+
if install_shared_storage:
batch.append('<module name="storage">')
batch.append('<request API_version="1.0">')
@@ -277,7 +284,7 @@
batch.append('<function_call name="install"/>')
batch.append('</request>')
batch.append('</module>')
-
+
batch.append('<module name="cluster">')
batch.append('<request API_version="1.0">')
batch.append('<function_call name="start_node">')
@@ -433,11 +440,11 @@
def nodeLeaveCluster(rc, cluster_shutdown=False, purge=False):
cshutdown = 'false'
- if cluster_shutdown == True:
+ if cluster_shutdown is True:
cshutdown = 'true'
purge_conf = 'true'
- if purge == False:
+ if purge is False:
purge_conf = 'false'
batch_str = '<module name="cluster"><request API_version="1.0"><function_call name="stop_node"><var mutable="false" name="cluster_shutdown" type="boolean" value="%s"/><var mutable="false" name="purge_conf" type="boolean" value="%s"/></function_call></request></module>' % (cshutdown, purge_conf)
@@ -453,7 +460,7 @@
def nodeJoinCluster(rc, cluster_startup=False):
cstartup = 'false'
- if cluster_startup == True:
+ if cluster_startup is True:
cstartup = 'true'
batch_str = '<module name="cluster"><request API_version="1.0"><function_call name="start_node"><var mutable="false" name="cluster_startup" type="boolean" value="%s"/></function_call></request></module>' % cstartup
@@ -462,7 +469,7 @@
return batchAttemptResult(ricci_xml)
def startService(rc, servicename, preferrednode=None):
- if preferrednode != None:
+ if preferrednode is not None:
batch_str = '<module name="cluster"><request API_version="1.0"><function_call name="start_service"><var mutable="false" name="servicename" type="string" value="%s"/><var mutable="false" name="nodename" type="string" value="%s"/></function_call></request></module>' % (servicename, preferrednode)
else:
batch_str = '<module name="cluster"><request API_version="1.0"><function_call name="start_service"><var mutable="false" name="servicename" type="string" value="%s"/></function_call></request></module>' % servicename
@@ -543,7 +550,7 @@
return doc
batch_str = '<module name="service"><request API_version="1.0"><function_call name="%s"><var mutable="false" name="services" type="list_xml"><service name="%s"/></var></function_call></request></module>' % (svc_func, servicename)
-
+
ricci_xml = rc.batch_run(batch_str, async=False)
if not ricci_xml or not ricci_xml.firstChild:
elem.setAttribute('message', 'operation failed')
--- conga/luci/site/luci/Extensions/StorageReport.py 2007/05/04 19:10:24 1.23.2.2
+++ conga/luci/site/luci/Extensions/StorageReport.py 2007/05/15 21:42:21 1.23.2.3
@@ -1,18 +1,30 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
import xml
import xml.dom
from xml.dom import minidom
-
from Variable import parse_variable, Variable, VariableList
+
from ricci_defines import *
-from conga_storage_constants import *
-from HelperFunctions import *
-from LuciZope import bytes_to_value_prefunits, get_systems_statuses
+from conga_storage_constants import ADD_SOURCES, get_fs_icon, \
+ get_mapper_icons, get_pretty_fs_name, get_pretty_mapper_info, \
+ get_pretty_prop_name, PAGETYPE, PT_MAPPER_ID, PT_MAPPER_TYPE, \
+ PT_PATH, STONAME, STORAGE, VIEW_BD, VIEW_MAPPER
-from ricci_communicator import get_ricci_communicator, batch_status, extract_module_status
+from HelperFunctions import convert_bytes, \
+ get_units_multiplier, bytes_to_value_units
+from LuciZope import bytes_to_value_prefunits, get_systems_statuses
+
+from ricci_communicator import get_ricci_communicator, \
+ batch_status, extract_module_status
SESSION_STORAGE_XML_REPORT = 'storage_xml_report_dir'
@@ -20,11 +32,11 @@
class StorageReport:
-
+
def __init__(self, storage_xml_report):
#self.__report = minidom.parseString(storage_xml_report).firstChild
self.__report = storage_xml_report.cloneNode(True)
-
+
self.__mappers = None
self.__m_temps = None
for node in self.__report.childNodes:
@@ -36,16 +48,16 @@
self.__m_temps = var.get_value()
except:
pass
- if self.__mappers == None or self.__m_temps == None:
+ if self.__mappers is None or self.__m_temps is None:
raise Exception, 'invalid storage_xml_report'
-
+
self.__mapp_dir = {} # holds mapper lists by mapper_type
for mapp_node in self.__mappers:
m_type = mapp_node.getAttribute('mapper_type')
if not (m_type in self.__mapp_dir):
self.__mapp_dir[m_type] = []
self.__mapp_dir[m_type].append(mapp_node.cloneNode(True))
-
+
self.__m_temps_dir = {} # holds mapper_template lists by mapper_type
for temp_node in self.__m_temps:
m_type = temp_node.getAttribute('mapper_type')
@@ -53,15 +65,15 @@
self.__m_temps_dir[m_type] = []
self.__m_temps_dir[m_type].append(temp_node.cloneNode(True))
#
-
-
-
-
-
+
+
+
+
+
def get_xml_report(self):
return self.__report.cloneNode(True)
-
-
+
+
def get_mappers(self, type=''):
l = []
if type == '':
@@ -72,8 +84,8 @@
for s in l:
r.append(s.cloneNode(True))
return r
-
-
+
+
def get_mappers_dir(self):
r = {}
for type in self.__mapp_dir:
@@ -82,8 +94,8 @@
l.append(m.cloneNode(True))
r[type] = l
return r
-
-
+
+
def get_mapper(self, id):
if id == '':
raise Exception, 'empty mapper_id!!!'
@@ -91,8 +103,8 @@
if m.getAttribute('mapper_id') == id:
return m.cloneNode(True)
return None
-
-
+
+
def get_mapper_temps_dir(self):
r = {}
for type in self.__m_temps_dir:
@@ -101,8 +113,8 @@
l.append(m.cloneNode(True))
r[type] = l
return r
-
-
+
+
def get_mapper_temps(self, type=''):
l = []
if type == '':
@@ -113,12 +125,12 @@
for s in l:
r.append(s.cloneNode(True))
return r
-
-
+
+
def get_targets(self, mapper):
- if mapper == None:
+ if mapper is None:
return []
-
+
targets_list = []
for node in mapper.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
@@ -129,12 +141,12 @@
if node.nodeName == BD_TYPE:
targets_list.append(node.cloneNode(True))
return targets_list
-
-
+
+
def get_new_targets(self, mapper):
- if mapper == None:
+ if mapper is None:
return []
-
+
targets_list = []
for node in mapper.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
@@ -145,12 +157,12 @@
if node.nodeName == BD_TEMPLATE:
targets_list.append(node.cloneNode(True))
return targets_list
-
-
+
+
def get_sources(self, mapper):
- if mapper == None:
+ if mapper is None:
return []
-
+
targets_list = []
for node in mapper.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
@@ -161,12 +173,12 @@
if node.nodeName == BD_TYPE:
targets_list.append(node.cloneNode(True))
return targets_list
-
-
+
+
def get_new_sources(self, mapper):
- if mapper == None:
+ if mapper is None:
return []
-
+
targets_list = []
for node in mapper.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
@@ -177,39 +189,38 @@
if node.nodeName == BD_TYPE:
targets_list.append(node.cloneNode(True))
return targets_list
-
-
+
+
def get_mapper_props(self, mapper):
- if mapper == None:
+ if mapper is None:
return None
-
+
props = None
for node in mapper.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == PROPS_TAG:
props = node.cloneNode(True)
- if props == None:
+ if props is None:
raise Exception, 'mapper missing properties tag'
return props
-
-
+
+
def get_target(self, mapper_id, path):
mapper = self.get_mapper(mapper_id)
- if mapper == None:
+ if mapper is None:
return None
-
+
targets = self.get_targets(mapper)
for t_xml in targets:
if t_xml.getAttribute('path') == path:
return t_xml.cloneNode(True)
return None
-
-
+
def is_storage_report_cached(session, storagename):
if session.has_key(SESSION_STORAGE_XML_REPORT):
reports_dir = session[SESSION_STORAGE_XML_REPORT]
if reports_dir.has_key(storagename):
- if reports_dir[storagename] != None:
+ if reports_dir[storagename] is not None:
return True
return False
@@ -221,12 +232,10 @@
session.set(SESSION_STORAGE_XML_REPORT, reports_dir)
return
-
-def cache_storage_report(ricci_comm,
- session):
+def cache_storage_report(ricci_comm, session):
try:
rep = get_storage_report(ricci_comm, session)
- if rep == None:
+ if rep is None:
raise Exception, 'Unable to communicate with host (either system down or ricci not running on it)'
else:
return True
@@ -240,32 +249,32 @@
session):
#print 'get_storage_report()'
#print ricci_comm, session
-
- if ricci_comm == None:
+
+ if ricci_comm is None:
return None
-
+
storagename = ricci_comm.hostname()
-
+
# setup cache, if not already set up
if not session.has_key(SESSION_STORAGE_XML_REPORT):
session.set(SESSION_STORAGE_XML_REPORT, {})
# return cached report if existing
if session[SESSION_STORAGE_XML_REPORT].has_key(storagename):
tmp_report = session[SESSION_STORAGE_XML_REPORT][storagename]
- if tmp_report != None:
+ if tmp_report is not None:
print 'using cached storage_xml_report'
return StorageReport(tmp_report)
-
-
+
+
# retrieve storage report using ricci
print 'retrieving new storage_xml_report'
-
+
#print ricci_comm.authenticated()
#print ricci_comm.cluster_info()
print ricci_comm.hostname()
print ricci_comm.os()
-
-
+
+
# request
doc = minidom.Document()
batch = doc.createElement('batch')
@@ -278,7 +287,7 @@
batch.appendChild(module)
module.appendChild(request)
request.appendChild(function)
-
+
# get report
batch_r = ricci_comm.process_batch(batch)
if batch_r.getAttribute('status') != '0':
@@ -290,7 +299,7 @@
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == 'module':
module_r = node
- if module_r == None:
+ if module_r is None:
raise Exception, 'malformed response: missing <module/> in <batch/>'
module_r_status = module_r.getAttribute('status')
if module_r_status != '0':
@@ -302,14 +311,14 @@
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == 'response':
resp_r = node
- if resp_r == None:
+ if resp_r is None:
raise Exception, 'malformed response: missing <response/> in <module/>'
fr_r = None
for node in resp_r.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == 'function_response':
fr_r = node
- if fr_r == None:
+ if fr_r is None:
raise Exception, 'malformed response: missing <function_response/> in <response/>'
succ_v = None
err_code_v = None
@@ -325,23 +334,23 @@
err_desc_v = var
except:
pass
- if succ_v == None:
+ if succ_v is None:
raise Exception, 'malformed response: missing "success" variable in <function_response/>'
- if succ_v.get_value() != True:
+ if succ_v.get_value() is not True:
# error
if err_code_v.get_value() == -1:
raise Exception, 'Generic error on host:\n\n%s' % err_desc_v.get_value()
else:
raise Exception, 'Host responded: %s' % err_desc_v.get_value()
-
+
#xml_report = fr_r.toxml()
xml_report = fr_r
-
+
# cache xml_report
reports_dir = session[SESSION_STORAGE_XML_REPORT]
reports_dir[storagename] = xml_report
session.set(SESSION_STORAGE_XML_REPORT, reports_dir)
-
+
return StorageReport(xml_report)
@@ -357,13 +366,13 @@
def get_bd_data(self, storage_report, mapper_id, path):
- if storage_report == None or mapper_id == None:
+ if storage_report is None or mapper_id is None:
return None
-
+
mapper = get_mapper_data(self, storage_report, mapper_id)
- if mapper == None:
+ if mapper is None:
return None
-
+
for t in mapper['targets']:
if t['path'] == path:
return t
@@ -394,7 +403,7 @@
ret_dir[mapp_type] = {}
ret_dir[mapp_type]['mappers'] = []
ret_dir[mapp_type]['mapper_template'] = get_mapper_template_data(self, storage_report, mapp_type)
-
+
# pretty stuff
for mapp_type in ret_dir:
info = ret_dir[mapp_type]
@@ -408,23 +417,23 @@
info['pretty_targets_name'] = info_source['pretty_targets_name']
info['pretty_source_name'] = info_source['pretty_source_name']
info['pretty_sources_name'] = info_source['pretty_sources_name']
-
+
return ret_dir
def get_mapper_data(self, storage_report, mapper_id):
- if self == None or storage_report == None or mapper_id == None:
+ if self is None or storage_report is None or mapper_id is None:
return None
-
+
session = self.REQUEST.SESSION
-
+
mapper = storage_report.get_mapper(mapper_id)
- if mapper == None:
+ if mapper is None:
return None
-
+
removable, props = get_props_data_internal(session, mapper)
-
+
new_targets = []
for t_xml in storage_report.get_new_targets(mapper):
new_targets.append(get_bd_data_internal(session, t_xml, mapper))
@@ -437,7 +446,7 @@
sources = []
for s_xml in storage_report.get_sources(mapper):
sources.append(get_bd_data_internal(session, s_xml, mapper))
-
+
type = mapper.getAttribute('mapper_type')
pretty_type, pretty_target_name, pretty_source_name = get_pretty_mapper_info(type)
pretty_name = mapper_id.replace('%s:' % type, '').replace('/dev/', '')
@@ -445,7 +454,7 @@
pretty_sources_name = '%ss' % pretty_source_name
icon_name, dummy1, dummy2 = get_mapper_icons(type)
color = 'black'
-
+
mapper_ret = {}
mapper_ret['pretty_type'] = pretty_type
mapper_ret['pretty_name'] = pretty_name
@@ -464,9 +473,9 @@
mapper_ret['icon'] = icon_name
mapper_ret['color'] = color
mapper_ret['xml'] = mapper.cloneNode(True)
-
+
assemble_all_targets(mapper_ret)
-
+
actions = []
if removable:
action = {'name' : 'Remove',
@@ -474,7 +483,7 @@
'link' : ''}
actions.append(action)
if type == MAPPER_VG_TYPE or type == MAPPER_MDRAID_TYPE or type == MAPPER_ATARAID_TYPE or type == MAPPER_MULTIPATH_TYPE:
- action = {'name' : 'Add %s' % mapper_ret['pretty_sources_name'],
+ action = {'name' : 'Add %s' % mapper_ret['pretty_sources_name'],
'msg' : '',
'link' : './?%s=%s&%s=%s&%s=%s' % (PAGETYPE, ADD_SOURCES, PT_MAPPER_ID, mapper_ret['mapper_id'], PT_MAPPER_TYPE, mapper_ret['mapper_type'])}
actions.append(action)
@@ -482,7 +491,7 @@
for nt in mapper_ret['new_targets']:
if nt['props']['snapshot']['value'] == 'false':
if nt['new']:
- action = {'name' : 'New %s' % mapper_ret['pretty_target_name'],
+ action = {'name' : 'New %s' % mapper_ret['pretty_target_name'],
'msg' : '',
'link' : './?%s=%s&%s=%s&%s=%s&%s=%s' \
% (PAGETYPE, VIEW_BD,
@@ -492,10 +501,10 @@
actions.append(action)
break
mapper_ret['actions'] = actions
-
+
if type == MAPPER_VG_TYPE:
link_snapshots(mapper_ret)
-
+
# cylinders work properly for VGs only, for now
mapper_ret['graphical_view'] = type != MAPPER_PT_TYPE
if mapper_ret['graphical_view']:
@@ -504,9 +513,9 @@
else:
mapper_ret['mappings-view_css_classnames'] = {'graphical_view' : 'invisible',
'textual_view' : 'visible'}
-
+
mapper_ret['need_apply_button'] = mutable_props(mapper_ret['props'])
-
+
return mapper_ret
@@ -517,7 +526,7 @@
orig_name = snap['props']['snapshot_origin']['value']
snap['description'] = '%s, %s\'s Snapshot' \
% (snap['description'], orig_name)
-
+
# find origin
for t in mapper['targets']:
if t['pretty_name'] == orig_name:
@@ -532,7 +541,7 @@
def assemble_all_targets(mapper_data):
mdata = mapper_data
targets_all = []
-
+
if mdata['mapper_type'] == MAPPER_VG_TYPE:
for t in mdata['targets']:
targets_all.append(t)
@@ -563,9 +572,9 @@
for t in mdata['new_targets']:
if t['props']['partition_type']['value'] != 'extended':
targets_all.append(t)
-
+
# TODO: place logical into extended
-
+
# sort partitions
sorted = []
while len(targets_all) != 0:
@@ -588,26 +597,26 @@
targets_all.append(t)
for t in mdata['new_targets']:
targets_all.append(t)
-
+
mdata['targets_all'] = targets_all
-
+
def get_mapper_template_data(self, storage_report, mapper_type):
- if self == None or storage_report == None or mapper_type == None:
+ if self is None or storage_report is None or mapper_type is None:
return None
-
+
session = self.REQUEST.SESSION
-
+
mapper_id = ''
-
+
templ_xml_list = storage_report.get_mapper_temps(mapper_type)
mapper = None
if len(templ_xml_list) != 0:
mapper = templ_xml_list[0]
- if mapper == None:
+ if mapper is None:
return None
-
+
removable, props = get_props_data_internal(session, mapper)
-
+
new_targets = []
for t_xml in storage_report.get_new_targets(mapper):
new_targets.append(get_bd_data_internal(session, t_xml, mapper))
@@ -620,7 +629,7 @@
sources = []
for s_xml in storage_report.get_sources(mapper):
sources.append(get_bd_data_internal(session, s_xml, mapper))
-
+
type = mapper.getAttribute('mapper_type')
pretty_type, pretty_target_name, pretty_source_name = get_pretty_mapper_info(type)
pretty_name = mapper_id.replace('%s:' % type, '').replace('/dev/', '')
@@ -628,7 +637,7 @@
pretty_sources_name = '%ss' % pretty_source_name
icon_name, dummy1, dummy2 = get_mapper_icons(type)
color = 'black'
-
+
min_sources = '0'
max_sources = '0'
new_props = {}
@@ -640,7 +649,7 @@
else:
new_props[name] = props[name]
props = new_props
-
+
mapper_ret = {}
mapper_ret['pretty_type'] = pretty_type
mapper_ret['pretty_name'] = pretty_name
@@ -662,9 +671,9 @@
mapper_ret['icon'] = icon_name
mapper_ret['color'] = color
mapper_ret['xml'] = mapper.cloneNode(True)
-
+
mapper_ret['actions'] = []
-
+
mapper_ret['need_apply_button'] = True
return mapper_ret
@@ -680,13 +689,13 @@
#return 'size has to be within limits'
#return request
#return 'OK'
-
+
object_type = request['object_type']
mapper_id = request['mapper_id']
-
+
props = None
content_props = None
-
+
if object_type == 'bd' or object_type == 'bd_template':
path = request[PT_PATH]
bd_data = get_bd_data(self, storage_report, mapper_id, path)
@@ -721,22 +730,22 @@
if sources_num == 0 or sources_num > len(data['new_sources']):
return 'BAD: Invalid number of %s selected' % data['pretty_sources_name']
- if props != None:
+ if props is not None:
res = check_props(self, props, request)
- if res[0] == False:
+ if res[0] is False:
return '%s %s' % (res[1], res[2])
-
- if content_props != None:
+
+ if content_props is not None:
res = check_props(self, content_props, request)
- if res[0] == False:
+ if res[0] is False:
return '%s %s' % (res[1], res[2])
-
+
return 'OK'
def check_props(self, props, request):
valid = True
var_name = ''
msg = 'no message - BUG :('
-
+
for prop_name in props:
if prop_name in request:
prop = props[prop_name]
@@ -806,7 +815,7 @@
var_name = prop_name
valid = False
break
-
+
return [valid, var_name, msg]
@@ -814,11 +823,11 @@
def apply(self, ricci, storage_report, request):
if validate(self, storage_report, request) != 'OK':
raise Exception, 'Internal error: input not validated!!!'
-
+
session = request.SESSION
-
+
storagename = request['storagename']
-
+
object_type = request['object_type']
mapper_id = request[PT_MAPPER_ID]
mapper_type = request[PT_MAPPER_TYPE]
@@ -826,14 +835,14 @@
path = ''
if request.has_key(PT_PATH):
path = request[PT_PATH]
-
-
+
+
batch_id = ''
-
+
if object_type == 'bd':
bd_data = get_bd_data(self, storage_report, mapper_id, path)
bd_xml = bd_data['xml'].cloneNode(True)
-
+
if action_type == 'Remove':
doc = minidom.Document()
batch = doc.createElement("batch")
@@ -845,15 +854,15 @@
f_call = doc.createElement("function_call")
f_call.setAttribute('name', 'remove_bd')
f_call.appendChild(Variable('bd', bd_xml.cloneNode(True)).export_xml(doc))
-
+
req.appendChild(f_call)
module.appendChild(req)
batch.appendChild(module)
-
+
res = ricci.process_batch(batch, True)
batch_id = res.getAttribute('batch_id')
-
-
+
+
elif action_type == 'Apply':
# BD props
props_xml = None
@@ -888,7 +897,7 @@
node.setAttribute('value', str(val))
else:
node.setAttribute('value', request[var_name])
-
+
# content
content_data_list = get_content_data_internal(session, bd_xml)
current_content_id = content_data_list[0]['id']
@@ -899,7 +908,7 @@
if c_data['id'] == selected_content_id:
selected_content_data = c_data
selected_content = c_data['xml'].cloneNode(True)
-
+
# update selected_content props
props_xml = None
for node in selected_content.childNodes:
@@ -934,7 +943,7 @@
node.setAttribute('value', str(val))
else:
node.setAttribute('value', request[req_name])
-
+
if current_content_id == selected_content_id:
# no change of content
# replace content_xml
@@ -966,21 +975,21 @@
f_call = doc.createElement("function_call")
f_call.setAttribute('name', 'modify_bd')
f_call.appendChild(Variable('bd', bd_xml).export_xml(doc))
-
+
req.appendChild(f_call)
module.appendChild(req)
batch.appendChild(module)
-
+
res = ricci.process_batch(batch, True)
batch_id = res.getAttribute('batch_id')
-
-
+
+
elif object_type == 'bd_template':
path = request[PT_PATH]
bd_data = get_bd_data(self, storage_report, mapper_id, path)
bd_xml = bd_data['xml'].cloneNode(True)
#return bd_xml.toprettyxml()
-
+
if action_type == 'Apply': # Create
# BD props
props_xml = None
@@ -1015,7 +1024,7 @@
node.setAttribute('value', str(val))
else:
node.setAttribute('value', request[var_name])
-
+
if path != 'new_snapshot':
# content
content_data_list = get_content_data_internal(session, bd_xml)
@@ -1027,7 +1036,7 @@
if c_data['id'] == selected_content_id:
selected_content_data = c_data
selected_content = c_data['xml'].cloneNode(True)
-
+
# update selected_content props
props_xml = None
for node in selected_content.childNodes:
@@ -1062,7 +1071,7 @@
node.setAttribute('value', str(val))
else:
node.setAttribute('value', request[req_name])
-
+
if current_content_id == selected_content_id:
# no change of content
# replace content_xml
@@ -1094,21 +1103,21 @@
f_call = doc.createElement("function_call")
f_call.setAttribute('name', 'create_bd')
f_call.appendChild(Variable('bd', bd_xml).export_xml(doc))
-
+
req.appendChild(f_call)
module.appendChild(req)
batch.appendChild(module)
-
+
res = ricci.process_batch(batch, True)
batch_id = res.getAttribute('batch_id')
-
-
-
+
+
+
elif object_type == 'mapper':
mapper_data = get_mapper_data(self, storage_report, mapper_id)
mapper_xml = mapper_data['xml'].cloneNode(True)
#return mapper_xml.toprettyxml()
-
+
if action_type == 'Remove':
doc = minidom.Document()
batch = doc.createElement("batch")
@@ -1120,15 +1129,15 @@
f_call = doc.createElement("function_call")
f_call.setAttribute('name', 'remove_mapper')
f_call.appendChild(Variable('mapper', mapper_xml).export_xml(doc))
-
+
req.appendChild(f_call)
module.appendChild(req)
batch.appendChild(module)
-
+
res = ricci.process_batch(batch, True)
batch_id = res.getAttribute('batch_id')
-
-
+
+
elif action_type == 'Apply':
# props
props_xml = None
@@ -1174,21 +1183,21 @@
f_call = doc.createElement("function_call")
f_call.setAttribute('name', 'modify_mapper')
f_call.appendChild(Variable('mapper', mapper_xml).export_xml(doc))
-
+
req.appendChild(f_call)
module.appendChild(req)
batch.appendChild(module)
-
+
res = ricci.process_batch(batch, True)
batch_id = res.getAttribute('batch_id')
-
-
+
+
elif object_type == 'mapper_template':
mapper_data = get_mapper_template_data(self, storage_report, mapper_type)
mapper_xml = mapper_data['xml'].cloneNode(True)
#return mapper_xml.toprettyxml()
-
+
if action_type == 'Apply':
# props
props_xml = None
@@ -1223,7 +1232,7 @@
node.setAttribute('value', str(val))
else:
node.setAttribute('value', request[var_name])
-
+
# find sources
for v in request.keys():
if v.find('source_bd_') == 0:
@@ -1246,23 +1255,23 @@
f_call = doc.createElement("function_call")
f_call.setAttribute('name', 'create_mapper')
f_call.appendChild(Variable('mapper', mapper_xml.cloneNode(True)).export_xml(doc))
-
+
req.appendChild(f_call)
module.appendChild(req)
batch.appendChild(module)
-
+
res = ricci.process_batch(batch, True)
batch_id = res.getAttribute('batch_id')
-
-
-
-
+
+
+
+
elif object_type == 'add_sources':
mapper_data = get_mapper_data(self, storage_report, mapper_id)
mapper_xml = mapper_data['xml'].cloneNode(True)
new_sources = []
#return mapper_xml.toprettyxml()
-
+
if action_type == 'Apply':
# find sources
for v in request.keys():
@@ -1286,15 +1295,15 @@
f_call.appendChild(Variable('mapper_id', mapper_id).export_xml(doc))
f_call.appendChild(Variable('mapper_state_ind', mapper_xml.getAttribute('state_ind')).export_xml(doc))
f_call.appendChild(VariableList('bds', new_sources, [], VARIABLE_TYPE_LIST_XML).export_xml(doc))
-
+
req.appendChild(f_call)
module.appendChild(req)
batch.appendChild(module)
-
+
res = ricci.process_batch(batch, True)
batch_id = res.getAttribute('batch_id')
-
-
+
+
if batch_id == '':
raise Exception, 'unsupported function'
else:
@@ -1302,17 +1311,17 @@
return batch_id
-def get_storage_batch_result(self,
- storagename,
- ricci,
- index_html_URL,
+def get_storage_batch_result(self,
+ storagename,
+ ricci,
+ index_html_URL,
batch_id):
error = True # ricci reported failure or no ricci
completed = False # no batch, or batch done (defined if no error)
url = index_html_URL # redirect URL
msg = 'Unknown error occured'
-
- if ricci == None:
+
+ if ricci is None:
# ricci down
error = True
url = url
@@ -1327,7 +1336,7 @@
error = True
url = url
msg = 'Ricci on %s responded with error. No detailed info available.' % storagename
- elif batch == None:
+ elif batch is None:
# no such batch
error = False
completed = True
@@ -1431,7 +1440,7 @@
url = '%s?%s=%s&%s=%s' \
% (index_html_URL, STONAME, storagename, PAGETYPE, STORAGE)
msg = err_msg
-
+
return {'error' : error,
'completed' : completed,
'redirect_url' : url,
@@ -1445,29 +1454,29 @@
-def get_commit_redirect(main_url,
- storagename,
+def get_commit_redirect(main_url,
+ storagename,
batch_xml):
module_r = None
for node in batch_xml.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == 'module':
module_r = node
- if module_r == None:
+ if module_r is None:
raise Exception, 'missing <module/> in <batch/>'
resp_r = None
for node in module_r.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == RESPONSE_TAG:
resp_r = node
- if resp_r == None:
+ if resp_r is None:
raise Exception, 'missing <response/> in <module/>'
fr_r = None
for node in resp_r.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == FUNC_RESP_TAG:
fr_r = node
- if fr_r == None:
+ if fr_r is None:
raise Exception, 'missing <function_response/> in <response/>'
vars = {}
for node in fr_r.childNodes:
@@ -1476,8 +1485,8 @@
vars[var.get_name()] = var
except:
pass
-
-
+
+
mapper_id = ''
mapper_type = ''
bd_path = ''
@@ -1499,7 +1508,7 @@
url_list.append('&%s=%s' % (PT_MAPPER_ID, mapper_id))
if bd_path != '':
url_list.append('&%s=%s' % (PT_PATH, bd_path))
-
+
if mapper_type == '':
url_list.append('&%s=%s' % (PAGETYPE, STORAGE))
elif bd_path != '':
@@ -1512,19 +1521,19 @@
def get_bd_data_internal(session, bd_xml, mapper_xml):
data = {}
-
+
removable, props = get_props_data_internal(session, bd_xml)
-
+
path = bd_xml.getAttribute('path')
mapper_type = bd_xml.getAttribute('mapper_type')
mapper_id = bd_xml.getAttribute('mapper_id')
contents = get_content_data_internal(session, bd_xml)
-
+
pretty_mapper_type, pretty_type, dummy2 = get_pretty_mapper_info(mapper_type)
pretty_name = path.replace('/dev/','')
dummy1, icon_name, dummy2 = get_mapper_icons(mapper_type)
color = 'black'
-
+
size_in_units, units = bytes_to_value_units(props['size']['value'])
description = None
@@ -1542,7 +1551,7 @@
if description is None:
description = '%s %s' % (size_in_units, units)
-
+
if bd_xml.nodeName == BD_TEMPLATE:
if mapper_type == MAPPER_PT_TYPE:
path = 'unused_segment_%s_%s' \
@@ -1560,7 +1569,7 @@
contents = []
path = 'new_snapshot'
pretty_name = ''
-
+
data['pretty_mapper_type'] = pretty_mapper_type
data['pretty_type'] = pretty_type
data['pretty_name'] = pretty_name
@@ -1574,7 +1583,7 @@
data['icon'] = icon_name
data['color'] = color
data['xml'] = bd_xml.cloneNode(True)
-
+
actions = []
if removable:
action = {'name' : 'Remove',
@@ -1593,12 +1602,12 @@
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == BD_TEMPLATE:
snap_lv = get_bd_data_internal(session, node, mapper_xml)
- if snap_lv != None:
+ if snap_lv is not None:
if snap_lv['props']['snapshot']['value'] == 'true':
origs = snap_lv['props']['snapshot_origin']['value']
if pretty_name in origs:
action = {'name' : 'Take Snapshot',
- 'msg' : '',
+ 'msg' : '',
'link' : './?%s=%s&%s=%s&%s=%s&%s=%s' \
% (PAGETYPE, VIEW_BD, \
PT_MAPPER_ID, data['mapper_id'], \
@@ -1606,9 +1615,9 @@
PT_PATH, snap_lv['path'])}
actions.append(action)
data['actions'] = actions
-
+
need_apply_butt = mutable_props(data['props'])
- if need_apply_butt == False:
+ if need_apply_butt is False:
if len(data['contents']) > 1:
need_apply_butt = True
elif len(data['contents']) == 1:
@@ -1616,15 +1625,15 @@
else:
need_apply_butt = False
data['need_apply_button'] = need_apply_butt
-
+
return data
def get_props_data_internal(session, xml_tag):
data = {}
removable = False
-
-
+
+
props_xml = None
for node in xml_tag.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
@@ -1641,13 +1650,13 @@
mutable = var.getAttribute('mutable') == 'true'
type = var.getAttribute('type')
value = var.getAttribute('value')
-
+
d_units = ''
if name in ['size', 'extent_size', 'block_size', 'size_free', 'partition_begin']:
d_units = 'bytes'
if 'percent' in name:
d_units = '%'
-
+
validation_data = {}
if type == VARIABLE_TYPE_INT:
d_type = 'int'
@@ -1699,15 +1708,15 @@
else:
d_type = 'label'
d_value = value
-
+
if not mutable and d_type != 'label' and d_type != 'hidden':
d_type = 'label'
d_value = str(value)
-
+
hidden = False
if type == 'hidden' or name in ['partition_begin', 'snapshot']:
hidden = True
-
+
if name == 'removable':
removable = value == 'true'
elif name == 'path':
@@ -1720,7 +1729,7 @@
'units' : d_units,
'validation' : validation_data,
'hidden' : hidden}
-
+
return (removable, data)
@@ -1749,7 +1758,7 @@
uuids.append(prop)
else:
rest.append(prop)
-
+
ordered = []
for prop in names:
ordered.append(prop)
@@ -1783,9 +1792,9 @@
if node.nodeName == CONTENT_TYPE:
c_xml = node
break
- if c_xml == None:
+ if c_xml is None:
return {}
-
+
a_xmls = []
for node in c_xml.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
@@ -1796,7 +1805,7 @@
if node.nodeName == "content_template":
a_xmls.append(node)
break
-
+
current = {}
removable, props = get_props_data_internal(session, c_xml)
current['props'] = props
@@ -1804,7 +1813,7 @@
current['name'] = name
current['id'] = id
current['xml'] = c_xml.cloneNode(True)
-
+
data = [current]
for a_xml in a_xmls:
available = {}
@@ -1814,9 +1823,9 @@
available['name'] = name
available['id'] = id
available['xml'] = a_xml.cloneNode(True)
-
+
data.append(available)
-
+
for d in data:
old_props = d['props']
new_props = {}
@@ -1827,7 +1836,7 @@
d['props'] = new_props
d['props_ordered'] = get_ordered_props(new_props)
d['is_source'] = False
-
+
# content's color and icon
color = 'black'
icon_name = ''
@@ -1849,10 +1858,10 @@
pass
elif type == 'hidden':
pass
-
+
d['color'] = color
d['icon'] = icon_name
-
+
return data
@@ -1892,7 +1901,7 @@
name = 'Extended Partition'
else:
name = "Unknown type"
-
+
return name, id
@@ -1916,12 +1925,12 @@
nonclu_list = clusters[cluname]
else:
cl = {'name' : cluname,
- 'alias' : clusters[cluname][0]['clualias'],
+ 'alias' : clusters[cluname][0]['clualias'],
'nodes' : clusters[cluname]}
clu_list.append(cl)
-
+
ret = [nonclu_list, clu_list, bad_list]
-
+
return ret
@@ -1932,18 +1941,18 @@
length):
# highlights
high_list = {}
-
+
# upper cyl
upper_cyl = {'offset' : 0,
'cyls' : [],
'highs' : [],
'js' : [],
- 'color' : 'blue',
- 'color_css' : '#0192db',
+ 'color' : 'blue',
+ 'color_css' : '#0192db',
'description': mapper_data['pretty_targets_name']}
if mapper_data['mapper_type'] == MAPPER_PT_TYPE:
upper_cyl['description'] = 'Physical %s' % upper_cyl['description']
-
+
offset = 0
for t in mapper_data['targets_all']:
if t['mapper_type'] == MAPPER_PT_TYPE:
@@ -1964,34 +1973,34 @@
data['color_css'] = 'black'
upper_cyl['cyls'].append(data)
offset = end
-
+
# scale ranges
for d in upper_cyl['cyls']:
d['beg'] = d['beg'] * length / offset
d['end'] = d['end'] * length / offset - 1
-
+
# build highlights
for d in upper_cyl['cyls']:
h_id = '%s_selected' % d['id']
beg = d['beg']
end = d['end']
- upper_cyl['highs'].append({'beg' : beg,
- 'end' : end,
+ upper_cyl['highs'].append({'beg' : beg,
+ 'end' : end,
'id' : h_id,
'type' : 'select'})
upper_cyl['js'].append([d['id'],
[beg, end],
d['bd']['pretty_name']])
high_list[d['id']] = [h_id]
-
+
# snapshots
bd = d['bd']
if bd['mapper_type'] == MAPPER_VG_TYPE and not bd['new']:
if 'origin' in bd:
# snapshot
snap_id = '%s_snapshot' % bd['path']
- upper_cyl['highs'].append({'beg' : beg,
- 'end' : end,
+ upper_cyl['highs'].append({'beg' : beg,
+ 'end' : end,
'id' : snap_id,
'type' : 'snapshot'})
orig = bd['origin']
@@ -1999,26 +2008,26 @@
high_list[d['id']].append(snap_id)
if 'snapshots' in bd:
# origin
- upper_cyl['highs'].append({'beg' : beg,
- 'end' : end,
+ upper_cyl['highs'].append({'beg' : beg,
+ 'end' : end,
'id' : '%s_origin' % bd['path'],
'type' : 'snapshot-origin'})
for snap in bd['snapshots']:
high_list[d['id']].append('%s_snapshot', snap['path'])
-
-
-
+
+
+
upper_cyl['js'] = str(upper_cyl['js']).replace('L,', ',').replace('L]', ']').replace('u\'', '\'').replace('L]', ']')
-
+
# lower cylinder
lower_cyl = {'offset' : 0,
'cyls' : [],
'highs' : [],
'js' : [],
- 'color' : 'red',
- 'color_css' : '#a43737',
+ 'color' : 'red',
+ 'color_css' : '#a43737',
'description': mapper_data['pretty_sources_name']}
-
+
offset = 0
for t in mapper_data['sources']:
data = {}
@@ -2032,14 +2041,14 @@
data['color_css'] = '#a43737'
lower_cyl['cyls'].append(data)
offset = end
-
+
if mapper_data['mapper_type'] == MAPPER_PT_TYPE:
lower_cyl['description'] = 'Logical %s' % mapper_data['pretty_targets_name']
lower_cyl['cyls'] = []
lower_cyl['color'] = 'blue'
lower_cyl['color_css'] = '#0192db'
lower_cyl['offset'] = 9999999999999999999999999
-
+
offset = 0
for t in mapper_data['targets_all']:
if t['props']['partition_type']['value'] != 'logical':
@@ -2058,8 +2067,8 @@
data['color_css'] = '#0192db'
lower_cyl['cyls'].append(data)
offset = end
-
-
+
+
# scale ranges
length_in_bytes = 0
for t in mapper_data['sources']:
@@ -2069,16 +2078,16 @@
for d in lower_cyl['cyls']:
d['beg'] = int(d['beg'] * ppb)
d['end'] = int(d['end'] * ppb - 1)
-
-
-
+
+
+
# build highlights
for d in lower_cyl['cyls']:
h_id = '%s_selected' % d['id']
beg = d['beg']
end = d['end']
- lower_cyl['highs'].append({'beg' : beg,
- 'end' : end,
+ lower_cyl['highs'].append({'beg' : beg,
+ 'end' : end,
'id' : h_id,
'type' : 'select'})
lower_cyl['js'].append([d['id'],
@@ -2086,20 +2095,20 @@
d['bd']['pretty_name']])
high_list[d['id']] = [h_id]
lower_cyl['js'] = str(lower_cyl['js']).replace('L,', ',').replace('L]', ']').replace('u\'', '\'').replace('L]', ']')
-
+
# transform list of highlights
high_list_js = [[mapper_data['mapper_id'], []]]
for id in high_list:
high_list_js.append([id, high_list[id]])
high_list_js = str(high_list_js).replace('L,', ',').replace('L]', ']').replace('u\'', '\'').replace('L]', ']')
-
+
# put everything together
ret = {}
ret['mapper'] = mapper_data
ret['upper_cyl'] = upper_cyl
ret['lower_cyl'] = lower_cyl
ret['js'] = high_list_js
-
+
return ret
--- conga/luci/site/luci/Extensions/Variable.py 2007/05/04 19:10:24 1.4.8.2
+++ conga/luci/site/luci/Extensions/Variable.py 2007/05/15 21:42:21 1.4.8.3
@@ -1,13 +1,24 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
import xml.dom
-from ricci_defines import VARIABLE_TAG, VARIABLE_TYPE_BOOL, VARIABLE_TYPE_FLOAT, VARIABLE_TYPE_INT, VARIABLE_TYPE_INT_SEL, VARIABLE_TYPE_LISTENTRY, VARIABLE_TYPE_LIST_INT, VARIABLE_TYPE_LIST_STR, VARIABLE_TYPE_LIST_XML, VARIABLE_TYPE_STRING, VARIABLE_TYPE_STRING_SEL, VARIABLE_TYPE_XML
+from ricci_defines import VARIABLE_TAG, VARIABLE_TYPE_BOOL, \
+ VARIABLE_TYPE_FLOAT, VARIABLE_TYPE_INT, VARIABLE_TYPE_INT_SEL, \
+ VARIABLE_TYPE_LISTENTRY, VARIABLE_TYPE_LIST_INT, \
+ VARIABLE_TYPE_LIST_STR, VARIABLE_TYPE_LIST_XML, VARIABLE_TYPE_STRING, \
+ VARIABLE_TYPE_STRING_SEL, VARIABLE_TYPE_XML
def parse_variable(node):
if node.nodeType != xml.dom.Node.ELEMENT_NODE:
raise Exception, 'not a variable'
if node.nodeName != str(VARIABLE_TAG):
raise Exception, 'not a variable'
-
+
attrs_dir = {}
attrs = node.attributes
for attrName in attrs.keys():
@@ -18,12 +29,12 @@
raise Exception, 'incomplete variable'
if (attrs_dir['type'] != VARIABLE_TYPE_LIST_INT and attrs_dir['type'] != VARIABLE_TYPE_LIST_STR and attrs_dir['type'] != VARIABLE_TYPE_LIST_XML and attrs_dir['type'] != VARIABLE_TYPE_XML) and ('value' not in attrs_dir):
raise Exception, 'incomplete variable'
-
+
mods = {}
for mod in attrs_dir:
if mod not in ['name', 'value', 'type']:
mods[mod] = attrs_dir[mod]
-
+
value = ''
if attrs_dir['type'] == VARIABLE_TYPE_LIST_STR:
value = []
@@ -38,7 +49,7 @@
v = attrValue
else:
continue
- if v == None:
+ if v is None:
raise Exception, 'invalid listentry'
value.append(v)
return VariableList(attrs_dir['name'], value, mods, VARIABLE_TYPE_LIST_STR)
@@ -71,7 +82,7 @@
value = (attrs_dir['value'] == 'true')
else:
raise Exception, 'invalid variable'
-
+
return Variable(attrs_dir['name'], value, mods)
@@ -84,7 +95,7 @@
def get_name(self):
return self.__name
-
+
def get_value(self):
return self.__value
@@ -92,15 +103,15 @@
if self.__is_bool(value):
self.__type = VARIABLE_TYPE_BOOL
self.__value = value
-
+
elif self.__is_int(value):
self.__type = VARIABLE_TYPE_INT
self.__value = int(value)
-
+
elif self.__is_float(value):
self.__type = VARIABLE_TYPE_FLOAT
self.__value = float(value)
-
+
elif self.__is_list(value):
raise Exception, "lists not implemented"
if self.__is_int(value[0]):
@@ -114,11 +125,11 @@
elif self.__is_xml(value):
self.__type = VARIABLE_TYPE_XML
self.__value = value
-
+
else:
self.__value = str(value)
self.__type = VARIABLE_TYPE_STRING
-
+
def type(self):
if 'valid_values' in self.__mods:
if self.__type == VARIABLE_TYPE_INT:
@@ -126,13 +137,13 @@
elif self.__type == VARIABLE_TYPE_STRING:
return VARIABLE_TYPE_STRING_SEL
return self.__type
-
+
def get_modifiers(self):
return self.__mods
def set_modifier(self, mod_name, mod_value):
self.__mods[mod_name] = mod_value
return
-
+
def export_xml(self, doc):
elem = doc.createElement(VARIABLE_TAG)
elem.setAttribute('name', self.__name)
@@ -178,10 +189,10 @@
return VARIABLE_TYPE_XML
else:
return VARIABLE_TYPE_STRING
-
-
-
-
+
+
+
+
def __is_xml(self, value):
try:
value.toxml()
@@ -220,8 +231,8 @@
except:
pass
return False
-
-
+
+
class VariableList(Variable):
def __init__(self, name, value, mods, list_type):
Variable.__init__(name, value, mods=mods)
@@ -233,29 +244,29 @@
self.__mods = mods
self.__type = list_type
self.__value = value
-
+
def get_name(self):
return self.__name
-
+
def get_value(self):
return self.__value
def set_value(self, value):
raise Exception, 'VariableList.set_value() not implemented'
-
+
def type(self):
return self.__type
-
+
def get_modifiers(self):
return self.__mods
def set_modifier(self, mod_name, mod_value):
self.__mods[mod_name] = mod_value
return
-
+
def export_xml(self, doc):
elem = doc.createElement(VARIABLE_TAG)
elem.setAttribute('name', self.__name)
elem.setAttribute('type', self.type())
-
+
l = self.get_value()
for x in l:
if self.type() == VARIABLE_TYPE_LIST_XML:
--- conga/luci/site/luci/Extensions/cluster_adapters.py 2007/05/14 18:00:14 1.255.2.4
+++ conga/luci/site/luci/Extensions/cluster_adapters.py 2007/05/15 21:42:21 1.255.2.5
@@ -1,5 +1,11 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from xml.dom import minidom
-import AccessControl
from ClusterModel.ModelBuilder import ModelBuilder
from ClusterModel.FailoverDomain import FailoverDomain
@@ -22,12 +28,11 @@
from ResourceHandler import create_resource
from system_adapters import validate_svc_update
from homebase_adapters import parseHostForm
-from LuciZope import userAuthenticated
from LuciClusterInfo import getClusterInfo
from conga_constants import *
-from FenceHandler import validateNewFenceDevice, FENCE_OPTS, \
+from FenceHandler import validateNewFenceDevice, \
validateFenceDevice, validate_fenceinstance, \
FD_VAL_FAIL, FD_VAL_SUCCESS
@@ -35,10 +40,11 @@
batch_status, extract_module_status
from LuciDB import manageCluster, createClusterSystems, \
- havePermCreateCluster, setNodeStatus, getStorageNode, \
+ setNodeStatus, getStorageNode, noNodeStatusPresent, \
getClusterNode, delCluster, buildClusterCreateFlags, \
- noNodeStatussPresent, resolve_nodename, set_node_flag, \
- getRicciAgent
+ resolve_nodename, set_node_flag, getRicciAgent
+
+from LuciZopePerm import havePermCreateCluster
luci_log = get_logger()
@@ -577,12 +583,12 @@
while True:
batch_ret = rq.checkBatch(cluster_ricci, batch_number)
code = batch_ret[0]
- if code == True:
+ if code is True:
break
if code == -1:
errors.append(batch_ret[1])
raise Exception, str(batch_ret[1])
- if code == False:
+ if code is False:
time.sleep(0.5)
except Exception, e:
incomplete = True
@@ -888,7 +894,7 @@
except Exception, e:
luci_log.debug_verbose('VRA1: no model: %s' % str(e))
return None
-
+
errors = list()
try:
res = create_resource(res_type, request.form, model)
@@ -935,7 +941,7 @@
errors.append('An invalid multicast selection was made')
return (False, {'errors': errors})
- if mcast_manual == True:
+ if mcast_manual is True:
try:
addr_str = form['mcast_address'].strip()
socket.inet_pton(socket.AF_INET, addr_str)
@@ -951,7 +957,7 @@
else:
addr_str = None
- if (addr_str is None and mcast_manual != True) or (mcast_manual == True and addr_str == model.getMcastAddr()):
+ if (addr_str is None and mcast_manual is not True) or (mcast_manual is True and addr_str == model.getMcastAddr()):
errors.append('No multicast configuration changes were made')
return (False, {'errors': errors})
@@ -1930,7 +1936,7 @@
if fdev.getName().strip() == fencedev_name:
fdev_to_delete = fdev
break
- if fdev_to_delete == None:
+ if fdev_to_delete is None:
luci_log.debug_verbose('VFD: Could not find fence device name in model')
return (False, {'errors':['Could not find fence device name in model']})
@@ -2647,7 +2653,7 @@
else:
svadd['currentItem'] = False
- if model.getIsVirtualized() == True:
+ if model.getIsVirtualized() is True:
vmadd = {}
vmadd['Title'] = "Add a Virtual Service"
vmadd['cfg_type'] = "vmadd"
@@ -2724,7 +2730,7 @@
kids = list()
kids.append(svadd)
- if model.getIsVirtualized() == True:
+ if model.getIsVirtualized() is True:
kids.append(vmadd)
kids.append(svcfg)
sv['children'] = kids
@@ -3161,7 +3167,7 @@
if nodename is None:
luci_log.debug_verbose('serviceMigrate1: no target node name')
return None
-
+
cluname = None
try:
cluname = req['clustername']
@@ -3335,14 +3341,14 @@
return None
objname = '%s____flag' % nodename_resolved
- fnpresent = noNodeStatussPresent(self, nodefolder, objname, nodename_resolved)
+ fnpresent = noNodeStatusPresent(self, nodefolder, objname, nodename_resolved)
if fnpresent is None:
luci_log.debug('NL1: An error occurred while checking flags for %s' \
% nodename_resolved)
return None
- if fnpresent == False:
+ if fnpresent is False:
luci_log.debug('NL2: flags are still present for %s -- bailing out' \
% nodename_resolved)
return None
@@ -4004,7 +4010,7 @@
if batch_xml is None:
# The job is done and gone from queue
- if redirect_message == False:
+ if redirect_message is False:
# We have not displayed this message yet
node_report['desc'] = REDIRECT_MSG
node_report['iserror'] = True
@@ -4139,7 +4145,7 @@
finished = batch_res[0]
err_msg = batch_res[1]
- if finished == True or finished == -1:
+ if finished is True or finished == -1:
if finished == -1:
flag_msg = err_msg
else:
@@ -4173,7 +4179,7 @@
part2 = tmpstr
###FIXME - The above assumes that the 'busyfirst' query var is at the
###end of the URL...
- busy_map['refreshurl'] = '5; url=%s?%s' % (part1, part2)
+ busy_map['refreshurl'] = '5; url=%s?%s' % (part1, part2)
req['specialpagetype'] = '1'
else:
try:
@@ -4482,7 +4488,7 @@
cc_xml = minidom.parseString(cc)
except:
pass
- if cc_xml == None:
+ if cc_xml is None:
msg_list.append('FAILED\n')
msg_list.append('Fix the error and try again:\n')
else:
@@ -4523,4 +4529,4 @@
model = req.SESSION.get('model')
cc = model.exportModelAsString()
- return {'msg': ''.join(msg_list), 'cluster_conf': cc}
+ return { 'msg': ''.join(msg_list), 'cluster_conf': cc }
--- conga/luci/site/luci/Extensions/conga_constants.py 2007/05/14 16:02:11 1.39.2.3
+++ conga/luci/site/luci/Extensions/conga_constants.py 2007/05/15 21:42:21 1.39.2.4
@@ -1,3 +1,10 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
# Cluster area page types
CLUSTERLIST = '3'
CLUSTERS = '4'
@@ -131,7 +138,7 @@
PRE_CFG = 'Reboot stage successful, but configuration for the cluster is not yet distributed.'
PRE_JOIN = 'Packages are installed and configuration has been distributed, but the node has not yet joined the cluster.'
-POSSIBLE_REBOOT_MESSAGE = 'This node is not currently responding and is probably rebooting as planned. This state should persist for 5 minutes or so...'
+POSSIBLE_REBOOT_MESSAGE = 'This node is not currently responding and is probably rebooting as planned. This state could persist for 5 minutes or so...'
REDIRECT_MSG = ' -- You will be redirected in 5 seconds.'
--- conga/luci/site/luci/Extensions/conga_ssl.py 2007/05/04 19:10:24 1.2.4.1
+++ conga/luci/site/luci/Extensions/conga_ssl.py 2007/05/15 21:42:21 1.2.4.2
@@ -1,3 +1,10 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
import sys
sys.path.append('/usr/lib/luci/ssl')
sys.path.append('/usr/lib64/luci/ssl')
@@ -9,7 +16,7 @@
# timeouts are in seconds (int)
class SSLSocket:
-
+
def __init__(self,
hostname,
port,
@@ -25,10 +32,10 @@
if self.__id != -1:
conga_ssl_lib.disconnect(self.__id)
self.__id = -1
-
+
def peer_fingerprint(self):
return conga_ssl_lib.peer_fingerprint(self.__id)
-
+
def trusted(self):
return conga_ssl_lib.trusted(self.__id) == 1
def trust(self):
@@ -37,7 +44,7 @@
return conga_ssl_lib.trust(self.__id, self.__hostname) == 1
def untrust(self):
return conga_ssl_lib.untrust(self.__id) == 1
-
+
def send(self, msg, timeout):
conga_ssl_lib.send(self.__id, msg, timeout)
def recv(self, timeout):
--- conga/luci/site/luci/Extensions/conga_storage_constants.py 2007/05/03 20:16:38 1.8.8.1
+++ conga/luci/site/luci/Extensions/conga_storage_constants.py 2007/05/15 21:42:21 1.8.8.2
@@ -1,4 +1,13 @@
-from ricci_defines import MAPPER_ATARAID_TYPE, MAPPER_CRYPTO_TYPE, MAPPER_iSCSI_TYPE, MAPPER_MDRAID_TYPE, MAPPER_MULTIPATH_TYPE, MAPPER_PT_TYPE, MAPPER_SYS_TYPE, MAPPER_VG_TYPE
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
+from ricci_defines import MAPPER_ATARAID_TYPE, MAPPER_CRYPTO_TYPE, \
+ MAPPER_iSCSI_TYPE, MAPPER_MDRAID_TYPE, MAPPER_MULTIPATH_TYPE, \
+ MAPPER_PT_TYPE, MAPPER_SYS_TYPE, MAPPER_VG_TYPE
## request vars ##
@@ -66,12 +75,12 @@
'extents_used' : "Used Extents",
'failed' : "Failed",
'format' : "Format",
- 'fstab' : "List in /etc/fstab",
- 'fstabpoint' : "/etc/fstab Mountpoint",
- 'gfs_fsname' : "Unique GFS Name",
+ 'fstab' : "List in /etc/fstab",
+ 'fstabpoint' : "/etc/fstab Mountpoint",
+ 'gfs_fsname' : "Unique GFS Name",
'has_journal' : "Journaling Enabled - ext3",
- 'journals_num' : "Number Of Journals",
- 'journal_size' : "Journal Size",
+ 'journals_num' : "Number Of Journals",
+ 'journal_size' : "Journal Size",
'label' : "Label",
'level' : "Level",
'locking_protocol' : "Locking Protocol",
@@ -84,7 +93,7 @@
'model' : "Model",
'mount' : "Mount",
'mountable' : "Mountable",
- 'mountpoint' : "Mountpoint",
+ 'mountpoint' : "Mountpoint",
'num_devices' : "Number of Devices",
'num_spares' : "Number of Spares",
'partition_begin' : "Partition Begin",
--- conga/luci/site/luci/Extensions/homebase_adapters.py 2007/05/14 18:00:14 1.50.2.3
+++ conga/luci/site/luci/Extensions/homebase_adapters.py 2007/05/15 21:42:21 1.50.2.4
@@ -1,15 +1,24 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from conga_constants import PLONE_ROOT, CLUSTER_NODE_NEED_AUTH, \
- STORAGE_FOLDER_PATH, CLUSTER_FOLDER_PATH
+ STORAGE_FOLDER_PATH, CLUSTER_FOLDER_PATH, LUCI_DEBUG_MODE
from RicciQueries import getClusterConf
from LuciSyslog import get_logger
from HelperFunctions import resolveOSType
-from LuciDB import delCluster, clearNodeStatus, delSystem, getClusterNode, \
- getClusters, getStorage, getStorageNode, \
- havePermAddCluster, havePermAddUser, havePermDelUser, \
- havePermEditPerms, havePermRemCluster, havePermRemStorage, \
- havePermAddStorage, manageCluster
+from LuciDB import delCluster, clearNodeStatus, delSystem, \
+ getClusterNode, getClusters, getStorage, getStorageNode, \
+ manageCluster
+
+from LuciZopePerm import havePermAddCluster, havePermRemCluster, \
+ havePermAddUser, havePermDelUser, havePermEditPerms, \
+ havePermRemStorage, havePermAddStorage
from ricci_communicator import RicciCommunicator
@@ -59,7 +68,7 @@
if not request.form.has_key('deluserId'):
return (False, { 'errors': [ 'No User ID given' ] })
-
+
userId = request.form['deluserId']
try:
@@ -67,27 +76,32 @@
if not user:
raise Exception, 'user %s does not exist' % userId
except Exception, e:
- luci_log.debug_verbose('VDU0: %s: %r' % (userId, e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VDU0: %s: %r' % (userId, e))
return (False, {'errors': [ 'No such user: "%s"' % userId ] })
for i in getClusters(self):
try:
i[1].manage_delLocalRoles([ userId ])
except Exception, e:
- luci_log.debug_verbose('VDU1: %s %s: %r' % (userId, i[0], e))
- errors.append('Error deleting roles from cluster "%s" for user "%s"' % (i[0], userId))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VDU1: %s %s: %r' % (userId, i[0], e))
+ errors.append('Error deleting roles from cluster "%s" for user "%s"' \
+ % (i[0], userId))
for i in getStorage(self):
try:
i[1].manage_delLocalRoles([ userId ])
except Exception, e:
- luci_log.debug_verbose('VDU2: %s: %r' % (userId, i[0], e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VDU2: %s: %r' % (userId, i[0], e))
errors.append('Error deleting roles from storage system "%s" for user "%s"' % (i[0], userId))
try:
self.acl_users.userFolderDelUsers([ userId ])
except Exception, e:
- luci_log.debug_verbose('VDU3: %s %r' % (userId, e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VDU3: %s %r' % (userId, e))
errors.append('Unable to delete user "%s"' % userId)
return (False, {'errors': errors })
@@ -118,7 +132,8 @@
try:
self.portal_registration.addMember(user, passwd, properties = { 'username': user, 'password': passwd, 'confirm': passwd, 'roles': [ 'Member' ], 'domains': [], 'email': '%s at conga.example.com' % user })
except Exception, e:
- luci_log.debug_verbose('VAU0: %s: %r' % (user, e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAU0: %s: %r' % (user, e))
return (False, { 'errors': [ 'Unable to add new user "%s"' % user ] })
if not self.portal_membership.getMemberById(user):
@@ -144,7 +159,8 @@
raise Exception, 'no node was given'
cur_host = sysData[0]
except Exception, e:
- luci_log.debug_verbose('vACI0: %s' % str(e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('vACI0: %r' % e)
return (False, { 'errors': [ 'You must provide the address of at least one node in the cluster you wish to add.' ]})
cur_entry = { 'host': cur_host }
@@ -154,7 +170,8 @@
cur_pass = sysData[1]
cur_entry['passwd'] = cur_pass
except:
- luci_log.debug_verbose('vACI1: %s no password given')
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('vACI1: %s no password given' % cur_host)
request.SESSION.set('add_cluster_initial', cur_entry)
return (False, { 'errors': [ 'No password was given for %s' % cur_host ] })
@@ -194,10 +211,10 @@
else:
cur_entry['fp'] = cur_fp[1]
except Exception, e:
- luci_log.debug_verbose('vACI2: %s: %s' % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('vACI2: %s: %r' % (cur_host, e))
request.SESSION.set('add_cluster_initial', cur_entry)
- return (False, { 'errors': [ 'Unable to establish a connection to the ricci agent on %s: %s' \
- % (cur_host, str(e)) ] })
+ return (False, { 'errors': [ 'Unable to establish a connection to the ricci agent on %s: %s' % (cur_host, str(e)) ] })
if not check_certs or cur_host_trusted:
try:
@@ -213,7 +230,8 @@
return (False, { 'errors': [ errmsg ] })
rc.trust()
except Exception, e:
- luci_log.debug_verbose('vACI3: %s %s' % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('vACI3: %s %r' % (cur_host, e))
request.SESSION.set('add_cluster_initial', cur_entry)
return (False, { 'errors': [ 'Unable to establish trust for host %s' % (cur_host, str(e)) ] })
elif check_certs:
@@ -241,7 +259,8 @@
raise Exception, 'rc is None'
cur_entry['trusted'] = rc.trusted()
except Exception, e:
- luci_log.debug_verbose('vACI4: %s %s' % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('vACI4: %s %r' % (cur_host, e))
request.SESSION.set('add_cluster_initial', cur_entry)
return (False, { 'errors': [ 'Unable to connect to the ricci agent on %s' % cur_host ] })
@@ -252,8 +271,8 @@
if not rc.authed():
raise Exception, 'authentication failed'
except Exception, e:
- errmsg = 'Unable to authenticate to the ricci agent on %s: %s' % (cur_host, str(e))
- luci_log.debug_verbose('vACI5: %s: %s' % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('vACI5: %s: %r' % (cur_host, e))
request.SESSION.set('add_cluster_initial', cur_entry)
return (False, { 'errors': [ 'Unable to authenticate to the ricci agent on "%s"' % cur_host ] })
@@ -280,8 +299,9 @@
cluster_name = cluster_info[0]
cluster_os = resolveOSType(rc.os())
- luci_log.debug_verbose('vACI5a: cluster os is %s (%s)' \
- % (cluster_os, rc.os()))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('vACI5a: cluster os is %s (%s)' \
+ % (cluster_os, rc.os()))
try:
cluster_conf = getClusterConf(rc)
@@ -347,7 +367,8 @@
try:
num_storage = int(request.form['numStorage'].strip())
except Exception, e:
- luci_log.debug_verbose('PHF1: numStorage field missing: %s' % str(e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('PHF1: numStorage field missing: %r' % e)
errors.append('The number of systems entered could not be determined.')
trust_shown = False
@@ -431,8 +452,8 @@
except:
pass
errors.append('Unable to retrieve the SSL fingerprint for node %s: %s' % (cur_host, str(e)))
- luci_log.debug_verbose('PHF2: %s: %s' \
- % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('PHF2: %s: %r' % (cur_host, e))
else:
try:
rc = RicciCommunicator(cur_host, enforce_trust=False)
@@ -456,9 +477,10 @@
del cur_system['trusted']
rc.untrust()
except:
- pass
+ pass
errors.append('Unable to add the key for node %s to the trusted keys list.' % cur_host)
- luci_log.debug_verbose('PHF3: %s: %s' % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('PHF3: %s: %r' % (cur_host, e))
system_list[cur_host] = cur_system
i += 1
@@ -476,13 +498,15 @@
try:
cluster_name = request.form['clusterName'].strip()
except:
- luci_log.debug_verbose('VAC0: no cluster name')
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAC0: no cluster name')
errors.append('No cluster name was given.')
try:
cluster_os = request.form['cluster_os'].strip()
except:
- luci_log.debug_verbose('VAC1: no cluster os')
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAC1: no cluster os')
errors.append('Unable to determine the version of cluster %s.' % cluster_name)
check_certs = request.form.has_key('check_certs')
@@ -523,8 +547,8 @@
% (cur_host, str(e)))
incomplete = True
cur_system['errors'] = True
- luci_log.debug_verbose('VAC2: %s: %s' \
- % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAC2: %s: %r' % (cur_host, e))
continue
try:
@@ -536,7 +560,8 @@
% (cur_host, str(e)))
incomplete = True
cur_system['errors'] = True
- luci_log.debug_verbose('VAC3: %s: %s' % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAC3: %s: %r' % (cur_host, e))
continue
cluster_info = rc.cluster_info()
@@ -559,16 +584,19 @@
try:
rc.unauth()
except Exception, e:
- luci_log.debug_verbose('VAC4: %s: %s' % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAC4: %s: %r' % (cur_host, e))
errors.append(err_msg)
- luci_log.debug_verbose('VAC5: %s' % err_msg)
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAC5: %s' % err_msg)
continue
cur_os = resolveOSType(rc.os())
if cur_os != cluster_os:
- luci_log.debug_verbose('VAC5a: "%s" / "%s" -> "%s"' \
- % (cluster_os, rc.os(), cur_os))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAC5a: "%s" / "%s" -> "%s"' \
+ % (cluster_os, rc.os(), cur_os))
incomplete = True
cur_system['errors'] = True
@@ -576,13 +604,15 @@
try:
rc.unauth()
except Exception, e:
- luci_log.debug_verbose('VAC6: %s: %s' % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAC6: %s: %r' % (cur_host, e))
err_msg = 'Node %s reports its cluster version is %s and we expect %s' \
% (cur_host, cur_os, cluster_os)
errors.append(err_msg)
- luci_log.debug_verbose('VAC7: %s' % err_msg)
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAC7: %s' % err_msg)
continue
else:
incomplete = True
@@ -594,10 +624,9 @@
err_msg = manageCluster(self, cluster_name, system_list, cluster_os)
if err_msg:
incomplete = True
- errors.append('An error occurred while creating the database objects for cluster %s: %s' \
- % (cluster_name, err_msg))
- luci_log.debug_verbose('VAC7: error adding cluster DB objects for %s: %s' \
- % (cluster_name, err_msg))
+ errors.append('An error occurred while creating the database objects for cluster %s: %s' % (cluster_name, err_msg))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAC7: error adding cluster DB objects for %s: %s' % (cluster_name, err_msg))
else:
messages.append('Cluster %s is now managed by Luci' % cluster_name)
incomplete = False
@@ -608,7 +637,7 @@
return_code = False
else:
return_code = True
-
+
return (return_code, {'errors': errors, 'messages': messages })
def validateAddSystem(self, request):
@@ -658,7 +687,8 @@
try:
request.SESSION.set('add_systems', add_systems)
except Exception, e:
- luci_log.debug_verbose('validateSA2: %s' % str(e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('validateSA2: %r' % e)
return_code = False
else:
try:
@@ -687,7 +717,8 @@
raise Exception, 'no user'
user_id = user.getUserId()
except Exception, e:
- luci_log.debug_verbose('VP1: no user "%s": %r' % (username, e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VP1: no user "%s": %r' % (username, e))
errors.append('An invalid user "%s" was given' % username)
if len(errors) > 0:
@@ -707,7 +738,8 @@
i[1].manage_delLocalRoles([ user_id ])
messages.append('Removed permission for user "%s" for cluster "%s"' % (user_id, i[0]))
except Exception, e:
- luci_log.debug_verbose('VP2: %s %s: %r' % (user_id, i[0], e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VP2: %s %s: %r' % (user_id, i[0], e))
errors.append('Failed to remove permission for user "%s" for cluster "%s"' % (user_id, i[0]))
else:
for i in clusters:
@@ -719,7 +751,8 @@
i[1].manage_setLocalRoles(user_id, roles)
messages.append('Added permission for user "%s" for cluster "%s"' % (user_id, i[0]))
except Exception, e:
- luci_log.debug_verbose('VP3: %s %s %r' % (user_id, i[0], e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VP3: %s %s %r' % (user_id, i[0], e))
errors.append('Failed to add permission for user "%s" for cluster "%s"' % (user_id, i[0]))
else:
try:
@@ -734,7 +767,8 @@
messages.append('Removed permission for user "%s" for cluster "%s"' % (user_id, i[0]))
except Exception, e:
- luci_log.debug_verbose('VP4: %s %s %r' % (user_id, i[0], e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VP4: %s %s %r' % (user_id, i[0], e))
errors.append('Failed to remove permission for user "%s" for cluster "%s"' % (user_id, i[0]))
@@ -814,7 +848,8 @@
if not rc:
raise Exception, 'connection failed'
except Exception, e:
- luci_log.debug_verbose('validateAuth0: %s: %s' % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('validateAuth0: %s: %r' % (cur_host, e))
errors.append('Unable to communicate with the ricci agent on %s: %s' \
% (cur_host, str(e)))
incomplete = True
@@ -842,7 +877,8 @@
pass
except Exception, e:
errors.append('Unable to authenticate to %s: %s' % (cur_host, str(e)))
- luci_log.debug_verbose('validateAuth1: %s: %s' % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('validateAuth1: %s: %r' % (cur_host, e))
incomplete = True
cur_system['error'] = True
@@ -856,7 +892,8 @@
try:
request.SESSION.set('auth_systems', system_list)
except Exception, e:
- luci_log.debug_verbose('validateAuthenticate2: %s' % str(e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('validateAuthenticate2: %r' % e)
else:
try:
request.SESSION.delete('auth_systems')
@@ -1086,7 +1123,8 @@
def createSystem(self, host, passwd):
try:
dummy = self.restrictedTraverse('%s%s' % (STORAGE_FOLDER_PATH, host)).objectItems()
- luci_log.debug_verbose('CS0: %s already exists' % host)
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('CS0: %s already exists' % host)
return 'Storage system %s is already managed' % host
except:
pass
@@ -1096,28 +1134,32 @@
if rc is None:
raise Exception, 'rc is None'
except Exception, e:
- luci_log.debug_verbose('CS1: %s: %s' % (host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('CS1: %s: %s' % (host, e))
return 'Unable to establish a secure connection to the ricci agent on %s: %s' % (host, str(e))
try:
if not rc.authed():
rc.auth(passwd)
except Exception, e:
- luci_log.debug_verbose('CS2: %s: %s' % (host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('CS2: %s: %s' % (host, e))
return 'Unable to communicate with the ricci agent on %s for authentication' % host
try:
i = rc.authed()
except Exception, e:
- luci_log.debug_verbose('CS3 %s: %s' % (host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('CS3 %s: %r' % (host, e))
return 'Unable to authenticate to the ricci agent on %s' % host
- if i != True:
+ if i is not True:
return 'Authentication for storage system %s failed' % host
try:
dummy = self.restrictedTraverse('%s%s' % (STORAGE_FOLDER_PATH, host)).objectItems()
- luci_log.debug_verbose('CS4 %s already exists' % host)
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('CS4 %s already exists' % host)
return 'Storage system %s is already managed' % host
except:
pass
@@ -1125,21 +1167,24 @@
try:
ssystem = self.restrictedTraverse(STORAGE_FOLDER_PATH)
except Exception, e:
- luci_log.debug_verbose('CS5 %s: %s' % (host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('CS5 %s: %r' % (host, e))
return 'Unable to create storage system %s: %s' % host
try:
ssystem.manage_addFolder(host, '__luci__:system')
newSystem = self.restrictedTraverse('%s%s' % (STORAGE_FOLDER_PATH, host))
except Exception, e:
- luci_log.debug_verbose('CS6 %s: %s' % (host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('CS6 %s: %r' % (host, e))
return 'Unable to create DB entry for storage system %s' % host
try:
newSystem.manage_acquiredPermissions([])
newSystem.manage_role('View', ['Access contents information', 'View'])
except Exception, e:
- luci_log.debug_verbose('CS7 %s: %s' % (host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('CS7 %s: %r' % (host, e))
return 'Unable to set permissions on storage system %s' % host
return None
@@ -1157,11 +1202,13 @@
members.sort()
user = members[0].getUserName()
except Exception, e:
- luci_log.debug_verbose('getDefaultUser0: %s' % str(e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('getDefaultUser0: %r' % e)
user = None
if not user:
- luci_log.debug_verbose('getDefaultUser1: user is none')
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('getDefaultUser1: user is none')
return user
def getUserPerms(self):
@@ -1174,7 +1221,8 @@
raise Exception, 'no portal members exist'
members.sort()
except Exception, e:
- luci_log.debug_verbose('getUserPerms0: %s' % str(e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('getUserPerms0: %r' % e)
return {}
for i in members:
@@ -1188,22 +1236,25 @@
clusters = self.restrictedTraverse('%s/systems/cluster/objectItems' % PLONE_ROOT)('Folder')
storage = self.restrictedTraverse('%s/systems/storage/objectItems' % PLONE_ROOT)('Folder')
except Exception, e:
- luci_log.debug_verbose('getUserPerms1: user %s: %s' % (userName, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('getUserPerms1: user %s: %r' % (userName, e))
continue
for c in clusters:
try:
perms[userName]['cluster'][c[0]] = i.has_role('View', c[1])
except Exception, e:
- luci_log.debug_verbose('getUserPerms2: user %s, obj %s: %s' \
- % (userName, c[0], str(e)))
-
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('getUserPerms2: user %s, obj %s: %r' \
+ % (userName, c[0], e))
+
for s in storage:
try:
perms[userName]['storage'][s[0]] = i.has_role('View', s[1])
except Exception, e:
- luci_log.debug_verbose('getUserPerms2: user %s, obj %s: %s' \
- % (userName, s[0], str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('getUserPerms2: user %s, obj %s: %r' \
+ % (userName, s[0], e))
return perms
def getClusterConfNodes(conf_dom):
--- conga/luci/site/luci/Extensions/ricci_communicator.py 2007/05/14 18:00:14 1.25.2.3
+++ conga/luci/site/luci/Extensions/ricci_communicator.py 2007/05/15 21:42:21 1.25.2.4
@@ -1,3 +1,10 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
import xml
import xml.dom
from xml.dom import minidom
@@ -15,15 +22,15 @@
def __init__(self, hostname, enforce_trust=True, port=11111):
self.__hostname = hostname
self.__port = port
-
+
self.__timeout_init = 4
self.__timeout_auth = 4
self.__timeout_short = 6
self.__timeout_long = 600
-
+
self.__privkey_file = '%sprivkey.pem' % CERTS_DIR_PATH
self.__cert_file = '%scacert.pem' % CERTS_DIR_PATH
-
+
try:
self.ss = SSLSocket(self.__hostname,
self.__port,
@@ -37,7 +44,7 @@
except:
raise RicciError, 'Error setting up SSL for connection to %s' \
% self.__hostname
-
+
# receive ricci header
hello = self.__receive(self.__timeout_init)
try:
@@ -46,14 +53,14 @@
% (self.__hostname, hello.toxml()))
except:
pass
-
+
self.__authed = hello.firstChild.getAttribute('authenticated') == 'true'
self.__cluname = hello.firstChild.getAttribute('clustername')
self.__clualias = hello.firstChild.getAttribute('clusteralias')
self.__reported_hostname = hello.firstChild.getAttribute('hostname')
self.__os = hello.firstChild.getAttribute('os')
self.__dom0 = hello.firstChild.getAttribute('xen_host') == 'true'
-
+
def hostname(self):
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('RC:hostname: [auth %d] hostname = %s' \
@@ -110,7 +117,7 @@
luci_log.debug_verbose('RC:auth0: already authenticated to %s' \
% self.__hostname)
return True
-
+
# send request
doc = minidom.Document()
ricci = doc.createElement("ricci")
@@ -119,7 +126,7 @@
ricci.setAttribute("password", password)
doc.appendChild(ricci)
self.__send(doc, self.__timeout_auth)
-
+
# receive response
resp = self.__receive(self.__timeout_auth)
self.__authed = resp.firstChild.getAttribute('authenticated') == 'true'
@@ -133,7 +140,7 @@
self.__dom0 = resp.firstChild.getAttribute('xen_host') == 'true'
except:
pass
-
+
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('RC:auth1: auth call returning %d' \
% self.__authed)
@@ -183,7 +190,7 @@
if not self.authed():
raise RicciError, 'not authenticated to host %s' % self.__hostname
-
+
# construct request
doc = minidom.Document()
ricci = doc.createElement("ricci")
@@ -197,7 +204,7 @@
ricci.setAttribute("async", async_str)
doc.appendChild(ricci)
ricci.appendChild(batch_xml.cloneNode(True))
-
+
# send request
try:
self.__send(doc, self.__timeout_short)
@@ -208,7 +215,7 @@
% (self.__hostname, str(e))
except:
raise RicciError, 'Error sending XML to host %s' % self.__hostname
-
+
# receive response
doc = self.__receive(self.__timeout_long)
if LUCI_DEBUG_MODE is True:
@@ -217,26 +224,26 @@
% (self.__hostname, doc.toxml()))
except:
pass
-
+
if doc.firstChild.getAttribute('success') != '0':
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('RC:PB3: batch command failed')
raise RicciError, 'The last ricci command to host %s failed' \
% self.__hostname
-
+
batch_node = None
for node in doc.firstChild.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == 'batch':
batch_node = node.cloneNode(True)
- if batch_node == None:
+ if batch_node is None:
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('RC:PB4: batch node missing <batch/>')
raise RicciError, 'missing <batch/> in ricci response from "%s"' \
% self.__hostname
return batch_node
-
+
def batch_run(self, batch_str, async=True):
try:
batch_xml_str = '<?xml version="1.0" ?><batch>%s</batch>' \
@@ -271,7 +278,7 @@
if not self.authed():
raise RicciError, 'Not authenticated to host %s' % self.__hostname
-
+
# construct request
doc = minidom.Document()
ricci = doc.createElement("ricci")
@@ -279,11 +286,11 @@
ricci.setAttribute("function", "batch_report")
ricci.setAttribute("batch_id", str(batch_id))
doc.appendChild(ricci)
-
+
# send request
self.__send(doc, self.__timeout_short)
-
-
+
+
# receive response
doc = self.__receive(self.__timeout_short)
if doc.firstChild.getAttribute('success') == '12':
@@ -295,7 +302,7 @@
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == 'batch':
batch_node = node.cloneNode(True)
- if batch_node == None:
+ if batch_node is None:
raise RicciError, 'Missing <batch/> in ricci\'s response from host %s' % self.__hostname
return batch_node
@@ -308,10 +315,10 @@
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('RC:send0: Error sending XML "%s" to %s: %s' % (buff, self.__hostname, str(e)))
raise RicciError, 'write error while sending XML to host %s' \
- % self.__hostname
+ % self.__hostname
except:
raise RicciError, 'write error while sending XML to host %s' \
- % self.__hostname
+ % self.__hostname
if LUCI_DEBUG_MODE is True:
try:
luci_log.debug_verbose('RC:send1: Sent XML "%s" to host %s' \
@@ -319,7 +326,7 @@
except:
pass
return
-
+
def __receive(self, timeout):
doc = None
xml_in = ''
@@ -340,7 +347,7 @@
% (xml_in, self.__hostname))
try:
- if doc == None:
+ if doc is None:
doc = minidom.parseString(xml_in)
except Exception, e:
if LUCI_DEBUG_MODE is True:
@@ -351,8 +358,8 @@
if not doc or not doc.firstChild:
raise RicciError, 'Error an empty response was received from host %s' % self.__hostname
-
- try:
+
+ try:
if doc.firstChild.nodeName != 'ricci':
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('RC:recv3: Expecting "ricci" got XML "%s" from %s' % (xml_in, self.__hostname))
@@ -361,11 +368,11 @@
raise RicciError, 'Invalid XML ricci response from host %s' \
% self.__hostname
return doc
-
+
def get_ricci_communicator(self, hostname, allowed_systems):
if not self.access_to_host_allowed(hostname, allowed_systems):
return None
-
+
try:
return RicciCommunicator(hostname)
except Exception, e:
@@ -395,13 +402,13 @@
# check the status of batch
# returns (int num, int total)
# * total:
-# total number of modules in batch
+# total number of modules in batch
# * num:
-# if num == total:
+# if num == total:
# all modules in the batch completed successfuly
-# if num > 0:
+# if num > 0:
# last seq. number of module that successfuly finished
-# if num < 0:
+# if num < 0:
# module (-num) failed (next module won't be processed)
def batch_status(batch_xml):
@@ -438,20 +445,20 @@
# extract error_code from module's response
# * module_num:
-# 1-based seq. number of module to process
+# 1-based seq. number of module to process
#
# returns (int error_code, string error_msg)
# * error_code: each module defines own error codes, which are >0
-# -101 - in progress
-# -102 - scheduled
-# -103 - removed from schedule
-# -104 - failed to execute module
-#
-# >-3 - module executed. Following codes are defined:
-# -2 - API error
-# -1 - undefined error occured (msg not necesarily very informative)
-# 0 - no error (msg is empty string)
-# >0 - predefined error has occured
+# -101 - in progress
+# -102 - scheduled
+# -103 - removed from schedule
+# -104 - failed to execute module
+#
+# >-3 - module executed. Following codes are defined:
+# -2 - API error
+# -1 - undefined error occured (msg not necesarily very informative)
+# 0 - no error (msg is empty string)
+# >0 - predefined error has occured
# (check respective API, msg will be fully descriptive)
# * error_msg: error message
@@ -481,7 +488,7 @@
if node_j.nodeType == xml.dom.Node.ELEMENT_NODE:
if node_j.nodeName == 'function_response':
code = -11111111
- msg = 'BUG'
+ msg = 'BUG'
for var in node_j.childNodes:
if var.nodeType == xml.dom.Node.ELEMENT_NODE:
if var.nodeName == 'var':
@@ -492,7 +499,7 @@
elif var.getAttribute('name') == 'error_description':
msg = var.getAttribute('value')
return code, msg
-
+
elif status == '1':
return -102, 'module scheduled for execution'
elif status == '2':
@@ -501,5 +508,5 @@
return -104, 'failed to locate/execute module'
elif status == '5':
return -103, 'module removed from schedule'
-
+
raise RicciError, 'no %dth module in the batch, or malformed response' % module_num
--- conga/luci/site/luci/Extensions/ricci_defines.py 2007/05/03 20:16:38 1.1.8.1
+++ conga/luci/site/luci/Extensions/ricci_defines.py 2007/05/15 21:42:21 1.1.8.2
@@ -1,3 +1,10 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
REQUEST_TAG = 'request'
RESPONSE_TAG = 'response'
--- conga/luci/site/luci/Extensions/storage_adapters.py 2007/05/04 19:10:24 1.9.4.2
+++ conga/luci/site/luci/Extensions/storage_adapters.py 2007/05/15 21:42:21 1.9.4.3
@@ -1,29 +1,22 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
+from conga_storage_constants import ADD_SOURCES, CLUNAME, CLUSTER_STORAGE, \
+ CREATE_MAPPER, get_pretty_mapper_info, PAGETYPE, PT_MAPPER_ID, \
+ PT_MAPPER_TYPE, PT_PATH, STONAME, STORAGE, STORAGESYS, \
+ VIEW_BD, VIEW_BDS, VIEW_MAPPER, VIEW_MAPPERS
-#from ZPublisher import HTTPRequest
-
-import xml
-import xml.dom
-from xml.dom import minidom
-
-from conga_storage_constants import *
-from ricci_defines import *
-from Variable import parse_variable
+from ricci_defines import MAPPER_SYS_TYPE, MAPPER_VG_TYPE, SYSTEM_PREFIX, VG_PREFIX
from LuciZope import get_systems_statuses
-
-
-#Policy for showing the cluster chooser menu:
-#1) If there are no clusters in the ManagedClusterSystems
-#folder, then only the admin user may see this menu, and
-#the configure option should not be displayed.
-#2)If there are clusters in the ManagedClusterSystems,
-#then only display chooser if the current user has
-#permissions on at least one. If the user is admin, show ALL clusters
-
def createStorageChooser(self, request, systems):
dummynode = {}
-
- #First, see if a storage system is chosen, then
+
+ #First, see if a storage system is chosen, then
#check that the current user can access that system
stoname = None
try:
@@ -40,7 +33,7 @@
pagetype = request[PAGETYPE]
except KeyError, e:
pagetype = "0"
-
+
sdata = {}
sdata['Title'] = "System List"
sdata['cfg_type'] = "storages"
@@ -54,8 +47,8 @@
sdata['show_children'] = True
else:
sdata['show_children'] = False
-
-
+
+
syslist = list()
if sdata['show_children']:
#display_clusters = True
@@ -78,7 +71,7 @@
data,
syslist)
sdata['children'] = syslist
-
+
mylist = list()
mylist.append(sdata)
#mylist.append(sadd)
@@ -114,14 +107,14 @@
kids)
ssys['children'] = kids
else:
- if system_data['authed'] == False:
+ if system_data['authed'] is False:
return
ssys['Title'] = system_data['hostname']
ssys['cfg_type'] = "storage"
ssys['absolute_url'] = '%s?%s=%s&%s=%s' \
% (url, PAGETYPE, STORAGE, STONAME, system_data['hostname'])
ssys['Description'] = "Configure storage on %s" % system_data['hostname']
-
+
if pagetype == STORAGE:
if stoname == system_data['hostname']:
ssys['currentItem'] = True
@@ -135,7 +128,7 @@
def create_mapper_subitem(storage_report, request, mapper_list, mapper_templ_list):
-
+
try:
pagetype_req = request[PAGETYPE]
except KeyError, e:
@@ -157,25 +150,25 @@
except KeyError, e:
url = "."
hostname = request[STONAME]
-
-
+
+
mapper_type = None
if len(mapper_list) != 0:
mapper_type = mapper_list[0].getAttribute('mapper_type')
if len(mapper_templ_list) != 0:
mapper_type = mapper_templ_list[0].getAttribute('mapper_type')
- if mapper_type == None:
+ if mapper_type is None:
return None
-
-
+
+
buff, dummy1, dummy2 = get_pretty_mapper_info(mapper_type)
pretty_names = '%ss' % buff
pretty_names_desc = 'Manage %ss' % buff
pretty_name_desc = 'Manage %s' % buff
pretty_new_name = 'New %s' % buff
pretty_new_name_desc = 'Create New %s' % buff
-
-
+
+
srs_p = {}
srs_p['Title'] = pretty_names
srs_p['cfg_type'] = "nodes"
@@ -190,9 +183,9 @@
srs_p['currentItem'] = True
else:
srs_p['currentItem'] = False
-
+
srs_list = []
-
+
# new mapper
if len(mapper_templ_list) != 0:
sr = {}
@@ -202,36 +195,36 @@
% (url, PAGETYPE, CREATE_MAPPER, STONAME, hostname, PT_MAPPER_TYPE, mapper_type)
sr['Description'] = pretty_new_name_desc
sr['show_children'] = False
-
+
if pagetype_req == CREATE_MAPPER and mapper_type_req == mapper_type:
sr['currentItem'] = True
else:
sr['currentItem'] = False
-
+
srs_list.append(sr)
-
+
# existing mappers
for sr_xml in mapper_list:
sr_id = sr_xml.getAttribute('mapper_id')
srname = sr_id.replace('%s:' % mapper_type, '').replace('/dev/', '')
-
+
if srname == '' and mapper_type == MAPPER_VG_TYPE and sr_id == VG_PREFIX:
#srname = 'Uninitialized PVs'
continue
-
+
sr = {}
sr['Title'] = srname
sr['cfg_type'] = "nodes"
sr['absolute_url'] = '%s?%s=%s&%s=%s&%s=%s&%s=%s' \
% (url, PAGETYPE, VIEW_MAPPER, STONAME, hostname, PT_MAPPER_TYPE, mapper_type, PT_MAPPER_ID, sr_id)
sr['Description'] = pretty_name_desc
-
+
if (pagetype_req == VIEW_MAPPER or pagetype_req == ADD_SOURCES or pagetype_req == VIEW_BD) and mapper_id_req == sr_id:
sr['currentItem'] = True
else:
sr['currentItem'] = False
sr['show_children'] = False
-
+
# targets
tgts_list = []
for tgt_xml in storage_report.get_targets(sr_xml):
@@ -246,16 +239,16 @@
% (url, PAGETYPE, VIEW_BD, STONAME, hostname, PT_MAPPER_TYPE, mapper_type, PT_MAPPER_ID, sr_id, PT_PATH, tg_path)
tg['Description'] = tgname
tg['show_children'] = False
-
+
if pagetype_req == VIEW_BD and path_req == tg_path:
tg['currentItem'] = True
else:
tg['currentItem'] = False
tgts_list.append(tg)
-
+
sr['children'] = tgts_list
srs_list.append(sr)
-
+
if len(srs_list) != 0:
srs_p['children'] = srs_list
return srs_p
@@ -266,9 +259,9 @@
def createStorageConfigTree(self, request, storage_report):
dummynode = {}
- if storage_report == None:
+ if storage_report is None:
return dummynode
-
+
try:
pagetype = request[PAGETYPE]
except KeyError, e:
@@ -290,12 +283,12 @@
except KeyError, e:
url = "."
hostname = request[STONAME]
-
-
+
+
### Hard Drives ###
-
+
hds_pretty_name, hd_pretty_name, dummy = get_pretty_mapper_info(MAPPER_SYS_TYPE)
-
+
hds_p = {}
hds_p['Title'] = hds_pretty_name
hds_p['cfg_type'] = "nodes"
@@ -310,14 +303,14 @@
hds_p['currentItem'] = True
else:
hds_p['currentItem'] = False
-
+
targets_list = storage_report.get_targets(storage_report.get_mapper(SYSTEM_PREFIX))
-
+
hds_list = []
for target in targets_list:
sys_id = target.getAttribute('mapper_id')
hd_path = target.getAttribute('path')
-
+
hd = {}
hd['Title'] = hd_path.replace('/dev/', '')
hd['cfg_type'] = "nodes"
@@ -325,22 +318,22 @@
% (url, PAGETYPE, VIEW_BD, STONAME, hostname, PT_MAPPER_TYPE, MAPPER_SYS_TYPE, PT_MAPPER_ID, sys_id, PT_PATH, hd_path)
hd['Description'] = 'Manage %s' % hd_pretty_name
hd['show_children'] = False
-
+
if pagetype == VIEW_BD and mapper_id == sys_id and path == hd_path:
hd['currentItem'] = True
else:
hd['currentItem'] = False
-
+
hds_list.append(hd)
-
+
hds_p['children'] = hds_list
-
-
-
+
+
+
## mappers ##
-
+
main_kids = [hds_p]
-
+
mappers_dir = storage_report.get_mappers_dir()
mapper_templs_dir = storage_report.get_mapper_temps_dir()
glo_dir = {}
@@ -351,12 +344,12 @@
glo_dir[cur_type] = [[], mapper_templs_dir[cur_type]]
else:
glo_dir[cur_type][1] = mapper_templs_dir[cur_type]
-
+
for cur_type in glo_dir:
if cur_type == MAPPER_SYS_TYPE:
continue
item = create_mapper_subitem(storage_report, request, glo_dir[cur_type][0], glo_dir[cur_type][1])
- if item == None:
+ if item is None:
continue
else:
main_kids.append(item)
@@ -372,4 +365,4 @@
baseurl = request['URL']
except KeyError, e:
baseurl = "."
- return '%s?%s=%s&%s=%s' % (baseurl, PAGETYPE, str(STORAGE), STONAME, hostname)
+ return '%s?%s=%s&%s=%s' % (baseurl, PAGETYPE, str(STORAGE), STONAME, hostname)
--- conga/luci/site/luci/Extensions/system_adapters.py 2007/05/14 18:00:14 1.2.2.2
+++ conga/luci/site/luci/Extensions/system_adapters.py 2007/05/15 21:42:21 1.2.2.3
@@ -1,6 +1,14 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from ricci_communicator import RicciCommunicator
from RicciQueries import list_services, updateServices, svc_manage
from LuciSyslog import get_logger
+from conga_constants import LUCI_DEBUG_MODE
from xml.dom import minidom
luci_log = get_logger()
@@ -11,7 +19,8 @@
if not rc:
raise Exception, 'None'
except Exception, e:
- luci_log.debug_verbose('GSSL0: %s: %s' % (hostname, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('GSSL0: %s: %r' % (hostname, e))
return []
service_list = list_services(rc)
@@ -74,7 +83,8 @@
if not rc:
raise Exception, 'unknown error'
except Exception, e:
- luci_log.debug_verbose('VSU0: %s: %s' % (hostname, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VSU0: %s: %r' % (hostname, e))
return (False, {'errors': [ 'Unable to connect to the ricci agent on %s: %s' % (hostname, str(e)) ]})
sys_svc_list = list()
@@ -86,7 +96,8 @@
sys_svc_hash[svc_name] = i
sys_svc_list.append(svc_name)
except Exception, e:
- luci_log.debug_verbose('VSU1: %s: %s' % (hostname, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VSU1: %s: %r' % (hostname, e))
return (False, {'errors': [ 'Unable to retrieve the list of services from %s' % hostname ]})
try:
@@ -136,6 +147,8 @@
raise Exception, 'none'
ret = svc_manage(rc, hostname, servicename, op)
except Exception, e:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VMS0: %r' % e)
result.setAttribute('message', str(e))
ret.appendChild(result)
else:
--- conga/luci/site/luci/Extensions/ClusterModel/Attic/BaseResource.py 2007/05/15 18:58:55 1.1.2.2
+++ conga/luci/site/luci/Extensions/ClusterModel/Attic/BaseResource.py 2007/05/15 21:42:21 1.1.2.3
@@ -21,4 +21,3 @@
def isDenyAll(self):
return self.deny_all_children
-
--- conga/luci/site/luci/Extensions/ClusterModel/Attic/Cluster.py 2007/05/15 18:58:55 1.1.2.2
+++ conga/luci/site/luci/Extensions/ClusterModel/Attic/Cluster.py 2007/05/15 21:42:21 1.1.2.3
@@ -39,7 +39,7 @@
for kid in kids:
if kid.getTagName().strip() == "quorumd":
return True
-
+
return False
def getQuorumdPtr(self):
@@ -47,11 +47,11 @@
for kid in kids:
if kid.getTagName().strip() == "quorumd":
return kid
-
+
return None
def generateXML(self, doc, parent=None):
- if self.is_cfg_version_dirty == False:
+ if self.is_cfg_version_dirty is False:
self.incrementConfigVersion()
else:
self.is_cfg_version_dirty = False
@@ -59,11 +59,11 @@
def getNameAlias(self):
return self.getAlias()
-
+
def getAlias(self):
# returns None if no alias set
alias = self.getAttribute("alias")
- if alias == None:
+ if alias is None:
alias = self.getName()
self.addAttribute('alias', alias)
return alias
--- conga/luci/site/luci/Extensions/ClusterModel/Attic/ClusterNode.py 2007/05/15 18:58:55 1.1.2.2
+++ conga/luci/site/luci/Extensions/ClusterModel/Attic/ClusterNode.py 2007/05/15 21:42:21 1.1.2.3
@@ -35,14 +35,14 @@
def getInterface(self):
nd = self.getMulticastNode()
- if nd == None:
+ if nd is None:
return None
else:
return nd.getAttribute("interface")
def setInterface(self, ifc):
nd = self.getMulticastNode()
- if nd == None:
+ if nd is None:
return
else:
nd.addAttribute("interface", ifc)
--- conga/luci/site/luci/Extensions/ClusterModel/Attic/FailoverDomainNode.py 2007/05/15 18:58:55 1.1.2.2
+++ conga/luci/site/luci/Extensions/ClusterModel/Attic/FailoverDomainNode.py 2007/05/15 21:42:21 1.1.2.3
@@ -20,16 +20,16 @@
if self.priority_level > 1:
self.priority_level = self.priority_level - 1
self.addAttribute("priority", str(self.priority_level))
-
+
def lowerPriorityLevel(self):
self.priority_level = self.priority_level + 1
self.addAttribute("priority", str(self.priority_level))
def getPriorityLevel(self):
return self.priority_level
-
+
def setPriorityLevel(self, level):
- self.priority_level = level
+ self.priority_level = level
self.addAttribute("priority", str(self.priority_level))
def addAttribute(self, name, value):
--- conga/luci/site/luci/Extensions/ClusterModel/Attic/FailoverDomains.py 2007/05/15 18:58:55 1.1.2.2
+++ conga/luci/site/luci/Extensions/ClusterModel/Attic/FailoverDomains.py 2007/05/15 21:42:21 1.1.2.3
@@ -8,7 +8,7 @@
from TagObject import TagObject
TAG_NAME = "failoverdomains"
-
+
class FailoverDomains(TagObject):
def __init__(self):
TagObject.__init__(self)
--- conga/luci/site/luci/Extensions/ClusterModel/Attic/FenceDevice.py 2007/05/15 18:58:55 1.1.2.2
+++ conga/luci/site/luci/Extensions/ClusterModel/Attic/FenceDevice.py 2007/05/15 21:42:21 1.1.2.3
@@ -34,7 +34,7 @@
agent = self.getAgentType()
if agent == "fence_drac": #2 variants of drac...
mname = self.getAttribute("modulename")
- if mname == None or mname == "":
+ if not mname:
return False
else:
return True
--- conga/luci/site/luci/Extensions/ClusterModel/Attic/ModelBuilder.py 2007/05/15 18:58:55 1.1.2.3
+++ conga/luci/site/luci/Extensions/ClusterModel/Attic/ModelBuilder.py 2007/05/15 21:42:21 1.1.2.4
@@ -88,7 +88,7 @@
'quorumd': QuorumD,
'heuristic': Heuristic,
'script': Script,
- 'nfsexport': NFSExport,
+ 'nfsexport': NFSExport,
'nfsclient': NFSClient,
'SAPInstance': SAPInstance,
'SABDatabase': SAPDatabase,
@@ -138,12 +138,12 @@
self.fence_xvmd_ptr = None
self.unusual_items = list()
self.isVirtualized = False
- if mcast_addr == None:
+ if mcast_addr is None:
self.usesMulticast = False
else:
self.usesMulticast = True
- if domm != None:
+ if domm is not None:
self.parent = domm
self.object_tree = self.buildModel(None)
self.check_empty_ptrs()
@@ -154,7 +154,7 @@
self.check_for_multicast()
self.check_for_nodeids()
else:
- if filename == None:
+ if filename is None:
if lock_type == DLM_TYPE:
self.lock_type = DLM_TYPE
self.object_tree = self.buildDLMModelTemplate()
@@ -178,7 +178,7 @@
def buildModel(self, parent_node, parent_object=None):
- if parent_node == None:
+ if parent_node is None:
parent_node = self.parent
new_object = None
@@ -204,7 +204,7 @@
self.unusual_items.append((parent_object, new_object))
for item in parent_node.childNodes:
result_object = self.buildModel(item, new_object)
- if result_object != None:
+ if result_object is not None:
new_object.addChild(result_object)
return None
@@ -245,7 +245,7 @@
for item in parent_node.childNodes:
result_object = self.buildModel(item, new_object)
- if result_object != None:
+ if result_object is not None:
new_object.addChild(result_object)
return (new_object)
@@ -267,7 +267,7 @@
self.CMAN_ptr = cman
obj_tree.addChild(cman)
- if self.usesMulticast == True:
+ if self.usesMulticast is True:
mcast = Multicast()
mcast.addAttribute("addr", self.mcast_address)
cman.addChild(mcast)
@@ -291,7 +291,7 @@
self.isModified = False
return obj_tree
-
+
def buildGULMModelTemplate(self):
obj_tree = Cluster()
self.cluster_ptr = obj_tree
@@ -326,7 +326,7 @@
self.isModified = False
return obj_tree
-
+
##Because fence devices are declared in a separate XML section
##in conf file, agent types for fence instances must be done in
@@ -337,7 +337,7 @@
agent_hash = {}
for fd in fds:
agent = fd.getAttribute("agent")
- if agent != None:
+ if agent is not None:
agent_hash[fd.getName()] = agent
nodes = self.getNodes()
@@ -349,33 +349,33 @@
child.setAgentType(agent_hash[child.getName()])
##This method builds RefObject containers for appropriate
- ##entities after the object tree is built.
+ ##entities after the object tree is built.
def resolve_references(self):
reset_list_sentinel = True
- while(reset_list_sentinel == True):
+ while(reset_list_sentinel is True):
reset_list_sentinel = False
resource_children = self.resourcemanager_ptr.getChildren()
for r_child in resource_children:
if r_child.getTagName() == SERVICE:
reset_list_sentinel = self.find_references(r_child)
- if reset_list_sentinel == True:
+ if reset_list_sentinel is True:
break
-
+
def find_references(self, entity, parent=None):
result = False
- if (entity.getAttribute("ref") != None) and (entity.isRefObject() == False):
+ if (entity.getAttribute("ref") is not None) and (entity.isRefObject() is False):
result = self.transform_reference(entity, parent)
return result
-
+
children = entity.getChildren()
if len(children) > 0:
for child in children:
result = self.find_references(child, entity)
- if result == True:
+ if result is True:
return result
-
+
return result
-
+
def transform_reference(self, entity, parent):
result = False
#This entity has a "ref" attr...need to walk through resources list
@@ -399,11 +399,11 @@
rf.addChild(kid)
result = True
break
-
- if result == False:
+
+ if result is False:
return result
-
- if parent == None: #Must be a service
+
+ if parent is None: #Must be a service
self.resourcemanager_ptr.addChild(rf)
self.resourcemanager_ptr.removeChild(entity)
return True
@@ -413,9 +413,9 @@
return True
def exportModelAsString(self):
- if self.perform_final_check() == False: # failed
+ if self.perform_final_check() is False: # failed
return None
-
+
#check for dual power fences
self.dual_power_fence_check()
self.restore_unusual_items()
@@ -437,7 +437,7 @@
self.resolve_fence_instance_types()
self.purgePCDuplicates()
self.resolve_references()
- self.check_for_multicast()
+ self.check_for_multicast()
finally:
pass
@@ -457,15 +457,15 @@
if kid == item[1]:
duplicate = True
break
- if duplicate == True:
+ if duplicate is True:
continue
else:
- item[0].addChild(item[1])
+ item[0].addChild(item[1])
def check_for_nodeids(self):
nodes = self.getNodes()
for node in nodes:
- if node.getAttribute('nodeid') == None:
+ if node.getAttribute('nodeid') is None:
new_id = self.getUniqueNodeID()
node.addAttribute('nodeid', new_id)
@@ -475,39 +475,39 @@
dex_list = list()
for nd_idx in range (1, (total_nodes + 3)):
dex_list.append(str(nd_idx))
-
+
for dex in dex_list:
found = False
for node in nodes:
ndid = node.getAttribute('nodeid')
- if ndid != None:
+ if ndid is not None:
if ndid == dex:
found = True
break
else:
continue
-
- if found == True:
+
+ if found is True:
continue
else:
return dex
-
+
def setIsVirtualized(self, isVirtualized):
- if isVirtualized == None:
+ if isVirtualized is None:
self.isVirtualized = False
else:
self.isVirtualized = isVirtualized
def getIsVirtualized(self):
return self.isVirtualized
-
+
def getNodes(self):
- #Find the clusternodes obj and return get_children
+ #Find the clusternodes obj and return get_children
return self.clusternodes_ptr.getChildren()
def addNode(self, clusternode):
self.clusternodes_ptr.addChild(clusternode)
- if self.usesMulticast == True:
+ if self.usesMulticast is True:
mcast = Multicast()
mcast.addAttribute("addr", self.mcast_address)
mcast.addAttribute("interface", "eth0") #eth0 is the default
@@ -525,7 +525,7 @@
found_one = True
- while found_one == True:
+ while found_one is True:
found_one = False
fdoms = self.getFailoverDomains()
for fdom in fdoms:
@@ -538,7 +538,7 @@
lock_type = self.getLockType()
if lock_type == GULM_TYPE:
- if self.isNodeLockserver(clusternode.getName()) == True:
+ if self.isNodeLockserver(clusternode.getName()) is True:
self.removeLockserver(clusternode)
self.isModified = True
@@ -595,7 +595,7 @@
self.fence_xvmd_ptr = None
def getFenceDevices(self):
- if self.fencedevices_ptr == None:
+ if self.fencedevices_ptr is None:
return list()
else:
return self.fencedevices_ptr.getChildren()
@@ -604,7 +604,7 @@
return self.fencedevices_ptr
def getFailoverDomains(self):
- if self.failoverdomains_ptr == None:
+ if self.failoverdomains_ptr is None:
return list()
else:
return self.failoverdomains_ptr.getChildren()
@@ -639,7 +639,7 @@
newnode = FailoverDomainNode()
if len(kids) != 0: #Use an existing node as a baseline...
attrs = kids[0].getAttributes()
- kees = attrs.keys()
+ kees = attrs.keys()
for k in kees:
newnode.addAttribute(k, attrs[k])
newnode.addAttribute("name", node)
@@ -656,9 +656,9 @@
if fdom.getName().encode('ascii', 'ignore') == fd:
kids = fdom.getChildren()
for kid in kids:
- if kid.getName().encode('ascii', 'ignore') == node:
+ if kid.getName().encode('ascii', 'ignore') == node:
fdom.removeChild(kid)
- return
+ return
return
@@ -666,13 +666,13 @@
return self.usesMulticast
def check_for_multicast(self):
- if self.usesMulticast == True:
+ if self.usesMulticast is True:
#set mcast address
children = self.CMAN_ptr.getChildren()
for child in children:
if child.getTagName() == MCAST_STR:
addr = child.getAttribute("addr")
- if addr != None:
+ if addr is not None:
self.mcast_address = addr
return
else: #What a mess! a multicast tag, but no addr attribute
@@ -689,34 +689,34 @@
return self.quorumd_ptr
def check_empty_ptrs(self):
- if self.resourcemanager_ptr == None:
+ if self.resourcemanager_ptr is None:
rm = Rm()
self.cluster_ptr.addChild(rm)
self.resourcemanager_ptr = rm
- if self.failoverdomains_ptr == None:
+ if self.failoverdomains_ptr is None:
fdoms = FailoverDomains()
self.resourcemanager_ptr.addChild(fdoms)
self.failoverdomains_ptr = fdoms
- if self.fencedevices_ptr == None:
+ if self.fencedevices_ptr is None:
fds = FenceDevices()
self.cluster_ptr.addChild(fds)
self.fencedevices_ptr = fds
-
- if self.resources_ptr == None:
+
+ if self.resources_ptr is None:
rcs = Resources()
self.resourcemanager_ptr.addChild(rcs)
self.resources_ptr = rcs
-
+
if self.GULM_ptr is None and self.fence_daemon_ptr is None:
fdp = FenceDaemon()
self.cluster_ptr.addChild(fdp)
self.fence_daemon_ptr = fdp
-
+
def getServices(self):
rg_list = list()
- if self.resourcemanager_ptr != None:
+ if self.resourcemanager_ptr is not None:
kids = self.resourcemanager_ptr.getChildren()
for kid in kids:
if kid.getTagName() == SERVICE:
@@ -731,34 +731,34 @@
return service
return None
-
+
def getVMs(self):
rg_list = list()
- if self.resourcemanager_ptr != None:
+ if self.resourcemanager_ptr is not None:
kids = self.resourcemanager_ptr.getChildren()
for kid in kids:
if kid.getTagName() == VM:
rg_list.append(kid)
return rg_list
-
+
def deleteService(self, service):
- if self.resourcemanager_ptr != None:
+ if self.resourcemanager_ptr is not None:
kids = self.resourcemanager_ptr.getChildren()
for kid in kids:
if kid.getName() == service:
self.resourcemanager_ptr.removeChild(kid)
break
-
+
def getResources(self):
- if self.resources_ptr != None:
+ if self.resources_ptr is not None:
return self.resources_ptr.getChildren()
else:
return list()
def getResourcesPtr(self):
return self.resources_ptr
-
+
def getResourceManagerPtr(self):
return self.resourcemanager_ptr
@@ -773,7 +773,7 @@
def getClusterNodesPtr(self):
return self.clusternodes_ptr
-
+
def getClusterPtr(self):
return self.cluster_ptr
@@ -811,7 +811,7 @@
def isNodeLockserver(self, name):
gptr = self.getGULMPtr()
- if gptr == None: #Obviously not GULM
+ if gptr is None: #Obviously not GULM
return False
children = gptr.getChildren()
for child in children:
@@ -822,7 +822,7 @@
def removeLockserver(self, clusternode):
gptr = self.getGULMPtr()
- if gptr == None: #Obviously not GULM
+ if gptr is None: #Obviously not GULM
return
children = gptr.getChildren()
for child in children:
@@ -851,9 +851,9 @@
#remove votes attr from each node
nodes = self.getNodes()
for node in nodes:
- if self.usesMulticast == True:
+ if self.usesMulticast is True:
mnode = node.getMulticastNode()
- if mnode != None:
+ if mnode is not None:
node.removeChild(mnode)
node.removeAttribute('votes')
@@ -870,7 +870,7 @@
ls.addAttribute('name', node.getName())
self.GULM_ptr.addChild(ls)
break
-
+
#set modified
self.isModified = True
@@ -903,9 +903,9 @@
self.isModified = True
def swap_multicast_state(self, address=None):
- if self.usesMulticast == True:
+ if self.usesMulticast is True:
#First, eliminate <multicast> tag
- if self.CMAN_ptr != None:
+ if self.CMAN_ptr is not None:
children = self.CMAN_ptr.getChildren()
if len(children) > 0:
for child in children:
@@ -913,7 +913,7 @@
self.CMAN_ptr.removeChild(child)
break
found_one = True
- while found_one == True:
+ while found_one is True:
found_one = False
nodes = self.clusternodes_ptr.getChildren()
for node in nodes:
@@ -923,16 +923,16 @@
node.removeChild(node_child)
found_one = True
break
- if found_one == True:
+ if found_one is True:
break
- self.usesMulticast = False
+ self.usesMulticast = False
self.mcast_address = None
self.isModified = True
-
+
else:
- if self.CMAN_ptr != None:
+ if self.CMAN_ptr is not None:
mcast = Multicast()
mcast.addAttribute("addr", address)
self.CMAN_ptr.addChild(mcast)
@@ -946,7 +946,7 @@
if node_child.getTagName() == MCAST_STR:
has_one = True
break
- if has_one == False:
+ if has_one is False:
mcast = Multicast()
mcast.addAttribute("addr", address)
mcast.addAttribute("interface", "eth0")
@@ -955,8 +955,8 @@
self.mcast_address = address
self.usesMulticast = True
self.isModified = True
-
-
+
+
def check_fence_daemon(self):
if self.GULM_ptr is None and self.fence_daemon_ptr is None:
@@ -970,7 +970,7 @@
return self.isModified
def setModified(self, modified=None):
- if modified == None:
+ if modified is None:
self.isModified = True
else:
self.isModified = modified
@@ -1008,7 +1008,7 @@
if fence.getName() == name:
kill_list.append(fence)
for victim in kill_list:
- level.removeChild(victim)
+ level.removeChild(victim)
def removeReferences(self, tagobj):
self.__removeReferences(tagobj, self.cluster_ptr)
@@ -1019,7 +1019,7 @@
level.removeChild(t)
continue
self.__removeReferences(tagobj, t)
-
+
def updateReferences(self):
self.__updateReferences(self.cluster_ptr)
def __updateReferences(self, level):
@@ -1027,14 +1027,14 @@
if t.isRefObject():
t.setRef(t.getObj().getName())
self.__updateReferences(t)
-
+
def perform_final_check(self):
- if self.check_gulm_count() == False:
+ if self.check_gulm_count() is False:
return False
self.check_two_node()
#add more checks
-
+
return True
def check_gulm_count(self):
@@ -1045,11 +1045,11 @@
return True
def check_two_node(self):
- if self.getLockType() == DLM_TYPE and self.quorumd_ptr == None:
+ if self.getLockType() == DLM_TYPE and self.quorumd_ptr is None:
clusternodes_count = len(self.clusternodes_ptr.getChildren())
#Make certain that there is a cman tag in the file
#If missing, it will not hurt to add it here
- if self.CMAN_ptr == None:
+ if self.CMAN_ptr is None:
cman = Cman()
self.cluster_ptr.addChild(cman)
self.CMAN_ptr = cman
@@ -1059,7 +1059,7 @@
else:
if self.CMAN_ptr.getAttribute('expected_votes') in ('0', '1'):
self.CMAN_ptr.removeAttribute('expected_votes')
- self.CMAN_ptr.removeAttribute('two_node')
+ self.CMAN_ptr.removeAttribute('two_node')
def dual_power_fence_check(self):
#if 2 or more power controllers reside in the same fence level,
@@ -1078,7 +1078,7 @@
kids = level.getChildren()
l = list()
for kid in kids:
- if kid.isPowerController() == True:
+ if kid.isPowerController() is True:
l.append(kid)
if len(l) > 1: #Means we found multiple PCs in the same level
for fence in l:
@@ -1093,10 +1093,10 @@
d.addAttribute(k, attrs[k])
d.addAttribute("option", "on")
level.addChild(d)
-
+
def purgePCDuplicates(self):
found_one = True
- while found_one == True:
+ while found_one is True:
found_one = False
nodes = self.getNodes()
for node in nodes:
@@ -1105,20 +1105,18 @@
kids = level.getChildren()
for kid in kids: #kids are actual fence instance objects
res = kid.getAttribute("option")
- if res != None:
+ if res is not None:
if res == "off":
kid.removeAttribute("option")
else:
level.removeChild(kid)
found_one = True
break
- if found_one == True:
+ if found_one is True:
break
-
+
def searchObjectTree(self, tagtype):
objlist = list()
self.object_tree.searchTree(objlist, tagtype)
return objlist
-
-
--- conga/luci/site/luci/Extensions/ClusterModel/Attic/TagObject.py 2007/05/15 18:58:56 1.1.2.2
+++ conga/luci/site/luci/Extensions/ClusterModel/Attic/TagObject.py 2007/05/15 21:42:21 1.1.2.3
@@ -11,7 +11,7 @@
def __init__(self, tagname=None):
self.attr_hash = {}
self.children = list()
- if tagname == None:
+ if tagname is None:
self.TAG_NAME = TAG_NAME
else:
self.TAG_NAME = tagname
@@ -39,7 +39,7 @@
#print "TAGNAME is %s" % TAG_NAME
#print "self.TAGNAME is %s" % self.TAG_NAME
tag = doc.createElement(self.TAG_NAME)
- if parent != None:
+ if parent is not None:
parent.appendChild(tag)
else:
doc.appendChild(tag)
@@ -48,7 +48,7 @@
#parent.appendChild(tag)
if len(self.children) > 0:
for child in self.children:
- if child == None:
+ if child is None:
continue
child.generateXML(doc, tag)
@@ -86,6 +86,6 @@
objlist.append(self)
if len(self.children) > 0:
for child in self.children:
- if child == None:
+ if child is None:
continue
child.searchTree(objlist, tagtype)
More information about the Cluster-devel
mailing list