ConfigToScript command

ConfigToScript

The WLST command ConfigToScript converts an existing server configuration (config directory) to an executable WLST python script.The syntax for this command is :
configToScript([configPath], [pyPath], [overwrite], [propertiesFile], [createDeploymentScript])

– configPath : Optional value. This is the path to the config directory that contains the configuration of the domain that you want to convert.  The default location is domain/config directory.
– pyPath : Optional value. This is the path and filename to which you want to write the converted WLST script. This argument defaults to domain/config/config.py.
– overwrite : Optional value. This is a boolean value specifying whether the script file should be overwritten if it already exists. This argument defaults to true, indicating that the script file is overwritten.
– propertiesFile : Optional value. This is a path to the directory in which you want WLST to write the properties files. This argument defaults to the pathname specified for the scriptPath argument.
– createDeploymentScript : Optional value. This is a boolean value specifying whether WLST creates a script that performs deployments only. This argument defaults to false, indicating that a deployment script is not created. The file named deploy.py will be created.
Here is an example in weblogic server 10.3, where I have created WLST scripts which include a properties file, python script which has configurations of the domain, file to store the passwords used in the domain by the servers.
From the command prompt, start the WLST.cmd file from the path D:BEA103wlserver_10.3commonbin. WLST will start in offline mode.
Execute the command configToScript as below:
configToScript(‘D:/BEA103/user_projects/domains/example_domain’,’D:/Files/MyScripts’,’true’,’D:/Files/MyScripts/config.py.properties’,’true’)
Below are the files that will be created in the D:/Files/MyScripts directory:
–    c2sConfigexample_domain
–    c2sSecretexample_domain
–    config.py
–    config.py.properties
–    deploy.py

12 comments

  1. Hello, Thanks you very much for this post. The command run successfully but I have a questions:

    The property file get created successfully but that file is having only admin server details like server name,port no,url,domain name etc. But the file doesn’t contain information about managed server. The managed server details are there in the config.py script and its hard coded in the script. Is there any way that we can get the managed server details also as a variable so that we can modify it based on the requirement like managed server new ip,port etc?
    If there is any way to get the config.py script in variable form then its will be very helpful to use thses script to replicate a domain to other servers like if we want to change the admin, managed server etc.

    Thanks
    Rahul Gupta

    1. Hello Rahul,

      The managed server details are there in the config.py script for example like:
      cd(“/Servers/MS1”)
      print “setting attributes for mbean type Server”
      set(“ListenPort”, “7005”)

      You can change it to:
      cd(“/Servers/MS1”)
      print “setting attributes for mbean type Server”
      set(“ListenPort”, “7007”)

      It is only a python script and it is not hard coded. You can make the changes. It is only a complete replica of the domain which is converted into this script.

      Let me know if you have any doubts.

      Thanks 🙂

  2. one more qurery:
    Why the username and password in config.py script are coming as weblogic,weblogic where my domain console credentials are different. What the significance of this username and password? What does this user name and password meant for?

    Thanks
    Rahul Gupta

  3. one more qurery: Why the user name and passowrd in config_properties.sh file are weblogic,weblogic wher my domain credebtials are different. What is the significance of this username and password? What does this user name and password meant for?

    Thanks
    Rahul Gupta

    1. Hi Rahul,

      The domain credentials are in the files c2sConfigDomainName and c2sSecretDomainName files. The file c2sConfigDomainName will have the encrypted username and password and the file c2sSecretDomainName file has the key to decrypt the passwords.

      I suppose the credentials weblogic, weblogic are the default credentials which the nodemanager uses for internal communication with the admin server.

      Regards,
      Divya

  4. Hi Divya,

    Can you give me an example of how to write a ANT script, as i want to deploy a file in WL through ant script.

    Thanks,
    Ravi C

  5. While running the configToScript I am getting this error.

    Can you please help? I am using wls 10.0.2.0 with sun jdk 1.5_17

    File “”, line 1, in ?
    File “”, line 1547, in configToScript
    WLSTException: Error occured while performing configToScript : Problem running configToScript: Error occured while performing configToScript : Error making set beans. Use dumpStack() to view the full stacktraceError occured while performing configToScript : Error making set beans. Use dumpStack() to view the full stacktrace Use dumpStack() to view the full stacktrace
    wls:/prpc/serverConfig> dumpStack()
    This Exception occurred at Mon Aug 29 15:25:29 PDT 2011.
    weblogic.management.scripting.ScriptException: Error occured while performing configToScript : Error making set beans. Use dumpStack() to view the full stacktrace
    at weblogic.management.scripting.ExceptionHandler.handleException(ExceptionHandler.java:51)
    at weblogic.management.scripting.WLSTUtils.throwWLSTException(WLSTUtils.java:178)
    at weblogic.management.scripting.ConfigToScript.createSetBeanAttributes(ConfigToScript.java:1153)
    at weblogic.management.scripting.ConfigToScript.setBeanAttributes(ConfigToScript.java:926)
    at weblogic.management.scripting.ConfigToScript.convert(ConfigToScript.java:201)
    at weblogic.management.scripting.WLScriptContext.callc2s(WLScriptContext.java:183)
    at weblogic.management.scripting.WLScriptContext.config2Py(WLScriptContext.java:134)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:160)
    at org.python.core.PyMethod.__call__(PyMethod.java:96)
    at org.python.core.PyObject.__call__(PyObject.java:248)
    at org.python.core.PyObject.invoke(PyObject.java:2016)
    at org.python.pycode._pyx38.configToScript$94(:1537)
    at org.python.pycode._pyx38.call_function()
    at org.python.core.PyTableCode.call(PyTableCode.java:208)
    at org.python.core.PyTableCode.call(PyTableCode.java:404)
    at org.python.core.PyTableCode.call(PyTableCode.java:253)
    at org.python.core.PyFunction.__call__(PyFunction.java:169)
    at org.python.pycode._pyx49.f$0(:1)
    at org.python.pycode._pyx49.call_function()
    at org.python.core.PyTableCode.call(PyTableCode.java:208)
    at org.python.core.PyCode.call(PyCode.java:14)
    at org.python.core.Py.runCode(Py.java:1135)
    at org.python.core.Py.exec(Py.java:1157)
    at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:148)
    at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:89)
    at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:70)
    at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:44)
    at weblogic.management.scripting.WLST.main(WLST.java:157)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at weblogic.WLST.main(WLST.java:29)
    weblogic.management.scripting.ScriptException: Error occured while performing configToScript : Error making set beans. Use dumpStack() to view the full stacktrace
    wls:/prpc/serverConfig> pwd

  6. Hi Divya/Team,
    Thanks for the wonderful posts. I have a req where I need to re-assign a managed server from one machine to another. The information of the machine is read via a property file.

    I tried looking for how to reassign a managed server from one to another machine but hardly found anything.

    Appreciate your help

    Thanks
    -Mukul

    1. Hi Mukul,

      Are you looking for steps to do it from the weblogic console?
      Or via WLST?

Comments are closed.