【发布时间】:2014-07-18 11:18:01
【问题描述】:
我对 WLST 脚本非常陌生,目前处于初级水平。我有一个脚本,它提示为它读取的每个数据源输入密码。虽然该部分工作正常,但我面临的挑战是,在生产环境中,我们要运行此脚本,将有多个托管服务器具有相同的数据源,但名称不同但 JNDI 相同,因为两个数据源都连接到同一个数据库。
在这种情况下,脚本当前的工作方式,它会提示它找到的每个数据源的密码,但我想修改脚本,以便它检查数据源的 JNDIName 以及是否已经提示任何具有相同数据源的密码JNDI 那么它应该使用相同的密码而不是再次提示输入密码。
还有多个数据源,如何处理?是否可以?此外,我不知道如何获取每个数据源的 JNDIName。我试图让 JNDIName 如下,这是行不通的- jndiName = dataSource.getJNDIName()
这是我在命令行上遇到的错误 -
Problem invoking WLST - Traceback (innermost last):
File "C:\Script\PostDeploy-DataSourcePasswords.py", line 59, in ?
File "C:\Script\PostDeploy-DataSourcePasswords.py", line 43, in updateJDBCPasswords
AttributeError: getJNDIName
这是我正在使用的脚本 -
import sys
#import wlstutility
#wlstutility.initialise(globals())
#from wlstutility import *
#from wlstutility.constructors import *
if len(sys.argv)<1:
print 'Usage: wlst.sh wibble.py <host:port>'
print ' for example: wlst.sh wibble.py prfadmin:14801'
exit()
hostPort = sys.argv[1]
print ('host:port = %s' % hostPort )
connectionUrl = ('t3://%s' % hostPort)
WL_USER='weblogic'
commitChanges=True
WL_PWD=raw_input("Enter Weblogic console password: ")
connect(WL_USER, WL_PWD, connectionUrl)
def updateJDBCPasswords():
PARAMS_TEMPLATE = '/JDBCSystemResources/%s/JDBCResource/%s/JDBCDriverParams/%s'
domainConfig()
# Get JDBC DataSources
cd("JDBCSystemResources")
dataSources = cmo.getJDBCSystemResources()
edit()
# For each DataSource update the password
for dataSource in dataSources :
dsName = dataSource.getName()
print ('DataSource Name : = %s' % dsName)
password=raw_input("Enter database password for " + dsName +" : ")
cd(PARAMS_TEMPLATE % (dsName, dsName, dsName) )
cmo.setPassword(password)
## ===========================================================
# Let's get going
edit()
startEdit()
updateJDBCPasswords()
# dump the changes made so far
print "=== START: The changes that will be applied ==="
showChanges()
if commitChanges :
# =========================================================
# commit the changes
save()
activate(block="true")
else:
# =========================================================
# rollback the changes
print "=== ROLLBACK - cancelling the changes so that they don't get applied ==="
cancelEdit('y')
# =========================================================
# all done - bye!
disconnect()
exit()
任何帮助将不胜感激。
感谢和问候,
阿姆鲁特·劳特。
【问题讨论】:
-
Amrut,您尝试过以互动方式锻炼吗?
标签: python weblogic11g wlst