我对目前处于初学者级别的WLST脚本&非常陌生。我有一个脚本提示输入每个数据源的密码。虽然这部分工作正常,但我面临的挑战是,在生产环境中,我们想要运行此脚本的位置,将有多个托管服务器具有相同数据源,名称不同但JNDI相同,因为这两个数据源都连接到同一数据库。使用WLST(多域)更改数据源密码
在该方案中的脚本的方式工作目前,它会提示输入密码,每找到数据源,但我想修改脚本,以便它检查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 Raut。
Amrut,你有没有尝试过以互动的方式锻炼? –