Showing posts with label WLST. Show all posts
Showing posts with label WLST. Show all posts

Thursday, February 21, 2013

Oracle SOA 11.1.1.6/ Weblogic 10.3.6: WLST Scripts to List Composites by Partions

Oracle SOA 11.1.1.6/ Weblogic 10.3.6: WLST Scripts to List Composites by Partions


sca_listCompositesInPartition is an online script taht can be used to display the composites in a partition. This script needs to be run from  $FW_Middleware\Oracle_SOA1\common\bin\wlst.cmd.

The script is supported by a properties file and the .py file (The script file).

The properties file looks has the following properties.


userName=weblogic
passWord=password
wlsHost=localhost
adminServerListenPort=7001
partitionsToBeChecked=default,partion1,partition2,partition3

The script itself is:

from java.io import FileInputStream
import re
import tempfile
propInputStream = FileInputStream("MonitorCompositesState.properties")
configProps = Properties()
configProps.load(propInputStream)

print '=============================================='
print '  COMPOSITE STATES WITH RESPECT TO PARTITIONS '
print '=============================================='
connect(configProps.get("userName"),configProps.get("passWord"),'t3://'+configProps.get("wlsHost")+':'+configProps.get("adminServerListenPort"))
splits=String(configProps.get("partitionsToBeChecked")).split(",")
for splitPartitionName in splits:
    print 'All the composites in partition:',splitPartitionName
    listcompos=sca_listCompositesInPartition(configProps.get("wlsHost"), configProps.get("adminServerListenPort"), configProps.get("userName"),configProps.get("passWord"),splitPartitionName) 
print '=============================================='
print''


Tuesday, February 5, 2013

Oracle SOA 11.1.1.6: WLST Scripts to Monitor Data Sources


This BLOG thread details the steps involved in creating WLST scripts to help to monitor the Data Sources on Weblogic Server with Admin Server or SOA  Server targets.

The scripts take advantage of a properties file which includes the server information. A file  CheckDataSourcesState.properties


userName=weblogic
passWord=password
wlsHost=localhost
adminServerListenPort=8001
dataSourcesToBeChecked=DataSourceDS1,DataSourceDS2



The WLST script can be created in an another file CheckDataSourcesState.py


import os
propInputStream = FileInputStream("CheckDataSourcesState.properties")
configProps = Properties()
configProps.load(propInputStream)
connect(configProps.get("userName"),configProps.get("passWord"),'t3://'+configProps.get("wlsHost")+':'+configProps.get("adminServerListenPort"))
serverRuntime()
dsMBeans = cmo.getJDBCServiceRuntime().getJDBCDataSourceRuntimeMBeans()
splits=String(configProps.get("dataSourcesToBeChecked")).split(",")
for ds in dsMBeans:
    for splitDSName in splits:
        if (splitDSName == ds.getName()):
              print 'DS name is: '+ds.getName()
              print 'State is ' +ds.getState()
              print ds.testPool()

Monday, June 4, 2012

Weblogic 10.3.5: WLST Scripts to Configure Credential Store Framework (CSF) For Access Level/Message Level security



Weblogic 10.3.5: WLST Scripts to Configure Credential Store Framework (CSF) For Access Level/Message Level security.

Follow these steps to configure the credential store to access the Oracle WSM keystore using WLST commands



  • Go to the Oracle Common home directory for your installation, for example /home/Oracle/Middleware/oracle_common.

  • Start WLST using the WLST.sh/cmd command located in the oracle_common/common/bin directory. For example:
  • /home/Oracle/Middleware/oracle_common/common/bin/wlst.sh (UNIX)
  • C:\Oracle\Middleware\oracle_common\common\bin\wlst.cmd (Windows)
                 When executed, these commands start WLST in offline mode. To use the credential store WLST  
                 commands, you must use WLST in online mode.

    • Start Oracle WebLogic Server. 

    • Connect to the running WebLogic Server instance using the connect() command. For example, the following command connects WLST to the Administration Server at the URLmyAdminServer.oracle.com:7001 using the username/password credentials weblogic/welcome1:

      
      
      connect("weblogic","welcome1","t3://myAdminServer.oracle.com:7001")
      
      
      Enter the createCred command to create an entry in the credential store for the keystore name and password as follows:
      createCred(map="oracle.wsm.security", key="keystore-csf-key", user="owsm", password="welcome1", desc="Keystore key")
      
      
      
      
      Enter the createCred command to create an entry in the credential store for the keystore name and password as follows:
      
      
      createCred(map="oracle.wsm.security", key="keystore-csf-key", user="owsm", password="welcome1", desc="Keystore key")
      
      
      Enter the createCred command to create an entry in the credential store for the signature key alias and password as follows:
      createCred(map="oracle.wsm.security", key="sign-csf-key", user="orakey", password="welcome1", desc="Signing key")
      Enter the createCred command to create an entry in the credential store for the encryption key alias and password as follows:
      createCred(map="oracle.wsm.security", key="enc-csf-key", user="orakey", password="welcome1", desc="Encryption key")

    Wednesday, May 23, 2012

    Weblogic 10.3.5: WLST in Embedded Mode

    Weblogic 10.3.5: WLST in Embedded Mode

    In embedded mode, you instantiate the WLST interpreter in your Java code and use it to run WLST commands and scripts. All WLST commands and variables that you use in interactive and script mode can be run in embedded mode.

    This example illustrates how to instantiate the WLST interpreter and use it to connect to a running server, create two servers, and assign them to clusters.


    package wlst;
    import java.util.*;
    import weblogic.management.scripting.utils.WLSTInterpreter;
    import org.python.util.InteractiveInterpreter;

    /**
     * Simple embedded WLST example that will connect WLST to a running server,
     * create two servers, and assign them to a newly created cluster and exit.
     * <p>Title: EmbeddedWLST.java</p>
     * <p>Copyright: Copyright (c) 2004</p>
     * <p>Company: BEA Systems</p>
     */

    public class EmbeddedWLST 
    {
      static InteractiveInterpreter interpreter = null;

      EmbeddedWLST() {
        interpreter = new WLSTInterpreter();
      }

    private static void connect() {
        
    
      String user="user1";
      String pass="pw12ab";
      String url ="t3://localhost:7001";
      Environment env = new Environment();
      env.setProviderUrl(url);
      env.setSecurityPrincipal(user);
      env.setSecurityCredentials(pass);
      Context ctx = env.getInitialContext();
      interpreter.exec
       ("connect('"+user+"','"+pass+"','"+url+"')");
      }

    private static void createServers() {
        StringBuffer buf = new StringBuffer();
        buf.append(startTransaction());
        buf.append("man1=create('msEmbedded1','Server')\n");
        buf.append("man2=create('msEmbedded2','Server')\n");
        buf.append("clus=create('clusterEmbedded','Cluster')\n");
        buf.append("man1.setListenPort(8001)\n");
        buf.append("man2.setListenPort(9001)\n");
        buf.append("man1.setCluster(clus)\n");
        buf.append("man2.setCluster(clus)\n");
        buf.append(endTransaction());
        buf.append("print ‘Script ran successfully ...’ \n");
        interpreter.exec(buf.toString());
      }

    private static String startTransaction() {
        StringBuffer buf = new StringBuffer();
        buf.append("edit()\n");
        buf.append("startEdit()\n");
        return buf.toString();
      }

    private static String endTransaction() {
        StringBuffer buf = new StringBuffer();
        buf.append("save()\n");
        buf.append("activate(block='true')\n");
        return buf.toString();
      }

      public static void main(String[] args) {
        new EmbeddedWLST();
        connect();
        createServers();
      }
    }
    
    
    Reference: http://docs.oracle.com/cd/E13222_01/wls/docs90/config_scripting/using_WLST.html 

    Weblogic 10.3.5: Enable Debugging Using the WebLogic Scripting Tool WLST Scripts and WLST from Java


    Weblogic 10.3.5: Enable Debugging Using the WebLogic Scripting Tool  WLST Scripts and WLST from Java

    WebLogic Scripting Tool (WLST) can be used to set the debugging values. For example, the following command runs a program for setting debugging values called debug.py:
    java weblogic.WLST debug.py
    The main scope, weblogic, does not appear in the graphic; jms is a sub-scope within weblogic. Note that the fully-qualified DebugScope for DebugJMSBackEnd is weblogic.jms.backend.
    The debug.py program contains the following code:
    user='user1'
    password='password'
    url='t3://localhost:7001'
    connect(user, password, url)
    edit()
    cd('Servers/myserver/ServerDebug/myserver')
    startEdit()
    set('DebugJMSBackEnd','true')
    save()
    activate()
    Note that you can also use WLST from Java. The following example shows a Java file used to set debugging values:
    import weblogic.management.scripting.utils.WLSTInterpreter;
    import java.io.*;
    import weblogic.jndi.Environment;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    
    public class test {
      public static void main(String args[]) {
     try {
      WLSTInterpreter interpreter = null;
      String user="user1";
      String pass="pw12ab";
      String url ="t3://localhost:7001";
      Environment env = new Environment();
      env.setProviderUrl(url);
      env.setSecurityPrincipal(user);
      env.setSecurityCredentials(pass);
      Context ctx = env.getInitialContext();
    
      interpreter = new WLSTInterpreter();
      interpreter.exec
       ("connect('"+user+"','"+pass+"','"+url+"')");
      interpreter.exec("edit()");
      interpreter.exec("startEdit()");
      interpreter.exec
       ("cd('Servers/myserver/ServerDebug/myserver')");
      interpreter.exec("set('DebugJMSBackEnd','true')"); 
      interpreter.exec("save()");
      interpreter.exec("activate()");
    
     } catch (Exception e) {
     System.out.println("Exception "+e);
     }
     }
    }
    Using the WLST is a dynamic method and can be used to enable debugging while the server is running.

    Saturday, May 12, 2012

    Oracle Fusion Middleware Security for Web Services 11g Release 1 (11.1.1.6) Policy Sets using WLST

    Policy sets provide a means to attach policies globally to a range of endpoints of the same type. 


    • In addition to attaching policies directly to endpoints, you can create policy sets that allow you to attach policies globally to a range of endpoints of the same type, regardless of the deployment state. You can create and manage policy sets using both Fusion Middleware Control and the WebLogic Scripting Tool, WLST. 
    • Attaching policies globally using policy sets allows an administrator to ensure that all subjects are secured in situations where the developer, assembler, or deployer did not explicitly specify the policies to be attached.
    • Policies attached globally using policy sets also provide the following:
      • Override the policies
      • Specify run time constraint
    • Policy subjects to which policy sets can be attached include SOA components, SOA service endpoints, SOA references, Web services endpoints, Web service clients, Web service connections, and asynchronous callback clients. Policy sets can be attached at the following scopes:
      • Domain — all policy subjects of the specified type in a domain
      • Server instance—all policy subjects of the specified type in a server instance
      • Application or Partition—all policy subjects of the specified type in an application or SOA partition
      • Application module or SOA composite—all policy subjects of the specified type in an application module or SOA composite
      • Service or reference—all policy subjects of the specified type in a SOA service or reference
      • Port or component—all policy subjects of the specified type in a port or SOA component

      CREATING A POLICY SET USINg  WLST

      CreatePolicySet.py


      import os
      propInputStream = FileInputStream("PolicySets.properties")
      configProps = Properties()
      configProps.load(propInputStream)
      connect(configProps.get("userName"),configProps.get("passWord"),'t3://'+configProps.get("wlsHost")+':'+configProps.get("adminServerListenPort"))
      splits=String(configProps.get("policysets_to_be_created")).split(",")
      for dsIndex in splits:
          beginRepositorySession()
          #Variable Definitions
          policySetName=configProps.get("policySetName_"+ str(dsIndex))
          policySetType=configProps.get("policySetType_"+ str(dsIndex))
          policySetAttachTo=configProps.get("policySetAttachTo_"+ str(dsIndex))
          policySetDescription=configProps.get("policySetDescription_"+ str(dsIndex))
          policySetEnabled=configProps.get("policySetEnabled_"+ str(dsIndex))
          policySetUrl=configProps.get("policySetUrl_"+ str(dsIndex))

          print "Creating Policy Sets for System Resource Name:"+policySetName + ", Policy Set Type:" + policySetType +" Attached To: "+ policySetAttachTo + " , Description:" + policySetDescription + ", Enabled true or false: "+ policySetEnabled 
          createPolicySet(policySetName,policySetType,policySetAttachTo,description=policySetDescription,enable=policySetEnabled)
          print "Attaching Policy Sets"
          attachPolicySetPolicy(policySetUrl)
          print "Commiting Session"
          commitRepositorySession() 

      PolicySets.properties

      userName=username
      passWord=password
      wlsHost=localhost
      domainDir=domainDir
      adminServerListenPort=7001
      #Total Number of Data Sources 
      policysets_to_be_created=1
      #Properties for the first PolicySets
      policySetName_1=TestWSClientPolicySet
      policySetType_1=sca-reference
      policySetAttachTo_1=Domain("domain") and Server("server1") and Composite("*CBP*")
      policySetDescription_1=Global policy attachments for SOA Reference resources.
      policySetEnabled_1=true
      policySetUrl_1=oracle/wss10_saml_token_client_policy_OPT_ON


      Monday, March 12, 2012

      Weblogic Fusion Middleware 10.3.5 WLST Script for Creation of the Database Resource and Redeployment of the Database Adapter

      Weblogic Fusion Middleware 10.3.5 WLST Script for Creation of the Database Resource and Redeployment of the Database Adapter
      
      
      On steps to executing the script, please click here
       
      import os
      connect(userName,passWord,'t3://'+wlsHost+':'+adminServerListenPort)
      edit()
      startEdit()
      
      soaJDBCSystemResource1 = create('DBAdapterTestDataSource',"JDBCSystemResource")
      soaJDBCResource1 = soaJDBCSystemResource1.getJDBCResource()
      soaJDBCResource1.setName('DBAdapterDataSource')
      
      soaConnectionPoolParams1 = soaJDBCResource1.getJDBCConnectionPoolParams()
      soaConnectionPoolParams1.setTestTableName("SQL SELECT 1 FROM DUAL")
      
      soaConnectionPoolParams1.setInitialCapacity(10)
      soaConnectionPoolParams1.setMaxCapacity(100)
      
      soaDataSourceParams1 = soaJDBCResource1.getJDBCDataSourceParams()
      soaDataSourceParams1.addJNDIName('jdbc/dbSample')
      soaDriverParams1 = soaJDBCResource1.getJDBCDriverParams()
      soaDriverParams1.setUrl('jdbc:oracle:thin:@'+db_host_name+':'+db_port+':'+db_sid)
      soaDriverParams1.setDriverName('oracle.jdbc.xa.client.OracleXADataSource')
      soaDriverParams1.setPassword('my_password')
      
      soaDriverProperties1 = soaDriverParams1.getProperties()
      soaProperty1 = soaDriverProperties1.createProperty("user")
      soaProperty1.setValue('scott')
      
      varSOAServerTarget = '/Servers/'+serverName
      soaServerTarget = getMBean(varSOAServerTarget)
      
      soaJDBCSystemResource1.addTarget(soaServerTarget)
      
      dumpStack()
      
      try : 
      
      save()
      
      activate(block="true")
      
      except:
          print "Error while trying to save and/or activate!!!"
          dumpStack()
      
      print "Creating DB adapter resource  information"
      try:
           redeploy('DBAdapter', '@deployment.plan@', upload='true', stageMode='stage') 
          
      except:
          print "Error while modifying db adapter connection factory" 
       
       

      WLST Script for Creation of JMS Resource and Redeployment of JMS Adapter


      This script can be used for creation of JMS Resource and Redeployment of JMS Adapter
      On steps to executing the script, please click here. 
      # lookup the JMSModule 
          jmsSOASystemResource = lookup("SOAJMSModule","JMSSystemResource")
              
          jmsResource = jmsSOASystemResource.getJMSResource()
          
          cfbean = jmsResource.lookupConnectionFactory('DemoSupplierTopicCF')
          if cfbean is None:
              print "Creating DemoSupplierTopicCF connection factory"
              demoConnectionFactory =
       jmsResource.createConnectionFactory('DemoSupplierTopicCF')
              demoConnectionFactory.setJNDIName('jms/DemoSupplierTopicCF')
              demoConnectionFactory.setSubDeploymentName('SOASubDeployment')
      
          topicbean = jmsResource.lookupTopic('DemoSupplierTopic')
          if topicbean is None:
              print "Creating DemoSupplierTopic jms topic"
              demoJMSTopic = jmsResource.createTopic("DemoSupplierTopic")
              demoJMSTopic.setJNDIName('jms/DemoSupplierTopic')
              demoJMSTopic.setSubDeploymentName('SOASubDeployment')
              
      try:
          save()
          # activate the changes
          activate(block="true")
          print "jms topic and factory for SOA Fusion Order Demo successfully created"
      except:
          print "Error while trying to save and/or activate!!!"
          dumpStack()
          
      print "Creating jms adapter connection factory information"
      try:
           redeploy('JmsAdapter', '@deployment.plan@', upload='true', stageMode='stage') 
          
      except:
          print "Error while modifying jms adapter connection factory"

      Monday, February 27, 2012

      Weblogic 10.3.5: Steps for Using WLST

      Weblogic 10.3.5: Steps for Using WLST

      Setting Up Your Environment

      To set up your environment for WLST:
      1. Install and configure the WebLogic Server software.
      2. Add WebLogic Server classes to the CLASSPATH environment variable and WL_HOME\server\bin to the PATH environment variable, where WL_HOME refers to the top-level installation directory for WebLogic Server.
      3. You can use a WL_HOME\server\bin\setWLSEnv script to set both variables.
        On Windows, a shortcut on the Start menu sets the environment variables and invokes WLST (ToolsArrow symbolWebLogic Scripting Tool).
         

      Invoking WLST

      To invoke WLST:
      1. If you will be connecting to a WebLogic Server instance through an SSL listen port on a server that is using the demonstration SSL keys and certificates, invoke WLST using the following command:
      2. java -Dweblogic.security.SSL.ignoreHostnameVerification=true -Dweblogic.security.TrustKeyStore=DemoTrust weblogic.WLST
        Otherwise, at a command prompt, enter one of the following commands:
        • java weblogic.WLST
        • java weblogic.WLST -loadProperties propertyFilename

      Running WLST from Ant

      The wlst Ant task is predefined in the version of Ant shipped with WebLogic Server and enables you to run WLST scripts from within your Ant build file.

      Note: If you want to use the task with your own Ant installation, add the following task definition in your build file:

      Note: <taskdef name="wlst" classname="weblogic.ant.taskdefs.management.WLSTTask" />
      To run WLST from an Ant script:
      1. Set your environment in a command shell.
        • On Windows NT, execute the setWLSEnv.cmd command, located in the directory WL_HOME\server\bin, where WL_HOME is the top-level directory of your WebLogic Server installation.
        • On UNIX, execute the setWLSEnv.sh command, located in the directory WL_HOME/server/bin, where WL_HOME is the top-level directory of your WebLogic Server installation.
      2. Add a call to the wlst Ant task to execute WLST commands. For example:
      3. <target name="runwlst"> 
           <wlst fileName="./myscript.py" executeScriptBeforeFile="true"
            debug="false" failOnError="false"> 
             <script>
                connect('weblogic','weblogic','t3://localhost:7001') 
             </script>
           </wlst>
        </target>

      Oracle SOA 11.1.1.5 Transferring Metadata using WLST

      Transferring Metadata using WLST

      To use WLST to transfer metadata:
      1. Export the metadata from the original partition using the exportMetadata command:
        exportMetadata(application='sampleApp', server='server1',
               toLocation='/tmp/myrepos/mypartition', docs='/**')
        
        This command exports a versioned stripe of the metadata documents from the metadata partition to a file system directory. Only customization classes declared in the cust-config element of adf-config.xml are exported. If there is no cust-config element declared in adf-config.xml, all customization classes are exported.
        To export all customizations, use the option restrictCustTo="%".
      2. If the production application is on a different system, copy the exported metadata to that system.
      3. Import the metadata to the other partition using the WLST importMetadata command:
        importMetadata(application='sampleApp', server='server1',
               fromLocation='/tmp/myrepos/mypartiton', docs='/**')
        
        The value of the fromLocation parameter must be on the same system that is running WLST or on a mapped network drive or directory mount. You cannot use direct network references such as \\mymachine\repositories\.
        Only customization classes declared in the cust-config element of adf-config.xml are imported. If there is no cust-config element declared in adf-config.xml, all customization classes are imported.
        To import all customizations, use the option restrictCustTo="%".

      Monday, December 26, 2011

      Oracle SOA 11.1.1.5 Changing MDS Configuration Attributes for Deployed Applications

      If your application uses an MDS Repository, you can modify configuration attributes after the application is deployed. To view or modify the attributes, you can use the System MBean Browser or WLST.
      To change the MDS configuration attributes of an application, take the following steps:
      1. Navigate to the application's home page by expanding the farm, then Application Deployments. Then, select an application.
        The application's home page is displayed.
      2. From the Application Deployment menu, choose System MBean Browser.
        The System MBean Browser page is displayed.


      3. Expand Application Defined MBeans, then oracle.adf.share.config, then Server: name, then Application: name, then ADFConfig, then ADFConfig, and ADFConfig.
      4. Select MDSAppConfig.
        The Application Defined MBeans page is displayed, as shown in the following figure:


      • To view or modify an attribute, select the attribute.
      • The attribute page is displayed.
      • If the attribute is not read-only, you can change the values. For example, for AutoPurgeTimeToLive, you can change the interval, by entering a new value in Value.
      • Click Apply.
      • Navigate up to ADFConfig (the parent of MDSAppConfig) and select it.
      • In the Operations tab, click Save.
      • Click Invoke.






      How IdP Groups Are Tied to Databricks Groups (Unity Catalog)

        🔗 How IdP Groups Are Tied to Databricks Groups (Unity Catalog) 🔑 Key Principle (Read This First) Databricks does NOT “map” IdP groups...