简体   繁体   中英

Running a recorded WLST Python file to setup WebLogic domain configuration

In our project, we have numerous steps to create different configurations on WebLogic server. I have created a local domain and I have recorded my steps in a Python file (by pressing 'Record' button on top, followed by manual steps to configure)

The configuration includes creation of Generic Data Source/s, security realms, changes to AdminServer and so on.

The purpose of recording the steps is obvious, to ease and speed up the process for others. I would like to know the steps on how I should run the recorded script? Shall I simply create a new domain, login to it and simply run the script? Or something else is also required?

Here's a snippet from .py file:

startEdit()
cd('/')
cmo.createJDBCSystemResource('test')
cd('/JDBCSystemResources/test/JDBCResource/test')
cmo.setName('test')
cd('/JDBCSystemResources/test/JDBCResource/test/JDBCDataSourceParams/test')
set('JNDINames',jarray.array([String('test')], String))
cd('/JDBCSystemResources/test/JDBCResource/test/JDBCDriverParams/test')
cmo.setUrl('jdbc:db2://server:port/DBNAME')
cmo.setDriverName('com.ibm.db2.jcc.DB2Driver')
.
.

I have referred to some questions: How to run wlst script by .py file , Record WLST Scripts for Adapter Settings for creating Outbound Connection Pools but those didn't help.

The simple answer to your question is yes, just create a new domain, start it and then run the script. Remember that your script needs to connect to your server before making any changes. To do that just add connect command at the beginning of your script.

[connect('adminuser','adminpass','t3://localhost:8001')][1] 

to launch your script simply go to the folder containing wlst.cmd (Windows) or wlst.sh (Linux) and run

wlst.sh your_script.py

Keep in mind that if you are targeting resources to clusters or particular server instances you have to make sure that cluster/server names on the new domain match those on the instance you've recorded your script.

Offline domain editing is also possible and there are plenty articles and blog posts on about it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM