This discussion is archived
2 Replies Latest reply: Apr 23, 2013 9:33 AM by 1004973 RSS

WLST Libraries

687374 Newbie
Currently Being Moderated
I have a number of WLST scripts which all use a number of common functions I've written such as:

common.py:
import sys

import os
import shutil
import re

def offline_createManagedServer(Name, Port, ListenAddress):
     cd('/')
     create(Name, 'Server')
     cd('Server/'+Name)
     set('ListenPort', int(Port))
     set('ListenAddress', ListenAddress)     

This is called by createDomain.py

     readTemplate('D:\\common\\bin\\osb1031' + '/wlserver_10.3/common/templates/domains/wls.jar')
     common.offline_createManagedServer('ManagedServer1', '7001', 'localhost')

I have been attempting to use the instructions at:
http://download.oracle.com/docs/cd/E12840_01/wls/docs103/config_scripting/using_WLST.html#wp1093407

Using the above code I get 'NameError: cd' at the first line in offline_createManagedServer -->     cd('/')

I then created the wl.py and import that and now get a different error:
Error: No domain or domain template has been read.
Error: set() cannot be applied at this point of path

I want to keep all the common functions in a library style script file so they can be shared.

Has anyone actually got this to work?

Edit:
I call the createDomain.py as follows:
set WL_HOME=D:\common\bin\osb1031\wlserver_10.3
call %WL_HOME%\server\bin\setWLSEnv.cmd
java weblogic.WLST createDomain.py

Edited by: user10074087 on Dec 13, 2009 10:20 PM
  • 1. Re: WLST Libraries
    687374 Newbie
    Currently Being Moderated
    In case anyone finds this useful, I ended up using:

         jpythonScriptsDir = os.environ.get("SCRIPTS_PYTHON")
         execfile(jpythonScriptsDir + '/common/' + 'import.py')

    I run this at the start of all scripts that need access to the common functions.

    execfile loads the definitions in import.py into the namespace that has all of the WLST functions.
  • 2. Re: WLST Libraries
    1004973 Newbie
    Currently Being Moderated
    Four years later and still very useful ... you got me unstuck from having the exact same problem all day, thanks!

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points