Sunday, August 5, 2012

Useful WLST

not very elegant.... just a copy/paste of what is generated by the Record utility in WLS console...

#Variable declaration

username='weblogic'
password='weblogic1'
serverurl='t3://myhost:7101'

clustername='osbdv2cl'

#Connect with WLST to Admin

cd /opt/oracle/domains/osbdv2do
. ./bin/setDomainEnv.sh
java weblogic.WLST
connect(username, password, serverurl)

#create DataSource (non-RAC, no XA, no LLR)

datasource='JMSPerfTestDataSource'
datasource_jndi='jdbc.JMSPerfTestDataSource'
datasource_url='jdbc:oracle:thin:@dbhost.com:1551:dosb01'
datasource_driver='oracle.jdbc.OracleDriver'
datasource_username='dv1_soainfra'
datasource_password='dv1_pippo'

edit()
startEdit()

cmo.createJDBCSystemResource(datasource)
cd('/JDBCSystemResources/' + datasource + '/JDBCResource/' + datasource)
cmo.setName(datasource)
cd('/JDBCSystemResources/' + datasource + '/JDBCResource/' + datasource + '/JDBCDataSourceParams/' + datasource)
set('JNDINames',jarray.array([String(datasource_jndi)], String))
cd('/JDBCSystemResources/' + datasource + '/JDBCResource/' + datasource + '/JDBCDriverParams/' + datasource)
cmo.setUrl(datasource_url)
cmo.setDriverName(datasource_driver)
cmo.setPassword(datasource_password)

cd('/JDBCSystemResources/' + datasource + '/JDBCResource/' + datasource + '/JDBCConnectionPoolParams/' + datasource)
cmo.setTestTableName('SQL SELECT 1 FROM DUAL')
cd('/JDBCSystemResources/' + datasource + '/JDBCResource/' + datasource + '/JDBCDriverParams/' + datasource + '/Properties/' + datasource + '')

cmo.createProperty('user')
cd('/JDBCSystemResources/' + datasource + '/JDBCResource/' + datasource + '/JDBCDriverParams/' + datasource + '/Properties/' + datasource + '/Properties/user')
cmo.setValue(datasource_username)
cd('/JDBCSystemResources/' + datasource + '/JDBCResource/' + datasource + '/JDBCDataSourceParams/' + datasource)
cmo.setGlobalTransactionsProtocol('None')
cd('/SystemResources/' + datasource)
set('Targets',jarray.array([ObjectName('com.bea:Name=' + clustername + ',Type=Cluster')], ObjectName))

save()
activate()

#create File Store

filestore_name='LocalJMSPerfTestFileStore'
filestore_target='osbdv2ms1 (migratable)'
filestore_directory='/opt/oracle/domains/osbdv2do/servers/osbdv2ms1/data/store'

edit()
startEdit()

cd('/')
cmo.createFileStore(filestore_name)
cd('/FileStores/' + filestore_name)
cmo.setDirectory(filestore_directory)
set('Targets',jarray.array([ObjectName('com.bea:Name=' + filestore_target + ',Type=MigratableTarget')], ObjectName))

save()
activate()

#create JDBC Store

jdbcstore_name='JDBCStoreJMSPerfTest'
jdbcstore_datasource='JMSPerfTestDataSource'
jdbcstore_prefix='JMSPerfTest'
jdbcstore_target='osbdv2ms1 (migratable)'

edit()
startEdit()

cd('/')
cmo.createJDBCStore(jdbcstore_name)
cd('/JDBCStores/'+ jdbcstore_name)
cmo.setDataSource(getMBean('/SystemResources/' + jdbcstore_datasource))
cmo.setPrefixName(jdbcstore_prefix)
set('Targets',jarray.array([ObjectName('com.bea:Name=' + jdbcstore_target + ',Type=MigratableTarget')], ObjectName))

save()
activate()

#create JMS Server

cmo.createJMSServer('JMSServerPerfTest')
cd('/Deployments/JMSServerPerfTest')
cmo.setPersistentStore(getMBean('/FileStores/LocalPerfTestFileStore'))
set('Targets',jarray.array([ObjectName('com.bea:Name=osbdv2ms1,Type=Server')], ObjectName))

#create JMS Module

cd('/')
cmo.createJMSSystemResource('JMSPerfTestModule')
cd('/SystemResources/JMSPerfTestModule')
set('Targets',jarray.array([ObjectName('com.bea:Name=osbdv2cl,Type=Cluster')], ObjectName))
#create JMS SubDeployment

cmo.createSubDeployment('JMSPerfTestSD')
cd('/SystemResources/JMSPerfTestModule/SubDeployments/JMSPerfTestSD')

set('Targets',jarray.array([ObjectName('com.bea:Name=PippoCommonJmsServer1,Type=JMSServer')], ObjectName))

#create JMS Distributed Queue

cd('/JMSSystemResources/JMSPerfTestModule/JMSResource/JMSPerfTestModule')
cmo.createUniformDistributedQueue('JMSPerfDQueue')
cd('/JMSSystemResources/JMSPerfTestModule/JMSResource/JMSPerfTestModule/UniformDistributedQueues/JMSPerfDQueue')
cmo.setJNDIName('jms.JMSPerfDQueue')
cmo.setDefaultTargetingEnabled(true)
cmo.unSet('Template')
cmo.setLoadBalancingPolicy('Round-Robin')
cmo.setResetDeliveryCountOnForward(true)
cmo.setIncompleteWorkExpirationTime(-1)
cmo.setForwardDelay(-1)
cmo.setAttachSender('supports')
cmo.setSAFExportPolicy('All')
cmo.setProductionPausedAtStartup(false)
cmo.setDefaultUnitOfOrder(false)
cmo.setDefaultTargetingEnabled(false)
cmo.setUnitOfOrderRouting('Hash')
cmo.setUnitOfWorkHandlingPolicy('PassThrough')
cmo.setInsertionPausedAtStartup(false)
cmo.setMessagingPerformancePreference(25)
cmo.setConsumptionPausedAtStartup(false)

#assign SubDeployment

cmo.setSubDeploymentName('JMSPerfTestSD')

save()
activate()

No comments: