<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7333189570510911465</id><updated>2026-04-17T00:20:13.575-07:00</updated><category term="WLST"/><category term="WebLogic 11g"/><category term="WebLogic 9.2"/><category term="Python"/><category term="Weblogic scripting tool"/><category term="WebLogic"/><category term="WebLogic 10"/><category term="WebLogic 12.2.1"/><category term="tutorial"/><category term="WLST Online"/><category term="Jython"/><category term="WebLogic 10.3.3"/><category term="WebLogic 12c"/><category term="Cluster"/><category term="Deployment"/><category term="Fusion Middleware"/><category term="NodeManager"/><category term="Oracle WebLogic 12c"/><category term="SOA"/><category term="ServerLifecycleRuntime"/><category term="WLST Tutorial"/><category term="WebLogic12c"/><category term="sample"/><category term="11g"/><category term="12c"/><category term="ADF"/><category term="ActivationTime"/><category term="Application status"/><category term="C style in Python"/><category term="Eclipse for WLST"/><category term="Example"/><category term="File in WLST"/><category term="Generic"/><category term="GridLink"/><category term="JDBC Connection Pool Monitoring"/><category term="JMS Bridge"/><category term="JMS Foreign ConnectionFactory"/><category term="JMS monitoring"/><category term="JMSRuntime"/><category term="MWM"/><category term="Multi DataSource"/><category term="NameError"/><category term="OEPE"/><category term="Production"/><category term="Self-tune ThreadPool"/><category term="ServerState"/><category term="WLST Offline"/><category term="WLST example"/><category term="WLST sample"/><category term="WebLogic 10.3.4"/><category term="can&#39;t write cache file for"/><category term="class in WLST"/><category term="deploy"/><category term="free tutorial"/><category term="help"/><category term="socket"/><category term="writeDomain"/><category term="10.0.3"/><category term="10.3"/><category term="10g"/><category term="8.1 Thread Model"/><category term="Automation JMS using Python"/><category term="Automation script"/><category term="BAM"/><category term="BEPL"/><category term="Best practices in WebLogic domain configuration"/><category term="Book review &amp; foreword for WebLogic book"/><category term="Bounce WebLogic"/><category term="Bridges in WLST"/><category term="C formats in WLST"/><category term="CCB"/><category term="CONFIG_JVM_ARG"/><category term="Call WLST from ant"/><category term="Capacity Constraint"/><category term="Cluster Address"/><category term="Cluster list wlst"/><category term="ClusterMessagingMode"/><category term="Color Output"/><category term="Composite management"/><category term="Configure User and groups in SecurityRealm"/><category term="Configure Virtual Target on Partition Domain"/><category term="ConnectionFactory"/><category term="Continue in WLST"/><category term="Create Datasource"/><category term="Create cluster with WLST"/><category term="Create managed Server using WLST"/><category term="Customizing wls domain in 12C"/><category term="Datasource monitoring with WLST"/><category term="Development"/><category term="DistributedQueueBean"/><category term="ECM"/><category term="EM"/><category term="Errors"/><category term="Example Script"/><category term="Exceptions"/><category term="FMW"/><category term="FREE"/><category term="File"/><category term="FileStore persistance"/><category term="FileStore using WLST"/><category term="First WLST book"/><category term="Foreign JNDI Provider"/><category term="GEOCODE datasource"/><category term="GUI editor"/><category term="HeapFreeCurrent"/><category term="HeapFreePercent"/><category term="IBM MQ"/><category term="IDD in WebLogic domain Partition"/><category term="IDE for WLST"/><category term="IndexError"/><category term="Instance"/><category term="Invoking WLST from ANT"/><category term="JDBC Connection pool in WLST"/><category term="JDBC from Jython"/><category term="JDBC store"/><category term="JDBCDataSourceRuntimeMBeans"/><category term="JDBCServiceRuntime"/><category term="JMS Destinations"/><category term="JMS Foreign Server"/><category term="JMS Foreign destination"/><category term="JMS MODULE"/><category term="JMS Module using Jython script"/><category term="JMS configuration using WLST"/><category term="JMS-MQ using WLST"/><category term="JMSserver using WLST"/><category term="JMX"/><category term="JVM monitoring"/><category term="Jython GetOpt"/><category term="KeyError"/><category term="Keystore"/><category term="Keystore setting for ManagedServer"/><category term="Learning WLST Automation"/><category term="MBean"/><category term="MOM"/><category term="MQ Manager"/><category term="Machine"/><category term="Managed server"/><category term="ManagedServer"/><category term="MapViewer datasource"/><category term="MaxThreadsConstraints"/><category term="Messaging"/><category term="Middleware"/><category term="Middleware Admin"/><category term="Middleware SOA"/><category term="Monitoring"/><category term="Multiple SecurityRealm in WebLogic Partition Domain"/><category term="Multitenancy"/><category term="NAVTEQ_UTIL"/><category term="NMType"/><category term="Node Manager Status from WLST"/><category term="ONS"/><category term="OOP in WLST"/><category term="ORS"/><category term="ORS Oracle Utilities Mobile Workforce Management"/><category term="Object in WLST"/><category term="Oracle"/><category term="Oracle Fussion Middleware"/><category term="Oracle Utilities"/><category term="Oracle Utilities Mobile Workforce Management"/><category term="Output redirection in Jython"/><category term="Overwrite"/><category term="Partion Domain with WLST"/><category term="Partition Domain with WLST"/><category term="Python GetOpt"/><category term="Python script"/><category term="Python script to configure WebLogic instance"/><category term="Python tutorial"/><category term="Regular Expressions in WLST"/><category term="Resource Groups in Multitenancy Domain"/><category term="Restart WebLogic"/><category term="Restricted JRF Domain"/><category term="Resume Queue"/><category term="Running WLST from ANT"/><category term="SBS"/><category term="SCA"/><category term="SOA Suite/Platform"/><category term="SQLState: 08006"/><category term="SSL"/><category term="SSL Privatekey setting for AdminServer"/><category term="STATE_ACTIVE"/><category term="STATE_RETIRED"/><category term="Samples WLST"/><category term="ScaleUp"/><category term="SecurityRealm"/><category term="Server Start Time"/><category term="ServerRuntimes"/><category term="Shell Script"/><category term="Side-by-Side deployment"/><category term="Stop"/><category term="Stop and Start Queue using WLST"/><category term="Store output"/><category term="SyntaxError"/><category term="Thread Count"/><category term="Threadpool configuration using WLST"/><category term="Threadpool monitoring"/><category term="Tuning with WLST"/><category term="UCF"/><category term="UCM"/><category term="Uniform Distributed Queue"/><category term="ValueError"/><category term="VirtualTarget"/><category term="VirtualTarget using WLT"/><category term="WLDF configuratin using WLST"/><category term="WLST 12.2.1"/><category term="WLST COLOR OUTPUT WEBLOGIC 9.2"/><category term="WLST Deployment"/><category term="WLST Error"/><category term="WLST Exception"/><category term="WLST GetOpt"/><category term="WLST Issues"/><category term="WLST Meterial"/><category term="WLST Overview"/><category term="WLST Python Error"/><category term="WLST Script for Queue"/><category term="WLST Thread scripts"/><category term="WLST Threads Monitor"/><category term="WLST UKF"/><category term="WLST class object"/><category term="WLST deployment on Multitenant Environment"/><category term="WLST edit"/><category term="WLST in Oracle Infrastructure 12.2.1"/><category term="WLST offline SQL query"/><category term="WLST properties"/><category term="WLST sql commands execution"/><category term="WLST undeploy partition"/><category term="WLST-Skript"/><category term="WebCenter"/><category term="WebLogic  11g supports Jython 2.2"/><category term="WebLogic - MQ queues"/><category term="WebLogic 10.3.1"/><category term="WebLogic 10g"/><category term="WebLogic 12.2.1 feature"/><category term="WebLogic 12.2.1.3"/><category term="WebLogic 12.2.x"/><category term="WebLogic 12c Cluster domain"/><category term="WebLogic 12c Multitenancy environment"/><category term="WebLogic 14c"/><category term="WebLogic Automation book"/><category term="WebLogic Domain Partition"/><category term="WebLogic MT"/><category term="WebLogic Monitoring with ANT"/><category term="WebLogic NodeManager"/><category term="WebLogic Partition Domain example"/><category term="WebLogic Server Control from ANT"/><category term="WebLogic Server Life Cycle commands with WLST"/><category term="WebLogic Server log"/><category term="WebLogic configuration from ANT"/><category term="WebLogic domain"/><category term="WebLogic domain log"/><category term="WebLogic domain templates addition with WLST"/><category term="WebLogic12c with Derby Database"/><category term="WebLogicc 12.2.1"/><category term="Weblogic 12.1.3 new feature in WLST"/><category term="Weblogic JMS-IBM MQ"/><category term="Weblogic scripting tool tutorial"/><category term="WorkManager"/><category term="WorkManager in WLST"/><category term="__name__ in WLST"/><category term="addTemplate"/><category term="adminHome"/><category term="ant"/><category term="authorization"/><category term="bea"/><category term="break in WLST"/><category term="cancel"/><category term="cancelEdit"/><category term="closeTemplate"/><category term="cluster state"/><category term="crate managedserver with WLST"/><category term="create Machine"/><category term="creation of Generic Datasource in Oracle Utilities"/><category term="currentTree"/><category term="debug WLST"/><category term="define method in WLST"/><category term="defining WLST Function"/><category term="dir in WLST"/><category term="domain"/><category term="domain migration"/><category term="domainRuntime"/><category term="dynamic Cluster in WebLogic"/><category term="em console on WebLogic domain"/><category term="enterprise manager  in WebLogic Domain"/><category term="findall WLST"/><category term="for loop in WLST"/><category term="forceShutdownPartitionWait in WebLogic"/><category term="format in WLST"/><category term="gethostname"/><category term="idle Thread count"/><category term="if-elif-else in WLST"/><category term="if-else in WLST"/><category term="jLine project in WLST"/><category term="jar loading in WLST"/><category term="java.lang.Thread"/><category term="jms"/><category term="jps"/><category term="loadTemplate"/><category term="logging using WLST"/><category term="mail from WLST"/><category term="match WLST"/><category term="network"/><category term="nm"/><category term="nmConnect"/><category term="nmKill"/><category term="nmStart"/><category term="nostage"/><category term="o nodemanager in java.library.path"/><category term="offline WLST Script"/><category term="offline class issue in 12.2.1"/><category term="online WLST"/><category term="os"/><category term="os.system"/><category term="output"/><category term="packages into WLST"/><category term="pass in WLST"/><category term="print in WLST"/><category term="python rstrip"/><category term="queue"/><category term="raw_input in WLST"/><category term="re examples in WLST"/><category term="re module in WLST"/><category term="read WLST"/><category term="readDomain"/><category term="readDomainTemplate"/><category term="remotely domain extension using WLST script"/><category term="rstrip"/><category term="save"/><category term="sca_activateComposite"/><category term="sca_retireComposite"/><category term="sca_retireComposite in wlst file"/><category term="scaleDown"/><category term="search WLST"/><category term="security"/><category term="selectCustomTemplate"/><category term="sendmail"/><category term="server state"/><category term="serverConfig"/><category term="sessionWLST sleep"/><category term="setOptions"/><category term="shutdown in WLST"/><category term="smtp"/><category term="smtplib in WLST"/><category term="split String in WLST"/><category term="split in WLST"/><category term="start in WLST"/><category term="startApplicaiton"/><category term="startNodeManager"/><category term="startNodeManager with WLST in Windows"/><category term="startParition in WebLogic"/><category term="startPartitionWait"/><category term="state in WLST"/><category term="stdin"/><category term="stop Partition using WLST"/><category term="stopApplicaiton"/><category term="storeUserConfig"/><category term="suspending Queue"/><category term="system package"/><category term="undeploy"/><category term="updateDomain"/><category term="version"/><category term="weblogic.Admin"/><category term="weblogic.Deployer"/><category term="while loop in WLST"/><category term="wls12c"/><category term="writeTemplate"/><title type='text'>WLST by Examples</title><subtitle type='html'>Writing a WLST script is an art of Administration. You will be using Python code, Jython scripting for building WebLogic platforms SOA, OSB, Portals, WebCenter, FMW. WLST is a Weapon in the hands of Middleware Engineers, Most of the WLST automations makes life easy for WebLogic Administrator, Configuring, Monitoring JDBC, JMS, JVM, Threads made simple.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>70</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-6926832446398678366</id><published>2023-05-19T09:14:00.000-07:00</published><updated>2025-04-30T11:42:37.471-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="offline class issue in 12.2.1"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 12.2.1"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST in Oracle Infrastructure 12.2.1"/><title type='text'>WLST Starting issue for FMW products</title><content type='html'>Oracle released the latest version of WebLogic 12.2.1 version in the month of October 2015. Interestingly lots of new features loaded into this version. To make common tools available for every Fusion Middleware product such as SOA, OSB, etc.&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;img alt=&quot;WLST shell  OSB FMW, SOA servers using alias in bash_profile&quot; border=&quot;0&quot; height=&quot;222&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGiv_mNbeieFgQv-5wP1tnL__nA7dQ1ju1_8a8ToNJNSxEqv4F-BgPHGZ8z7IgRYPQjcDMJ7zIae8x_ACNj2X5CR4gAITJ_uSVrTBNzIPvmfkLiuO4lWSX-wZZyRQsrxSQ2-wt_HK0zvg/w400-h222/1658833327776674-0.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot; title=&quot;WLST sh alias&quot; width=&quot;400&quot; /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;WLST OSB FMW, SOA servers using alias in bash_profile&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
  &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGiv_mNbeieFgQv-5wP1tnL__nA7dQ1ju1_8a8ToNJNSxEqv4F-BgPHGZ8z7IgRYPQjcDMJ7zIae8x_ACNj2X5CR4gAITJ_uSVrTBNzIPvmfkLiuO4lWSX-wZZyRQsrxSQ2-wt_HK0zvg/s1600/1658833327776674-0.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;
    
  &lt;/a&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
When I&#39;ve executed &#39;java weblogic.WLST&#39; (old fashion) in the command prompt as I&#39;ve done in the earlier version. It was deprecated in the latest version!!!&lt;br /&gt;
&lt;br /&gt;
In the 12c (12.2.1 version) instead of using WebLogic you need to use Middleware infrastructure 12.2.1 installer. Which is going to support different Suite products : SOA Suite, EBS suite etc.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Could not find the offline class&lt;/h3&gt;
The earlier version WLST was available from the WL_HOME/common/bin/wlst.sh or cmd. Now it is deprecated in the latest version. 

&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSu3DvQyUMCdvALXoLQQjocWlqnXEJY0XmVsrh52GjgRMxNmBhCocb0E8dJLHE7XIb79Vx8EObqFVpNrI1Xbi0HFk8zlSZ5mDvgC4bSxoUMP2nbzPebLAOBXwz2H_J84fq6ONdhqtH6Lc/s1600/OFFLINE_CLASS_NOTFOUND.JPG&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;Oracle FMWInfrastructure   issue with WLST&quot; border=&quot;0&quot; height=&quot;129&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSu3DvQyUMCdvALXoLQQjocWlqnXEJY0XmVsrh52GjgRMxNmBhCocb0E8dJLHE7XIb79Vx8EObqFVpNrI1Xbi0HFk8zlSZ5mDvgC4bSxoUMP2nbzPebLAOBXwz2H_J84fq6ONdhqtH6Lc/s640/OFFLINE_CLASS_NOTFOUND.JPG&quot; title=&quot;WLST issue in WebLogic 12.2.1&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;WLST RuntimeException in WebLogic 12.2.1&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
The fix here is that you must use the script present in $ORACLE_HOME/oracle_common/common/bin/wlst.sh, this will support all Oracle Fusion Middleware Homes.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhybMFkeB_Hvtbhd6o-ojv1dWmesx6MS4dL65C4Tzm1XOpz4vXTRPGQXWnsXN7GC_U9YWi8GFjCXu4GznZo58tk3bA6o4hXRWLnfNpMcP9WKbTi4aFTSTa-sXVPytudVwf8Aa1ztcyD_aA/s1600/wlst_path.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;WLST script path for Oracle FMW&quot; border=&quot;0&quot; height=&quot;245&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhybMFkeB_Hvtbhd6o-ojv1dWmesx6MS4dL65C4Tzm1XOpz4vXTRPGQXWnsXN7GC_U9YWi8GFjCXu4GznZo58tk3bA6o4hXRWLnfNpMcP9WKbTi4aFTSTa-sXVPytudVwf8Aa1ztcyD_aA/s400/wlst_path.png&quot; title=&quot;WLST Script execution made simple for FMW products&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;WLST path in 11g and 12c differed&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
Best practice is you must include the following line in the profile file such as&amp;nbsp;&lt;b&gt;.bash_profile&lt;/b&gt; or&lt;b&gt; .bashrc&lt;/b&gt; in your user home directory:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:bash&quot;&gt;alias wlst=&quot;/home/oracle/products/12.2.1/Oracle_Home/oracle_common/bin/wlst.sh&quot; 
 # or best for all next versions 
alias wlst=$ORACLE_HOME/oracle_common/common/bin/wlst.sh&lt;/pre&gt;
&lt;br /&gt;
Hope you like this fix, share this trick with your friends! Dont forget to like it on Facebook!&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/6926832446398678366/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2015/12/1221-wlst-starting-issue.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/6926832446398678366'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/6926832446398678366'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2015/12/1221-wlst-starting-issue.html' title='WLST Starting issue for FMW products'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGiv_mNbeieFgQv-5wP1tnL__nA7dQ1ju1_8a8ToNJNSxEqv4F-BgPHGZ8z7IgRYPQjcDMJ7zIae8x_ACNj2X5CR4gAITJ_uSVrTBNzIPvmfkLiuO4lWSX-wZZyRQsrxSQ2-wt_HK0zvg/s72-w400-h222-c/1658833327776674-0.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-3965171956297943662</id><published>2023-02-26T06:07:00.001-08:00</published><updated>2025-04-30T09:34:19.248-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="dynamic Cluster in WebLogic"/><category scheme="http://www.blogger.com/atom/ns#" term="Oracle WebLogic 12c"/><category scheme="http://www.blogger.com/atom/ns#" term="scaleDown"/><category scheme="http://www.blogger.com/atom/ns#" term="ScaleUp"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST"/><title type='text'>Dynamic Cluster Scaling with WLST</title><content type='html'>Dynamic Cluster configuration on WebLogic Domain&lt;br /&gt;
&lt;br /&gt;&lt;b&gt;
Prerequisites&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://weblogic12cessentials.blogspot.in/2015/04/installation-of-weblogic-server-1213-on.html&quot; target=&quot;_blank&quot;&gt;Install Oracle WebLogic 12.2.1 or above versions on any platform&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://weblogic12cessentials.blogspot.in/2015/06/3-ways-to-create-weblogic-12c-domain.html&quot; target=&quot;_blank&quot;&gt;Configure a fresh WebLogic domain&amp;nbsp;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
In this exciting example 😊 new learning about how to use the dynamic cluster in the latest version of WebLogic 12c [12.1.2] and above this was introduced for WebLogic on Cloud computing. To workout this you must configure a &lt;b&gt;Server&lt;/b&gt; template when you give the &lt;b&gt;maximum&lt;/b&gt; number of cluster servers these managed server automatically increased. When you decrease it the number of managed servers come to &lt;b&gt;SHUTDOWN&lt;/b&gt; state as expected. To do same task from the automation using WLST prompt you need to use the following two functions:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;b&gt;&lt;i&gt;scaleUp&lt;/i&gt;&lt;/b&gt; increase the number of managed servers in the cluster&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;i&gt;scaleDown&lt;/i&gt;&lt;/b&gt; to decrease the number of managed servers in the cluster.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4YakSEN73dKV92B4WgzfF7D7KXD62bkrwwT1XaXrg_6GeSo9vqPRQb3m3eivCPjKjsL5sDLb9t9D8Fh8zXp9n5VDfsICJc_uFonpHVsZZo4Ujrq_zfO9rQHhD73NudIV1Rc1mA_Acflk/s1600/DynamicClustr.JPG&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;
  &lt;img alt=&quot;Image for Dynamic cluster in WebLogic&quot; border=&quot;0&quot; height=&quot;366&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4YakSEN73dKV92B4WgzfF7D7KXD62bkrwwT1XaXrg_6GeSo9vqPRQb3m3eivCPjKjsL5sDLb9t9D8Fh8zXp9n5VDfsICJc_uFonpHVsZZo4Ujrq_zfO9rQHhD73NudIV1Rc1mA_Acflk/w640-h366/DynamicClustr.JPG&quot; title=&quot;Dynamic cluster in WebLogc 12.2.1&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Dynamic Cluster configuration on WebLogic Domain&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;now let&#39;s do the automation exercise&lt;br /&gt;
  
  
&lt;pre class=&quot;brush:py&quot;&gt;# Dated  : 4th Feb 2016
# ScriptName : dynamicCluster.py
# Purpose :
# This script will create server template and using that
# configures a dyanamic cluster

def createServer_Template(tmpName, basePort, sslPort, machine):
        print &#39;creating server tempalte for &#39;+tmpName
        cd(&#39;/&#39;)
        cmo.createServerTemplate(&#39;&#39;+tmpName)

        cd(&#39;/ServerTemplates/&#39;+tmpName)
        cmo.setListenPort(int(basePort))

        cd(&#39;/ServerTemplates/&#39;+tmpName+&#39;/SSL/&#39;+tmpName)
        cmo.setListenPort(int(sslPort))

        cd(&#39;/ServerTemplates/&#39;+tmpName)
        cmo.setMachine(None)


def create_dynamicCluster(clustrName, tmpName, prefix):
        print &#39;Creating dynamic cluster: &#39;+clustrName
        cd(&#39;/&#39;)
        cmo.createCluster(clustrName)

        cd(&#39;/Clusters/&#39;+clustrName)
        cmo.setClusterMessagingMode(&#39;unicast&#39;)

        cd(&#39;/ServerTemplates/&#39;+tmpName)
        cmo.setCluster(getMBean(&#39;/Clusters/&#39;+clustrName))

        cd(&#39;/Clusters/&#39;+clustrName+&#39;/DynamicServers/&#39;+clustrName)
        cmo.setServerTemplate(getMBean(&#39;/ServerTemplates/&#39;+tmpName))
        cmo.setDynamicClusterSize(2)
        cmo.setMaxDynamicClusterSize(8)
        cmo.setCalculatedListenPorts(true)
        cmo.setCalculatedMachineNames(true)
        cmo.setCalculatedListenPorts(true)
        cmo.setServerNamePrefix(prefix)

def main():
        connect(&quot;weblogic&quot;,&quot;welcome1&quot;,&quot;t3://192.168.33.100:6100&quot;)
        edit()
        startEdit()

        print &#39;Creating server templates...&#39;
        # creating server templates
        createServer_Template(&#39;app_tier_tmp&#39;, 7120, 8120, &#39;mydev&#39;)
        createServer_Template(&#39;web_tier_tmp&#39;, 6120, 9120, &#39;mydev&#39;) # Machine already configured

        create_dynamicCluster(&#39;app_dclustr&#39;, &#39;app_tier_tmp&#39;,&#39;app_server0&#39;)
        create_dynamicCluster(&#39;web_dclustr&#39;, &#39;web_tier_tmp&#39;,&#39;web_server0&#39;)
        print &#39;Dynamic cluster configuration completed...&#39;
        activate()

main()
&lt;/pre&gt;
&lt;br /&gt;
The above generic WLST script can be executed as shown below:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8-UujHbzd-CK81rsJZRuiTz7YImO6Qrgm6rdyKKdcoiaTh3btEEJLPmCMuzktRlZxIVrbm8Xu2v6QC2PMZ96gpHrGn9LksoAhztG7TtCrLeL3vgKZU7KQzbvdbMuK4dyNatgdR1GuIx4/s1600/DynamicTemp_clustr.JPG&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Elastic cluster configuration with WLST&quot; border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8-UujHbzd-CK81rsJZRuiTz7YImO6Qrgm6rdyKKdcoiaTh3btEEJLPmCMuzktRlZxIVrbm8Xu2v6QC2PMZ96gpHrGn9LksoAhztG7TtCrLeL3vgKZU7KQzbvdbMuK4dyNatgdR1GuIx4/s640/DynamicTemp_clustr.JPG&quot; title=&quot;Dynamic Cluster using WLST&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
You could also double confirm this from your &lt;b&gt;&lt;i&gt;WebLogic Admin Console&lt;/i&gt;&lt;/b&gt; work-area when you select clustser in the Environment of under your Domain .&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7CPwlmvptCpHFH5F1p7NXRKYteiKXU6Qc-J95AQP78yO-UvzLfipPZzrNlny3HgWpu22ZKTAGu-WvHomKChRM2BdjXRZTCD2H2wDiWvDjqMppbN1kM-pDBpFmfsQr3fcXsiBFm8_YXMU/s1600/DynamicClustr_console.JPG&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;wlst output confirm Admin console&quot; border=&quot;0&quot; height=&quot;117&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7CPwlmvptCpHFH5F1p7NXRKYteiKXU6Qc-J95AQP78yO-UvzLfipPZzrNlny3HgWpu22ZKTAGu-WvHomKChRM2BdjXRZTCD2H2wDiWvDjqMppbN1kM-pDBpFmfsQr3fcXsiBFm8_YXMU/s400/DynamicClustr_console.JPG&quot; title=&quot;Elastic cluster confirmation WebLogic Admin Console&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Dynamic Cluster configuration in WebLogic 12.2.1 Domain&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;Suggestion for future enhancements to the above script you can do following:&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;create a &lt;i&gt;&lt;b&gt;properties&lt;/b&gt;&lt;/i&gt; file and pass all the main program required arguments&lt;/li&gt;
&lt;li&gt;Cluster Message Mode can be dynamic&lt;/li&gt;
&lt;li&gt;Machine per template can be set dynamic&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
Elastic Cluster on-demand scale up&lt;br /&gt;
&lt;br /&gt;
In the WLST prompt you can test it as :&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;scaleUp (&quot;app_dclustr&quot;,1, true, true)
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
scaleUp execution for single server:&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpGp0SMdwqj1jb8pbpkFaNMKaFqPQBfj9ACM4OicTjpf1vAUo459wqLdmIPB5qOEVNN6q0IFby_hI8dRuGytguINFDBoEA8mRaySObbrPQ3lt2JxILhRfM_n44OJbzPfcA60PHp-aS_lM/s1600/scaleUp-01.JPG&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;WLST Scalability implementation&quot; border=&quot;0&quot; height=&quot;260&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpGp0SMdwqj1jb8pbpkFaNMKaFqPQBfj9ACM4OicTjpf1vAUo459wqLdmIPB5qOEVNN6q0IFby_hI8dRuGytguINFDBoEA8mRaySObbrPQ3lt2JxILhRfM_n44OJbzPfcA60PHp-aS_lM/s640/scaleUp-01.JPG&quot; title=&quot;scaleUp cluster in WebLogic 12.2.1&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;ScaleUp in WLST Execution&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;scaleDown(&#39;app_dclustr&#39;,2,true,true)
&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;
Scale down weblogic cluster&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2zYvhmpHSf_jAOMKQqvlbf0UsY9f2BJKZ23qWjJv-nSHoJ8xQEd984wUZN6tLkGdINPWBfXEuLNRvnYhook-PeXq1hIaAMnB-7astNYCyJi1vnsbtId1V3nQgCWuO3Ub8xZN-ip60mhA/s1600/scaleDown.JPG&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;scale down in WebLogic 12.2.1 Domain&quot; border=&quot;0&quot; height=&quot;298&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2zYvhmpHSf_jAOMKQqvlbf0UsY9f2BJKZ23qWjJv-nSHoJ8xQEd984wUZN6tLkGdINPWBfXEuLNRvnYhook-PeXq1hIaAMnB-7astNYCyJi1vnsbtId1V3nQgCWuO3Ub8xZN-ip60mhA/s640/scaleDown.JPG&quot; title=&quot;scaleDown using WLST&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Scale Down cluster size in WLST&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;Hope you enjoyed by reading this post,&amp;nbsp; Stay tuned to this blog and share with your friends techies...&lt;/div&gt;&lt;div&gt;Waiting for your comments and suggestions!!&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/3965171956297943662/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2016/02/dynamic-cluster-scaling-with-wlst.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/3965171956297943662'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/3965171956297943662'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2016/02/dynamic-cluster-scaling-with-wlst.html' title='Dynamic Cluster Scaling with WLST'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4YakSEN73dKV92B4WgzfF7D7KXD62bkrwwT1XaXrg_6GeSo9vqPRQb3m3eivCPjKjsL5sDLb9t9D8Fh8zXp9n5VDfsICJc_uFonpHVsZZo4Ujrq_zfO9rQHhD73NudIV1Rc1mA_Acflk/s72-w640-h366-c/DynamicClustr.JPG" height="72" width="72"/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-4305174373644959757</id><published>2023-02-12T05:50:00.000-08:00</published><updated>2025-04-30T09:26:28.587-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cluster state"/><category scheme="http://www.blogger.com/atom/ns#" term="Color Output"/><category scheme="http://www.blogger.com/atom/ns#" term="Jython"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="server state"/><category scheme="http://www.blogger.com/atom/ns#" term="ServerLifecycleRuntime"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 11g"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 12c"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 9.2"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST"/><title type='text'>Server State using WLST</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;Hello! Dear Automation focused engineer we have this post about how to work simple server status list for a WebLogic domain. This logic can be build and executed for huge number of WebLogic or FMW Servers in Produciton helps to view all at a time hostnames, their corresponding states.&amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Why we needWebLogic Server State? What all those states?&lt;/h4&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;While trouble shooting Middleware/FMW administrator need to check the status of all the WebLogic server instances. This is the basic need when the all the servers are in bounced for production code move. This same script can be applicable for the pre-production or staging environment too. WLST provides the built-in methods, which gives the status of the Server instance or servers in a Cluster. Here we will deal with individual instance wise data.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrtZ6S-jADVI7YlkMbBzDuKu6039w0f2tAy1p7uknIukrenxj8-83gMY3wnLHuyscfpqlWY-oZtpJJCuw-0N9JOFZlPxDKuERfbTPbd1LVl82WoYSTwvQo4TCUYRDYFuuM-H0W1_8HNCo/s1600/ServerLifeCycle.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;Image of ServerLifeCycle in WLST&quot; border=&quot;0&quot; height=&quot;324&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrtZ6S-jADVI7YlkMbBzDuKu6039w0f2tAy1p7uknIukrenxj8-83gMY3wnLHuyscfpqlWY-oZtpJJCuw-0N9JOFZlPxDKuERfbTPbd1LVl82WoYSTwvQo4TCUYRDYFuuM-H0W1_8HNCo/w640-h324/ServerLifeCycle.png&quot; title=&quot;WebLogic ServerLifeCycle MBean&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;WebLogic Server Life cycle state diagram&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;

There are several ways to list out the servers. The simple way here you go with interactive way...&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;In the following example&amp;nbsp;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;We are collecting all the list of servers present in the WebLogic domain&lt;/li&gt;&lt;li&gt;state function applied on each server as item&amp;nbsp; passed to it&lt;/li&gt;&lt;li&gt;repeat this step 2 until all server list ends&lt;/li&gt;&lt;/ol&gt;&amp;nbsp;
&lt;pre class=&quot;brush:py&quot;&gt;wls:/demodomain/serverConfig&amp;gt; x=ls(&#39;Servers&#39;,returnMap=&#39;true&#39;)
dr--   demoadm
dr--   demoms1
dr--   demoms2

wls:/demodomain/serverConfig&amp;gt; x
[demoadm, demoms1, demoms2]
wls:/demodomain/serverConfig&amp;gt; for i in x:
... state(i,&#39;Server&#39;)
...
Current state of &quot;demoadm&quot; : RUNNING
Current state of &quot;demoms1&quot; : SHUTDOWN
Current state of &quot;demoms2&quot; : SHUTDOWN

&lt;/pre&gt;
Cluster listing
&lt;pre class=&quot;brush:py&quot;&gt;wls:/demodomain/serverConfig&amp;gt; c=ls(&#39;Clusters&#39;,returnMap=&#39;true&#39;)
dr--   clstr01

wls:/demodomain/serverConfig&amp;gt; c
[clstr01]
wls:/demodomain/serverConfig&amp;gt; state(c[0],&#39;Cluster&#39;)

There are 2 server(s) in cluster: clstr01

States of the servers are
demoms1---SHUTDOWN
demoms2---SHUTDOWN

&lt;/pre&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhf5FMqbIAkBlOvJCI7EqOXtgwlWyjPnCb5d2mp378bCj-8HKEcP94LuF8s5AI0m6MdraRdfJsO2N0L5teW1fafrSVVfzkJUGiYgNYunmjwpkqBDMZmI_kIxmD8iz59wVZ1DNzyQJa_4X0/s1600/ServerLifeCycle_mbean.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;92&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhf5FMqbIAkBlOvJCI7EqOXtgwlWyjPnCb5d2mp378bCj-8HKEcP94LuF8s5AI0m6MdraRdfJsO2N0L5teW1fafrSVVfzkJUGiYgNYunmjwpkqBDMZmI_kIxmD8iz59wVZ1DNzyQJa_4X0/s320/ServerLifeCycle_mbean.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;ServerLIfecycleRuntime Mbean tree&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
Using above shown MBean hierarchy we can fetch the all WebLogic domain server instance&#39;s states. If your production WebLogic domain consists of two digit (eg. 60 instances) or three digit number (eg. 120 instances) of managed server then, it is difficult to see all server’s state at once. Weblogic Administration console is unable to show all the servers in the domain on a single page. Navigating in between also a time eating process so think! think better way!! WLST has the solution. &lt;br /&gt;
&lt;br /&gt;
To get the status of all servers in the domain can be obtained with the following steps&lt;br /&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Connect to the WebLogic Admin Server&lt;/li&gt;&lt;li&gt;Fetch the Managed server list from the &lt;b&gt;domainRuntime &lt;/b&gt;MBean&lt;/li&gt;&lt;li&gt;Iterate the loop and get the state of each Managed Server with &lt;b&gt;ServerLifeCycle Runtime&lt;/b&gt; MBean &lt;/li&gt;&lt;li&gt;Repeat if required the step 3 as per the user input to Continue...&lt;/li&gt;&lt;li&gt;Finally if all desired output is visible then disconnect from the AdminServer and exit.&lt;/li&gt;&lt;/ol&gt;
&lt;br /&gt;
  
&lt;pre class=&quot;brush:py&quot; name=&quot;code&quot;&gt;################################################## 
# This script is used to check the status of all WL instances including the admin
###########################################################

def conn():
    UCF=&#39;/path/.AdminScripts/userConfigFile.sec&#39;
    UKF=&#39;/path/.AdminScripts/userKeyFile.sec&#39;
    admurl = &quot;t3://hostname:wlport&quot;

    try:
        connect(userConfigFile=UCF, userKeyFile=UKF, url=admurl)
    except ConnectionException,e:
        print &#39;\033[1;31m Unable to find admin server...\033[0m&#39;
        exit()

def ServrState():
    print &#39;Fetching state of every WebLogic instance&#39;
#Fetch the state of the every WebLogic instance
    for name in serverNames:
        cd(&quot;/ServerLifeCycleRuntimes/&quot; + name.getName())
        serverState = cmo.getState()
        if serverState == &quot;RUNNING&quot;:
            print &#39;Server &#39; + name.getName() + &#39; is :\033[1;32m&#39; + serverState + &#39;\033[0m&#39;
        elif serverState == &quot;STARTING&quot;:
            print &#39;Server &#39; + name.getName() + &#39; is :\033[1;33m&#39; + serverState + &#39;\033[0m&#39;
        elif serverState == &quot;UNKNOWN&quot;:
            print &#39;Server &#39; + name.getName() + &#39; is :\033[1;34m&#39; + serverState + &#39;\033[0m&#39;
        else:
            print &#39;Server &#39; + name.getName() + &#39; is :\033[1;31m&#39; + serverState + &#39;\033[0m&#39;
        quit()

def quit():
    print &#39;\033[1;35mRe-Run the script HIT any key..\033[0m&#39;
    Ans = raw_input(&quot;Are you sure Quit from WLST... (y/n)&quot;)
    if (Ans == &#39;y&#39;):
        disconnect()
        stopRedirect()
        exit()
    else:
        ServrState()

if __name__== &quot;main&quot;:
    redirect(&#39;./logs/Server.log&#39;, &#39;false&#39;)       
    conn()
    serverNames = cmo.getServers()
    domainRuntime()
    ServrState()&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Smart Script &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Recently I have online discussion with &lt;b&gt;Dianyuan Wang, &lt;/b&gt;state of the Managed servers can be obtained with &lt;b&gt;state() &lt;/b&gt;command. This function can be used in two ways:&amp;nbsp;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;To get individual managed server status you need to pass arguments as managed server name, type as &#39;Server&#39;.&amp;nbsp;&lt;/li&gt;&lt;li&gt;Other one is to get individual Cluster wise status.&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This can be achieved by passing two arguments cluster name and type as &#39;Cluster&#39;. The following script will be illustrate the second option, which I found that shorten code that gives same script outcome as above script. It could be leverage your scripting thoughts it is like a plain vanilla form as shown below:&lt;br /&gt;
&lt;br /&gt;
Note: Hope you follow the WLST Tricks &amp;amp; tips &lt;br /&gt;
  
&lt;pre class=&quot;brush:py&quot; name=&quot;code&quot;&gt;try:
    connect(url = &quot;t3://adminhostname:adminport&quot;)
except:
    print &quot;Connection failed&quot;
state(&#39;appclstr&#39;,&#39;Cluster&#39;)
state(&#39;web1clstr&#39;,&#39;Cluster&#39;)

...
state(&#39;webNclstr&#39;,&#39;Cluster&#39;)
&lt;/pre&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;pub-0762912933528813&quot;;
/* 336x280, created 10/19/10 */
google_ad_slot = &quot;4167369161&quot;;
google_ad_width = 336;
google_ad_height = 280;
//&lt;/script&gt;
&lt;/div&gt;
--&amp;gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Extra Stroke of this new script is that prints how many servers available in each given cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Server state with redirecting, re in WLST &lt;/h3&gt;
Wang mailed me his situation clarity of explanation why he chosen state command. And how he resolved with Python script tricks here. Its a great learning for me so sharing with you when I saw same question in StackExchange today(28 April 2014) after 3 years!!

&quot;The reason I do not use (for now) domainConfig is because some how few Weblogic domains are not in a good state, and when I run the domainConfig command, it complains that it is not enabled. Hence the alternative way I&#39;ve selected here is using state command. But it don&#39;t return the state. It always return None. But it prints out the state of the server. Here you go, Better way is capture that printing output to a file using WLST command redirect-stopRedirect and then, use the Python regular expression to extract the state of each server. 

The following is the Python snippet how I use the redirect:
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt; 
# Fill your own connection details 
  serverlist=cmo.getServers()   
  for s in serverlist:   
    server_nm = s.getName()
    urldict[server_nm]=&#39;t3s://&#39;+s.getListenAddress()+&#39;:&#39;+str(s.getAdministrationPort())   
    #domainRuntime()
    #cd(&#39;ServerLifeCycleRuntimes/&#39;+server_nm)
    fileName=&#39;/tmp/myserver_state.txt&#39;
    redirect(fileName)
    state(server_nm,&#39;Server&#39;)
    stopRedirect()
    f = open(fileName)
    try:
      for line in f.readlines():
        if re.search(&#39;Current state&#39;,line):
          status[server_nm]=line
    except:
      continue
 
  Ks = status.keys()
  for s in Ks:   
    if re.search(&#39;RUNNING&#39;,status[s]):
		try:
		connect(username,password,urldict[s])
		except:
		continue
		cd(&quot;/Servers/&quot; + s)  


...
&lt;/pre&gt;
best regards!
 
Dianyuan Wang
&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Here I request you please write back your experiencing with this posting looking ahead for your issues/ suggestions as comments.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/4305174373644959757/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2010/02/server-state-using-wlst.html#comment-form' title='31 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/4305174373644959757'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/4305174373644959757'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2010/02/server-state-using-wlst.html' title='Server State using WLST'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrtZ6S-jADVI7YlkMbBzDuKu6039w0f2tAy1p7uknIukrenxj8-83gMY3wnLHuyscfpqlWY-oZtpJJCuw-0N9JOFZlPxDKuERfbTPbd1LVl82WoYSTwvQo4TCUYRDYFuuM-H0W1_8HNCo/s72-w640-h324-c/ServerLifeCycle.png" height="72" width="72"/><thr:total>31</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-6984567208794634583</id><published>2022-08-31T04:06:00.000-07:00</published><updated>2025-04-30T09:29:11.120-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JDBC from Jython"/><category scheme="http://www.blogger.com/atom/ns#" term="SQLState: 08006"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST offline SQL query"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST sql commands execution"/><title type='text'>Database connection from WLST offline/Jython</title><content type='html'>&lt;h3&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;
This blog post &lt;/span&gt;objective&lt;/h3&gt;
&lt;div&gt;
There are many monitoring scripts were developed by me in previous posts in this blog you might have seen in the above menu, we will have some wild requirement which uses pure Jython SQL module which will be full capable of&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;You might need the output instantly with nice UI developed in AngularJS, JQuery.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;You could use the same logic for connecting the Fusion application schema and get the required information.&lt;/li&gt;
&lt;li&gt;You can use this DB update logic in many other WLST scripts such as deployment tracking&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;img alt=&quot;Jython WLST code referring to Database&quot; border=&quot;0&quot; height=&quot;222&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh78y1FQ_nxw-9eBf9VlCB-vrd5D-9KtApDgASMSEJtDLpRF9uuOhpwLCGggIuBhakzsR3GKMPjLj3R6SPmSPMsnJRxMbwEdneiL09YCcyDV4jlrBKMsSpUtsVLvvBX72OzoWrtvmRplqY/w400-h222/1672120055362235-0.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot; title=&quot;SQL query from Jython WLST&quot; width=&quot;400&quot; /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;WLST Jython code referring to Oracle JDBC / SQL query&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
  &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh78y1FQ_nxw-9eBf9VlCB-vrd5D-9KtApDgASMSEJtDLpRF9uuOhpwLCGggIuBhakzsR3GKMPjLj3R6SPmSPMsnJRxMbwEdneiL09YCcyDV4jlrBKMsSpUtsVLvvBX72OzoWrtvmRplqY/s1600/1672120055362235-0.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;
    
  &lt;/a&gt;
&lt;/div&gt;&lt;br /&gt;
My Experiment setup&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://myofwexperiments.blogspot.in/2015/08/install-weblogic-1036-on-vagrant-ubuntu.html&quot; target=&quot;_blank&quot;&gt;Vagrant Ubuntu box with Weblogic 11g installed&amp;nbsp;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://weblogic12cessentials.blogspot.in/2015/08/jdbc-datasource-creation-on-vagrant.html&quot; target=&quot;_blank&quot;&gt;Vagrant Ubuntu box with Oracle XE database&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
Here is some sample snippets which could help you to workout differently!! Hope you like this thought.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3&gt;
Connect to the Oracle DB from WLST&lt;/h3&gt;
&lt;br /&gt;
Jython provides zxJDBC module to connect with the various Databases. one among is Oracle! Here I am tried out in the offline WLST.
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;wls:/offline&amp;gt; from com.ziclix.python.sql import zxJDBC

jdbc_url = &quot;jdbc:oracle:thin:@192.168.33.115:1521:XE&quot;
username = &quot;test&quot;
password = &quot;welcome1&quot;
driver = &quot;oracle.jdbc.xa.client.OracleXADataSource&quot;

conn = zxJDBC.connect(jdbc_url, username, password, driver)
cursor = conn.cursor(1)
&lt;/pre&gt;
&lt;h3&gt;
Fetching records from DB from WLST&lt;/h3&gt;
Here is the sample of SQL query which fetch the records from the database into cursor object. We can use two methods to retrieve them: fetchall(), fetchone().

&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;wls:/offline&amp;gt; cursor.execute(&quot;select * from app_table&quot;)
wls:/offline&amp;gt; print cursor.rowcount
0
wls:/offline&amp;gt; cursor.fetchall()
[(100.0, &#39;Calendar&#39;), (101.0, &#39;benfits&#39;)]

wls:/offline&amp;gt; cursor.execute(&quot;select * from app_table where appname=&#39;benfits&#39;&quot;)
wls:/offline&amp;gt; cursor.fetchall()
[(101.0, &#39;benfits&#39;)]
wls:/offline&amp;gt; cursor.execute(&quot;select count(*) from app_table where appname=&#39;benfits&#39;&quot;)
wls:/offline&amp;gt; cursor.fetchone()
(1.0,)
&lt;/pre&gt;
&lt;h3&gt;
Inserting records from WLST&lt;/h3&gt;
&lt;pre class=&quot;brush:py&quot;&gt;wls:/offline&amp;gt; stmt=&quot;INSERT INTO app_table values (?, ?)&quot;
wls:/offline&amp;gt; rs=cursor.executemany(stmt,[103,&#39;secureapp.war&#39;])
wls:/offline&amp;gt; conn.commit()
wls:/offline&amp;gt; cursor.execute(&quot;select * from app_table&quot;)
wls:/offline&amp;gt; cursor.rowcount
0
wls:/offline&amp;gt; cursor.fetchall()
[(100.0, &#39;Calendar&#39;), (101.0, &#39;benfits&#39;), (103.0, &#39;secureapp.war&#39;)]&lt;/pre&gt;
&lt;h3&gt;
Update records in Database from WLST&lt;/h3&gt;
&lt;pre class=&quot;brush:py&quot;&gt;wls:/offline&amp;gt; stmt=&quot;UPDATE app_table set appname = &#39;benefits.war&#39; where appid=101&quot;
wls:/offline&amp;gt; rs=cursor.execute(stmt)
wls:/offline&amp;gt; conn.commit()
wls:/offline&amp;gt; cursor.execute(&quot;select * from app_table&quot;)
wls:/offline&amp;gt; cursor.fetchall()
[(100.0, &#39;Calendar&#39;), (101.0, &#39;benefits.war&#39;), (103.0, &#39;secureapp.war&#39;)]
wls:/offline&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;h3&gt;Troubleshooting: DatabaseError: IO Error: Connection reset [SQLCode: 17002], [SQLState: 08006] &lt;/h3&gt;
&lt;br /&gt;
To fix this issue Change the setup for your application, so you add the next parameter to the java command:
-Djava.security.egd=file:/dev/../dev/urandom
&lt;br /&gt;&lt;br /&gt;&lt;div&gt;

We made this change in our java.security file and it has gotten rid of the error.
&lt;pre class=&quot;brush:bash&quot;&gt;$ export JAVA_OPTION=&#39;-Djava.security.egd=file:/dev/../dev/urandom&#39;
vagrant@mydev:/vagrant/pybin/reautomation$ wlst $JAVA_OPTION db_utility.py

&lt;/pre&gt;
&lt;br /&gt;&lt;b&gt;
References:&lt;/b&gt;&lt;br /&gt;&lt;a href=&quot;http://www.jython.org/archive/21/docs/zxjdbc.html&quot; target=&quot;_blank&quot;&gt;1. Jython 21 documentation&amp;nbsp;&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://www.jython.org/jythonbook/en/1.0/DatabasesAndJython.html&quot; target=&quot;_blank&quot;&gt;2. Jython Book 1.0 Documentation on database&lt;/a&gt;&amp;nbsp;&lt;br /&gt;&lt;a href=&quot;http://www.javamonamour.org/2012/04/wlst-and-oracle-db-zxjdbc-jython.html&quot; target=&quot;_blank&quot;&gt;3. Inspiring DB connection from WLST&amp;nbsp;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/6984567208794634583/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2015/08/database-connect-from-wlst-offlinejython.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/6984567208794634583'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/6984567208794634583'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2015/08/database-connect-from-wlst-offlinejython.html' title='Database connection from WLST offline/Jython'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh78y1FQ_nxw-9eBf9VlCB-vrd5D-9KtApDgASMSEJtDLpRF9uuOhpwLCGggIuBhakzsR3GKMPjLj3R6SPmSPMsnJRxMbwEdneiL09YCcyDV4jlrBKMsSpUtsVLvvBX72OzoWrtvmRplqY/s72-w400-h222-c/1672120055362235-0.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-4656431609578553224</id><published>2022-08-31T03:16:00.000-07:00</published><updated>2025-04-30T09:31:14.153-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Automation JMS using Python"/><category scheme="http://www.blogger.com/atom/ns#" term="Example"/><category scheme="http://www.blogger.com/atom/ns#" term="JMS Module using Jython script"/><category scheme="http://www.blogger.com/atom/ns#" term="Learning WLST Automation"/><category scheme="http://www.blogger.com/atom/ns#" term="tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 12.2.1"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic12c"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST Script for Queue"/><title type='text'>JMS Module with ConnectionFactory and Queue configuration using WLST</title><content type='html'>After almost three and half years again revisited to the JMS module script. This time the project needs are quite different. Where the Oracle WebLogic domains classified environments &amp;nbsp;but they are standalone server domains. That is only AdminServer will be there in the domain and that would be target for the JMS module, JMS Destinations.&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;img alt=&quot;JMS Module using WLST&quot; border=&quot;0&quot; height=&quot;335&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBG4IgROT11O3437RZ-ynLGBzXNCYxJNayZp1NYzqABCotBiejZFjywE-wQq798efHWtq9L56FwghyNz-ydH71sRYYhvlxdgMbQ98D_7WzywpSse9ppx_0DeAZ8rf3VYFMT_r__Wq2B60/w400-h335/1661941356549654-0.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot; title=&quot;WLST script for JMS Module configuration&quot; width=&quot;400&quot; /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;JMS Module configuring using WLST&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
  &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBG4IgROT11O3437RZ-ynLGBzXNCYxJNayZp1NYzqABCotBiejZFjywE-wQq798efHWtq9L56FwghyNz-ydH71sRYYhvlxdgMbQ98D_7WzywpSse9ppx_0DeAZ8rf3VYFMT_r__Wq2B60/s1600/1661941356549654-0.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;
    
  &lt;/a&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Lets begin the experimenting now, the prerequisites for this are:&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;A WebLogic &lt;a href=&quot;http://wlstbyexamples.blogspot.in/2009/10/dynamic-domain-creation-with-wlst.html&quot; target=&quot;_blank&quot;&gt;Domain configured&lt;/a&gt; with single AdminServer&lt;/li&gt;
&lt;li&gt;AdminServer should be up and RUNNING&lt;/li&gt;
&lt;li&gt;To execute the WLST script required PATH, alias should be defined in the profile as shown below:&lt;/li&gt;
&lt;div&gt;
&lt;pre class=&quot;brush:bash&quot;&gt;export MW_HOME=/u01/app/oracle/fmw
export WL_HOME=$MW_HOME/wls/wlserver
export USER_MEM_ARGS=&quot;-Djava.security.egd=file:/dev/./urandom&quot;
alias wlst=&quot;$MW_HOME/oracle_common/common/bin/wlst.sh -skipWLSModuleScanning&quot;
&lt;/pre&gt;
&lt;br /&gt;
You can use this freshly created alias &lt;b&gt;&lt;u&gt;wlst &lt;/u&gt;&lt;/b&gt;at any directory to invoke WLST shell. &amp;nbsp;The option -skipWLSModuleScanning is easy, faster learnt while working on &lt;a href=&quot;http://wlatricksntips.blogspot.in/2017/05/learning-dockerization-for-weblogic-on.html&quot; target=&quot;_blank&quot;&gt;docker containers&amp;nbsp;&lt;/a&gt;and simple way to use.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;li&gt;Execute the c&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2013/01/jms-configuration-using-wlst.html&quot; target=&quot;_blank&quot;&gt;onfigure JMS Servers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;The WLST Script for JMS configurations and all frequently changing values are moved into the properties file.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;#========================================
# WLST Script purpose: Configuring JMS Module
# Author: Pavan Devarakonda
# Update date: 3rd Aug 2017
#========================================
from java.util import Properties
from java.io import FileInputStream
from java.io import File
from java.io import FileOutputStream
from java import io
from java.lang import Exception
from java.lang import Throwable
import os.path
import sys

envproperty=&quot;&quot;
if (len(sys.argv) &amp;gt; 1):
        envproperty=sys.argv[1]
else:
        print &quot;Environment Property file not specified&quot;
        sys.exit(2)

propInputStream=FileInputStream(envproperty)
configProps=Properties()
configProps.load(propInputStream)

##########################################
# Create JMS Moudle will take the 
# arguments as name, subdeployment name
# target can be on admin or managed server or cluster
##########################################
def createJMSModule(jms_module_name, adm_name, subdeployment_name):
        cd(&#39;/JMSServers&#39;)
        jmssrvlist=ls(returnMap=&#39;true&#39;)
        print jmssrvlist
        cd(&#39;/&#39;)
        module = create(jms_module_name, &quot;JMSSystemResource&quot;)
        #cluster = getMBean(&quot;Clusters/&quot;+cluster_target_name)
        #module.addTarget(cluster)
        #adm_name=get(&#39;AdminServerName&#39;)
        adm=getMBean(&quot;Servers/&quot;+adm_name)
        module.addTarget(adm)
        cd(&#39;/SystemResources/&#39;+jms_module_name)

        module.createSubDeployment(subdeployment_name)
        cd(&#39;/SystemResources/&#39;+jms_module_name+&#39;/SubDeployments/&#39;+subdeployment_name)
        list=[]
        for j in jmssrvlist:
                s=&#39;com.bea:Name=&#39;+j+&#39;,Type=JMSServer&#39;
                list.append(ObjectName(str(s)))
        set(&#39;Targets&#39;,jarray.array(list, ObjectName))


def getJMSModulePath(jms_module_name):
        jms_module_path = &quot;/JMSSystemResources/&quot;+jms_module_name+&quot;/JMSResource/&quot;+jms_module_name
        return jms_module_path

def createJMSTEMP(jms_module_name,jms_temp_name):
        jms_module_path= getJMSModulePath(jms_module_name)
        cd(jms_module_path)
        cmo.createTemplate(jms_temp_name)
        cd(jms_module_path+&#39;/Templates/&#39;+jms_temp_name)
        cmo.setMaximumMessageSize(20)

##########################################
# JMS Queu configuration function 
# arguments are : JMS module name, Queue jndiname
# Queue name, jndi name hu
##########################################
def createJMSQ(jms_module_name,jndi,jms_queue_name):
        jms_module_path = getJMSModulePath(jms_module_name)
        cd(jms_module_path)
        cmo.createQueue(jms_queue_name)
        cd(jms_module_path+&#39;/Queues/&#39;+jms_queue_name)
        cmo.setJNDIName(jndi)
        cmo.setSubDeploymentName(subdeployment_name)

adminUser=configProps.get(&quot;adminUser&quot;)
adminPassword=configProps.get(&quot;adminPassword&quot;)
adminURL=configProps.get(&quot;adminURL&quot;)

connect(adminUser,adminPassword,adminURL)
#adm_name=get(&#39;AdminServerName&#39;)
adm_name=ls(&#39;Servers&#39;,returnMap=&#39;true&#39;)[0]
print adm_name
edit()
startEdit()

##########################################
#   JMS CONFIGURATION## 
##########################################
total_conf=configProps.get(&quot;total_conf&quot;)
tot_djmsm=configProps.get(&quot;total_default_jms_module&quot;)
#subdeployment_name=configProps.get(&quot;subdeployment_name&quot;)

a=1
while(a &amp;lt;= int(tot_djmsm)):
        i=int(a)
        jms_mod_name=configProps.get(&quot;jms_mod_name&quot;+ str(i))
        #cluster=configProps.get(&quot;jms_mod_target&quot;+ str(i))
        subdeployment_name=configProps.get(&quot;subdeployment_name&quot;+ str(i))
        createJMSModule(jms_mod_name,adm_name,subdeployment_name)
        total_q=configProps.get(&quot;total_queue&quot;+str(i))
        j=1
        while(j &amp;lt;= int(total_q)):
                queue_name=configProps.get(&quot;queue_name&quot;+ str(i)+str(j))
                queue_jndi=configProps.get(&quot;queue_jndi&quot;+ str(i)+str(j))
                createJMSQ(jms_mod_name,queue_jndi,queue_name)
                j = j + 1
        i=i+1
        a = a+1
save()
activate(block=&quot;true&quot;)
disconnect() 

&lt;/pre&gt;
&lt;br /&gt;
Now see this is a sample of properties file that could help you to build the JMS Module, be read by the WLST script at the run time:
&lt;br /&gt;
&lt;pre class=&quot;brush:bash&quot;&gt;###################################################
# JMS SUBDEPLOY CONFIGURATION
###################################################
total_subdply=2
total_default_jms_module=2
total_conf=0
subdeployment_name1=DemoJMSFAServer1
subdeployment_name2=DemoJMSFAServer2

###################################################
# JMS MODULE CONFIGURATION
###################################################
jms_mod_name1=Demo-SystemModule1
jms_mod_name2=Demo-SystemModule2

###################################################
# JMS CONNECTION FACTORY CONFIGURATION
###################################################
conf_jndi1=demoCF
conf_name1=jms/demoCF

###################################################
#   JMS QUEUE CONFIGURATION
###################################################

total_queue1=2
queue_name11=Q1
queue_jndi11=Q1

queue_name12= BQ1
queue_jndi12= BQ1


total_queue2=2
queue_name21=Q2
queue_jndi21=Q2

queue_name22= BQ2
queue_jndi22= BQ2

#========== ADMIN DETAILS =========================
adminUser=weblogic
adminPassword=welcome1
adminURL=t3://192.168.33.100:8100
&lt;/pre&gt;
output
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;$ wlst jms_module.py jms_module.properties

&lt;/pre&gt;
let&#39;s see what happen when you apply this logic on your project? Did you notice any errors? Please write back 🔙 with your error screen shot.&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;&lt;b&gt;
How do you know everything went well? &lt;/b&gt;Open the WebLogic Administration console to check the JMS Module Configuration has successfully created a new JMS resource or not.&lt;br /&gt;
&lt;br /&gt;
You may be intrested to learn more WLST scripting for JMS you can also visit the &lt;a href=&quot;http://wlstbyexamples.blogspot.in/2013/01/this-post-is-continous-series-of-jms.html&quot; target=&quot;_blank&quot;&gt;Uniform Distributed Queue configuration&lt;/a&gt; post. Thanks for being with us in this post, Please write to us your errors and exceptions when you run this script.&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/4656431609578553224/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2017/08/jms-module-with-connectionfactory-and.html#comment-form' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/4656431609578553224'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/4656431609578553224'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2017/08/jms-module-with-connectionfactory-and.html' title='JMS Module with ConnectionFactory and Queue configuration using WLST'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBG4IgROT11O3437RZ-ynLGBzXNCYxJNayZp1NYzqABCotBiejZFjywE-wQq798efHWtq9L56FwghyNz-ydH71sRYYhvlxdgMbQ98D_7WzywpSse9ppx_0DeAZ8rf3VYFMT_r__Wq2B60/s72-w400-h335-c/1661941356549654-0.png" height="72" width="72"/><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-529981973010835927</id><published>2021-08-14T03:37:00.004-07:00</published><updated>2022-08-31T21:42:55.154-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CONFIG_JVM_ARG"/><category scheme="http://www.blogger.com/atom/ns#" term="Fusion Middleware"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 14c"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST"/><title type='text'>How to include modules and Java Options in WLST Shell?</title><content type='html'>In recent developments in the Python impacting WLST Shell as well. We might want to use Python module into our WLST scripts as well. Sometimes you need a Python module that is available for Python Community same we may use in your WLST, and sometimes you might need some JAVA_OPTIONS must be included before the WLST shell is launched.&lt;br /&gt;
&lt;br /&gt;
Here I will walk you through some scenarios where you need to customize.&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;When there is customization in WebLogic domains such as &lt;b&gt;Oracle Utilities&lt;/b&gt; products uses the SSL enable communication for their AdminServer - Managed servers&lt;/li&gt;&lt;li&gt;WLST shell using a connection to AdminServer with &lt;b&gt;t3s &lt;/b&gt;protocol&lt;/li&gt;&lt;li&gt;WebLogic domain for Oracle Data Integrator uses WLST when a managed server used to stop with &#39;stopManagedWebLogic.sh&#39; or even AdminServer using &#39;stopWebLogic.sh&#39; script calls WLST scripts to stop and when there is SSL enabled for the security purpose then WLST shell interaction requires SSL configuration details&lt;/li&gt;&lt;/ol&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;How to include the Python module in WLST?&lt;/h3&gt;
This could be a common requirement when automation scripts needs multiple Python modules into their WLST Shell.&lt;br /&gt;
&lt;br /&gt;
Better you can add to your profile script. I&#39;ve added the following lines to the .bashrc profile script.

&lt;pre class=&quot;brush: bash&quot;&gt;alias wlst=&quot;$WL_HOME/../oracle_common/common/bin/wlst.sh&quot;
export CONFIG_JVM_ARGS=&quot;-Djava.security.egd=file:/dev/./urandom \
-Dweblogic.security.SSL.enableJSSE=true \
-Dweblogic.security.SSL.ignoreHostnameVerification=true \
-Dweblogic.security.TrustKeyStore=DemoTrust \
-Dweblogic.security.CustomTrustKeyStoreType=JKS&quot;

&lt;/pre&gt;

Note here if you are using Demo certificates then you can use the above. But if you have custom certificates then you need to provide Custom Certificates location.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;How you can tune or optimize your WLST Shell launching time?&lt;/h3&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In your .bashrc or bash_profile you can include the following environment variable which will boost-up or speed up your JVM launching time.&lt;/div&gt;

&lt;pre class=&quot;brush: bash&quot;&gt;export CONFIG_JVM_ARGS=-Djava.security.egd=file:/dev/./urandom
&lt;/pre&gt;
&lt;br /&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;

Configuring FMW domains we expected more with CONFIG_JVM_ARG

&lt;/h3&gt;&lt;pre class=&quot;brush: bash&quot;&gt;export CONFIG_JVM_ARGS=-Dcom.oracle.cie.config.showProfile=true
&lt;/pre&gt;
This will enable the option in the configuration type screen to create a new compact SOA/OSB domain or any FMW 12+ domain. Without -Dcom.oracle.cie.config.showProfile=true FMW Domain creation will not show the Embedded Database option for Database configuration type in the Wizard.</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/529981973010835927/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2018/04/how-to-include-modules-and-java-options.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/529981973010835927'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/529981973010835927'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2018/04/how-to-include-modules-and-java-options.html' title='How to include modules and Java Options in WLST Shell?'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-966084663071153570</id><published>2018-08-19T05:32:00.000-07:00</published><updated>2018-08-19T05:32:32.558-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="creation of Generic Datasource in Oracle Utilities"/><category scheme="http://www.blogger.com/atom/ns#" term="GEOCODE datasource"/><category scheme="http://www.blogger.com/atom/ns#" term="MapViewer datasource"/><category scheme="http://www.blogger.com/atom/ns#" term="MWM"/><category scheme="http://www.blogger.com/atom/ns#" term="NAVTEQ_UTIL"/><category scheme="http://www.blogger.com/atom/ns#" term="Oracle Utilities Mobile Workforce Management"/><category scheme="http://www.blogger.com/atom/ns#" term="ORS"/><title type='text'>Configuration of GEOCODE Datasource for Oracle MapViewer</title><content type='html'>Couple of years back in the same blog I&#39;ve posted how we can configure a generic datasource in WebLogic domain using WLST. Working in today&#39;s trend continuous deployment(CD) automation development I&#39;ve worked on similar task that is GEOCODE datasource configuration. GEOCODE datasource is the basic configuration requirement for running Oracle MapViewer.&lt;br /&gt;
&lt;br /&gt;
In Oracle Utilities Mobile Workforce Management runs on WebLogic server.&lt;br /&gt;
&lt;br /&gt;
Pre-requisites&lt;br /&gt;
Oracle native WebLogic domain configured and the Admin Server must be up and running because our automation will be going to work online WLST.&lt;br /&gt;
&lt;br /&gt;
How does it works?&lt;br /&gt;
&lt;br /&gt;
In the Oracle Utilities products have a file ENVIRON.INI, that will having all connection related parameters available such as: ADMIN HOST, ADMIN PORT, UserStoreConfig files userConfigFile&lt;br /&gt;
userKeyFile path. By reading this file as properties we can get connected to the&amp;nbsp; running WebLogic Admin Server.&lt;br /&gt;
&lt;br /&gt;
We will need the GEOCODE data source parameters, this can be passed as properties file ConfigGEOCODE.properties. To create a data source we need the following :&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Name of the datasoruce as GEOCODE&lt;/li&gt;
&lt;li&gt;JNDI Name as NAVTEQ_UTIL&lt;/li&gt;
&lt;li&gt;Select the database as Oracle&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
Connection pool configuration in the JDBC System Resource&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;Enter your database hostname&lt;/li&gt;
&lt;li&gt;Database port&lt;/li&gt;
&lt;li&gt;Database name&lt;/li&gt;
&lt;li&gt;Database user credentials&lt;/li&gt;
&lt;li&gt;Test Connection Pool&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;pre class=&quot;brush:py&quot;&gt;###################****##############****################################################
# Generic Datasource configuration script applicable on any Operating Environments (Unix, Windows)
# ScriptName    : ConfigGEOCODE.py
# Properties    : ConfigGEOCODE.properties
# Updated by    : Pavan Devarakonda
# Date creation : 9th Aug 2018
###############     Connecting to Start     ################################################
def connectAdmin() :
 try:
  import os
  splebase=os.environ[&#39;SPLEBASE&#39;]
  loadProperties(splebase+&quot;/etc/ENVIRON.INI&quot;)
  userconfig = splebase+&quot;/etc/.wlsuserconfig&quot;
  userkey = splebase+&quot;/etc/.wlsuserkey&quot;
  adminurl=&quot;t3s://&quot;+WEB_ADMIN_SERVER+&quot;:&quot;+WLS_ADMIN_PORT
  printline(&#39;Connectiong to adminurl: &#39;+adminurl)
  connect(userConfigFile=userconfig,userKeyFile=userkey, url=adminurl)
  printline(&#39;Successfully connected&#39;)
 except:
  printline(&#39;Unable to find admin server...&#39;)
  exit()

#================== Printing line =====================================
def printline(msg):
        print 45*&#39;#&#39;
        print msg
        print 45*&#39;#&#39;

################### Configuring Connection Pool #############################
def connPool(DSnam) :
 DRVPARM=&#39;/JDBCSystemResources/&#39;+DSnam+&#39;/JDBCResource/&#39;+DSnam+&#39;/JDBCDriverParams/&#39;+DSnam
 cd(DRVPARM)
 set(&#39;Url&#39;,DBURL)
 set(&#39;DriverName&#39;,DBDRV)
 cmo.setPassword(&#39;XXXXXX&#39;)

 cd(DRVPARM+&#39;/Properties/&#39;+DSnam)
 cmo.createProperty(&#39;user&#39;)
 cd(DRVPARM+&#39;/Properties/&#39;+DSnam+&#39;/Properties/user&#39;)
 set(&#39;Value&#39;,DBUSR)

############         Creating Data source    ###############################
def createDS() :
 DSnam = DSName
 printline(&#39;Creating datasource :&#39;+DSnam)
 cmo.createJDBCSystemResource(DSnam)
 RESOURCE=&#39;/JDBCSystemResources/&#39;+DSnam+&#39;/JDBCResource/&#39;+DSnam
 cd(RESOURCE)
 set(&#39;Name&#39;,DSnam)
 #Setting JNDI name
 cd(RESOURCE+&#39;/JDBCDataSourceParams/&#39;+DSnam)
 print RESOURCE+&#39;/JDBCDataSourceParams/&#39;+DSnam
 set(&#39;JNDINames&#39;,jarray.array([String(JNDIname)], String))

 connPool(DSnam)

 #Set Connection Pool specific parameters
 cd(RESOURCE+&#39;/JDBCConnectionPoolParams/&#39;+DSnam)
 cmo.setTestConnectionsOnReserve(true)
 cmo.setTestTableName(&#39;SQL SELECT 1 FROM DUAL\r\n\r\n&#39;)
 #cmo.setTestTableName(&#39;SQL ISVALID&#39;)
 cmo.setConnectionReserveTimeoutSeconds(25)
 cmo.setMaxCapacity(15)
 cmo.setConnectionReserveTimeoutSeconds(10)
 cmo.setTestFrequencySeconds(120)

 cd(RESOURCE+&#39;/JDBCDataSourceParams/&#39;+DSnam)
 cmo.setGlobalTransactionsProtocol(&#39;TwoPhaseCommit&#39;)

 # targets the GEOCODE DataSource to utilities_cluster1
 cd(&#39;/SystemResources/&#39;+DSnam)
 set(&#39;Targets&#39;,jarray.array([ObjectName(&#39;com.bea:Name=&#39;+clstrNam+&#39;,Type=Cluster&#39;)], ObjectName))

###########################  Main Module   #####################################
if __name__== &quot;main&quot;:
 connectAdmin()
 edit()
 startEdit()
 # Create a new JDBC resource)
 try:
  cd(&#39;/&#39;)
  createDS()

 except BeanAlreadyExistsException:
  printline(&#39;Error: GEOCODE Datasource already exist&#39;)
  cancelEdit(&#39;y&#39;); exit()
 save()
 activate()
 printline(&#39;Successfully created GEOCODE datasource&#39;)
 disconnect()

&lt;/pre&gt;
The properties file look like this:
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;#=========================================
DBURL=jdbc:oracle:thin:@mydb.server.com:1521:M1DBMAPS
DBDRV=oracle.jdbc.xa.client.OracleXADataSource
DBPASS=XXXXXXX
DBUSR=NAVTEQ_UTIL
DSName=GEOCODE
JNDIname=NAVTEQ_UTIL
clstrNam=utilities_cluster1
&lt;/pre&gt;
The script execution goes as follows:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
Now prepare for execution of WLST script, setup the environment and also define proper SSL related options to include in JAVA_OPTIONS which will be considered when wlst.sh execution time.

&lt;pre class=&#39;brush:bash&#39;&gt;

wlst -loadProperties ConfigGEOCODE.properties ConfigGEOCODE.py
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
This script execution was tested successful and ready to use. You need to enter properties file corresponding to your database values. 
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/966084663071153570/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2018/08/configuration-of-geocode-datasource-for.html#comment-form' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/966084663071153570'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/966084663071153570'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2018/08/configuration-of-geocode-datasource-for.html' title='Configuration of GEOCODE Datasource for Oracle MapViewer'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><thr:total>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-2563765735328587632</id><published>2018-07-13T03:17:00.000-07:00</published><updated>2018-08-19T03:16:01.630-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CCB"/><category scheme="http://www.blogger.com/atom/ns#" term="Keystore"/><category scheme="http://www.blogger.com/atom/ns#" term="Keystore setting for ManagedServer"/><category scheme="http://www.blogger.com/atom/ns#" term="MWM"/><category scheme="http://www.blogger.com/atom/ns#" term="Oracle Utilities"/><category scheme="http://www.blogger.com/atom/ns#" term="ORS Oracle Utilities Mobile Workforce Management"/><category scheme="http://www.blogger.com/atom/ns#" term="SSL"/><category scheme="http://www.blogger.com/atom/ns#" term="SSL Privatekey setting for AdminServer"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 12.2.1.3"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST"/><title type='text'>Setting Keystore and SSL for a WebLogic Server using WLST</title><content type='html'>&lt;h2&gt;
&lt;span style=&quot;background-color: #660000; color: #f4cccc; font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Configuring Custom SSL for WebLogic server&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/h2&gt;
Working on the Oracle Utilities project, where our Environment requirement is that Mobile runtimes will communicates with secure servers. So we need to make the WebLogic server SSL Enabled with&amp;nbsp; Custom SSL certificates configuration.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQBC9xbIJncpvqGzWmq8xAHVBMfPuWoMEbJ6PJk4VsfTgQz-TNk0N2Oc99h8gfJeggVaVgM-4zzA2qgBHsB3fMR0L3AAL0cmOglFBoSSODi_z8MTjc_Oxqt6Br5zSubV0G6JjuBh8rLHs/s1600/KeystoreSSL_WLS.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;413&quot; data-original-width=&quot;793&quot; height=&quot;332&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQBC9xbIJncpvqGzWmq8xAHVBMfPuWoMEbJ6PJk4VsfTgQz-TNk0N2Oc99h8gfJeggVaVgM-4zzA2qgBHsB3fMR0L3AAL0cmOglFBoSSODi_z8MTjc_Oxqt6Br5zSubV0G6JjuBh8rLHs/s640/KeystoreSSL_WLS.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;WLST keystore SSL for Admin Server, Managed Server&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
Assumptions:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;WebLogic 12.2.1.3 domain configured&lt;/li&gt;
&lt;li&gt;Each WebLogic server SSL enabled already&lt;/li&gt;
&lt;li&gt;AdminServer up and running&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
Here in this example I am using CA provided certificates but to publish in this post giving dummy paths and file names. The prerequisites you must have the Custom Identity and Custom Trust store

&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;#!/usr/bin/python
# Author    : Pavan Devarakonda
# Save Script as  : set_keystoreSSL.py
# Initial drafted : 12/07/2018
#==========================================

import re

# Get location of the properties file.
execfile(&#39;/opt/MWM/scripts/set_keystore.properties&#39;)
def connectAdmin():
        # Connect to the AdminServer.
        try:
                connect(admin_username, admin_password, admin_url)
        except:
                print &#39;Unable to connect to AdminServer&#39;
                exit()

def setKSnSSL4server(serverName, ksIdentityPath,ksIdentityPassword,ksTrustPath,ksTrustPassword,privateKeyAlias,keyPhrase):
        # Set keystore information.
        print &quot;===============================&quot;
        print &quot;set keystore to &quot;+serverName
        print &quot;===============================&quot;
        cd(&#39;/Servers/&#39; + serverName)
        cmo.setKeyStores(&#39;CustomIdentityAndCustomTrust&#39;)

        cmo.setCustomIdentityKeyStoreFileName(ksIdentityPath)
        cmo.setCustomIdentityKeyStoreType(&#39;JKS&#39;)
        set(&#39;CustomIdentityKeyStorePassPhrase&#39;, ksIdentityPassword)
        cmo.setCustomTrustKeyStoreFileName(ksTrustPath)
        cmo.setCustomTrustKeyStoreType(&#39;JKS&#39;)
        set(&#39;CustomTrustKeyStorePassPhrase&#39;, ksTrustPassword)
        print &quot;set SSL to &quot;+serverName
        print &quot;===============================&quot;
        cd(&#39;/Servers/&#39; + serverName + &#39;/SSL/&#39; + serverName)
        cmo.setServerPrivateKeyAlias(privateKeyAlias)
        set(&#39;ServerPrivateKeyPassPhrase&#39;, keyPhrase)

def main():
        connectAdmin()
        print servers
        edit()
        startEdit()
        print &quot;=========================================================================&quot;
        print &quot;AdminServer, utilities_server1 server set keystore, SSL custom keystore&quot;
        print &quot;=========================================================================&quot;
  setKSnSSL4server(adm[&#39;name&#39;], adm[&#39;identity.path&#39;], adm[&#39;identity.password&#39;],adm[&#39;trust.path&#39;],adm[&#39;trust.password&#39;],adm[&#39;privateKeyAlias&#39;],adm[&#39;keyPhrase&#39;])
  setKSnSSL4server(ms1[&#39;name&#39;], ms1[&#39;identity.path&#39;], ms1[&#39;identity.password&#39;],ms1[&#39;trust.path&#39;],ms1[&#39;trust.password&#39;],ms1[&#39;privateKeyAlias&#39;],ms1[&#39;keyPhrase&#39;])
        save()
        activate()
        disconnect()
        exit()

main()

&lt;/pre&gt;
This time the properties file is also python script to use the dictionary capabilities of Python to refer to the Weblogic server and its corresponding server&#39;S keystore, SSL details to store together.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;# AdminServer connection details.
admin_username=&#39;system&#39;
admin_password=&#39;welcome1&#39;
admin_url=&#39;t3://test.server.com:7001&#39;

#Dictionaries for AdminServer, utilities_server1 keystore, SSL values

adm = { &#39;name&#39;:&#39;AdminServer&#39;,&#39;identity.path&#39;:&#39;/opt/myalias_cert/myIdentity.jks&#39;, &#39;identity.password&#39;:&#39;welcome1&#39;, \
&#39;trust.path&#39;:&#39;/opt/myalias_cert/myTrustStore.jks&#39;, &#39;trust.password&#39;:&#39;welcome1&#39;, \
&#39;keyPhrase&#39;:&#39;welcome1&#39;, &#39;privateKeyAlias&#39;:&#39;myalias&#39;}

ms1 = { &#39;name&#39;:&#39;utilities_server1&#39;,&#39;identity.path&#39;:&#39;/opt/myalias_cert/myIdentity.jks&#39;, &#39;identity.password&#39;:&#39;welcome1&#39;, \
&#39;trust.path&#39;:&#39;/opt/myalias_cert/myTrustStore.jks&#39;, &#39;trust.password&#39;:&#39;welcome1&#39;, \
&#39;keyPhrase&#39;:&#39;welcome1&#39;, &#39;privateKeyAlias&#39;:&#39;myalias&#39;}

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;The execution or the above script output looks as below:

You can execute.

</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/2563765735328587632/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2018/07/setting-keystore-and-ssl-for-weblogic.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/2563765735328587632'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/2563765735328587632'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2018/07/setting-keystore-and-ssl-for-weblogic.html' title='Setting Keystore and SSL for a WebLogic Server using WLST'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQBC9xbIJncpvqGzWmq8xAHVBMfPuWoMEbJ6PJk4VsfTgQz-TNk0N2Oc99h8gfJeggVaVgM-4zzA2qgBHsB3fMR0L3AAL0cmOglFBoSSODi_z8MTjc_Oxqt6Br5zSubV0G6JjuBh8rLHs/s72-c/KeystoreSSL_WLS.JPG" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-412194325222241</id><published>2018-02-03T00:55:00.000-08:00</published><updated>2018-02-03T09:28:16.686-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="closeTemplate"/><category scheme="http://www.blogger.com/atom/ns#" term="loadTemplate"/><category scheme="http://www.blogger.com/atom/ns#" term="remotely domain extension using WLST script"/><category scheme="http://www.blogger.com/atom/ns#" term="selectCustomTemplate"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 12.2.x"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic12c"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="writeDomain"/><category scheme="http://www.blogger.com/atom/ns#" term="writeTemplate"/><title type='text'>Remotely domain extension using WLST</title><content type='html'>WebLogic latest version 12.2.x come up with different WebLogic domain templates and their usage methods in WLST. Usually WebLogic domain can be created with base domain template using wls.jar. Then after that domain need to be customized as the projects where we need the extended domain.&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;When the domain spread across multiple machines/nodes&lt;/li&gt;
&lt;li&gt;One successful configuration domain reuse to create new domains&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
Here is small experiment with the domain template, here we have two nodes associated with&amp;nbsp; 192.168.33.100 - Machine100 and 192.168.33101 - Machine101 IP addresses and machine. The admin server configured in the Machine100 and also two web servers in webcluster, two app servers in appcluster. The whole configuration we need in Machine101.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Earlier to WebLogic 12.2 version we have pack and unpack option only for the domain expansion in the remote machine otherwise copy the domain folder need to copy.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In the latest versions of WebLogic 12.2.x above are having different WLST methods that relates to template usage.&lt;/div&gt;
&lt;div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEVSwuKG3RlMuP9zi0o7VeKncuV7Aka6KULf1eeEYJWEfaei8wmSvc3d00VoWHDKJDIxXTruOuDMUQ5DMroFiF5Ibrc7E0GkA-nmHyOYGGCEb3Z5-YdhCVFRyZvESS-Hrqr6661_aNjWo/s1600/12.2Template.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;768&quot; data-original-width=&quot;1366&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEVSwuKG3RlMuP9zi0o7VeKncuV7Aka6KULf1eeEYJWEfaei8wmSvc3d00VoWHDKJDIxXTruOuDMUQ5DMroFiF5Ibrc7E0GkA-nmHyOYGGCEb3Z5-YdhCVFRyZvESS-Hrqr6661_aNjWo/s640/12.2Template.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Remotely extension of WebLogic Domain using WLST and pack-unpack&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
Lets explore options available in WLST&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
selectTemplate() in WLST&lt;/h3&gt;
&lt;div&gt;
There are multiple domain templates, extension templates for domains are available in Oracle WebLogic installation media pack it self. Some of the application specific templates also available with the media pack.&lt;/div&gt;
&lt;h3&gt;
selectCustomTemplate() in WLST&lt;/h3&gt;
&lt;div&gt;
We can create our own WebLogic domain template using writeTemplate() that will be containing the project specific configurations such as - servers, cluster, JDBC, JMS are pre-configured and reusable. The select custom template method followed by loadTemplate command.&lt;/div&gt;
&lt;h3&gt;
loadTemplates() in WLST&lt;/h3&gt;
&lt;div&gt;
The loadTemplates(0 is the command always used after selectTemplate or selectCustomTemplate commands.&lt;/div&gt;
&lt;br /&gt;
&lt;h2&gt;Automation solution: Create domain template and configure domain&lt;/h2&gt;
&lt;br /&gt;
Like here we need to create extension domain in the Machine101, you may need to to do for multiple machines in production environments.&lt;br /&gt;
&lt;br /&gt;
The process is simplified into few steps&lt;/div&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;connect to the existing domain&lt;/li&gt;
&lt;li&gt;Read the domain and generate the custom domain template&lt;/li&gt;
&lt;li&gt;Create the extended domain enter the same domain name and path or fresh domain can be configured with the new domain name, listen address modification as required&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;#======================================
# 
# File: remoteDomain.py
# Applicable WebLogic version: 12.2.x
# This will solve pack and unpack strange issues
#
#===============================================
def printline(s):
    print &quot;-&quot;*10 + s
 
def createDomainTemplate(templateLocation):
    
    &#39;&#39;&#39; Generate the custom domain template  &#39;&#39;&#39;
    connect(admuser,admpass,admurl)
    
    print (&quot;Writing Custom Template...&quot;)
    writeTemplate(templateLocation)
    print (&quot;Writing Template...: Completed&quot;)
    disconnect()
    
def create_Domain(templateLocation, domainPath):
 &#39;&#39;&#39; Creating extended domain remotely 
 selectCustomTemplate, loadTemplates will get the inputs
 then writeDomain will create the domain &#39;&#39;&#39;
 
 selectCustomTemplate(templateLocation)
 loadTemplates()
 print (&quot;Creating extended domain...&quot;)
 writeDomain (domainPath)
 closeTemplate()
 print (&quot;Creating domain...: Completed&quot;)
       
       
def main():
 &#39;&#39;&#39;
 Change the following values according to your domain
 user security better to use storeuserconfig
 and domain template 
 you can move these variables into properties file
 &#39;&#39;&#39;
 templateLocation =&#39;/u01/app/oracle/prod_domain_template.jar&#39;
 domainPath=&#39;/u01/app/oracle/prod_domain&#39;
 admuser=&#39;weblogic&#39;
 admpass=&#39;welcome1&#39;
 admurl=&#39;192.168.33.100:8001&#39;
 
 createDomainTemplate(templateLocation)
 create_Domain(templateLocation, domainPath)
    
if __name__ == &quot;__main__&quot;:
    printline()
    print(&quot;SCRIPT BEING RUN DIRECTLY&quot;)
    printline()
    main()
 printline()
&lt;/pre&gt;
&lt;/div&gt;
&lt;h3&gt;
Remotely execution of script&lt;/h3&gt;
WLST SCRIPT 

&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/412194325222241/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2018/02/remotely-domain-extension-using-wlst.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/412194325222241'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/412194325222241'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2018/02/remotely-domain-extension-using-wlst.html' title='Remotely domain extension using WLST'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEVSwuKG3RlMuP9zi0o7VeKncuV7Aka6KULf1eeEYJWEfaei8wmSvc3d00VoWHDKJDIxXTruOuDMUQ5DMroFiF5Ibrc7E0GkA-nmHyOYGGCEb3Z5-YdhCVFRyZvESS-Hrqr6661_aNjWo/s72-c/12.2Template.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-5264463678807373380</id><published>2017-07-26T20:15:00.003-07:00</published><updated>2022-07-26T04:13:40.623-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Automation script"/><category scheme="http://www.blogger.com/atom/ns#" term="Tuning with WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 11g"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 12.2.1"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 12c"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic domain log"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic Server log"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST"/><title type='text'>Logging configuration for domain and WebLogic server</title><content type='html'>&lt;b&gt;Why we need Logging&lt;/b&gt;?&lt;br&gt;
To understand in a basic level, when we run the WebLogic Servers we don&#39;t know what is happening inside the process. &amp;nbsp;It is kind of black box to us. To know what is happening inside the domain or server side to get more details we have logging mechanism enabled in WebLogic domains.&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
  &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd76TV-Ac3Bfe27yaBVvtB_ltCxHQGmUPkuUmBUovJ3io461sUaSgE5bZaeuDvZQ-4z8HQWpyKwrbbk4ypeYozSRQzmzvPjZxHww38qLkWgwR8N0oFv5umY4sIT0HWmOs3VWx0XLUtiKI/s1600/1658834015467890-0.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;
    &lt;img border=&quot;0&quot;   src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd76TV-Ac3Bfe27yaBVvtB_ltCxHQGmUPkuUmBUovJ3io461sUaSgE5bZaeuDvZQ-4z8HQWpyKwrbbk4ypeYozSRQzmzvPjZxHww38qLkWgwR8N0oFv5umY4sIT0HWmOs3VWx0XLUtiKI/s1600/1658834015467890-0.png&quot; width=&quot;400&quot;&gt;
  &lt;/a&gt;
&lt;/div&gt;&lt;br&gt;
&lt;br&gt;
WebLogic Logging works for multiple hierarchical Subsystem. At the top level it is already enabled and we can use the existing setup. But for some reasons each project will have separate logging needs.&lt;br&gt;
&lt;br&gt;&lt;b&gt;
When we can use this?&lt;/b&gt;&lt;br&gt;
If there are multiple Testing logging configuration at different levels:

&lt;br&gt;
&lt;ol&gt;
&lt;li&gt;&lt;b&gt;&lt;i&gt;domain level logs&lt;/i&gt;&lt;/b&gt; - global status&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;&lt;b&gt;Server level logs&lt;/b&gt;&lt;/i&gt; - admin or managed server status&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;i&gt;Resource level logs&lt;/i&gt;&lt;/b&gt; - JDBC, JMS, application status&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
We can set the common attributes of JMX MBean reset with new values which will work for your project needs.&lt;br&gt;
&lt;br&gt;
While creating this snippet we have tried to execute it on WebLogic 11g [10.3.6] and WebLogic 12c.&lt;/div&gt;
&lt;div&gt;
&lt;br&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;brush:py&quot;&gt;########################################################################
# Python Script file: logrotate.py
# Author: Pavan Devarakonda
# Date : 25-Jul-2017
########################################################################
loadProperties(&#39;demodomain.properties&#39;)
# Functions
def editMode():
   edit()
   startEdit()

def saveActivate():
   save()
   activate()
   print &#39;###### Completed configuration of domain logs ##############&#39;

def exitDisconnect():
        disconnect()
        exit()

def connectToAdmin():
    connect(username,password,url)

def domainlog_rotation(domainname,FC,MinSize):
        &quot;&quot;&quot;
        It will take the three parameters domainpath ,domainname is string values
        and FileCount -  FC and File MinSize - MinSize are integer values these values loaded from properties
        so they need to type cast to integers
        &quot;&quot;&quot;
        cd(&#39;/Log/&#39;+domainname)
        cmo.setRotationType(&#39;bySize&#39;)
        cmo.setRotateLogOnStartup(true)
        cmo.setFileCount(int(FC))
        cmo.setNumberOfFilesLimited(true)
        cmo.setFileMinSize(int(MinSize))
        cmo.setLogFileRotationDir(domainpath+domainname+&#39;/RotationDir&#39;)
        save()

def ServerLogRotation(S,SFC,SMinsize):
        &quot;&quot;&quot;
        This module will rotate the AdminServer or Managed Server loggger settings
        It takes three params - S as name of the server, SFC - Server FileCount, SMinsize - Server FileMinSize
        &quot;&quot;&quot;
        print S+ &#39; server log  setting...&#39;
        cd(&#39;/Servers/&#39;+S+&#39;/Log/&#39;+S)
        cmo.setRotationType(&#39;bySize&#39;)
        cmo.setRotateLogOnStartup(true)
        cmo.setFileCount(int(SFC))
        cmo.setNumberOfFilesLimited(true)
        cmo.setFileMinSize(int(SMinsize))
        cmo.setLogFileRotationDir(domainpath+domainname+&#39;/RotationDir +S&#39;)

def printline(): print &#39;#&#39;*50

def main():
        printline(); print &#39;Starting domain logs Configurations &#39;; printline()
        connectToAdmin()
        editMode()
        domainlog_rotation(domainname,FC,MinSize)
        printline(); print &#39;Starting Server logs configurations&#39; ; printline()
        cd(&#39;/&#39;)
        for server_name in ls(&#39;Servers&#39;,returnMap=&#39;true&#39;):
                if server_name == &#39;AdminServer&#39;:
                        ServerLogRotation(server_name,ASFC,ASMinsize)
                else:
                        ServerLogRotation(server_name,MSFC,MSMinsize)
        saveActivate()
        exitDisconnect()

main()
&lt;/pre&gt;
&lt;br&gt;
Please double check all indentation blocks.
&lt;br&gt;
The properties file used for sample tests is as follows:&lt;br&gt;
&lt;br&gt;
&lt;pre class=&quot;brush:py&quot;&gt;#WebLogic console connection parameters
username=weblogic
password=welcome1
url=t3://192.168.33.102:8001
domainname=demo_domain

# Domain logger configurations
FC=4
MinSize=5
domainpath=/u01/oracle/domains/

# ManagedServer logger configurations
MSFC=3
MSMinsize=2

# AdminServer logger configurations
ASFC=5

&lt;/pre&gt;
&lt;br&gt;
Sample execution output as follows:
&lt;br&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiop3LNpq4Rt4L2ijoFe_qG6G12XpeWM5SMLUR1zePCgargNlMGE6hYABjp58cSHAvJyag3jblRxpWarHz_Dke8ZwsVW9et__ojfTG9UtABd49L8E4ClHS7GGfgZ6pLUnvhAvQ5Eoe7EmM/s1600/logRotate.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;731&quot; data-original-width=&quot;707&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiop3LNpq4Rt4L2ijoFe_qG6G12XpeWM5SMLUR1zePCgargNlMGE6hYABjp58cSHAvJyag3jblRxpWarHz_Dke8ZwsVW9et__ojfTG9UtABd49L8E4ClHS7GGfgZ6pLUnvhAvQ5Eoe7EmM/s640/logRotate.JPG&quot; width=&quot;618&quot;&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;WebLogic Logger enabled and configuration using WLST scrpt execution.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/5264463678807373380/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2017/07/logging-configuration-for-domain-and.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/5264463678807373380'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/5264463678807373380'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2017/07/logging-configuration-for-domain-and.html' title='Logging configuration for domain and WebLogic server'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd76TV-Ac3Bfe27yaBVvtB_ltCxHQGmUPkuUmBUovJ3io461sUaSgE5bZaeuDvZQ-4z8HQWpyKwrbbk4ypeYozSRQzmzvPjZxHww38qLkWgwR8N0oFv5umY4sIT0HWmOs3VWx0XLUtiKI/s72-c/1658834015467890-0.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-5199912360667412363</id><published>2017-04-08T02:06:00.001-07:00</published><updated>2017-04-08T21:22:51.482-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Cluster"/><category scheme="http://www.blogger.com/atom/ns#" term="Cluster Address"/><category scheme="http://www.blogger.com/atom/ns#" term="ClusterMessagingMode"/><category scheme="http://www.blogger.com/atom/ns#" term="Machine"/><category scheme="http://www.blogger.com/atom/ns#" term="NMType"/><category scheme="http://www.blogger.com/atom/ns#" term="NodeManager"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 12.2.1"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 12c Cluster domain"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic12c"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST Offline"/><title type='text'>WebLogic 12c Cluster Domain configuration using WLST offline</title><content type='html'>Objective of this script is to Leverage the time takes to configure the WebLogic Domain and after starting the admin server then following list need to be configured for HA/reliability.&lt;br /&gt;
Everytime I work on new project there is a need of creation of the clustered domain. From my past experiences collected all basic requirements together list them over here.
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;AdminServer configuration includes Name, Listen Address, ListenPort&lt;/li&gt;
&lt;li&gt;User credentials username, password&lt;/li&gt;
&lt;li&gt;After writing basic domain going for create machine which include Name, type of machine&lt;/li&gt;
&lt;li&gt;Nodemaager includes NMTypes such as plain, ssl, hosted node, nodemanager port&lt;/li&gt;
&lt;li&gt;Managed servers have Name, ListenAddress, ListenPort, set machine&lt;/li&gt;
&lt;li&gt;Cluster includes name, ClusterAddress, Servers part of the cluster interesting part here&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Assumptions for this task:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://weblogic12cessentials.blogspot.in/2015/05/1.html&quot; target=&quot;_blank&quot;&gt;Vagrant Ubuntu launched&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://wlatricksntips.blogspot.in/2017/03/single-click-installation-of-weblogic.html&quot; target=&quot;_blank&quot;&gt;Java and WebLogic Installed&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://wlatricksntips.blogspot.in/2010/09/setting-up-fine-weblogic-profile-on.html&quot; target=&quot;_blank&quot;&gt;wlst alias into bash profile&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYa5WEbUn_UuXPd7tY79BE8a2ovHJYkhsZ2lnTyzyaCuTga0TZEcBWNZc9psOcRQlNlBF4E_hxTE_6dm9WhlqQlElkbEb2yV6hD79ocacD7ZKeciuknhyfdbAMmbycRFqQxNNOoEEui9g/s1600/WLST_Clstr_domain.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;WebLogic 12.2.1 cluster domain creation with WLST&quot; border=&quot;0&quot; height=&quot;368&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYa5WEbUn_UuXPd7tY79BE8a2ovHJYkhsZ2lnTyzyaCuTga0TZEcBWNZc9psOcRQlNlBF4E_hxTE_6dm9WhlqQlElkbEb2yV6hD79ocacD7ZKeciuknhyfdbAMmbycRFqQxNNOoEEui9g/s640/WLST_Clstr_domain.JPG&quot; title=&quot;WebLogic 12c Cluster domain configuration using WLST Offline&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;WLST Configuring WebLogic Cluster Domain&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
In the script as per my convenience some of them are hardcoded, My hardcoded values:&lt;/div&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;Managed Server list&lt;/li&gt;
&lt;li&gt;Cluster list&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
In this script lots of Python sequence functions are used.&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;List index,&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Dictionary keys&lt;/li&gt;
&lt;li&gt;String startwith&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Lets begin the fun of WLST HERE...&lt;/div&gt;
&lt;pre class=&quot;brush:py&quot;&gt;# purpose:  Create the domian with the one Admin Server along with the
# two managed servers in each cluster. app_cluster, web_cluster
# Assumption here all managed servers runs on the same machine
# Modified date: 07-April-2017
# File name     :       create_clusterdomain.py
# Dependencies  :       cluster_domain.properties
# Note this names of managed servers, cluster, hostname all hard coded
#
def printline(s):
    print &quot;-&quot;*10 + s

loadProperties(&#39;/u01/app/software/scripts/pybin/cluster_domain.properties&#39;)

# Created a Cluster and assaign the servers to that cluster
# Create a domain from the weblogic domain template

WLHOME=os.environ[&quot;WL_HOME&quot;]
readTemplate(WLHOME+&#39;/common/templates/wls/wls.jar&#39;)
printline(&quot;reading template completed&quot;)

# Configure the Administration Servers with out using SSL Port

cd(&#39;Servers/AdminServer&#39;)
set(&#39;ListenAddress&#39;,WLSAdminIP)
set(&#39;ListenPort&#39;, int(AdminPort))

printline(&quot;AdminServer ListenAddress, port set&quot;)

cd(&#39;/&#39;)
cd(&#39;Security/base_domain/User/weblogic&#39;)
cmo.setPassword(AdminPasswd)
printline(&quot;User credentials set&quot;)

setOption(&#39;OverwriteDomain&#39;, &#39;true&#39;)
writeDomain(DomainPath+&#39;/&#39;+DomainName)
printline(&quot;Domain creation done.&quot;)

closeTemplate()
readDomain(DomainPath+&#39;/&#39;+DomainName)
machines={&#39;myM100&#39;:&#39;192.168.33.100&#39;, &#39;myM110&#39;:&#39;192.168.33.110&#39;}

for m in machines.keys():
        cd(&#39;/&#39;)
        create(m, &#39;UnixMachine&#39;)
        cd(&#39;Machine/&#39; + m)
        create(m, &#39;NodeManager&#39;)
        cd(&#39;NodeManager/&#39; + m)
        set(&#39;ListenAddress&#39;, machines[m])
        set(&#39;NMType&#39;,&#39;ssl&#39;)

# Create the Managed Servers and  configuration them
ManagedServerList=[&#39;app01&#39;,&#39;app02&#39;,&#39;web01&#39;,&#39;web02&#39;]

app_ca=&quot;&quot;
web_ca=&quot;&quot;
for s in ManagedServerList:
        cd(&#39;/&#39;)
        create(s,&#39;Server&#39;)
        cd(&#39;Server/&#39;+s)
        i=ManagedServerList.index(s)
        lp=8101+i
        set(&#39;ListenPort&#39;, int(lp))
        j=int(s[-1])
        m=machines.keys()[j-1]
        set(&#39;ListenAddress&#39;, machines[m])
        set(&#39;Machine&#39;, m)

        if s.startswith(&#39;app&#39;) :
                if j%2==0:
                        app_ca+=&#39;,&#39;
                app_ca+=machines[m]+&#39;:&#39;+str(lp)

        elif s.startswith(&#39;web&#39;):
                if j%2==0:
                        web_ca+=&#39;,&#39;
                web_ca+=machines[m]+&#39;:&#39;+str(lp)

        printline(&quot;Managed server :&quot;+s+&quot; created&quot;)

printline(&quot;configured managed servers done.&quot;)
printline(&quot;app cluster address:&quot;+app_ca)
printline(&quot;Web cluster address:&quot;+web_ca)

# Create and Configure a Cluster and assian the Managed Servers to that cluster
clusters={&#39;app_clustr1&#39;:&#39;app01,app02&#39;, &#39;web_clustr1&#39;:&#39;web01,web02&#39;}
clstrs=clusters.keys()
for c in clstrs:
        cd(&#39;/&#39;)
        create(c,&#39;Cluster&#39;)
        assign(&#39;Server&#39;, clusters[c],&#39;Cluster&#39;, c)
        cd(&#39;Clusters/&#39;+c)
        set(&#39;ClusterMessagingMode&#39;,&#39;multicast&#39;)
        if c.startswith(&#39;app&#39;):
                set(&#39;ClusterAddress&#39;,app_ca)
        elif c.startswith(&#39;web&#39;):
                set(&#39;ClusterAddress&#39;,web_ca)
        set(&#39;MulticastAddress&#39;,&#39;237.0.0.101&#39;)
        set(&#39;MulticastPort&#39;,7200+clstrs.index(c))
        printline(&quot;cluster &quot;+c+&quot; created&quot;)

printline(&quot;Configured clusters and assigned managed servers done.&quot;)
#Write the domain and Close the domain template

updateDomain()
closeDomain()

printline(&quot;Task completed successfully, exiting!!!&quot;)
exit()

&lt;/pre&gt;
Now the properties file which you can enhance with your limitations
&lt;br /&gt;
&lt;pre class=&quot;brush:bash&quot;&gt;WLSAdminIP=192.168.33.100
AdminPort=8001
AdminPasswd=welcome1
DomainPath=/u01/app/oracle/domains
DomainName=uat_domain

&lt;/pre&gt;
&lt;br /&gt;
Lets have the execution screen for you:

&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhudeS1omobeq7NUPrHedolLCGg8UGYKavG3uEvk64C4HhnP-DdYiz5VZfUTjjzppJsC46ZIOHDgJxqxZD6gP0YhOqgmv4efHhJLYHwsgQABXqaraoA9tGpBywp-RhF0SetB5gu9IOyxIDW/s1600/cluster_domain_wlst.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;452&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhudeS1omobeq7NUPrHedolLCGg8UGYKavG3uEvk64C4HhnP-DdYiz5VZfUTjjzppJsC46ZIOHDgJxqxZD6gP0YhOqgmv4efHhJLYHwsgQABXqaraoA9tGpBywp-RhF0SetB5gu9IOyxIDW/s640/cluster_domain_wlst.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Please write your valuable feedback on this post, so that we can keep improve further to have more interesting fun stuff soon for you.
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/5199912360667412363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2017/04/weblogic-12c-cluster-domain.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/5199912360667412363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/5199912360667412363'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2017/04/weblogic-12c-cluster-domain.html' title='WebLogic 12c Cluster Domain configuration using WLST offline'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYa5WEbUn_UuXPd7tY79BE8a2ovHJYkhsZ2lnTyzyaCuTga0TZEcBWNZc9psOcRQlNlBF4E_hxTE_6dm9WhlqQlElkbEb2yV6hD79ocacD7ZKeciuknhyfdbAMmbycRFqQxNNOoEEui9g/s72-c/WLST_Clstr_domain.JPG" height="72" width="72"/><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-337818741178741675</id><published>2017-02-22T19:13:00.000-08:00</published><updated>2022-08-31T04:53:38.169-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="can&#39;t write cache file for"/><category scheme="http://www.blogger.com/atom/ns#" term="EM"/><category scheme="http://www.blogger.com/atom/ns#" term="em console on WebLogic domain"/><category scheme="http://www.blogger.com/atom/ns#" term="enterprise manager  in WebLogic Domain"/><category scheme="http://www.blogger.com/atom/ns#" term="Restricted JRF Domain"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 12.2.1"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic domain templates addition with WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST"/><title type='text'>Restricted JRF WebLogic infrastructure domain configuration using WLST</title><content type='html'>While working on Fusion Middleware products we need to prepare the WebLogic restricted JRF domain, most of the time configuration Wizard leads to confusion and stuck with what to do for RCU configurations. Even when you need to create a domain for Collocated OHS Environment. &lt;br&gt;
&lt;br&gt;&lt;b&gt;
Pr-requisites&lt;/b&gt;&lt;br&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://myofwexperiments.blogspot.in/2016/11/installing-latest-jdk-for-oracle-fusion.html&quot; target=&quot;_blank&quot;&gt;Oracle JDK&lt;/a&gt; Installed&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://myofwexperiments.blogspot.in/2016/01/oracle-fusion-middleware-infrastructure.html&quot; target=&quot;_blank&quot;&gt;Oracle Fusion Middleware Infrastructure 12.2.1&lt;/a&gt; installed&lt;/li&gt;
&lt;li&gt;Environment setup with bash profile&lt;/li&gt;
&lt;/ol&gt;
Templates used for configuring the Restricted JRF domain&lt;br&gt;
&lt;br&gt;
&lt;ol&gt;
&lt;li&gt;JRF Restricted template -&amp;nbsp;oracle.jrf_restricted_template.jar&lt;/li&gt;
&lt;li&gt;Enterprise Manager -&amp;nbsp;oracle.em_wls_restricted_template.jar&lt;/li&gt;
&lt;li&gt;Coherence - wls_coherence_template.jar [default selected with above anyone of the template]&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
  &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj76Lorr4FFfVIpeUqCRbmzhnjPe3CR1-fPzngk_2e0dRTaMG1Dd3o4dnK9984ex6Ywq84eGtMYPViVBU78Ig7EoRlnquvKVBleLU5Rf10Xd3uJp9sy22R8JpqpSVtOiv5fhsG98Q_vmb8/s1600/1661946804247019-0.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;
    &lt;img border=&quot;0&quot;   src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj76Lorr4FFfVIpeUqCRbmzhnjPe3CR1-fPzngk_2e0dRTaMG1Dd3o4dnK9984ex6Ywq84eGtMYPViVBU78Ig7EoRlnquvKVBleLU5Rf10Xd3uJp9sy22R8JpqpSVtOiv5fhsG98Q_vmb8/s1600/1661946804247019-0.png&quot; width=&quot;400&quot;&gt;
  &lt;/a&gt;
&lt;/div&gt;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;Lets first create the properties file:
&lt;br&gt;
&lt;br&gt;
&lt;pre class=&quot;brush:py&quot;&gt;TEMPLATE=/u01/app/oracle/fmw1221/wlserver/common/templates/wls/wls.jar 
MW_HOME=/u01/app/oracle/fmw1221
ADMIN_LISTEN_ADDRESS=192.168.33.100
ADMIN_PORT=8001
ADMIN_USER=weblogic
ADMIN_PWD=Welcome1
DOMAIN_NAME=RestrictedJRF_Domain
DOMAIN_DIR=/u01/app/oracle/domains
&lt;/pre&gt;
&lt;br&gt;
Note: You could modifiy the MW_HOME&amp;nbsp; path&lt;br&gt;
&lt;br&gt;
The WLST Script is &amp;nbsp;as follows:&lt;br&gt;
&lt;br&gt;
&lt;pre class=&quot;brush:py&quot;&gt;def create_prod_domain():
 print &quot;Reading base domain tempalte&quot;
 readTemplate(TEMPLATE)
 cd(&#39;/&#39;)

 print &quot;AdminServer settings&quot;
 cmo.setName(DOMAIN_NAME)
 cd(&#39;Servers/AdminServer&#39;)
 cmo.setListenAddress(ADMIN_LISTEN_ADDRESS)
 cmo.setListenPort(int(ADMIN_PORT))
 cd( &#39;/&#39; )
 cd( &#39;Security/&#39;+DOMAIN_NAME+&#39;/User/&#39; +ADMIN_USER)
 cmo.setPassword(ADMIN_PWD)
 cd(&#39;/&#39;)

 print &quot;Production domain setup..&quot;
 setOption(&quot;ServerStartMode&quot;, &quot;prod&quot;)
 setOption(&quot;OverwriteDomain&quot;, &quot;true&quot;)
 writeDomain( DOMAIN_DIR+&#39;/&#39;+DOMAIN_NAME )
 print &quot;==============================================&quot;
 print &quot;Production domain created successfully...&quot;
 print &quot;==============================================&quot;

 closeTemplate()


def apply_jrf2domain():
 # Apply the JRF Template.
 print &quot;reading domain:&quot;+DOMAIN_NAME
 readDomain(DOMAIN_DIR+&#39;/&#39;+DOMAIN_NAME )
 addTemplate(MW_HOME + &#39;/oracle_common/common/templates/wls/oracle.jrf_restricted_template.jar&#39;)
 print &quot;Adding Template :oracle.jrf_restricted_template.jar&quot;

 # I&#39;m including the EM template too.
 addTemplate(MW_HOME + &#39;/em/common/templates/wls/oracle.em_wls_restricted_template.jar&#39;)
 print &quot;Added Template :oracle.em_wls_restricted_template.jar&quot;

 updateDomain()
 print &quot;Updated the domain with Restricted JRF and Enterprise Manager templates&quot;
 closeDomain()
 print &quot;Close the domain&quot;
 exit()

def main():
 print &quot;==============================================&quot;
 print &quot;Welcome to Restricted JRF domain configuration&quot;
 print &quot;==============================================&quot;

 create_prod_domain()
 print &quot;Domain created successfully...&quot;
 apply_jrf2domain()

main()&lt;/pre&gt;
&lt;br&gt;
The script execution will be as follows:
&lt;br&gt;
&lt;pre class=&quot;brush:py&quot;&gt;wlst -loadProperties RestrictedJRF_domain.properties create_RestrictedJRF_domain.py
&lt;/pre&gt;
&lt;br&gt;
Note: wlst must be aliased to the Infrastructure installation wlserver path
&lt;br&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3XlU6vUjgK9Vg6J0nzzR3QYyBqdTcu54d6luM-2PNfN2eXgGwut6IbWM0kx5lYAtcg0SmPv4_f2zWKCo3wLeR4P-BjpPtlXxOyegkGnCrXNxh2XjhCjmg4YGMjcPlt4OrX5Ahw_PQ0a4/s1600/RestrictedJRF_EM.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;248&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3XlU6vUjgK9Vg6J0nzzR3QYyBqdTcu54d6luM-2PNfN2eXgGwut6IbWM0kx5lYAtcg0SmPv4_f2zWKCo3wLeR4P-BjpPtlXxOyegkGnCrXNxh2XjhCjmg4YGMjcPlt4OrX5Ahw_PQ0a4/s640/RestrictedJRF_EM.JPG&quot; width=&quot;640&quot;&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Restricted JRF WebLogic infrastructure domain with EM template&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&amp;nbsp;Advantage of this domain:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;Enterprise Manager Fusion Middleware Control&lt;/li&gt;
&lt;li&gt;Easy to work on FW products such as SOA, OSB, and &lt;a href=&quot;http://myofwexperiments.blogspot.in/2015/12/oracle-http-server-1221-installation.html&quot; target=&quot;_blank&quot;&gt;Collocated OHS &lt;/a&gt;etc&lt;/li&gt;
&lt;/ul&gt;
Note that it will be consuming more memory foot print than regular base domain.&lt;br&gt;
&lt;br&gt;
Start your Restricted JRF Domain and when you look into WebLogic Admin console deployments see the following:

&lt;br&gt;
&lt;br&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggbuETuf1-tlVLdyI4hyzU5_EBqpOW8NXBXRrk_wc40VQhCJMggwQYXmUaProlXtMn_6Z0BnvB4ReWJrwLZrdU2AGVh31pKjlzlHjOgXq49J1rnkQSSjJ4-sOMBIswKSyoTTd7n6RQgoo/s1600/jrf_domain.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;331&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggbuETuf1-tlVLdyI4hyzU5_EBqpOW8NXBXRrk_wc40VQhCJMggwQYXmUaProlXtMn_6Z0BnvB4ReWJrwLZrdU2AGVh31pKjlzlHjOgXq49J1rnkQSSjJ4-sOMBIswKSyoTTd7n6RQgoo/s640/jrf_domain.JPG&quot; width=&quot;640&quot;&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;WebLogic Restricted Domain deployment&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/337818741178741675/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2017/02/restricted-jrf-weblogic-infrastructure.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/337818741178741675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/337818741178741675'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2017/02/restricted-jrf-weblogic-infrastructure.html' title='Restricted JRF WebLogic infrastructure domain configuration using WLST'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj76Lorr4FFfVIpeUqCRbmzhnjPe3CR1-fPzngk_2e0dRTaMG1Dd3o4dnK9984ex6Ywq84eGtMYPViVBU78Ig7EoRlnquvKVBleLU5Rf10Xd3uJp9sy22R8JpqpSVtOiv5fhsG98Q_vmb8/s72-c/1661946804247019-0.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-1828796608458185720</id><published>2016-06-18T22:47:00.000-07:00</published><updated>2016-06-22T23:22:56.188-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Deployment"/><category scheme="http://www.blogger.com/atom/ns#" term="Multitenancy"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 12.2.1"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic MT"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST deployment on Multitenant Environment"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST undeploy partition"/><title type='text'>Multitenancy in WebLogic 12c Part -7 Deploy and Undeploy Application to a Domain Partition</title><content type='html'>After almost four months took me to write this, due to busy in work this blog post on WebLogic 12.2.1 MT feature exploration took some time. To workout multiple deployment scenarios on MT environment we need real-time implementation environments. As of now I&#39;ve limiting my scope to web application deployment on to a partition. You could do much more wider automation using WLST based on this script.
&lt;br /&gt;
&lt;h3&gt;
Pre-requisites set-up for Multitenancy:&lt;/h3&gt;
You can also visit the following post so that you can have connectivity what we are discussing here.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ol style=&quot;background-color: white; color: #666666; font-family: &#39;Trebuchet MS&#39;, Trebuchet, Verdana, sans-serif; font-size: 13.2px; line-height: 18.48px;&quot;&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/security-realm-for-multitenants-in.html&quot; style=&quot;color: #888888; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Configure Security Realm&lt;/a&gt;&amp;nbsp;for MT&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-2.html&quot; style=&quot;color: #888888; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Create Users &amp;amp; Groups for Partition domain&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-3.html&quot; style=&quot;color: #888888; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Configure Virtual Target&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-4.html&quot; style=&quot;color: #888888; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Creating Partition Domain&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-5.html&quot; target=&quot;_blank&quot;&gt;Configure IDD for Partition&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-6.html&quot; target=&quot;_blank&quot;&gt;Partition Control (start/stop using WLST)&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Deploy and Undeploy Application on Partition [This post]&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;h3&gt;
 Download sample application&lt;/h3&gt;
You can download sample web application for WebLogic environment :&lt;br /&gt;
Here I am using benefits.war which available in Oracle examples.&lt;br /&gt;
Download &lt;a href=&quot;http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/wls/10g/r3/cluster/session_state/session_state.htm&quot;&gt;Shopping Cart Sample Link&lt;/a&gt;
&lt;/div&gt;
&lt;br /&gt;
Deploying an application to a WebLogic server fine it was upto 11g and regular WebLogic environment. In WebLogic 12.2.1 MT introduced with the great feature that is maintaining small domain partitions where you can feel the required resources all that need to run the application you will get in the partition. This MT deployment might more frequent when your application moved to WebLogic 12.2.1.&lt;br /&gt;
&lt;br /&gt;
The deploy() and undeploy() command variation with the number of arguments you pass that are related to partition or resource group template. Here I&#39;ve used first option targeting to a RUNNING State partition. As Oracle recommends to use ResourceGroupTemplate as target in the MT environment.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikDhqLdEhoRu9yna2jYdSBdJJAwvpfW3MEQdCM7_F9lKGDxS8DY87oWZp_shP3rpDgdSco7jjuMZR9YdqO3Qm9IK75QShc8McGsZYAnJk-Pksl6EgHY4ay3tRbxua4Vo5jM8qfOZoMd8c/s1600/deploypart4.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;undeploy with WLST on Partition Domain&quot; border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikDhqLdEhoRu9yna2jYdSBdJJAwvpfW3MEQdCM7_F9lKGDxS8DY87oWZp_shP3rpDgdSco7jjuMZR9YdqO3Qm9IK75QShc8McGsZYAnJk-Pksl6EgHY4ay3tRbxua4Vo5jM8qfOZoMd8c/s640/deploypart4.JPG&quot; title=&quot;deploy using WLST on Multi-Tenant Domain&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;WebLogic web application deployment with WLST to a partition&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
The best benefit you can provide it to the partition deployment do one time deployment same partition you can package using export you will get final outcome as zip file. That you can reuse in other test environments as well.using import.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;def deploy2partition(a,ap, p,rg,o):
        progress=deploy(appName=a, path=ap, partition=p, resourceGroup=rg, deploymentOrder=o, securityModel=&#39;DDOnly&#39;)
        while not (progress.isCompleted() or progress.isFailed()) :
                os.time.sleep(2)
        print progress.getState()

def undeploy4mPartition(a, p):
        progress=undeploy(appName=a,  partition=p)
        while not (progress.isCompleted() or progress.isFailed()) :
                java.lang.Thread.sleep(2000)
        print progress.getState()

def main():
        # The following are the properties which can be changed according to your needs.
        APP_PATH=&#39;/u01/app/software/benefits.war&#39;
        APPNAME=&#39;BENEFITS&#39;
        USER=&#39;weblogic&#39;
        PASSWD=&#39;welcome1&#39;
        ADMURL=&#39;t3://192.168.33.100:6100&#39;

        connect(USER, PASSWD, ADMURL)
        partitionName=&quot;Corporate_partition&quot;
        rgName=&quot;Corporate_rg&quot;
        DOrder=10

        if len(sys.argv) &amp;gt;1:
                choice  = sys.argv[1]
        else:
                usage()

        if choice == &#39;deploy&#39;:
                deploy2partition(APPNAME, APP_PATH, partitionName, rgName, DOrder)
        elif choice == &#39;undeploy&#39;:
                undeploy4mPartition(APPNAME, partitionName)

        disconnect()
        print &quot;Deployment process on partition completed successful !!!&quot;

def usage():
        print &quot;&quot;&quot;Usage:
        wlst &quot;&quot;&quot;+sys.argv[0] +&quot;&quot;&quot; deploy | undeploy&quot;&quot;&quot;
        exit()

main()
&lt;/pre&gt;
&lt;br /&gt;
The deploy option:
&lt;br /&gt;
&lt;pre class=&quot;brush:bash&quot;&gt; wlst partitionDeploy1.py deploy
&lt;/pre&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiok1g08SswTT1UQ-pS1j0kUVQ7Hg-RPb2RaMCpTHUh2cAuAaeS2TzmHBqyKpCAyr88HtyZbD1vV1xf-houhOQJV-NkHiI3s4EIE9pltZimAruF37ImJb1Gn7bmj9Sd7TUZP78sVRuLJjE/s1600/partitionDeploy.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;329&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiok1g08SswTT1UQ-pS1j0kUVQ7Hg-RPb2RaMCpTHUh2cAuAaeS2TzmHBqyKpCAyr88HtyZbD1vV1xf-houhOQJV-NkHiI3s4EIE9pltZimAruF37ImJb1Gn7bmj9Sd7TUZP78sVRuLJjE/s640/partitionDeploy.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;WLST deploy on Partition Domain&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
Administration Console deployment update:



&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzqS3A9VoNXMTOs3o95hlurBKzU53DPaQ_fZp4_tIoUz02QuolcsDD_vrsDdA8Hsky2sBdwfkad6r0iYPYH6kV3-6qPAjLz0OIu79Sekg9tIGADPTnrBFUfX4GG-ya_zXY0DYQwtO9YQc/s1600/deploypart3.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;233&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzqS3A9VoNXMTOs3o95hlurBKzU53DPaQ_fZp4_tIoUz02QuolcsDD_vrsDdA8Hsky2sBdwfkad6r0iYPYH6kV3-6qPAjLz0OIu79Sekg9tIGADPTnrBFUfX4GG-ya_zXY0DYQwtO9YQc/s640/deploypart3.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
The undeploy option:
&lt;br /&gt;
&lt;pre class=&quot;brush:bash&quot;&gt; wlst partitionDeploy1.py undeploy
&lt;/pre&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbnGBnCKzzM5SDYCxJIOp5EWCkfIqc22Fus2HaldeZn8xvwAyTsXyNB5XMvG1fnuMgBN0yGHj53QQcwpZ3aFkSk7Adfam4eJcbfp36QfUMzLqzp4FNHCfp-4X1l1dMc3VYtBvcNq5udkE/s1600/undeploy2.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;323&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbnGBnCKzzM5SDYCxJIOp5EWCkfIqc22Fus2HaldeZn8xvwAyTsXyNB5XMvG1fnuMgBN0yGHj53QQcwpZ3aFkSk7Adfam4eJcbfp36QfUMzLqzp4FNHCfp-4X1l1dMc3VYtBvcNq5udkE/s640/undeploy2.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;WLST Undeploy on Partion&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/1828796608458185720/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2016/06/multitenancy-in-weblogic-12c-part-7.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/1828796608458185720'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/1828796608458185720'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2016/06/multitenancy-in-weblogic-12c-part-7.html' title='Multitenancy in WebLogic 12c Part -7 Deploy and Undeploy Application to a Domain Partition'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikDhqLdEhoRu9yna2jYdSBdJJAwvpfW3MEQdCM7_F9lKGDxS8DY87oWZp_shP3rpDgdSco7jjuMZR9YdqO3Qm9IK75QShc8McGsZYAnJk-Pksl6EgHY4ay3tRbxua4Vo5jM8qfOZoMd8c/s72-c/deploypart4.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-3763972891746129530</id><published>2016-01-25T23:59:00.001-08:00</published><updated>2022-08-31T04:35:47.686-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="forceShutdownPartitionWait in WebLogic"/><category scheme="http://www.blogger.com/atom/ns#" term="startParition in WebLogic"/><category scheme="http://www.blogger.com/atom/ns#" term="startPartitionWait"/><category scheme="http://www.blogger.com/atom/ns#" term="stop Partition using WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST"/><title type='text'>Multitenancy in WebLogic 12c Part -6 Partition Domain Control</title><content type='html'>Controlling means starting the partition and shutdown the partition that we have created in the earlier post. Here my exploration on the two important WLST functions:&lt;br&gt;
&lt;br&gt;
&lt;ol&gt;
&lt;li&gt;startPartitionWait&lt;/li&gt;
&lt;li&gt;forceShutdownPartitionWait&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
  &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6vKH-MbD7_fiKIUaurOOUABvIf1E0RHG1rLRnfs9MlKbnF0x2znHJs1V2KBFg1GSnhePgu_ELDWgYO8PMhyaiApiEW6YhHE7-ut3yiSOjGLORwy3kJfHCu1ydpyOZ8rOBCMuWKvra0oM/s1600/1661945739698040-0.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;
    &lt;img border=&quot;0&quot;   src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6vKH-MbD7_fiKIUaurOOUABvIf1E0RHG1rLRnfs9MlKbnF0x2znHJs1V2KBFg1GSnhePgu_ELDWgYO8PMhyaiApiEW6YhHE7-ut3yiSOjGLORwy3kJfHCu1ydpyOZ8rOBCMuWKvra0oM/s1600/1661945739698040-0.png&quot; width=&quot;400&quot;&gt;
  &lt;/a&gt;
&lt;/div&gt;&lt;br&gt;
&lt;div&gt;
Starts the given partition and waits until the partition reaches the requested state that is RUNNING state. To run this command the partition must already exist. Therefore startPartitionWait should not be used in the edit session.&lt;/div&gt;
&lt;div&gt;
&lt;br&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
The forceShutdownPartitionWait command will Shutdown the given partition and waits until the partition state reaches the SHUTDOWN state. Same rule works for this command as well, the partition must be exists to control it.&lt;br&gt;
&lt;br&gt;
Prerequisites:&lt;br&gt;
&lt;br&gt;
&lt;ol style=&quot;background-color: white; color: #666666; font-family: &#39;trebuchet ms&#39;, trebuchet, verdana, sans-serif; font-size: 13.2px; line-height: 18.48px;&quot;&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/security-realm-for-multitenants-in.html&quot; style=&quot;color: #888888; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Configure Security Realm&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-2.html&quot; style=&quot;color: #888888; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Create Users &amp;amp; Groups for Partition domain&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-3.html&quot; style=&quot;color: #888888; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Configure Virtual Target&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-4.html&quot; target=&quot;_blank&quot;&gt;Creating Partition Domain&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-5.html&quot; target=&quot;_blank&quot;&gt;Configure IDD for Partition&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-6.html&quot; target=&quot;_blank&quot;&gt;Partition Control (start/stop using WLST)&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br&gt;
Here I&#39;ve prepared the customized script for stop, start and restart all the partitions in the domain.

&lt;br&gt;
&lt;pre class=&quot;brush:bash&quot;&gt;# This script will start the partition

def startPartition(partitionName):
        print &quot;Staring the partition :&quot;+ partitionName
        partitionBean=cmo.lookupPartition(partitionName)
        startPartitionWait(partitionBean)

def startAllPartitions():
        print &quot;Starting all partitions ...&quot;
        startPartition(&#39;Corporate_partition&#39;)
        startPartition(&#39;Online_partition&#39;)

def stopPartition(partitionName):
        print &quot;Stoping the partition :&quot;+ partitionName
        partitionBean=cmo.lookupPartition(partitionName)
        forceShutdownPartitionWait(partitionBean)

def stopAllPartitions():
        print &quot;Starting all partitions ...&quot;
        stopPartition(&#39;Corporate_partition&#39;)
        stopPartition(&#39;Online_partition&#39;)


def main():
        connect(&quot;weblogic&quot;,&quot;welcome1&quot;,&quot;t3://192.168.33.100:6100&quot;)

        print &quot;Partition Control Menu...&quot;
        print &quot;===========================&quot;
        print &quot;1. Start all partitions&quot;
        print &quot;2. Shutdown all partitions&quot;
        print &quot;3. Restart all partitions&quot;
        control=input(&quot;Enter your control choice: &quot;)

        if control==1:
                startAllPartitions()
        elif control==2:
                stopAllPartitions()
        elif control==3:
                stopAllPartitions()
                startAllPartitions()
        else:
                print &quot;invalid option...&quot;
        disconnect()


main()

&lt;/pre&gt;
The execution goes as shown below...


&lt;/div&gt;
&lt;div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifAa_6C-H-QwPfyFOe6F4_fLtB-7gKbaqEf_4010CW1VcudhlB0n3IRPuL_Xy6dLx5cYN6TDX91K71Gtq6iXnSE9wwSCgENvZimSjnmbdm0QLQMMBlfLbthmnuJh1Es4Etn__KNWREu4E/s1600/start_Partition_command.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;198&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifAa_6C-H-QwPfyFOe6F4_fLtB-7gKbaqEf_4010CW1VcudhlB0n3IRPuL_Xy6dLx5cYN6TDX91K71Gtq6iXnSE9wwSCgENvZimSjnmbdm0QLQMMBlfLbthmnuJh1Es4Etn__KNWREu4E/s400/start_Partition_command.JPG&quot; width=&quot;400&quot;&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Starting Partition using WLST&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAuV-6DOMAdHAGzs5LrToJn4_3w65JoSN7coLy98gWnOauq4wmhcXlcA322Xf-sqdnQfkbDNBiJaSLgO62FOIdtmSEU_YMO2HL1JZ9kGFgDjjKkv1ohIjI1MMhCWiW6NnXf8jFtu2dPWw/s1600/start_Partition.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;121&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAuV-6DOMAdHAGzs5LrToJn4_3w65JoSN7coLy98gWnOauq4wmhcXlcA322Xf-sqdnQfkbDNBiJaSLgO62FOIdtmSEU_YMO2HL1JZ9kGFgDjjKkv1ohIjI1MMhCWiW6NnXf8jFtu2dPWw/s640/start_Partition.JPG&quot; width=&quot;640&quot;&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Partition state RUNNING&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
Stop the Partition with menu option 2&lt;br&gt;
&lt;br&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxRH-fGKTKiJmBaBiG_iLt4XX7wyHJ1UedpKqb8t3GYjxJUbERfsqNAUz5E2u72ByF6ip8R_MRmlCsciXT4eFmKg1YfZddBzN3e3D3kXnlySEaxtGwLXyeQrMgO7OKrnnDHTg9869kDPw/s1600/stop_partition_command.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;131&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxRH-fGKTKiJmBaBiG_iLt4XX7wyHJ1UedpKqb8t3GYjxJUbERfsqNAUz5E2u72ByF6ip8R_MRmlCsciXT4eFmKg1YfZddBzN3e3D3kXnlySEaxtGwLXyeQrMgO7OKrnnDHTg9869kDPw/s400/stop_partition_command.JPG&quot; width=&quot;400&quot;&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Stop Partition using WLST&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
Double check the same on the WebLogic Admin console:&lt;br&gt;
&lt;br&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRw5fEMjNLFE95py_BE2KZNwmyUXLBHeVsGufL_PoR1nzD0FFnNrVfcFTGWS6zAYILO2KtKDIAEF1bdgDyXWIuMOsFxNUxzKx23FM43uYXxJQvgq_lRX0PYRcJBK6YzX566Wpo2HO5L-E/s1600/stop_partition.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;192&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRw5fEMjNLFE95py_BE2KZNwmyUXLBHeVsGufL_PoR1nzD0FFnNrVfcFTGWS6zAYILO2KtKDIAEF1bdgDyXWIuMOsFxNUxzKx23FM43uYXxJQvgq_lRX0PYRcJBK6YzX566Wpo2HO5L-E/s400/stop_partition.JPG&quot; width=&quot;400&quot;&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Shutdown Partitions on WebLogic Admin Console&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/3763972891746129530/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2016/01/multitenancy-in-weblogic-12c-part-6.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/3763972891746129530'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/3763972891746129530'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2016/01/multitenancy-in-weblogic-12c-part-6.html' title='Multitenancy in WebLogic 12c Part -6 Partition Domain Control'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6vKH-MbD7_fiKIUaurOOUABvIf1E0RHG1rLRnfs9MlKbnF0x2znHJs1V2KBFg1GSnhePgu_ELDWgYO8PMhyaiApiEW6YhHE7-ut3yiSOjGLORwy3kJfHCu1ydpyOZ8rOBCMuWKvra0oM/s72-c/1661945739698040-0.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-8133194901920813933</id><published>2016-01-25T20:28:00.000-08:00</published><updated>2016-01-27T01:06:16.562-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="IDD in WebLogic domain Partition"/><category scheme="http://www.blogger.com/atom/ns#" term="Resource Groups in Multitenancy Domain"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 12.2.1"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic Partition Domain example"/><title type='text'>Multitenancy in WebLogic 12c Part -5: Identity Domain (IDD) for Partition</title><content type='html'>&lt;span style=&quot;background-color: white; color: #666666; font-family: &amp;quot;trebuchet ms&amp;quot; , &amp;quot;trebuchet&amp;quot; , &amp;quot;verdana&amp;quot; , sans-serif; font-size: 13.2px; line-height: 18.48px;&quot;&gt;Welcome back to the series of Multitenancy experiments on partitioned domain.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #666666; font-family: &amp;quot;trebuchet ms&amp;quot; , &amp;quot;trebuchet&amp;quot; , &amp;quot;verdana&amp;quot; , sans-serif; font-size: 13.2px; line-height: 18.48px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1dZa3jfF3OZV6kSKvy78YsDGE_zDQdCbcZrrOyrjYdvyxMspZv6k6ekJFfBcliPYJF0yjTac3uM3W-PaWhIS2W33gj2LGwqw_ZN_J3tZuqNSGDuk3cfCVHgHITO5ArvLxubsISuuxTYU/s1600/Multi_Partition_domain.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;427&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1dZa3jfF3OZV6kSKvy78YsDGE_zDQdCbcZrrOyrjYdvyxMspZv6k6ekJFfBcliPYJF0yjTac3uM3W-PaWhIS2W33gj2LGwqw_ZN_J3tZuqNSGDuk3cfCVHgHITO5ArvLxubsISuuxTYU/s640/Multi_Partition_domain.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Resource groups in WebLogic Multitenancy Domain partition&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;span style=&quot;color: #666666; font-family: trebuchet ms, trebuchet, verdana, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: white; font-size: 13.2px; line-height: 18.48px;&quot;&gt;Prerequsites&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ol style=&quot;background-color: white; color: #666666; font-family: &#39;Trebuchet MS&#39;, Trebuchet, Verdana, sans-serif; font-size: 13.2px; line-height: 18.48px;&quot;&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/security-realm-for-multitenants-in.html&quot; style=&quot;color: #888888; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Configure Security Realm&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-2.html&quot; style=&quot;color: #888888; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Create Users &amp;amp; Groups for Partition domain&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-3.html&quot; style=&quot;color: #888888; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Configure Virtual Target&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-4.html&quot; target=&quot;_blank&quot;&gt;Creating Partition Domain&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Configure IDD for Partition&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-6.html&quot; target=&quot;_blank&quot;&gt;Partition Control (start/stop using WLST)&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:bash&quot;&gt;def add_IDD4_Partition(realmName, partitionName, primary_IDD ): 
 &quot;&quot;&quot;
 This function is developed for generic  use to adding Identity domain 
 to a partition domain.
 &quot;&quot;&quot;
 sec = cmo.getSecurityConfiguration()
 sec.setAdministrativeIdentityDomain(&quot;AdminIDD&quot;)
 
 realm = cmo.getSecurityConfiguration().lookupRealm(realmName)
 
 # Authentication 
 defAtnP = realm.lookupAuthenticationProvider(&#39;ATNPartition&#39;)
 defAtnP.setIdentityDomain(primary_IDD)
 defAtnA = realm.lookupAuthenticationProvider(&#39;ATNAdmin&#39;)
 defAtnA.setIdentityDomain(&quot;AdminIDD&quot;)
 
 # Search for the Partition and set it as primary IDD
 p= cmo.lookupPartition(partitionName)
 p.setPrimaryIdentityDomain(primary_IDD)
 
 # For Default realm setting the IDD
 realm = sec.getDefaultRealm()
 defAtn = realm.lookupAuthenticationProvider(&#39;DefaultAuthenticator&#39;)
 defAtn.setIdentityDomain(&quot;AdminIDD&quot;)
 
 
def main():
 connect(&quot;weblogic&quot;,&quot;welcome1&quot;,&quot;t3://192.168.33.100:6100&quot;)
 edit()
 startEdit()
 
 add_IDD4_Partition(&#39;Corporate_Realm&#39;, &quot;Corporate_partition&quot;, &quot;Corporate_IDD&quot; )
 add_IDD4_Partition(&#39;Online_Realm&#39;, &quot;Online_partition&quot;, &quot;Online_IDD&quot; )
 
 save()
 activate()
 disconnect()
 
main()

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Lets run the script that will add the Identity Domain for each partition.
&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhIJDSuNbmHEFz6ioxxQC1kOFfrTFf3aV5hlrQuBXzNJH5mORcHh427LtoTv7IKTR4YxNFj9WdhUhThQiAh1kvijMmPkH2Ytdl-XFm8Mi2idIqE9MuvGvHWPeDBZF6ZPSHePrL3opz-U0/s1600/SecRealm1.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;WebLogic Multitenancy Partition domain with Security Realm&quot; border=&quot;0&quot; height=&quot;372&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhIJDSuNbmHEFz6ioxxQC1kOFfrTFf3aV5hlrQuBXzNJH5mORcHh427LtoTv7IKTR4YxNFj9WdhUhThQiAh1kvijMmPkH2Ytdl-XFm8Mi2idIqE9MuvGvHWPeDBZF6ZPSHePrL3opz-U0/s640/SecRealm1.JPG&quot; title=&quot;Corporate Realm in the Multitenancy Partition&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Select the Corporate Realm in the Security&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
Now select one of the security realm which you have created for the partition.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilAQ_LMg4DTXDSubowrNilh0Ff4uIWb-_RODNpA062BuK-GfZqlLvTAIKefJj_CjZQvUbWp4Lw_whcPSMvYknQ6AodGHpItQLVYtw1v4Bk4IrfjhsZ14_h0-UsQtZmbg7HBihEKQre48M/s1600/IDD_Partition.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;556&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilAQ_LMg4DTXDSubowrNilh0Ff4uIWb-_RODNpA062BuK-GfZqlLvTAIKefJj_CjZQvUbWp4Lw_whcPSMvYknQ6AodGHpItQLVYtw1v4Bk4IrfjhsZ14_h0-UsQtZmbg7HBihEKQre48M/s640/IDD_Partition.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/8133194901920813933/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2016/01/multitenancy-in-weblogic-12c-part-5.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/8133194901920813933'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/8133194901920813933'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2016/01/multitenancy-in-weblogic-12c-part-5.html' title='Multitenancy in WebLogic 12c Part -5: Identity Domain (IDD) for Partition'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1dZa3jfF3OZV6kSKvy78YsDGE_zDQdCbcZrrOyrjYdvyxMspZv6k6ekJFfBcliPYJF0yjTac3uM3W-PaWhIS2W33gj2LGwqw_ZN_J3tZuqNSGDuk3cfCVHgHITO5ArvLxubsISuuxTYU/s72-c/Multi_Partition_domain.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-2514582600650504870</id><published>2016-01-17T07:41:00.003-08:00</published><updated>2016-01-17T07:44:40.295-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Partition Domain with WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 12.2.1"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 12.2.1 feature"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 12c Multitenancy environment"/><title type='text'>Multitenancy in WebLogic 12c Part -4: Creating Partiton domain</title><content type='html'>Welcome back to the series of Multitenancy experiments on partitioned domain.&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;background-color: white; color: #666666; font-family: &#39;Trebuchet MS&#39;, Trebuchet, Verdana, sans-serif; font-size: 13.2px; line-height: 18.48px;&quot;&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/security-realm-for-multitenants-in.html&quot; style=&quot;color: #888888; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Configure Security Realm&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-2.html&quot; style=&quot;color: #888888; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Create Users &amp;amp; Groups for Partition domain&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-3.html&quot; target=&quot;_blank&quot;&gt;Configure Virtual Target&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Creating Partition Domain&lt;/li&gt;
&lt;/ol&gt;
WebLogic domain partitions are an administrative and runtime slice of a WebLogic domain that is dedicated to running application instances and related resources for different tenant.
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;def create_Partition(vtName, partitionName, rgName, realmName):
        &quot;&quot;&quot;
        This function programmed for creating partition in WebLogic domain
        it takes four arguments virtual target, Partition Name, Resource Group
        and Security Realm Name.

        &quot;&quot;&quot;
        vt = cmo.lookupVirtualTarget(vtName)
        p = cmo.createPartition(partitionName)
        p.addAvailableTarget(vt)
        p.addDefaultTarget(vt)
        rg=p.createResourceGroup(rgName)
        rg.addTarget(vt)
        realm = cmo.getSecurityConfiguration().lookupRealm(realmName)
        p.setRealm(realm)

def main():
        connect(&quot;weblogic&quot;,&quot;welcome1&quot;,&quot;t3://192.168.33.100:6100&quot;)
        edit()
        startEdit()
        create_Partition(&quot;Online_vt&quot;,&quot;Online_partition&quot;,&quot;Online_rg&quot;,&#39;Online_Realm&#39;)
        create_Partition(&quot;Corporate_vt&quot;,&quot;Corporate_partition&quot;,&quot;Corporate_rg&quot;,&#39;Corporate_Realm&#39;)
        save()
        activate()
        disconnect()

main()
&lt;/pre&gt;
&lt;br /&gt;
creating partition requires partition name, there should be resource group which can be created with default or you can have your own template for resource group. The resources could be JMS, JDBC Data source, JCA, JTA


&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn26ys6fSkuB5qBK8BTZ4dIgSgkGrPOmrEaS0Yci1MSt_t89xWZFKOjfhmtOnmQVQArkjGfVw4Z8kscyRNv3olJ-sdX0ch0KPVGSGb1Vj8AnCoVepeyf6pU5-KIKXoQKBkKMCK8U2NE2M/s1600/partition.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;438&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn26ys6fSkuB5qBK8BTZ4dIgSgkGrPOmrEaS0Yci1MSt_t89xWZFKOjfhmtOnmQVQArkjGfVw4Z8kscyRNv3olJ-sdX0ch0KPVGSGb1Vj8AnCoVepeyf6pU5-KIKXoQKBkKMCK8U2NE2M/s640/partition.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;WLST Script for create partition on WebLogic domain&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
admin console output&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVx16U2FdfqqCwGAnCq_yR22agjSJiIaLa7QJvpH6Zm9IbABuDpglJ3Pb532bUnjSU27oiTea7iDDPmnPRi-BOe4dNfe46K6LOfFNQJ75G1z2ia6Woj52S6N7Z-zXW8qAIHHFvqsYDptc/s1600/Partition_wl_console.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;166&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVx16U2FdfqqCwGAnCq_yR22agjSJiIaLa7QJvpH6Zm9IbABuDpglJ3Pb532bUnjSU27oiTea7iDDPmnPRi-BOe4dNfe46K6LOfFNQJ75G1z2ia6Woj52S6N7Z-zXW8qAIHHFvqsYDptc/s640/Partition_wl_console.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Partition successful execution of WLST&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;b&gt;&lt;span style=&quot;background-color: yellow; font-size: large;&quot;&gt;Note: After you configure the new partitions in the domain you must restart the environment.&lt;/span&gt;&lt;/b&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/2514582600650504870/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2016/01/multitenancy-in-weblogic-12c-part-4.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/2514582600650504870'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/2514582600650504870'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2016/01/multitenancy-in-weblogic-12c-part-4.html' title='Multitenancy in WebLogic 12c Part -4: Creating Partiton domain'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn26ys6fSkuB5qBK8BTZ4dIgSgkGrPOmrEaS0Yci1MSt_t89xWZFKOjfhmtOnmQVQArkjGfVw4Z8kscyRNv3olJ-sdX0ch0KPVGSGb1Vj8AnCoVepeyf6pU5-KIKXoQKBkKMCK8U2NE2M/s72-c/partition.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-5597336181008823738</id><published>2016-01-17T05:40:00.001-08:00</published><updated>2016-01-17T05:40:17.423-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Configure Virtual Target on Partition Domain"/><category scheme="http://www.blogger.com/atom/ns#" term="VirtualTarget"/><category scheme="http://www.blogger.com/atom/ns#" term="VirtualTarget using WLT"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogicc 12.2.1"/><title type='text'>Multitenancy in WebLogic 12c Part -3: Create Virtual target for the Partition Domain</title><content type='html'>Create Virtual target for the Partition Domain&lt;br /&gt;
&lt;br /&gt;
Welcome back to the series of Multitenancy experiments with WLST.
&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/security-realm-for-multitenants-in.html&quot; target=&quot;_blank&quot;&gt;Configure Security Realm&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-2.html&quot; target=&quot;_blank&quot;&gt;Create Users &amp;amp; Groups for Partition domain&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Configure Virtual Target&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
In this sample virtual target is targeted to the admin server, you can also target to cluster. The uri prefix is /corporate This is the url prefix used for making JMX connections to &amp;nbsp;MBeanServer.&lt;br /&gt;
&lt;br /&gt;
In this example you could find the re-usability of the functions easy to call them!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;py&quot; name=&quot;code&quot;&gt;def create_VirtualTarget(vt_name, uriPrefix, serverName):
        &quot;&quot;&quot;
        This method is developed for create Virtual Targets
        based on three arguments Virtual Target Name, URI prefix and actual physical target
        &quot;&quot;&quot;
        vt = cmo.createVirtualTarget(vt_name)
        vt.setHostNames(array([&quot;192.168.33.100&quot;],java.lang.String))
        vt.setUriPrefix(uriPrefix)
        as = cmo.lookupServer(serverName)
        vt.addTarget(as)

def main():
        connect(&quot;weblogic&quot;,&quot;welcome1&quot;,&quot;t3://192.168.33.100:6100&quot;)
        edit()
        startEdit()
        create_VirtualTarget(&quot;Corporate_vt&quot;, &quot;/corporate&quot;,&quot;tr_admin&quot;)
        create_VirtualTarget(&quot;Online_vt&quot;, &quot;/online&quot;,&quot;tr_admin&quot;)
        save()
        activate()
        disconnect()

main()
&lt;/pre&gt;
&lt;br /&gt;
Execute it with the following way!
&lt;br /&gt;
&lt;pre&gt; wlst createVirtualTargets.py
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxtfI4OYYcwWjCzakhui5TE6FR-m7WeMGwbMmejtAsi_AZ7iIw_uWCazBXZMpfSExOI-xxxsSO4k_NYzMlW3QYXeWV95Ui6eSy3NwP6dOjgj8NOyfjob9ZfM09gPNe2HeD0SOlp2TuzfU/s1600/createVT.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxtfI4OYYcwWjCzakhui5TE6FR-m7WeMGwbMmejtAsi_AZ7iIw_uWCazBXZMpfSExOI-xxxsSO4k_NYzMlW3QYXeWV95Ui6eSy3NwP6dOjgj8NOyfjob9ZfM09gPNe2HeD0SOlp2TuzfU/s640/createVT.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Execution of WLST Script for create Virtual Targets for partition domain&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
On the WebLogic Admin Console you could select the domain structure expand &quot;Environment&quot; branch. You can select Virtual Target on the tree.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqr02efnhb7h4cQK0J3Ao6CC9cXEqAOAh2dBzuDxL7pedLt-1p65XnAYotgnJAyAK21vO3fX_TI1Sf7LhvLQ9WVaOLl4RaqyGbTFg6tsq9VB951e8hsBLjdd6b42_CvIXWefo9xERdtPo/s1600/SelectVT.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqr02efnhb7h4cQK0J3Ao6CC9cXEqAOAh2dBzuDxL7pedLt-1p65XnAYotgnJAyAK21vO3fX_TI1Sf7LhvLQ9WVaOLl4RaqyGbTFg6tsq9VB951e8hsBLjdd6b42_CvIXWefo9xERdtPo/s1600/SelectVT.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;domain Structure with Virtual Target&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
On the work area you could see following screen :&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWMGmY-8jrfl1CbHrCPLGnjYCn1gy42DWas_58c1uqJYK0OCB6Z712J6wxkIcO63ID45pRJDkmKlwfEQOwGxsHa49VTaA94KHFUzr4uPfcdpzmXktD_-MIN-ocgwagEQTQCUQ0kD3iN-I/s1600/VT_Partition.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;WebLogic 12.2.1 Virtual Target configuration WLST&quot; border=&quot;0&quot; height=&quot;214&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWMGmY-8jrfl1CbHrCPLGnjYCn1gy42DWas_58c1uqJYK0OCB6Z712J6wxkIcO63ID45pRJDkmKlwfEQOwGxsHa49VTaA94KHFUzr4uPfcdpzmXktD_-MIN-ocgwagEQTQCUQ0kD3iN-I/s640/VT_Partition.JPG&quot; title=&quot;Virtual Target configuration with WLST&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Virtual Target configuration using WLST&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/5597336181008823738/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2016/01/multitenancy-in-weblogic-12c-part-3.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/5597336181008823738'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/5597336181008823738'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2016/01/multitenancy-in-weblogic-12c-part-3.html' title='Multitenancy in WebLogic 12c Part -3: Create Virtual target for the Partition Domain'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxtfI4OYYcwWjCzakhui5TE6FR-m7WeMGwbMmejtAsi_AZ7iIw_uWCazBXZMpfSExOI-xxxsSO4k_NYzMlW3QYXeWV95Ui6eSy3NwP6dOjgj8NOyfjob9ZfM09gPNe2HeD0SOlp2TuzfU/s72-c/createVT.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-8439733734639621698</id><published>2016-01-17T03:43:00.000-08:00</published><updated>2016-01-17T05:50:35.644-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Configure User and groups in SecurityRealm"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 12.2.1"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic Domain Partition"/><title type='text'>Multitenancy in WebLogic 12c Part -2: Create User and Group per Domain Partition </title><content type='html'>&lt;pre&gt;def create_userGroup(realmName, userName, groupName):
 cd(&#39;/&#39;)
 print &#39;add user: r
ealmName &#39; + realmName
 if realmName == &#39;DEFAULT_REALM&#39;:
   realm = cmo.getSecurityConfiguration().getDefaultRealm()
 else:
   realm = cmo.getSecurityConfiguration().lookupRealm(realmName)
 print &quot;Creating user &quot; + userName + &quot; in realm: &quot; + realm.getName()
 atn = realm.lookupAuthenticationProvider(&#39;ATNPartition&#39;)
 if atn.userExists(userName):
   print &quot;User already exists.&quot;
 else:
   atn.createUser(userName, &#39;${password}&#39;, realmName + &#39; Realm User&#39;)
 print &quot;Done creating user. ${password}&quot;
 print &quot;Creating group &quot; + groupName + &quot; in realm: &quot; + realm.getName()
 if atn.groupExists(groupName):
   print &quot;Group already exists.&quot;
 else:
   atn.createGroup(groupName, realmName + &#39; Realm Group&#39;)
 if atn.isMember(groupName,userName,true) == 0:
   atn.addMemberToGroup(groupName, userName)
 else:
   print &quot;User is already member of the group.&quot;
def main():
 connect(&quot;weblogic&quot;,&quot;welcome1&quot;,&quot;t3://192.168.33.100:6100&quot;)

 create_userGroup(&#39;Online_Realm&#39;, &#39;mt_adm1&#39;,&#39;Administrator&#39;)
 create_userGroup(&#39;Corporate_Realm&#39;, &#39;mt_adm2&#39;,&#39;Administrator&#39;)

 disconnect()

main()

&lt;/pre&gt;
&lt;br /&gt;
Note: Remember this important point when you modify a security related configurations we should not use edit() or startEdit().
We are good to go lets execute the script...

&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;py&quot; name=&quot;code&quot;&gt;wlst createUserGroups.py
&lt;/pre&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilBal7pwIWhE5X8M7bV2epq_JSdyGa0AipHnWI3wuhyGxkdTLru_fuDNmCSAY1yhnyl13Vd6QC0TTSWXrjJt5bd4jdhvgAsuKdv79BigOV8XaQEwULNPxW8CQw9z0s-TOiD_wem2dxoh0/s1600/createUserGroups.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;332&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilBal7pwIWhE5X8M7bV2epq_JSdyGa0AipHnWI3wuhyGxkdTLru_fuDNmCSAY1yhnyl13Vd6QC0TTSWXrjJt5bd4jdhvgAsuKdv79BigOV8XaQEwULNPxW8CQw9z0s-TOiD_wem2dxoh0/s640/createUserGroups.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;create User and Group per Domain partition using WLST&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIE5rgocuxHP9LyAwKgVQY1jX12en6n2IQJpXrNKwTA8NS4nYnLiQjiC3ibNozXASnxq1532jJv4lppLStYp2UxzQZnoqzoxqDg15IlfDb5bTRclulpYZvnQ6Y4TTcBoA1mAUbdQSFUgE/s1600/UserGrp.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;258&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIE5rgocuxHP9LyAwKgVQY1jX12en6n2IQJpXrNKwTA8NS4nYnLiQjiC3ibNozXASnxq1532jJv4lppLStYp2UxzQZnoqzoxqDg15IlfDb5bTRclulpYZvnQ6Y4TTcBoA1mAUbdQSFUgE/s640/UserGrp.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;WebLogic Admin Console sreen User configuration for Partitioned Domain&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/8439733734639621698/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2016/01/multitenancy-in-weblogic-12c-part-2.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/8439733734639621698'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/8439733734639621698'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2016/01/multitenancy-in-weblogic-12c-part-2.html' title='Multitenancy in WebLogic 12c Part -2: Create User and Group per Domain Partition '/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilBal7pwIWhE5X8M7bV2epq_JSdyGa0AipHnWI3wuhyGxkdTLru_fuDNmCSAY1yhnyl13Vd6QC0TTSWXrjJt5bd4jdhvgAsuKdv79BigOV8XaQEwULNPxW8CQw9z0s-TOiD_wem2dxoh0/s72-c/createUserGroups.JPG" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-20206792534496964</id><published>2016-01-12T09:58:00.002-08:00</published><updated>2016-06-22T23:24:56.597-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="authorization"/><category scheme="http://www.blogger.com/atom/ns#" term="Multiple SecurityRealm in WebLogic Partition Domain"/><category scheme="http://www.blogger.com/atom/ns#" term="Partion Domain with WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="security"/><category scheme="http://www.blogger.com/atom/ns#" term="SecurityRealm"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST 12.2.1"/><title type='text'>Multitenancy in WebLogic 12c Part -1: Security Realm for  Partition Domain</title><content type='html'>In the new ear of &amp;nbsp;Multi-tenancy environment with WebLogic the application server software it self changed a lot internally to support the Partition based domains which supporting existing features as well. When we create a new SecurityRealm for a Partition, we need to create the following MBeans :&lt;br /&gt;
&lt;br /&gt;
Let me begin with sample Training project where it runs with Online and Corporate training partitions. Here in this post we can configure security realm for each partition.
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Authenticator&lt;/li&gt;
&lt;li&gt;Role&lt;/li&gt;
&lt;li&gt;Identity Asserter&lt;/li&gt;
&lt;li&gt;Role Mapper&lt;/li&gt;
&lt;li&gt;Authorizer&lt;/li&gt;
&lt;li&gt;Adjucator&lt;/li&gt;
&lt;li&gt;Auditor&lt;/li&gt;
&lt;li&gt;Credential Mapper&lt;/li&gt;
&lt;li&gt;Certificate Path Provider&lt;/li&gt;
&lt;li&gt;Password Validator&lt;/li&gt;
&lt;/ul&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZvBf1RTHdpd0ue4FvnPNHTUPD41_qO8qfn1NYGYgBNUD7XvTMrJ59cvMJ3FTvIA_zphQia3Qc1zwcBJoRfZFXziijZLy9V1SQOskUzxmfUDqSj8l7A1Ntx3XeIH8sca9l5l9c_7u70Lk/s1600/Security_MT.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;518&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZvBf1RTHdpd0ue4FvnPNHTUPD41_qO8qfn1NYGYgBNUD7XvTMrJ59cvMJ3FTvIA_zphQia3Qc1zwcBJoRfZFXziijZLy9V1SQOskUzxmfUDqSj8l7A1Ntx3XeIH8sca9l5l9c_7u70Lk/s640/Security_MT.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;WebLogic Multi-tenancy - SecurityRealm configuration&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
Lets make re-usable module so that everyone can use the function as it is. The changes could be in the main module only. Further simplification you could also move the values into a separate properties file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;def create_securityRealm4partition(realmName):
 
 security = cmo.getSecurityConfiguration()
 print &#39;realm name is &#39; + realmName
 realm = security.createRealm(realmName)
 
 # ATN
 atnp = realm.createAuthenticationProvider(&#39;ATNPartition&#39;,&#39;weblogic.security.providers.authentication.DefaultAuthenticator&#39;)
 atna = realm.createAuthenticationProvider(&#39;ATNAdmin&#39;,&#39;weblogic.security.providers.authentication.DefaultAuthenticator&#39;)
 
 # IA
 ia = realm.createAuthenticationProvider(&#39;IA&#39;,&#39;weblogic.security.providers.authentication.DefaultIdentityAsserter&#39;)
 ia.setActiveTypes([&#39;AuthenticatedUser&#39;])
 
 # ATZ/Role
 realm.createRoleMapper(&#39;Role&#39;,&#39;weblogic.security.providers.xacml.authorization.XACMLRoleMapper&#39;)
 realm.createAuthorizer(&#39;ATZ&#39;,&#39;weblogic.security.providers.xacml.authorization.XACMLAuthorizer&#39;)
 
 # Adjudicator
 realm.createAdjudicator(&#39;ADJ&#39;,&#39;weblogic.security.providers.authorization.DefaultAdjudicator&#39;)
 
 # Auditor
 realm.createAuditor(&#39;AUD&#39;,&#39;weblogic.security.providers.audit.DefaultAuditor&#39;)

 # Credential Mapper
 realm.createCredentialMapper(&#39;CM&#39;,&#39;weblogic.security.providers.credentials.DefaultCredentialMapper&#39;)
 
 # Cert Path
 realm.setCertPathBuilder(realm.createCertPathProvider(&#39;CP&#39;,&#39;weblogic.security.providers.pk.WebLogicCertPathProvider&#39;))
 
 # Password Validator
 pv = realm.createPasswordValidator(&#39;PV&#39;, &#39;com.bea.security.providers.authentication.passwordvalidator.SystemPasswordValidator&#39;)
 pv.setMinPasswordLength(8)
 pv.setMinNumericOrSpecialCharacters(1)

def main():
 connect(&quot;weblogic&quot;,&quot;welcome1&quot;,&quot;t3://192.168.33.100:6100&quot;)
 edit()
 startEdit()

 create_securityRealm4partition(&#39;Online_Realm&#39;)
 create_securityRealm4partition(&#39;Corporate_Realm&#39;)

 save()
 activate()
 disconnect()
main()
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt; wlst createSecurityRealm.py

&lt;/pre&gt;
&lt;pre class=&quot;brush:py&quot;&gt;&lt;/pre&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipDXKonJGgQ6QF_ig96ByCBOjW4gyIXYLgjkrZlYkCQlERsjM9tzF-G_DZzlNOIXsuGpLPDtfk9mwBeE5CxdtWrzXl56EggRxYl7sj2EXRdZ5V1K2MzOsMlUJUqfxc5sEUQzc3Jq3TdH4/s1600/SecRealm.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;SecurityRealm using WLST&quot; border=&quot;0&quot; height=&quot;388&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipDXKonJGgQ6QF_ig96ByCBOjW4gyIXYLgjkrZlYkCQlERsjM9tzF-G_DZzlNOIXsuGpLPDtfk9mwBeE5CxdtWrzXl56EggRxYl7sj2EXRdZ5V1K2MzOsMlUJUqfxc5sEUQzc3Jq3TdH4/s640/SecRealm.JPG&quot; title=&quot;Security Realm Configuration&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Configure Security realm for partitions using WLST Script createSecurityRealm.py&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
On the other hand you can see the WebLogic Admin console output as well:&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOnKhJxSjF8N1AQjy2KofsSxrKM33RQf5AASVa71wJl7ZzYKcSRRkOPRwet6tRnwJfb13MS6axn1tOOK8bIlwjV9tcIyokCd20D8Stx_VS3oFn1m6SGjb7uJz3yiwqfEomrVyP8dn9kGg/s1600/SecRealm1.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;388&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOnKhJxSjF8N1AQjy2KofsSxrKM33RQf5AASVa71wJl7ZzYKcSRRkOPRwet6tRnwJfb13MS6axn1tOOK8bIlwjV9tcIyokCd20D8Stx_VS3oFn1m6SGjb7uJz3yiwqfEomrVyP8dn9kGg/s640/SecRealm1.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Security Realm on Domain Partition&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
This article is a series of blog posts you will be more excited to see the next posts see below:&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;background-color: white; color: #666666; font-family: &amp;quot;trebuchet ms&amp;quot;, trebuchet, verdana, sans-serif; font-size: 13.2px; line-height: 18.48px;&quot;&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/security-realm-for-multitenants-in.html&quot; style=&quot;color: #888888; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Configure Security Realm&lt;/a&gt;&amp;nbsp;for MT&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-2.html&quot; style=&quot;color: #888888; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Create Users &amp;amp; Groups for Partition domain&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-3.html&quot; style=&quot;color: #888888; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Configure Virtual Target&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-4.html&quot; style=&quot;color: #888888; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Creating Partition Domain&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-5.html&quot; target=&quot;_blank&quot;&gt;Configure IDD for Partition&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;http://wlstbyexamples.blogspot.in/2016/01/multitenancy-in-weblogic-12c-part-6.html&quot; target=&quot;_blank&quot;&gt;Partition Control (start/stop using WLST)&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;&lt;a href=&quot;https://wlstbyexamples.blogspot.in/2016/06/multitenancy-in-weblogic-12c-part-7.html&quot; target=&quot;_blank&quot;&gt;Deploy and Undeploy Application on Partition&amp;nbsp;&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/20206792534496964/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2016/01/security-realm-for-multitenants-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/20206792534496964'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/20206792534496964'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2016/01/security-realm-for-multitenants-in.html' title='Multitenancy in WebLogic 12c Part -1: Security Realm for  Partition Domain'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZvBf1RTHdpd0ue4FvnPNHTUPD41_qO8qfn1NYGYgBNUD7XvTMrJ59cvMJ3FTvIA_zphQia3Qc1zwcBJoRfZFXziijZLy9V1SQOskUzxmfUDqSj8l7A1Ntx3XeIH8sca9l5l9c_7u70Lk/s72-c/Security_MT.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-3235457936690937611</id><published>2015-11-06T16:16:00.000-08:00</published><updated>2015-11-06T16:16:28.039-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="break in WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="Continue in WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="for loop in WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="if-elif-else in WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="if-else in WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="pass in WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="while loop in WLST"/><title type='text'>WLST Programming Controls</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Effective programming could be developed using right decision making in your scripts. Here I would like to share some basics of Python program controls that would be used in the WLST scripts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;background-color: purple; color: white;&quot;&gt;
if-else in WLST
&lt;/h3&gt;
&lt;br /&gt;
&lt;br /&gt;
This is common decision making control in every programming language same in WLST. Python based program control much simple no braces required when you construct the if condition. There is no complex confusions for string comparisons and numeric value comparisons. As you know there is no semicolons for statements. The relational operators we have to use straight English words &lt;u&gt;and&lt;/u&gt;, &lt;u&gt;or&lt;/u&gt;, &lt;u&gt;not.&amp;nbsp;&lt;/u&gt;&lt;br /&gt;
&lt;u&gt;&lt;br /&gt;&lt;/u&gt;
&lt;u&gt;&lt;br /&gt;&lt;/u&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;background-color: purple; color: white;&quot;&gt;
if-elif-else in WLST : if-else ladder
&lt;/h3&gt;
&lt;br /&gt;
In normal programming need this would be mostly used in  two or three steps on the ladder preferable. Before you enter here you need to check this really required that gives optimizing your WLST script.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisn_c1tGDTqO6tcxhmH5H7hhi3zg0Gf8xiDCp-Zi4x5dphOMEGGRGh3IOuHAAOvwqMsvVbxKqqrLF1hyK0NtgUuQ2rg5Zrpyz5qmXJJfXxN3vOBocAiPN6IA4282XNg7K_CaHd1FOfv08/s1600/if-elif-else.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;238&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisn_c1tGDTqO6tcxhmH5H7hhi3zg0Gf8xiDCp-Zi4x5dphOMEGGRGh3IOuHAAOvwqMsvVbxKqqrLF1hyK0NtgUuQ2rg5Zrpyz5qmXJJfXxN3vOBocAiPN6IA4282XNg7K_CaHd1FOfv08/s400/if-elif-else.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;if-elif-else in WLST Scripting&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
Most of the WLST scripts that you develop for reuse with iterative process need to be in the looping structures for more time. If you write the script optimized way means you need to focus on few facts:&lt;br /&gt;
clean, faster, better&lt;br /&gt;
&lt;br /&gt;
While loop can be used when you want to pass the iterations with numbers. We need to initialize the iteration variable and within the loop we need to increase or decrease that value to complete the loop. While loop will be entered into its block when the given expression is executed and resulted true.&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;background-color: purple; color: white;&quot;&gt;
Iterations in WLST Scripts&lt;/h3&gt;
&lt;br /&gt;
We can see the major categories of WLST iterations control flows available such as &#39;for loop&#39; and &#39;while loop&#39;. Before iterating important Python function for automatic number list generation is given below.&lt;br /&gt;
&lt;h4&gt;
The range() function&lt;/h4&gt;
When you are using for-loop best trick to use with range built in Python function. It will take three different optional arguments and gives you different variety of values in the range of list as output.&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Until the given number&lt;/li&gt;
&lt;li&gt;From one particular value to another&lt;/li&gt;
&lt;li&gt;From one value to another with increment by value&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Experimenting with range function to understand all its capabilities The range command always start from the 0 if you pass single argument that is considered as number of values you want as output.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush :py&quot;&gt;wls:/offline&amp;gt; R=range(11)
wls:/offline&amp;gt; R
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
wls:/offline&amp;gt; R=range(2,10,2)
wls:/offline&amp;gt; R
[2, 4, 6, 8]
wls:/offline&amp;gt; R=range(2,10,3)
wls:/offline&amp;gt; R
[2, 5, 8]
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;background-color: purple; color: white;&quot;&gt;
While loop control&lt;/h3&gt;
This loop control works as same as in C programming style loop. The execution of while loop should not have any control on the variable that is used for iterate the loop. You need to initialize, check the termination condition and in the while loop block it should be iterated by increase or decrease as per program needs.&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6TlFT6S-GJVpiYJhthyGG_i5Lj1T4mHX_5smM6X7c3oizDaIgQUhyphenhyphenjrVw0V6ZYomOTuN9fQ7LdweEaMfdTGjkY2IxEBFgDnznX7ZxqovfrPDzO2W1iutcTUV9PrJq9xg9sW2efH3EGog/s1600/wlstLoops.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;398&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6TlFT6S-GJVpiYJhthyGG_i5Lj1T4mHX_5smM6X7c3oizDaIgQUhyphenhyphenjrVw0V6ZYomOTuN9fQ7LdweEaMfdTGjkY2IxEBFgDnznX7ZxqovfrPDzO2W1iutcTUV9PrJq9xg9sW2efH3EGog/s400/wlstLoops.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;font-size: 13.3333339691162px;&quot;&gt;WLST While loop - WLST for loop&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;wls:/offline&amp;gt; i=0
wls:/offline&amp;gt; while i &amp;lt; 10:
... jms_server=&quot;JMSServer&quot;+str(i)
... print jms_server
... i+=1
...

&lt;/pre&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrc23PGAw0MmaL-ahLeXEgouIWSukQoeb-NQNOL1C_OewjNbfhm0TeahJuKB6tqsmIX7EBgwfYryoeKZuK545cfp5ZlXiJcHKJl7FmZfnFhwKvXz5ota1BsDgBkMOPtsNGApFOsH7qQzg/s1600/while_loop.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrc23PGAw0MmaL-ahLeXEgouIWSukQoeb-NQNOL1C_OewjNbfhm0TeahJuKB6tqsmIX7EBgwfYryoeKZuK545cfp5ZlXiJcHKJl7FmZfnFhwKvXz5ota1BsDgBkMOPtsNGApFOsH7qQzg/s1600/while_loop.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;While loop in WLST Script example&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;h3 style=&quot;background-color: purple; color: white;&quot;&gt;
The &#39;for loop&#39; in WLST&lt;/h3&gt;
&lt;br /&gt;
Every scripts developer favorite iterator controller is &lt;b&gt;for&lt;/b&gt; loop. Let us dive into some of the examples with it. The example of the &#39;for loop&#39; in WLST is given below

&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;wls:/offline&amp;gt; slist=range(1,11)
wls:/offline&amp;gt; for i in slist:
...     print &#39;managed&#39;+str(i)+&#39;_server&#39;
...
managed1_server
managed2_server
managed3_server
managed4_server
managed5_server
managed6_server
managed7_server
managed8_server
managed9_server
managed10_server
&lt;/pre&gt;
&lt;br /&gt;
Now lets get our WebLogic stuff here :) There could be a deployment on specific  standalone servers instances which are not part of the cluster.
Fetching only the managed servers excluding the adminserver from the server list that we get them from the ServerLifeCycleRuntimes MBean, Here I&#39;ve considered the AdminServer name can be any name that includes Admin or adm etc. To solve this we can use lower() string function on the server name and check server names not contains &#39;adm&#39; then it is managed server list!
 
&lt;br /&gt;
&lt;pre class=&quot;brush :py&quot;&gt;wls:/offline&amp;gt; connect(&#39;weblogic&#39;,&#39;welcome1&#39;,&#39;t3://192.168.33.100:7001&#39;)
Connecting to t3://192.168.33.100:7001 with userid weblogic ...
Successfully connected to Admin Server &#39;wappAdmin&#39; that belongs to domain &#39;wappdomain&#39;.

wls:/wappdomain/serverConfig&amp;gt; domainRuntime()
Location changed to domainRuntime tree. This is a read-only tree with DomainMBean as the root.
For more help, use help(domainRuntime)

wls:/wappdomain/domainRuntime&amp;gt; cd(&#39;/ServerLifeCycleRuntimes/&#39;)
wls:/wappdomain/domainRuntime/ServerLifeCycleRuntimes&amp;gt; ls()
dr--   wappAdmin
dr--   wappMS1
dr--   wappMS2

wls:/wappdomain/domainRuntime/ServerLifeCycleRuntimes&amp;gt;  x=ls(returnMap=&#39;true&#39;)
dr--   wappAdmin
dr--   wappMS1
dr--   wappMS2

wls:/wappdomain/domainRuntime/ServerLifeCycleRuntimes&amp;gt; [s for s in x if &#39;adm&#39; in s.lower()]
[&#39;wappAdmin&#39;]
wls:/wappdomain/domainRuntime/ServerLifeCycleRuntimes&amp;gt; [s for s in x if &#39;adm&#39; not in s.lower()]
[&#39;wappMS1&#39;, &#39;wappMS2&#39;]
&lt;/pre&gt;
The last output is really awesome you will save lines as well because you don&#39;t need new line for if condition.

&lt;br /&gt;
&lt;h3 style=&quot;background-color: purple; color: white;&quot;&gt;
While loop usage vs for loop &lt;/h3&gt;
&lt;br /&gt;
While loop&lt;br /&gt;&lt;ol&gt;
&lt;li&gt;&amp;nbsp;Takes more time to executed&amp;nbsp;&lt;/li&gt;
&lt;li&gt;initialization, increase/decrease iterator variable &amp;nbsp;&lt;/li&gt;
&lt;li&gt;Easy to construct infinite loops with intervals &amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
For loop&amp;nbsp;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;ol&gt;
&lt;li&gt;&amp;nbsp;Fastest loop&amp;nbsp;&lt;/li&gt;
&lt;li&gt;depends on range function to iterate on numbers&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Flexible for including single lambda conditions&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&amp;nbsp;Will update the following soon after sample executions completed. But these control flags works as in C language.&lt;br /&gt;&lt;br /&gt;
&lt;h3 style=&quot;background-color: purple; color: white;&quot;&gt;
The break statement in WLST
&lt;/h3&gt;
Some of the code scenarios we need to terminate the iteration with a certain conditions. The &#39;break&#39; statement in WLST will terminates the current loop. This control jump statement could be under if or else block only.

&lt;pre class=&quot;brush:py&quot;&gt; 
# check for prime
n=input(&quot;enter a number: &quot;)

i = 2
while i &amp;lt; n:
        if n%i == 0:
                print &quot;Given &quot;, n, &quot; not prime&quot;
                break
        i+=1
else:
        print n, &quot; is prime&quot;

&lt;/pre&gt;
This logic will be applicable in many scenario, When an application is available on a WebLogic instance overall state for the application would be available. So you could break the loop and come out.

&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmJBl1GLBYhIsUimHvTKfwetgczMbf78VZuIDlT_MGmAoabrxehnU6-E_7Dfe4hdDYb5d30Qo_wBMvjKoKDvdkpKrBijCJH4eDVmGEEoOR6DB6vvbuNZ0STeD50eHZWEratfuOlGYliyI/s1600/Prime_py.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmJBl1GLBYhIsUimHvTKfwetgczMbf78VZuIDlT_MGmAoabrxehnU6-E_7Dfe4hdDYb5d30Qo_wBMvjKoKDvdkpKrBijCJH4eDVmGEEoOR6DB6vvbuNZ0STeD50eHZWEratfuOlGYliyI/s400/Prime_py.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;The break statement in WLST&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;h3 style=&quot;background-color: purple; color: white;&quot;&gt;
The continue statement in WLST
&lt;/h3&gt;
To skip an iteration in the loop that could be for-loop or while-loop the keyword you need to use &#39;continue&#39;. This continue statement also requires certain condition for skip the loop. So it can be part of either in the if or in the else block.
Lets experiment with continue statement, printing the 0-10 numbers except when 5, 6,7 in the sequence.

&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt; 
# This script will illustrate for loop skip
r=range(11)
for i in r:
        if i in (5, 6, 7):
                continue
        print i

&lt;/pre&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhg4lHaSpL-OZSWiZzcIbcgY4H_pfV-CV1woxR449yAwhUCzBuQn7GBuakEl5jz-DFI2q4EklAKgOCgEYFSZ1-tjf6W8udL1pNkcGHMK-JbCRPpgYaWnpGAJxPKwjkQs7drKqXBmvMwnVA/s1600/continue_skipnum.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhg4lHaSpL-OZSWiZzcIbcgY4H_pfV-CV1woxR449yAwhUCzBuQn7GBuakEl5jz-DFI2q4EklAKgOCgEYFSZ1-tjf6W8udL1pNkcGHMK-JbCRPpgYaWnpGAJxPKwjkQs7drKqXBmvMwnVA/s400/continue_skipnum.JPG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;The continue statement in WLST&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
The pass statement in WLST

&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/3235457936690937611/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2015/07/wlst-programming-controls.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/3235457936690937611'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/3235457936690937611'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2015/07/wlst-programming-controls.html' title='WLST Programming Controls'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisn_c1tGDTqO6tcxhmH5H7hhi3zg0Gf8xiDCp-Zi4x5dphOMEGGRGh3IOuHAAOvwqMsvVbxKqqrLF1hyK0NtgUuQ2rg5Zrpyz5qmXJJfXxN3vOBocAiPN6IA4282XNg7K_CaHd1FOfv08/s72-c/if-elif-else.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-7467122460883530854</id><published>2015-07-19T23:10:00.001-07:00</published><updated>2015-07-19T23:10:10.315-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="o nodemanager in java.library.path"/><category scheme="http://www.blogger.com/atom/ns#" term="startNodeManager with WLST in Windows"/><title type='text'>startNodeManager with WLST in Windows</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
If you are working on OFMW environments there is a utility script startNMProps.sh/.cmd file present in the ORACLE_COMMON_HOME/common/bin. This script would update the nodemanager.properties file, which is exists in the WL_HOME/common/nodemanger [NM_Home].
&lt;br /&gt;
When I&#39;ve used the example command given in the WLST help got the following error:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;Caused by: java.lang.UnsatisfiedLinkError: no nodemanager in java.library.path
&lt;/pre&gt;
&lt;br /&gt;
Here the problem could be solved or workaround with two options:&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Check your JAVA_HOME, JAVA_VENDOR values correctly pointed or not.&lt;/li&gt;
&lt;li&gt;Change the nodemanager.properties content with the following option&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;pre&gt;NativeVersionEnabled=false
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
When you execute the startNodeManager command for the WLST offline you could pass two arguments: DomainRegistrationEnabled, NodeManagerHome.&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;wls:/offline&amp;gt; startNodeManager(DomainRegistrationEnabled=&#39;true&#39;,NodeManagerHome=&#39;c:/Oracle/product/fmw/wlserver_10.3/common/nodemanager&#39;)
Launching NodeManager ...
Removed output here...
Where it displays that generated nodemanager.properties and also shows the domain mapping.
:
:
NMProcess: INFO: Secure socket listener started on port 5556
Successfully launched the Node Manager.
The Node Manager process is running independent of the WLST process.
Exiting WLST will not stop the Node Manager process. Please refer
to the Node Manager logs for more information.
The Node Manager logs will be under c:\Oracle\product\fmw\wlserver_10.3\common\nodemanager
Node Manager starting in the background
&lt;/pre&gt;
&lt;br /&gt;
You could experiment on NodeManager on Windows share your issues in the comments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/7467122460883530854/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2015/07/startnodemanager-with-wlst-in-windows.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/7467122460883530854'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/7467122460883530854'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2015/07/startnodemanager-with-wlst-in-windows.html' title='startNodeManager with WLST in Windows'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-5279091177911726638</id><published>2015-07-12T19:06:00.001-07:00</published><updated>2022-07-27T00:54:33.073-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="jps"/><category scheme="http://www.blogger.com/atom/ns#" term="nmConnect"/><category scheme="http://www.blogger.com/atom/ns#" term="Node Manager Status from WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="os"/><category scheme="http://www.blogger.com/atom/ns#" term="socket"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST"/><title type='text'>NodeManager Status from WLST</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
When you use WebLogic admin console you know the Node manager is &#39;Reachable&#39; or &#39;Inactive&#39; state. The same thing if you wish to get it from WLST machine monitoring, this is not available as exposed MBean attribute.&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
  &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjdFG_oh1oYFpr0ldqojiGYXHAO0Rd3TR9XGbLo8uvtvC_q2cv83P6oVmAMRAHJ34yYlop5SKuvbqCx6PiRHaNn9IXKJ8x48mZDZZhJC_u3k23jzecUDd3r8r4kICE1danr3JYEHicDUo/s1600/1658908466635876-0.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;
    &lt;img border=&quot;0&quot;   src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjdFG_oh1oYFpr0ldqojiGYXHAO0Rd3TR9XGbLo8uvtvC_q2cv83P6oVmAMRAHJ34yYlop5SKuvbqCx6PiRHaNn9IXKJ8x48mZDZZhJC_u3k23jzecUDd3r8r4kICE1danr3JYEHicDUo/s1600/1658908466635876-0.png&quot; width=&quot;400&quot;&gt;
  &lt;/a&gt;
&lt;/div&gt;&lt;br&gt;
&lt;br&gt;&lt;b&gt;
How to find the NodeManager Running from WLST?&lt;/b&gt;&lt;br&gt;
Brainstorming...&lt;br&gt;
Found three alternative solutions.&lt;br&gt;
&lt;br&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Use jps command to find the NodeManager Pid exist or not&lt;/li&gt;
&lt;li&gt;Connect the Nodemanager if it is succeeds then NM Reachable otherwise not.&lt;/li&gt;
&lt;li&gt;Use a simple socket module to create the socket object on the host, port&lt;/li&gt;
&lt;/ol&gt;
&lt;br&gt;
&lt;h3&gt;
 NodeManager Check with jps command &lt;/h3&gt;
JDK provides jps command to show the list of Java Pids with name of the Java program. provided your JAVA_HOME must be available in os environment variables. So conditions applied here!! anyways lets see the solution :

&lt;br&gt;
&lt;br&gt;
&lt;pre class=&quot;brush:py&quot;&gt;
def nm_status():
        NMstatus=os.system(&#39;jps |grep -i nodemanager|grep -v grep&#39;)
        if NMstatus==0:
                return &#39;Reachable&#39;
        else:
                return &#39;Inactive&#39;
&lt;/pre&gt;
Note: Please check indentations after copying to your editor.
&lt;br&gt;
The disadvantage of this method is it is going to work on Linux/Unix environments only, No Windows.

&lt;br&gt;
&lt;h3&gt;
Connect to NodeMnager get State &lt;/h3&gt;
&lt;br&gt;
WLST Command nmConnect() is going to connect if the machine have a Node Manager running, but here it does not returns the output to a variable. The output normally redirecting to standard output stdout. If we can redirect that to a file and check that contians &quot;Connected&quot;word then you can confirm Nodemanager is &#39;Reachable&#39; otherwise &#39;Inactive&#39; state.

&lt;br&gt;
&lt;br&gt;
&lt;pre class=&quot;brush:py&quot;&gt;
def NM_status(nmUser, nmPassword, nmHost, nmPort, dName, domainPath,nmTYPE):
 &quot;&quot;&quot; This option nmConnect will give that it is reachable or not from stdout &quot;&quot;&quot;
        redirect(&#39;/tmp/mywlst.out&#39;)
        nmConnect(nmUser, nmPassword, nmHost, nmPort, dName, domainPath,nmTYPE)
        stopRedirect()
        flag=0
        for line in open(&quot;/tmp/mywlst.out&quot;):
         if &quot;Connected&quot; in line:
          flag=1
          break

 nmDisconnect()
        if flag==1:
          return &quot;Reachable&quot;
        else:
         return &quot;Inactive&quot;
&lt;/pre&gt;
&lt;br&gt;
Here we met the purpose of knowing about the status of Node manager. Still looking for better alternative than this!

&lt;br&gt;
&lt;h3&gt;
Node manager status by Socket module&lt;/h3&gt;
In Python we have Socket object and its related methods to check weather a port is available or not. On a machine if we try to create socket object with Node manager ip address, port then it is going to check the port availability that gives us status!

&lt;br&gt;
&lt;br&gt;
&lt;pre class=&quot;brush:py&quot;&gt;
def is_available(address, port):
    import socket
    try:
        s = socket.socket()
        s.connect((address, int(port)))
        return true
    except:
        return false

def nmStatus(machinesList):
 &quot;&quot;&quot; This will create global string with Node manager status&quot;
 machine_port=5556
 machine_host=localhost
 global g_str  
 g_str+=&quot;NM &quot;+machine+ &quot; -   &quot;
     
 if is_available(machine_host, machine_port):
  g_str+=&quot;Reachable&quot;+&quot;\n&quot;
 else:
  g_str+=&quot;Inactive&quot;+&quot;\n&quot;
 
&lt;/pre&gt;
In you main script you could call nmStatus to know about the nodemanager status. Do you have any new thoughts, ideas or suggestions are welcome, Thanks for being with me.
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/5279091177911726638/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2015/07/nodemanager-status-from-wlst.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/5279091177911726638'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/5279091177911726638'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2015/07/nodemanager-status-from-wlst.html' title='NodeManager Status from WLST'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjdFG_oh1oYFpr0ldqojiGYXHAO0Rd3TR9XGbLo8uvtvC_q2cv83P6oVmAMRAHJ34yYlop5SKuvbqCx6PiRHaNn9IXKJ8x48mZDZZhJC_u3k23jzecUDd3r8r4kICE1danr3JYEHicDUo/s72-c/1658908466635876-0.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-5820100617716519493</id><published>2014-12-31T21:00:00.001-08:00</published><updated>2023-03-25T21:07:32.121-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="findall WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="match WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="re examples in WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="re module in WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="Regular Expressions in WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="search WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="split String in WLST"/><title type='text'>Regular Expressions (re module) in WLST</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Python based WLST tutorial is to present a detailed and descriptive introduction into regular expressions.
Every scripting language powered up with this regular expressions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc5gLgQ1deHoemF9t9vVgseYKARsOOELXmZxKQShs60jCibtoJAnGrAq4QcnIyRe9aWLpJsVJ97MVq2qoJAnqWDDubzE3yDJfPvKW_fMeGtZLAJV8JJjIUQVgPk4lqAgVNXd6hgRNi5f8/s1600/WLST_re_01.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;Regular expressions examples in WLST&quot; border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc5gLgQ1deHoemF9t9vVgseYKARsOOELXmZxKQShs60jCibtoJAnGrAq4QcnIyRe9aWLpJsVJ97MVq2qoJAnqWDDubzE3yDJfPvKW_fMeGtZLAJV8JJjIUQVgPk4lqAgVNXd6hgRNi5f8/s1600/WLST_re_01.png&quot; title=&quot;re in WLST&quot; width=&quot;303&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Regular Expressions in WLST&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
In scripting, Very complex problems can be resolved with simple regular expressions. If you are not aware of each expressions meaning then it would be Greek &amp;amp; &amp;nbsp;Latin. You need to understand how they can be applicable then you can construct your WLST script in such a way that it could give a fantastic outcomes.
A regular expression is that a set of possible input raw strings (includes alphanumerical, whitespaces, symbols).&lt;br /&gt;
&lt;br /&gt;
Regular expressions descends from fundament concept in Computer Science called finite automata theory. 
 
 
A regular expression can match a string in more than one place.
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;background-color: purple; color: white;&quot;&gt;
Meta Characters in WLST&lt;/h3&gt;
The special meaning for each symbol that we use in the regular expression. We have the following meta characters allowed in WLST.

&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGImIBybVAVbWKmjQvQth8xCzugEL8WqC-PaKeuIJFYCwEk_vPRFcwPKtxsI899Rkef_GIZAZpPhpXaM335u46cbTFoKFGEzeD734NoLdb03PI8e7cQPVOxeVU2YFJo3edL6wWvkrnAqQ/s1600/re_metachar_table.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;WLST using meta chars&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGImIBybVAVbWKmjQvQth8xCzugEL8WqC-PaKeuIJFYCwEk_vPRFcwPKtxsI899Rkef_GIZAZpPhpXaM335u46cbTFoKFGEzeD734NoLdb03PI8e7cQPVOxeVU2YFJo3edL6wWvkrnAqQ/s400/re_metachar_table.png&quot; title=&quot;Meta Characters in re module&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;background-color: purple; color: white;&quot;&gt;
Dot . in expression – any char&lt;/h3&gt;
The . dot or period regular expression can be used to matches any character. Remember this don’t matches new line ‘\n’.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikxsRggVJoCS-o-mH9L-1weNrJD9z0huFdE69vjjVYZFkQQFpeNq9xxHQHwlRqB1jDqFGTilzR-TTUrw0Z0oAuUlXwJl08Bww6sIFeTLlcamFDM_cT2rYxbtbeJwHdaZ2fXABsESvMFVA/s1600/re_dot.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;132&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikxsRggVJoCS-o-mH9L-1weNrJD9z0huFdE69vjjVYZFkQQFpeNq9xxHQHwlRqB1jDqFGTilzR-TTUrw0Z0oAuUlXwJl08Bww6sIFeTLlcamFDM_cT2rYxbtbeJwHdaZ2fXABsESvMFVA/s1600/re_dot.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;background-color: purple; color: white;&quot;&gt;
The Character classes&lt;/h3&gt;
Character classes [] can be used to match any specific set of characters.&lt;br /&gt;
Here is the example to understand the expression that uses character class. The expression second char can be one of the three chars given in the char class [eor]. So the pattern matches three words from the given text.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiveBQ6fJHjsnsE38PR8RX7fmtNet72iEHsRtINpTYT-ZsHuHnC-fpvGnhf_002TgDbNL8EiERLgpin6ZL_R6u2Aa5kXPqJi1pltIJRFDnfl8At6H4a1i8h8pjyL4GzWI-9OAeh7FCV6go/s1600/re_charcls_01.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;104&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiveBQ6fJHjsnsE38PR8RX7fmtNet72iEHsRtINpTYT-ZsHuHnC-fpvGnhf_002TgDbNL8EiERLgpin6ZL_R6u2Aa5kXPqJi1pltIJRFDnfl8At6H4a1i8h8pjyL4GzWI-9OAeh7FCV6go/s1600/re_charcls_01.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;background-color: purple; color: white;&quot;&gt;
Negate character class&lt;/h3&gt;
Character class can be negated with ^ symbol inside the character class. That is [^].&lt;br /&gt;
[aeiou] will match any of the characters a, e, i, o, or u&lt;br /&gt;
[yY]es will match Yes or yes&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG0MvsApWuUZvh1BRBSNfcFu1euvjM_Pv4dM1JQoEQjSxu1YrRp7DnXIEr8uR03LV7WciedutEwtj3GIhGzM3PzuTx_V_luJwFJRUhhu15b3hKVzmFWehfNGXBOGdCf7iEKPtJ5G8_NQ4/s1600/re_NegCharcls02.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;110&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG0MvsApWuUZvh1BRBSNfcFu1euvjM_Pv4dM1JQoEQjSxu1YrRp7DnXIEr8uR03LV7WciedutEwtj3GIhGzM3PzuTx_V_luJwFJRUhhu15b3hKVzmFWehfNGXBOGdCf7iEKPtJ5G8_NQ4/s1600/re_NegCharcls02.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Negate Character class in re&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
Ranges can also be specified in character classes&lt;br /&gt;
[1-9] is the same as [123456789]&lt;br /&gt;
[abcde] is equivalent to [a-e]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also combine multiple ranges in the pattern&lt;br /&gt;
[abcde123456789] is equivalent to [a-e1-9]&lt;br /&gt;
&lt;br /&gt;
Note that the hyphen - character has a special meaning in a character class but only if it is used within a range, if you use hypen at beginning its meaning changes it doesn&#39;t meant for range.&lt;br /&gt;
[-123] would match the characters -, 1, 2, or 3&lt;br /&gt;
&lt;br /&gt;
Commonly used character classes can be referred to by name (alpha, lower, upper, alnum, digit, punct, cntrl)&lt;br /&gt;
Syntax [:name:]&lt;br /&gt;
[a-zA-Z] &amp;nbsp; &amp;nbsp; &amp;nbsp; [[:alpha:]]&lt;br /&gt;
[a-zA-Z0-9] &amp;nbsp; &amp;nbsp;[[:alnum:]]&lt;br /&gt;
[45a-z] &amp;nbsp; &amp;nbsp; &amp;nbsp;[45[:lower:]]&lt;br /&gt;
Important for portability across languages&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVR1yfQowN3a9fTj5RjV-jFfEomTbPL0YJyug8Xl-NGq6n2hDHNPojQMpic0oy_xRfc-bEHPJh_8iMM-ZcYnJ6yf_Vr4CiJXXTxD3nWT2FBCuT2thaUROn6SkpULXhQGS25EuWj3FvW5w/s1600/re_match_methods.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;142&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVR1yfQowN3a9fTj5RjV-jFfEomTbPL0YJyug8Xl-NGq6n2hDHNPojQMpic0oy_xRfc-bEHPJh_8iMM-ZcYnJ6yf_Vr4CiJXXTxD3nWT2FBCuT2thaUROn6SkpULXhQGS25EuWj3FvW5w/s1600/re_match_methods.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;compile - search, match patterns on data&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;import re

t=&quot;Demoadmin, demo_ms1, demo_ms2, my_clustr1&quot;
p=re.compile(&#39;(d\w+)&#39;,re.I)
pos=0
while 1:
        m=p.search(t, pos)
        if m:
                print &quot;Now search start position :&quot;, pos
                print m.group()
                pos=m.end()
        else:
                break

&lt;/pre&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5FJxrkjmPCWDKEbRfvD7lNhfUSXNqd34B-_tF5945ccBwuJxVNlDTNJa4mbuvZgoZL-8bx2Ltg-O9n2XTKZ-WvQ73ROPkj1Vd2tAImwWcKu-_fD1OUtSHLnds3maBnq_AeSGkUdwMuLM/s1600/compile_search.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;132&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5FJxrkjmPCWDKEbRfvD7lNhfUSXNqd34B-_tF5945ccBwuJxVNlDTNJa4mbuvZgoZL-8bx2Ltg-O9n2XTKZ-WvQ73ROPkj1Vd2tAImwWcKu-_fD1OUtSHLnds3maBnq_AeSGkUdwMuLM/s640/compile_search.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Regular expression Compile pattern on search method&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;h3 style=&quot;background-color: purple; color: white;&quot;&gt;
Regular expression FLAGS&lt;/h3&gt;
&lt;br /&gt;
re.I == re.IGNORECASE Ignore case&lt;br /&gt;
re.L == re.LOCALE Make \w, \b, and \s locale dependent&lt;br /&gt;
re.M == re.MULTILINE Multiline&lt;br /&gt;
re.S == re.DOTALL Dot matches all (including newline)&lt;br /&gt;
re.U == re.UNICODE Make \w, \b, \d, and \s unicode dependent&lt;br /&gt;
re.X == re.VERBOSE Verbose (unescaped whitespace in pattern&lt;br /&gt;
is ignored, and &#39;#&#39; marks comment lines)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;background-color: purple; color: white;&quot;&gt;
 5 important re functions on WLST&lt;/h3&gt;
There are few regular expression functions defined in the re module. Lets experiment with each one and see how they work.
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;wls:/offline&amp;gt; dir(re)
[&#39;DOTALL&#39;, &#39;I&#39;, &#39;IGNORECASE&#39;, &#39;L&#39;, &#39;LOCALE&#39;, &#39;M&#39;, &#39;MULTILINE&#39;, &#39;S&#39;, &#39;U&#39;, &#39;UNICODE&#39;, &#39;VERBOSE&#39;, &#39;X&#39;, &#39;__all__&#39;, &#39;__doc__&#39;, &#39;__file__&#39;, &#39;__name__&#39;, &#39;compile&#39;, &#39;error&#39;, &#39;escape&#39;, &#39;findall&#39;, &#39;match&#39;, &#39;module&#39;, &#39;name&#39;, &#39;purge&#39;, &#39;search&#39;, &#39;split&#39;, &#39;sre&#39;, &#39;sub&#39;, &#39;subn&#39;, &#39;sys&#39;, &#39;template&#39;]
&lt;/pre&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYDpMqwmOHc2wmJqWtj2nBCMLoxrRaUVNHevqAeMohjLwS_OxYUzVR9yE0S2r_V9CR94bu2ej3oKHNp8xM1SLoP3MsrMDDbNrqficjnSiTRlP1eqxlbPAyG9-i78W6vW2zPZjEXyEuqd0/s1600/re_module_functions.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;178&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYDpMqwmOHc2wmJqWtj2nBCMLoxrRaUVNHevqAeMohjLwS_OxYUzVR9yE0S2r_V9CR94bu2ej3oKHNp8xM1SLoP3MsrMDDbNrqficjnSiTRlP1eqxlbPAyG9-i78W6vW2zPZjEXyEuqd0/s1600/re_module_functions.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;The re module methods and their functionality&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
Lets begin here...
&lt;br /&gt;
&lt;ol&gt;
&lt;br /&gt;&lt;h3 style=&quot;background-color: purple; color: white;&quot;&gt;
&lt;li&gt;
The re.match() method 
&lt;/li&gt;
&lt;/h3&gt;
The match() method works is that it will only find matches if they occur at the start of the string being searched.

&lt;pre class=&quot;brush:py&quot;&gt;wls:/offline&amp;gt; import re
wls:/offline&amp;gt; str=&quot;WLST WebLogic wsadmin WebSphere&quot;
wls:/offline&amp;gt; mo=re.match(r&#39;WLST&#39;,str)
wls:/offline&amp;gt; mo.group(0)
&#39;WLST&#39;
&lt;/pre&gt;
&lt;br /&gt;&lt;h3 style=&quot;background-color: purple; color: white;&quot;&gt;
&lt;li&gt; 
 The re.split() method  
&lt;/li&gt;
&lt;/h3&gt;
The re.split() method accepts a pattern argument. This pattern specifies the delimiter(s) with it, we can use any text that matches a pattern as the delimiter to separate text data. This is powerful to get the desired data from the text data.&lt;/ol&gt;
&lt;ol&gt;&lt;br /&gt;&amp;nbsp;

&lt;pre class=&quot;brush:py&quot;&gt;clstrAddress=&quot;machine01.vybhava.com:8901,machine02.vybhava.com:8902&quot;
wls:/offline&amp;gt;  s=re.split(r&quot;[:,]\d{4}&quot;,clstrAddress)
wls:/offline&amp;gt; s
[&#39;machine01.vybhava.com&#39;, &#39;,machine02.vybhava.com&#39;, &#39;&#39;]
&lt;/pre&gt;
&lt;ol&gt;&lt;br /&gt;&lt;/ol&gt;
Now lets experiment with simple script where various forms of split works.&lt;/ol&gt;
&lt;ol&gt;&lt;br /&gt;&amp;nbsp;

&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFr4fR8qOr4XZGXYouVl4-y33rfV1My2atIa3uy-7sonwaZAeE-jUPXt_Q0F8WbiBP4nn7d0w6G62oW0vA7DIx0ONSCsE66xfqNnjSQBjSOxXCrgDESPKgXi6-1zNnM28HWZrF1OojX8A/s1600/split_method.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;252&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFr4fR8qOr4XZGXYouVl4-y33rfV1My2atIa3uy-7sonwaZAeE-jUPXt_Q0F8WbiBP4nn7d0w6G62oW0vA7DIx0ONSCsE66xfqNnjSQBjSOxXCrgDESPKgXi6-1zNnM28HWZrF1OojX8A/s640/split_method.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Split method samples in WLST&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;pre class=&quot;brush:py&quot;&gt;import re

servers=&quot;admin, ms1, ms2, ms3, cluster1&quot;
print re.split(&#39;\W+&#39;, servers)

print re.split(&#39;(\W+)&#39;, servers)

print re.split(&#39;\W+&#39;, servers, 2)

print re.split(&#39;\W+&#39;, servers, 3)

# The split mehtod works with multiple delimiters
e=os.environ[&#39;PATH&#39;]
for p in re.split(r&#39;:&#39;, e):
    print p

&lt;/pre&gt;
&lt;br /&gt;


&lt;br /&gt;&lt;h3 style=&quot;background-color: purple; color: white;&quot;&gt;
&lt;li&gt;The re.search() method&amp;nbsp;&lt;/li&gt;
&lt;/h3&gt;
The following examples will illustrate how to search function with re module flags without it.
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;#=====================================================================
# Created by : Manish K
# Updated by : Pavan Devarakonda
# Date : 20 Dec 2014
#=====================================================================
import re

s1 = &quot;India is a country!&quot;
s2 = &quot;Delhi is the capital of India&quot;
str = s1 + &quot;\n&quot; + s2

###### To Search first char in multilne
mo = re.search(r&quot;^D[\w]*&quot;, str, re.M)
print &quot;searched word with first char D:&quot;,mo.group()

###### To Search last char in multilne

mo1 = re.search(r&quot;I[\w]*$&quot;, str, re.M)
print &quot;Searched India:&quot;, mo1.group()

##### To match ignoring case

mo2 = re.search(r&quot;india&quot;, str, re.I)
print &quot;Ignore case:&quot;, mo2.group()

if re.search(r&#39;[!@#$%^&amp;amp;*()]&#39;, str):
 print &quot;Some special Char found&quot;
else:
 print &quot;Nothing special found&quot;

print &quot;Original str:&quot;, str
splitstr = re.split(&quot;\n&quot;, str)
print &quot;split string with newline:&quot;,splitstr

## Optional Items
optSearch = &quot;Find date Feb 2015, 12&quot;
mo3 = re.search(r&quot;Feb(ruary)? 2015&quot;, optSearch)
print &quot;Optional search:&quot;, mo3.group()

## using +
mo4 = re.search(r&quot;(Feb(ruary)?) ([0-9]+)&quot;, optSearch)
print &quot;Search with + : &quot;, mo4.group()


## unsing *
mo5 = re.search(r&quot;[0-9].*&quot;, optSearch)
print &quot;Using *&quot;, mo5.group()

### Grouping by the use of ()

gprStr = &quot;Customer number: 232454, Date: February 12, 2015&quot;
mo6 = re.search(&quot;([0-9]+).*: (.*)&quot;, gprStr)
print &quot;Grouping with ():&quot;
print mo6.group()
print mo6.group(1)
print mo6.group(2)
print mo6.groups()

&lt;/pre&gt;
Lets execute the above experiment on search function.
&lt;pre class=&quot;brush:py&quot;&gt;$ wlst search_re.py

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

searched word with first char D: Delhi
Searched India: India
Ignore case: India
Some special Char found
Original str: India is a country!
Delhi is the capital of India
split string with newline: [&#39;India is a country!&#39;, &#39;Delhi is the capital of India&#39;]
Optional search: Feb 2015
Search with + :  Feb 2015
Using * 2015, 12
Grouping with ():
232454, Date: February 12, 2015
232454
February 12, 2015
(&#39;232454&#39;, &#39;February 12, 2015&#39;)

&lt;/pre&gt;
&lt;br /&gt;&lt;h3 style=&quot;background-color: purple; color: white;&quot;&gt;
&lt;li&gt;The re.findall() method&lt;/li&gt;
&lt;/h3&gt;
&lt;br /&gt;
When there is the need to find the multiple occurrences of a pattern in a text then findall() is the best function to use. This function returns a list of resulted strings.&lt;br /&gt;
&lt;br /&gt;
Example on findall method in re module.

&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;import re
line=&quot;WebLogic Automation course helps WebLogic Admins fish best opportunities&quot;

print &quot;words starts with A&quot;
print re.findall(r&quot;\bA[\w]*&quot;,line)

print &quot;Find all five characthers long words&quot;
print re.findall(r&quot;\b\w{5}\b&quot;, line)

# Find all four, six characthers long words
print &quot;4, 6 char long words&quot;
print re.findall(r&quot;\b\w{4,6}\b&quot;, line)

# Find all words which are at least 13 characters long
print &quot;13 char&quot;
print re.findall(r&quot;\b\w{13,}\b&quot;, line)
&lt;/pre&gt;
Execution of the above example gives the output as follows:

&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;$ wlst findallre.py

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

words starts with A
[&#39;Automation&#39;, &#39;Admins&#39;]
Find all five characthers long words
[&#39;helps&#39;]
4, 6 char long words
[&#39;course&#39;, &#39;helps&#39;, &#39;Admins&#39;, &#39;fish&#39;, &#39;best&#39;]
13 char
[&#39;opportunities&#39;]

&lt;/pre&gt;
&lt;br /&gt;
&lt;li&gt;&lt;br /&gt;&lt;h3 style=&quot;background-color: purple; color: white;&quot;&gt;
The re.sub() method in WLST&lt;/h3&gt;
&lt;/li&gt;
One of the most important function in the re module is sub(). It works like &#39;find and replace&#39;. 

&lt;pre class=&quot;brush:py&quot;&gt;sub(pattern, repl, string [, count=0])

&lt;/pre&gt;
&lt;br /&gt;
This method replaces all occurrences of the re pattern in the given string with repl, substituting all occurrences unless max count provided. This method would return modified string as output.

&lt;pre class=&quot;brush:py&quot;&gt;#!/usr/bin/python
import re

DOB = &quot;28-11-2003# This is DOB &quot;

# Delete Python-style comments
num = re.sub(r&#39;#.*$&#39;, &quot;&quot;, DOB)
print &quot;DOB Num : &quot;, num

# Remove anything other than digits
x = re.sub(r&#39;\D&#39;, &quot;&quot;, DOB)
print &quot;DOB without - : &quot;, x

# Substituting other symbol in anything other than digits
FDOB = re.sub(r&#39;\D&#39;, &quot;/&quot;, num)
print &quot;DOB in new format : &quot;, FDOB
&lt;/pre&gt;
This find and replacement experiment output

&lt;pre class=&quot;brush:py&quot;&gt;DOB Num :  28-11-2003
DOB without - :  28112003
DOB in new format :  28/11/2003
&lt;/pre&gt;
&lt;br /&gt;
Hope this has given you some basic idea on re module usage in WLST shell. This can help you when you write a monitoring script and that will be given to reporting or graph designs on UI.

&lt;br /&gt;
&lt;h3&gt;Extract hostname and IP from a String using re&lt;/h3&gt;
Python gives us wonderful option to name the pattern which you are searching for. To make it possible ?P will be used in the searching pattern and within angular braces name will be defined.
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;
wls:/offline&gt; s=&#39;www.vybhava.com=192.168.33.100&#39;
wls:/offline&gt; hi=re.match(r&#39;(?P&lt;hostname&gt;[_a-z]\w*\.[_a-z]\w*.[_a-z]\w*)\s*=\s*(?P&lt;ip&gt;\d+\.\d+\.\d+\.\d+)&#39;,s)
wls:/offline&gt; hi.group(&#39;hostname&#39;)
&#39;www.vybhava.com&#39;
wls:/offline&gt; hi.group(&#39;ip&#39;)
&#39;192.168.33.100&#39;
&lt;/pre&gt;

&lt;/ol&gt;
Write back to us with your Feedback, queries on regular expressions usage in WLST. &lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/5820100617716519493/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2014/12/regular-expressions-in-wlst.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/5820100617716519493'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/5820100617716519493'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2014/12/regular-expressions-in-wlst.html' title='Regular Expressions (re module) in WLST'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc5gLgQ1deHoemF9t9vVgseYKARsOOELXmZxKQShs60jCibtoJAnGrAq4QcnIyRe9aWLpJsVJ97MVq2qoJAnqWDDubzE3yDJfPvKW_fMeGtZLAJV8JJjIUQVgPk4lqAgVNXd6hgRNi5f8/s72-c/WLST_re_01.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-8362928208472311533</id><published>2014-12-25T10:44:00.000-08:00</published><updated>2014-12-25T22:15:34.058-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="File"/><category scheme="http://www.blogger.com/atom/ns#" term="File in WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="help"/><category scheme="http://www.blogger.com/atom/ns#" term="Jython"/><category scheme="http://www.blogger.com/atom/ns#" term="Oracle Fussion Middleware"/><category scheme="http://www.blogger.com/atom/ns#" term="output"/><category scheme="http://www.blogger.com/atom/ns#" term="Output redirection in Jython"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="sample"/><category scheme="http://www.blogger.com/atom/ns#" term="Store output"/><category scheme="http://www.blogger.com/atom/ns#" term="tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic  11g supports Jython 2.2"/><category scheme="http://www.blogger.com/atom/ns#" term="WebLogic 9.2"/><category scheme="http://www.blogger.com/atom/ns#" term="WLST"/><title type='text'>File IO in WLST: How to store output of WLST/Jython?</title><content type='html'>Hey WLST scripting enthos Guys!!&lt;br /&gt;
&lt;br /&gt;
I was prepared some of industry most reffered WLST monitoring scripts... they are running well and good... Now the need is to store the result of this monitoring script into a FILE. How to make this? how to redirect this output... normally output is coming from &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;print &lt;/span&gt;command in the jython/python. I was searching in google for this output storing to a file from WLST not really good outcomes... then I thought better I choose file style as in C programming allows Standard Output to a files with file pointers. This found a jython tutorial which is already available in online...&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSh0__XPP2fw0DDnnHI88ImV5OoUBxfHw2nc4lfW2BWcdqTdFN1inp11xVcW81hjo1Zc55EvbcZJajMM7b8Bz_NQAbU7nO4ekOkafidrk-83x4L3lDFeUZpKgNU_vhKMyHTvEBim5yP1s/s1600/FileIO.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSh0__XPP2fw0DDnnHI88ImV5OoUBxfHw2nc4lfW2BWcdqTdFN1inp11xVcW81hjo1Zc55EvbcZJajMM7b8Bz_NQAbU7nO4ekOkafidrk-83x4L3lDFeUZpKgNU_vhKMyHTvEBim5yP1s/s1600/FileIO.png&quot; height=&quot;356&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;WLST File input output operations&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;pub-0762912933528813&quot;;
/* 336x280, created 10/19/10 */
google_ad_slot = &quot;4167369161&quot;;
google_ad_width = 336;
google_ad_height = 280;
//&lt;/script&gt;
&lt;/div&gt;
--&amp;gt;&lt;br /&gt;
&lt;h3&gt;
Standard Out and Error &lt;/h3&gt;
&lt;br /&gt;
Standard output and standard error (commonly abbreviated stdout and stderr) are pipes that are built into every unix-like platform. The stdout (fileObject) is defined in the Python standard sys module, and it is a stream object. Calling its write() function which will print out whatever string you pass as argument to it, then return the length of the output. In fact, this is what the print function really does; it adds a carriage return to the end of the string that you’re printing, and calls sys.stdout.write function.

&lt;pre class=&quot;brush:py&quot;&gt;
##############################################
# This program is to illustrate sys fileojects
# Standard Output stdout
# Standard Error stderr
##############################################
print &quot;Normal print...&quot;
for i in range(3):
        print &quot;WLST is awesome!!!&quot;

import sys
print &quot;sys.stdout....&quot;
for i in range(5):
        l=sys.stdout.write(&#39;WLST By Examples\n&#39;)

print &quot;sys.stderr....&quot;
for i in range(4):
        errline=sys.stderr.write(&#39;WLST in 12.1.3 Wonderful!! &#39;)

&lt;/pre&gt;
Here it shows the difference of print, write function with/without carriage return example.
&lt;pre class=&quot;brush:py&quot;&gt;
$ wlst fileObj_sys.py

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Normal print...
WLST is awesome!!!
WLST is awesome!!!
WLST is awesome!!!
sys.stdout....
WLST By Examples
WLST By Examples
WLST By Examples
WLST By Examples
WLST By Examples
sys.stderr....
WLST in 12.1.3 Wonderful!! WLST in 12.1.3 Wonderful!! WLST in 12.1.3 Wonderful!!

&lt;/pre&gt;

In the simplest case, sys.stdout and sys.stderr send their output to the same place.
In Python, standard output, standard error does not add carriage returns for you. If you want carriage returns. you’ll need to write manually include the carriage return characters.

sys.stdout and sys.stderr are stream objects, but they are write-only. Here important fact is that when you attempting to call their read() method will always raise an IOError.
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;&lt;a href=&quot;http://sites.google.com/site/weblogicadminsite/Home/wlstlinks/my-wlst-links&quot;&gt;Jython Tutorial&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Redirecting output with file descriptor is fine worked good...&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
now one more thing... need a timestamp for everytime when you run the monitoring script...&lt;/div&gt;
&lt;div&gt;
Solution again available in the same tutorial...&lt;/div&gt;
&lt;div&gt;
jython is going to support Java internally... Java&#39;s Date utility gives you the facility to have a time stamp redirect this print to the same file descriptor ... your job is done!!&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;fileObj = open(&#39;test.txt&#39;, &#39;w&#39;)
writeList=[&quot;I am an Indian&quot;, &quot;I love my India&quot;, \
&quot;I want to go to USA&quot;, &quot;I want to earn dollars&quot;, \
&quot;I want to die in India&quot;]

for i in writeList:
 print &amp;gt;&amp;gt;fileObj, i

fileObj.close()

# Default file mode is read (r)
fileObj = open(&#39;test.txt&#39;)

# We can move fileObj position here it is 0
fileObj.seek(0)

for lines in fileObj.readlines():
 print lines

fileObj.close()
&lt;/pre&gt;
Creates test.txt with lines in list and then will read lines from same file.
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;wls:/offline&amp;gt; execfile(&#39;filereadWrite.py&#39;)
I am an Indian

I love my India

I want to go to USA

I want to earn dollars

I want to die in India

&lt;/pre&gt;
&lt;br /&gt;
&lt;h3&gt;
The file attributes&lt;/h3&gt;
Following table have the list of the file object attributes. Which we can directly access them public. 

&lt;br /&gt;
&lt;table class=&quot;src&quot; style=&quot;background-color: #f7f7f7; border-collapse: collapse; border: 1px solid rgb(214, 214, 214); color: black; font-family: Helvetica, Arial, sans-serif; font-size: 12px; margin: 8px 0px; padding: 0px; vertical-align: top; width: 560px;&quot;&gt;&lt;tbody style=&quot;margin: 0px; padding: 0px;&quot;&gt;
&lt;tr style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;th style=&quot;background-color: #eeeeee; border-collapse: collapse; border: 1px solid rgb(214, 214, 214); margin: 0px; padding: 5px;&quot;&gt;Attribute&lt;/th&gt;&lt;th style=&quot;background-color: #eeeeee; border-collapse: collapse; border: 1px solid rgb(214, 214, 214); margin: 0px; padding: 5px;&quot;&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;tr style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;td style=&quot;border-collapse: collapse; border: 1px solid rgb(214, 214, 214); margin: 0px; padding: 5px;&quot;&gt;file.closed&lt;/td&gt;&lt;td style=&quot;border-collapse: collapse; border: 1px solid rgb(214, 214, 214); margin: 0px; padding: 5px;&quot;&gt;Returns true if file is closed, false otherwise.&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;td style=&quot;border-collapse: collapse; border: 1px solid rgb(214, 214, 214); margin: 0px; padding: 5px;&quot;&gt;file.mode&lt;/td&gt;&lt;td style=&quot;border-collapse: collapse; border: 1px solid rgb(214, 214, 214); margin: 0px; padding: 5px;&quot;&gt;Returns access mode with which file was opened.&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;td style=&quot;border-collapse: collapse; border: 1px solid rgb(214, 214, 214); margin: 0px; padding: 5px;&quot;&gt;file.name&lt;/td&gt;&lt;td style=&quot;border-collapse: collapse; border: 1px solid rgb(214, 214, 214); margin: 0px; padding: 5px;&quot;&gt;Returns name of the file.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;pre class=&quot;brush:py&quot;&gt;# This program illustrates the file attributes

f=open(&#39;fileattr.py&#39;)
print &quot;mode:&quot;,f.mode
print &quot;name:&quot;,f.name

if f.closed:
        print f.name, &quot; is closed&quot;
else:
        print f.name,&quot; is not closed&quot;

&lt;/pre&gt;
Its execution gives the output as follows
&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;wls:/offline&amp;gt; execfile(&#39;fileattr.py&#39;)
mode: r
name: fileattr.py
fileattr.py  is not closed

&lt;/pre&gt;
&lt;h3&gt;
 Testing &lt;/h3&gt;
&lt;h3&gt;
 with-as operation on Files &lt;/h3&gt;
Following example shows how to use with
&lt;br /&gt;
&lt;h3&gt;
How do I test a simple Jython script at Jython prompt?&lt;br /&gt;
&lt;/h3&gt;
You can use the following lines to invoke Jython Shell on your WebLogic environment. This is possible because WLST is based on Jython Shell, obviously you can get a Jython prompt in the WebLogic environment. &lt;br /&gt;
Normally you can get with &lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;&quot;&gt;$ java&amp;nbsp; org.python.util.jython&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Otherwise use the following way to skip caching:&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;&quot;&gt;$ java -Dpython.cachedir.skip=true org.python.util.jython&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
Remember that, WebLogic 9.2 supports Jython 2.1 featured shell, The new Oracle Fusion middleware, WebLogic 11g supports Jython 2.2 features. &lt;br /&gt;
&lt;br /&gt;
In many capacity planning analysis you need the statistcs of day or hour by hour etc., These statistics can be for JVM monitoring or for JMS or JDBC DataSource or Thread Count of a WebLogic domain.&lt;br /&gt;
Simply printing to standard output you can redirect them to your desired filenames which you specify in the Jython script. To do print to a file use:&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;f = open(&quot;JVMStat.txt&quot;, &quot;w&quot;)
# JVM monitoasring Script loop
       print &amp;gt;&amp;gt;f, &quot;JVM Status Line here&quot;
f.close()
&lt;/pre&gt;
And to add to the end of a existing file use:&lt;br /&gt;
&lt;pre class=&quot;brush:py&quot;&gt;f = open(&quot;JVMStat.txt&quot;, &quot;a&quot;)
       print &amp;gt;&amp;gt;f, &quot;Added lines comes here&quot;
f.close()
&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;
Hope this will give you hint for your need in WLST and file usage. For any issue keep writing back to me.&lt;br /&gt;
&lt;br /&gt;
Enjoy with Jython!!! in WLST !!!&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/8362928208472311533/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2009/05/how-to-store-output-of-wlst.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/8362928208472311533'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/8362928208472311533'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2009/05/how-to-store-output-of-wlst.html' title='File IO in WLST: How to store output of WLST/Jython?'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSh0__XPP2fw0DDnnHI88ImV5OoUBxfHw2nc4lfW2BWcdqTdFN1inp11xVcW81hjo1Zc55EvbcZJajMM7b8Bz_NQAbU7nO4ekOkafidrk-83x4L3lDFeUZpKgNU_vhKMyHTvEBim5yP1s/s72-c/FileIO.png" height="72" width="72"/><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7333189570510911465.post-1041497801777767703</id><published>2014-12-19T01:03:00.002-08:00</published><updated>2015-07-29T02:56:06.348-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="class in WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="define method in WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="Instance"/><category scheme="http://www.blogger.com/atom/ns#" term="Object in WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="OOP in WLST"/><category scheme="http://www.blogger.com/atom/ns#" term="Weblogic scripting tool"/><title type='text'>Object Oriented Programming in WLST</title><content type='html'>I taught Object orientation programming with C++ and Java previously. With that experiance I am &amp;nbsp;trying to explore more in the Pythonic OOP in WLST.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgg7mAvBe7DSDc6DLkfELeH6jd_ZgWU0mWlSmD1tt3OzcH0tC7szS5xm0YsEhLpLRQwjC_N7DPkwML7woBRDCphqApg221zMe4b_Y1k9wBWPiq17O5zoePa26BIN8BMPV0YU-A-I8FsFSY/s1600/class_in_Wlst.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;288&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgg7mAvBe7DSDc6DLkfELeH6jd_ZgWU0mWlSmD1tt3OzcH0tC7szS5xm0YsEhLpLRQwjC_N7DPkwML7woBRDCphqApg221zMe4b_Y1k9wBWPiq17O5zoePa26BIN8BMPV0YU-A-I8FsFSY/s400/class_in_Wlst.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;class definition in WLST Script&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
In WLST every thing is object as its base scripting language is Python suppose the same. If you create normal variable assignment uses their base objects like int, float, str etc. Each object will be created on JVM with ID, Type (object type) and value. In this post you will get to know about Object orientation for WLST scripts. The four pillars of Object orientation are supported in WLST as well.
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Encapsulation - How you hide within object&lt;/li&gt;
&lt;li&gt;Abstraction - How the object make interact with the world&lt;/li&gt;
&lt;li&gt;Inheritance -Reusing functionalities of a object&lt;/li&gt;
&lt;li&gt;Polymorphism - Dynamism to your methods&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
Why should I use OOP in WLST?&lt;/h3&gt;
&lt;div&gt;
The best features identified and designed for object oriented programming mainly following:&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Object are &lt;b&gt;&lt;u&gt;natural &lt;/u&gt;&lt;/b&gt;easy to understand and write&lt;/li&gt;
&lt;li&gt;Objects are more &lt;b&gt;&lt;u&gt;reusable&lt;/u&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Objects are more &lt;u&gt;&lt;b&gt;maintainable&lt;/b&gt;&lt;/u&gt;&lt;/li&gt;
&lt;li&gt;Objects can be &lt;b&gt;&lt;u&gt;extended&lt;/u&gt;&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
What is class in WLST?&lt;/h3&gt;
&lt;/div&gt;
&lt;div&gt;
A class is a special user defined data type, which defines how to build a certain kind of objects. These classes also stores some common data itms that are shared by all its instances of the class. Instances are objects that are created which follow the definition given inside of the class.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In simple words class is a blue print for constructing the objects.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Initializer method __init__&lt;/div&gt;
&lt;div&gt;
The functions that you define within the class are called methods. for all methods must use the first argument as self.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3&gt;
What is &#39;self&#39; do in WLST?&lt;/h3&gt;
&lt;div&gt;
The Self is object pointer like in C++, Java we have this pointer that refers to the newly created runtime object attributes values.In __init__, self refers to the object currently being created. In WLST classes self used more often than Java. You don&#39;t need to give a value for self. When you call the method VM automatically provides the value for self.&lt;/div&gt;
&lt;h3&gt;
What is Instance?&lt;/h3&gt;
&lt;div&gt;
An instance can be created in the main program that is after completing the class block. To create we need the className followed by perantesis.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
i=className()&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
calling the method can be done with instance period followed by method signature with required parameters.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Magical methods&lt;/div&gt;
&lt;div&gt;
There are some methods which are executed without calling them! Example initializer method, printing the object into string type using __repr__, and __str__ .When you call the instance in print command it will automaticall invoke these magical methods.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Best practics for class definitons&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;While you defining a class the class name must begin with Capital letter&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Explicit inheriting object type give more power to your class&lt;/li&gt;
&lt;li&gt;Define a method like a function. must have a first argument as self which provide access to current instance attribute values&lt;/li&gt;
&lt;li&gt;Better to have a DocString for each method you define in the class&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
class level methods&lt;/div&gt;
&lt;div&gt;
static methods&lt;/div&gt;
&lt;div&gt;
Inheritance&amp;nbsp;&lt;/div&gt;
&lt;h3&gt;
Multiple Inheritance&lt;/h3&gt;
&lt;pre class=&quot;brush:py&quot;&gt;# This illustrates the subclassing
# Empty class with pass 
# usage of issubclass function

class Animal(object): pass
class Snake(Animal):
 def __init__(self):
  print &quot;Ssss n a k e!!&quot;
class Python(Snake):
 &quot;I like Python class&quot;
 atr=0
 def __init__(self):
  print &quot;Busssshhhh!!!&quot;
  Snake.__init__(self)
  self.atr+=1
 def __repr__(self):
  return &#39;This is Python object&#39;

print &quot;issubclass(Animal,object:)&quot;,issubclass(Animal,object)
print &quot;issubclass(Snake,Animal:)&quot;,issubclass(Snake,Animal)
print &quot;issubclass(Python, Snake:)&quot;,issubclass(Python, Snake)

p=Python()
print &quot;Instance printing:&quot;, p
print &quot;docString:&quot;, p.__doc__
print &quot;p is from class:&quot;, p.__class__

print &quot;p type:&quot;,type(p)
print &quot;p id:&quot;, id(p)
print &quot;p attribute:&quot;, p.atr
 
&lt;/pre&gt;
&lt;h3&gt;
Private variables in class&lt;/h3&gt;
&lt;div&gt;
In Python classes by default everything is public access. to provide encapsulation for the object double underscore represents the private variables(__var1).&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3&gt;
&amp;nbsp;
Exercise for Learners&lt;/h3&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;Create a class for configuring a simple domain with initializer method that will load all properties that required to configure. [managed servers, machines, cluster]&lt;/li&gt;
&lt;li&gt;Create a singleton class that would allow single connection object that can be preserved and used for monitoring JVM, Threads etc.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://wlstbyexamples.blogspot.com/feeds/1041497801777767703/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlstbyexamples.blogspot.com/2014/12/object-oriented-programming-in-wlst.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/1041497801777767703'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7333189570510911465/posts/default/1041497801777767703'/><link rel='alternate' type='text/html' href='http://wlstbyexamples.blogspot.com/2014/12/object-oriented-programming-in-wlst.html' title='Object Oriented Programming in WLST'/><author><name>Pavan Devarakonda [PD]</name><uri>http://www.blogger.com/profile/06638309611528564002</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlVFxKj_ku3SHqu-QA51KNdF9LDgCIHP58C1BGz2vyYKBZxps1AIO3p27EINl5HJ6f0kAlKKUyysUsdFdeqtJYwam9Gmpdi70vJP_gGsJUICLK0IFXEc7mNky_M2c0GRFPKxV2OG_ENKcqqSmx5blLtLav-X1BXTHrPRg4t1lxwMNMa4o/s220/Pavan.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgg7mAvBe7DSDc6DLkfELeH6jd_ZgWU0mWlSmD1tt3OzcH0tC7szS5xm0YsEhLpLRQwjC_N7DPkwML7woBRDCphqApg221zMe4b_Y1k9wBWPiq17O5zoePa26BIN8BMPV0YU-A-I8FsFSY/s72-c/class_in_Wlst.png" height="72" width="72"/><thr:total>0</thr:total></entry></feed>