Saturday, July 19, 2014

Creating a connection to Weblogic env

Step1: Create a script as below in a text file
####################################################################
#This will connect to Weblogic, get into runtime, and get the weblogic running state.#
####################################################################
connect('haare','haare123','t3://localhost:7001')
cd('AppDeployments')
myapps=cmo.getAppDeployments()
print '----',myapps
print '----',pwd()
domainRuntime()
cd('/ServerRuntimes/myserver')
print 'the current running state is-->'+cmo.getState()
###########################
#The State can be written to a file#
###########################
f=open("d:\<filename>.txt","w")
print >>f,cmo.getState()
f.close()
#########################
#Or Appended to an existing file#
##########################

f = open("D:\filename.txt", "a")
       print >>f, cmo.getState()
f.close()

#########END OF CODE########
Step 2: Save this as a filename.py file

Step3: Open cmd and run From Command Prompt >wlst filename.py

Assumptions:The weblogic server is up and listening on port 7001
This is done on a Windows 7 64 bit env or from the server where weblogic is running
wlst's path is set in environment variable using " set path=%path%;d:/wlst;"

============================================================

Additional Notes:

  1. When you are running in domainRuntimes() then weblogic monitoring is possible.
  2. At each level we can see what commands are available to execute through ls()
  3. The ones with permission "-r--" the values can be obtained using get('<parameter>'). Example get('State').
  4. The very same commands can be put in a script and executed.

Creating a development environment

Weblogic control through java is an exciting area. I am attempting to create administration code snippets for managing weblogic center. Thew first attempt is developing this using the IDE i have which is Netbeans IDE 8.0.

One of the first challenges one faces is to how to get the WLSTInterpretor. A good approach has been suggested by the author Geertjan in his blog https://blogs.oracle.com/geertjan/entry/python_in_netbeans_ide_8

One can always use a text pad for getting the code created and run as a python script.