[Cluster-devel] conga/luci/site/luci/Extensions LuciDB.py Reso ...
rmccabe at sourceware.org
rmccabe at sourceware.org
Tue May 22 02:45:57 UTC 2007
CVSROOT: /cvs/cluster
Module name: conga
Branch: EXPERIMENTAL
Changes by: rmccabe at sourceware.org 2007-05-22 02:45:54
Modified files:
luci/site/luci/Extensions: LuciDB.py ResourceHandler.py
homebase_adapters.py
Log message:
backend support for SAPInstance and SAPDatabase
Patches:
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.9&r2=1.1.2.10
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.3&r2=1.1.2.4
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.6&r2=1.50.2.7
--- conga/luci/site/luci/Extensions/Attic/LuciDB.py 2007/05/18 05:23:55 1.1.2.9
+++ conga/luci/site/luci/Extensions/Attic/LuciDB.py 2007/05/22 02:45:54 1.1.2.10
@@ -667,6 +667,8 @@
luci_log.debug_verbose('GC0: %r %s' % (e, str(e)))
return None
+ if isAdmin(self):
+ return clusters
return check_clusters(self, clusters)
def getStorage(self):
@@ -682,12 +684,12 @@
def check_clusters(self, clusters):
user = getSecurityManager().getUser()
- return filter(lambda x: user.has_role('View', x[1]), clusters)
+ return filter(lambda x: user.has_permission('View', x[1]), clusters)
def cluster_permission_check(cluster):
try:
user = getSecurityManager().getUser()
- if user.has_role('View', cluster[1]):
+ if user.has_permission('View', cluster[1]):
return True
except:
pass
@@ -695,7 +697,7 @@
def allowed_systems(self, systems):
user = getSecurityManager().getUser()
- return filter(lambda x: user.has_role('View', x[1]), systems)
+ return filter(lambda x: user.has_permission('View', x[1]), systems)
def access_to_host_allowed(self, hostname, allowed_systems_list):
allowed = dict(map(lambda x: [ x[0], None ], allowed_systems_list))
--- conga/luci/site/luci/Extensions/Attic/ResourceHandler.py 2007/05/15 21:42:21 1.1.2.3
+++ conga/luci/site/luci/Extensions/Attic/ResourceHandler.py 2007/05/22 02:45:54 1.1.2.4
@@ -19,6 +19,8 @@
from ClusterModel.OpenLDAP import OpenLDAP
from ClusterModel.LVM import LVM
from ClusterModel.MySQL import MySQL
+from ClusterModel.SAPDatabase import SAPDatabase
+from ClusterModel.SAPInstance import SAPInstance
from LuciSyslog import get_logger
from conga_constants import LUCI_DEBUG_MODE
@@ -67,7 +69,7 @@
raise KeyError, 'No IP address was given'
res.addAttribute('address', addr)
except KeyError, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addIp4: %s' % err)
@@ -88,7 +90,7 @@
raise Exception, 'No mount point was given for "%s"' % rname
res.addAttribute('mountpoint', mountpoint)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addFs6: %s' % err)
@@ -99,7 +101,7 @@
raise Exception, 'No device was given for "%s"' % rname
res.addAttribute('device', device)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addFs7: %s' % err)
@@ -115,7 +117,7 @@
except:
pass
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addFs8: %s' % err)
@@ -126,7 +128,7 @@
raise Exception, 'No filesystem type was given for "%s"' % rname
res.addAttribute('fstype', fstype)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addFs9: %s' % err)
@@ -168,7 +170,7 @@
raise Exception, 'No mount point was given for "%s"' % rname
res.addAttribute('mountpoint', mountpoint)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addGfs5: %s' % err)
@@ -179,7 +181,7 @@
raise Exception, 'No device was given for "%s"' % rname
res.addAttribute('device', device)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addGfs6: %s' % err)
@@ -195,7 +197,7 @@
except:
pass
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addGfs7: %s' % err)
@@ -227,7 +229,7 @@
raise Exception, 'No mount point was given for "%s"' % rname
res.addAttribute('mountpoint', mountpoint)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addNfsm5: %s' % err)
@@ -238,7 +240,7 @@
raise Exception, 'No host server was given for "%s"' % rname
res.addAttribute('host', host)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addNfsm6 error: %s' % err)
@@ -254,7 +256,7 @@
except:
pass
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addNfsm7: %s' % err)
@@ -265,7 +267,7 @@
raise Exception, 'No export path was given for "%s"' % rname
res.addAttribute('exportpath', exportpath)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addNfsm8: %s' % err)
@@ -277,7 +279,7 @@
% (nfstype, rname)
res.addAttribute('nfstype', nfstype)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addNfsm9: %s' % err)
@@ -298,7 +300,7 @@
raise Exception, 'No target was given for "%s"' % rname
res.addAttribute('target', target)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addNfsc5: %s' % err)
@@ -314,7 +316,7 @@
except:
pass
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addNfsc6: %s' % err)
@@ -339,7 +341,7 @@
raise Exception, 'No path to a script file was given for this "%s"' % rname
res.addAttribute('file', path)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addScr5: %s' % err)
@@ -355,7 +357,7 @@
raise Exception, 'No workgroup was given for "%s"' % rname
res.addAttribute('workgroup', workgroup)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addSmb5: %s' % err)
@@ -371,7 +373,7 @@
raise KeyError, 'No server root was given for "%s"' % rname
res.addAttribute('server_root', server_root)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addApache5: %s' % err)
@@ -382,7 +384,7 @@
raise KeyError, 'No path to the Apache configuration file was given for "%s"' % rname
res.addAttribute('config_file', config_file)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addApache6: %s' % err)
@@ -398,7 +400,7 @@
except:
pass
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addApache7: %s' % err)
@@ -409,7 +411,7 @@
except KeyError, e:
res.addAttribute('shutdown_wait', '0')
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addApache7: %s' % err)
@@ -425,7 +427,7 @@
raise KeyError, 'No path to the MySQL configuration file was given for "%s"' % rname
res.addAttribute('config_file', config_file)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addMySQL5: %s' % err)
@@ -436,7 +438,7 @@
raise KeyError, 'No address was given for "%s"' % rname
res.addAttribute('listen_address', listen_addr)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addMySQL6: %s' % err)
@@ -452,7 +454,7 @@
except:
pass
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addMySQL7: %s' % err)
@@ -463,7 +465,7 @@
except KeyError, e:
res.addAttribute('shutdown_wait', '0')
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addMySQL7: %s' % err)
@@ -479,7 +481,7 @@
raise KeyError, 'No URL list was given for "%s"' % rname
res.addAttribute('url_list', url_list)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addOpenLDAP5: %s' % err)
@@ -490,7 +492,7 @@
raise KeyError, 'No path to the OpenLDAP configuration file was given for "%s"' % rname
res.addAttribute('config_file', config_file)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addOpenLDAP6: %s' % err)
@@ -506,7 +508,7 @@
except:
pass
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addOpenLDAP7: %s' % err)
@@ -517,7 +519,7 @@
except KeyError, e:
res.addAttribute('shutdown_wait', '0')
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addOpenLDAP7: %s' % err)
@@ -532,7 +534,7 @@
raise KeyError, 'No postmaster user was given for "%s"' % rname
res.addAttribute('postmaster_user', user)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addPostgreSQL85: %s' % err)
@@ -543,7 +545,7 @@
raise KeyError, 'No path to the PostgreSQL 8 configuration file was given for "%s"' % rname
res.addAttribute('config_file', config_file)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addPostgreSQL86: %s' % err)
@@ -559,7 +561,7 @@
except:
pass
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addPostgreSQL87: %s' % err)
@@ -570,7 +572,7 @@
except KeyError, e:
res.addAttribute('shutdown_wait', '0')
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addPostgreSQL87: %s' % err)
@@ -586,7 +588,7 @@
raise KeyError, 'No Tomcat user was given for "%s"' % rname
res.addAttribute('tomcat_user', user)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addTomcat55: %s' % err)
@@ -597,7 +599,7 @@
raise KeyError, 'No path to the Tomcat 5 configuration file was given for "%s"' % rname
res.addAttribute('config_file', config_file)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addTomcat56: %s' % err)
@@ -613,7 +615,7 @@
except:
pass
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addTomcat57: %s' % err)
@@ -624,7 +626,7 @@
raise KeyError, 'No cataliny base directory was given for "%s"' % rname
res.addAttribute('catalina_base', catalina_base)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addTomcat58: %s' % err)
@@ -635,7 +637,7 @@
except KeyError, e:
res.addAttribute('shutdown_wait', '0')
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addTomcat59: %s' % err)
@@ -651,7 +653,7 @@
raise KeyError, 'No volume group name was given for "%s"' % rname
res.addAttribute('vg_name', vg_name)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addLVM5: %s' % err)
@@ -662,28 +664,106 @@
raise KeyError, 'No logical volume name was given for "%s"' % rname
res.addAttribute('lv_name', lv_name)
except Exception, e:
- err = repr(e)
+ err = str(e)
errors.append(err)
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('addLVM6: %s' % err)
return errors
+def addSAPDatabase(res, rname, form, model):
+ errors = list()
+
+ try:
+ sid = form['SID'].strip()
+ if not sid:
+ raise KeyError, 'No SAP system identifier was given.'
+ res.addAttribute('SID', sid)
+ except Exception, e:
+ err = str(e)
+ errors.append(err)
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('addSAPD0: %s' % err)
+
+ try:
+ dbtype = form['DBTYPE'].strip()
+ if not dbtype in [ 'ORA', 'DB6', 'ADA' ]:
+ raise Exception, 'You gave an invalid database type: %s' % dbtype
+ res.addAttribute('DBTYPE', dbtype)
+ except Exception, e:
+ err = str(e)
+ errors.append(err)
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('addSAPD1: %s' % err)
+
+ if form.has_key('DBJ2EE_ONLY'):
+ res.addAttribute('DBJ2EE_ONLY', 'TRUE')
+ else:
+ res.removeAttribute('DBJ2EE_ONLY')
+
+ # Optional string parameters
+ for param in [ 'DIR_EXECUTABLE', 'NETSERVICENAME', 'DIR_BOOTSTRAP', 'DIR_SECSTORE' ]:
+ try:
+ pval = form[param].strip()
+ if not pval:
+ raise KeyError, 'blank'
+ res.addAttribute(param, pval)
+ except KeyError, e:
+ res.removeAttribute(param)
+ except Exception, e:
+ err = str(e)
+ errors.append(err)
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('addSAPD2: %s %s' % (param, err))
+ return errors
+
+def addSAPInstance(res, rname, form, model):
+ errors = list()
+
+ try:
+ iname = form['InstanceName'].strip()
+ if not iname:
+ raise KeyError, 'No SAP instance name was given.'
+ res.addAttribute('InstanceName', iname)
+ except Exception, e:
+ err = str(e)
+ errors.append(err)
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('addSAPI0: %s' % err)
+
+ # Optional string parameters
+ for param in [ 'DIR_EXECUTABLE', 'DIR_PROFILE', 'START_PROFILE' ]:
+ try:
+ pval = form[param].strip()
+ if not pval:
+ raise KeyError, 'blank'
+ res.addAttribute(param, pval)
+ except KeyError, e:
+ res.removeAttribute(param)
+ except Exception, e:
+ err = str(e)
+ errors.append(err)
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('addSAPI1: %s %s' % (param, err))
+ return errors
+
resource_table = {
- 'ip': [ addIp, Ip ],
- 'fs': [ addFs, Fs ],
- 'gfs': [ addClusterfs, Clusterfs ],
- 'nfsm': [ addNetfs, Netfs ],
- 'nfsx': [ addNFSExport, NFSExport ],
- 'nfsc': [ addNFSClient, NFSClient ],
- 'scr': [ addScript, Script ],
- 'smb': [ addSamba, Samba ],
- 'tomcat-5': [ addTomcat5, Tomcat5 ],
- 'postgres-8': [ addPostgres8, Postgres8 ],
- 'apache': [ addApache, Apache ],
- 'openldap': [ addOpenLDAP, OpenLDAP ],
- 'lvm': [ addLVM, LVM ],
- 'mysql': [ addMySQL, MySQL ]
+ 'ip': [ addIp, Ip ],
+ 'fs': [ addFs, Fs ],
+ 'gfs': [ addClusterfs, Clusterfs ],
+ 'nfsm': [ addNetfs, Netfs ],
+ 'nfsx': [ addNFSExport, NFSExport ],
+ 'nfsc': [ addNFSClient, NFSClient ],
+ 'scr': [ addScript, Script ],
+ 'smb': [ addSamba, Samba ],
+ 'tomcat-5': [ addTomcat5, Tomcat5 ],
+ 'postgres-8': [ addPostgres8, Postgres8 ],
+ 'apache': [ addApache, Apache ],
+ 'openldap': [ addOpenLDAP, OpenLDAP ],
+ 'lvm': [ addLVM, LVM ],
+ 'mysql': [ addMySQL, MySQL ],
+ 'SAPDatabase': [ addSAPDatabase, SAPDatabase ],
+ 'SAPInstance': [ addSAPInstance, SAPInstance ]
}
def create_resource(res_type, form, model):
--- conga/luci/site/luci/Extensions/homebase_adapters.py 2007/05/18 05:23:55 1.50.2.6
+++ conga/luci/site/luci/Extensions/homebase_adapters.py 2007/05/22 02:45:54 1.50.2.7
@@ -757,7 +757,7 @@
if not request.form.has_key('__CLUSTER'):
for i in clusters:
try:
- if user.has_role('View', i[1]):
+ if user.has_permission('View', i[1]):
roles = list(i[1].get_local_roles_for_userid(user_id))
roles.remove('View')
@@ -775,7 +775,7 @@
for i in clusters:
if i[0] in request.form['__CLUSTER']:
try:
- if not user.has_role('View', i[1]):
+ if not user.has_permission('View', i[1]):
roles = list(i[1].get_local_roles_for_userid(user_id))
roles.append('View')
i[1].manage_setLocalRoles(user_id, roles)
@@ -787,7 +787,7 @@
errors.append('Failed to add permission for user "%s" for cluster "%s"' % (user_id, i[0]))
else:
try:
- if user.has_role('View', i[1]):
+ if user.has_permission('View', i[1]):
roles = list(i[1].get_local_roles_for_userid(user_id))
roles.remove('View')
@@ -808,7 +808,7 @@
if not request.form.has_key('__SYSTEM'):
for i in storage:
try:
- if user.has_role('View', i[1]):
+ if user.has_permission('View', i[1]):
roles = list(i[1].get_local_roles_for_userid(user_id))
roles.remove('View')
@@ -823,7 +823,7 @@
for i in storage:
if i[0] in request.form['__SYSTEM']:
try:
- if not user.has_role('View', i[1]):
+ if not user.has_permission('View', i[1]):
roles = list(i[1].get_local_roles_for_userid(user_id))
roles.append('View')
i[1].manage_setLocalRoles(user_id, roles)
@@ -832,7 +832,7 @@
errors.append('Failed to add permission for user "%s" for system "%s"' % (user_id, i[0]))
else:
try:
- if user.has_role('View', i[1]):
+ if user.has_permission('View', i[1]):
roles = list(i[1].get_local_roles_for_userid(user_id))
roles.remove('View')
@@ -1279,14 +1279,14 @@
for c in clusters:
try:
- perms[userName]['cluster'][c[0]] = i.has_role('View', c[1])
+ perms[userName]['cluster'][c[0]] = i.has_permission('View', c[1])
except Exception, e:
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('getUserPerms2: user %s, obj %s: %r %s' % (userName, c[0], e, str(e)))
for s in storage:
try:
- perms[userName]['storage'][s[0]] = i.has_role('View', s[1])
+ perms[userName]['storage'][s[0]] = i.has_permission('View', s[1])
except Exception, e:
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('getUserPerms2: user %s, obj %s: %r %s' % (userName, s[0], e, str(e)))
More information about the Cluster-devel
mailing list