用于监视 Webshpere 中的管理控制台属性的 Python 脚本

发布于 2024-12-10 22:04:06 字数 191 浏览 3 评论 0原文

我需要用 Python 或 JACL 脚本编写脚本,在其中需要监视远程服务器上运行的应用程序的管理控制台并从中提取信息。我需要提取以下信息:

  • jdbc
  • jms
  • web 容器线程
  • 默认工作管理器线程。

如果有人能帮助我编写这个脚本,我将不胜感激。 谢谢

I've a requirement for writing a script in Python or JACL script in which I need to monitor and pull the information from Admin Console of the application running on remote server. I require to pull following information:

  • jdbc
  • jms
  • web container threads
  • default work manager threads.

If anyone can help me writing this script, it'll be highly appreciated.
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

望笑 2024-12-17 22:04:06

创建一个名为 config.py 的文件并将以下内容粘贴到其中。

#
## Récupération du fichier de config à partir des paramètres du script
#
import sys
if (len(sys.argv) > 0):
configFile = sys.argv[0]
else:
configFile = 'F:\config.xml'

#
### Variables d'environnement du script
#
server = AdminControl.queryNames('node='+AdminControl.getNode( )+',type=Server,*')
serverName = AdminControl.getAttribute(server, "name")
nodeName = AdminControl.getNode( )
cellName = AdminControl.getCell( )

# scope à remplacer par cluster=clusterName lorsqu'applicable??
scope = ' -node '+nodeName+' -server '+serverName
scopeAlt = ' -scope Node='+nodeName+',Server='+serverName
scopeConfig =       'server(cells/'+cellName+'/nodes/'+nodeName+'/servers/'+serverName+'|server.xml)'
scopeResources = 'cells/'+cellName+'/nodes/'+nodeName+'/servers/'+serverName+'|resources.xml'
authPrefix = nodeName


#
### Fonctions utilitaires
#
def getAttributeD(xmlElement, name, default):
if xmlElement.hasAttribute(name):
    return xmlElement.getAttribute(name)
return default

def getAttribute(xmlElement, name):
return xmlElement.getAttribute(name)

_regBuses = {}
def addBus(bus):
_regBuses[bus['name']] = bus

def getBus(busName):
return _regBuses[busName]

_regDataProviders = {}
def getDataProviderId(providerName):
if providerName in _regDataProviders.keys():
    return _regDataProviders[providerName]
ps = AdminJDBC.listJDBCProviders(providerName)
if len(ps) > 0:
    p = ps[0]
else:
    print("JDBC Provider non trouve : " + providerName)
    p = providerName
_regDataProviders[providerName] = p
return p

#
### Lecture du fichier de config
#
print('Lecture du fichier de config : ' + configFile)
import javax.xml.parsers.DocumentBuilderFactory as DocumentBuilderFactory
dbf = DocumentBuilderFactory.newInstance()
db = dbf.newDocumentBuilder()
document = db.parse(configFile)
config = document.getDocumentElement()


#
### JVM properties
#
jvm = AdminConfig.list('JavaVirtualMachine')
props = config.getElementsByTagName('property')
for i in range(props.getLength()):
xmle = props.item(i)
propName = getAttribute(xmle, 'name')
propValue = getAttribute(xmle, 'value')
propDesc = getAttributeD(xmle, 'description', '')
propRequired = getAttributeD(xmle, 'required', 'false')
print('Creation de la propriete JVM : ' + propName)
AdminConfig.create('Property', jvm, '[[validationExpression ""] [name "'+propName+'"] [description "'+propDesc+'"] [value "'+propValue+'"] [required "'+propRequired+'"]]')


# 
### Authentication
#
auths = config.getElementsByTagName('authentication')
for i in range(auths.getLength()):
xmle = auths.item(i)
name = getAttribute(xmle, 'name')
user = getAttribute(xmle, 'user')
pwd = getAttribute(xmle, 'password')
desc = getAttributeD(xmle, 'description', '')
print('Creation de l\'authentification : ' + name)
AdminTask.createAuthDataEntry('[-alias '+name+' -user '+user+' -password "'+pwd+'" -  description "'+desc+'" ]')


#
### JDBC Providers
#
providers = config.getElementsByTagName('jdbcProvider')
for i in range(providers.getLength()):
xmle = providers.item(i)
name = getAttribute(xmle, 'name')
shortName = getAttributeD(xmle, 'shortName', name)
dbType = getAttribute(xmle, 'databaseType')
providerType = getAttribute(xmle, 'providerType')
implementationType = getAttribute(xmle,  'implementationType')
classPath = getAttribute(xmle,  'classPath')
nativePath = getAttribute(xmle,  'nativePath')
desc = getAttributeD(xmle,  'description', '')
print('Creation du fournisseur JDBC : ' + name)
AdminTask.createJDBCProvider('['+scopeAlt+' -databaseType '+dbType+' -providerType "'+providerType+'" -implementationType "'+implementationType+'" -name "'+name+'" -description "'+desc+'" -classpath ['+classPath+'] -nativePath ['+nativePath+' ] ]')

#
### JDBC Datasources
#
dss = config.getElementsByTagName('jdbcDataSource')
for i in range(dss.getLength()):
xmle = dss.item(i)
name = getAttribute(xmle, 'name')
jndiName = getAttribute(xmle, 'jndiName')
providerName = getAttribute(xmle, 'jdbcProvider')
auth = getAttribute(xmle, 'authentication')
dbName = getAttribute(xmle, 'database')
dbHost = getAttribute(xmle, 'host')
dbPort = getAttribute(xmle, 'port')
dataStoreHelperClassName = getAttributeD(xmle, 'dataStoreHelperClassName', 'com.ibm.websphere.rsadapter.DB2UniversalDataStoreHelper')
print('Creation de la source de données : ' + name)
providerId = getDataProviderId(providerName)
authX = authPrefix + '/' + auth
AdminTask.createDatasource(providerId, '[-name '+name+' -jndiName '+jndiName+' -  dataStoreHelperClassName '+dataStoreHelperClassName+' -containerManagedPersistence false -componentManagedAuthenticationAlias '+authX+' -xaRecoveryAuthAlias '+authX+' -configureResourceProperties [[databaseName java.lang.String '+dbName+'] [driverType java.lang.Integer 4] [serverName java.lang.String '+dbHost+'] [portNumber java.lang.Integer '+dbPort+']]]')


#   
### Internal & External Buses (JMS)
#
buses = config.getElementsByTagName('internalBus')
for i in range(buses.getLength()):
xmle = buses.item(i)
busName = getAttribute(xmle, 'name')
busDesc = getAttributeD(xmle, 'description', '')
logSize = getAttributeD(xmle, 'logSize', '100')
minStoreSize = getAttributeD(xmle, 'minStoreSize', '200')
maxStoreSize = getAttributeD(xmle, 'minStoreSize', '500')
unlimitedStoreSize = getAttributeD(xmle, 'unlimitedStoreSize', 'false')
print('Creation du bus interne : ' + busName)
AdminTask.createSIBus('[-bus '+busName+' -description ['+busDesc+'] -busSecurity false]')
AdminTask.addSIBusMember('[-bus '+busName+' ' + scope + ' -fileStore  -logSize '+logSize+' -minPermanentStoreSize '+minStoreSize+' -maxPermanentStoreSize '+maxStoreSize+' -unlimitedPermanentStoreSize '+unlimitedStoreSize+' -minTemporaryStoreSize '+minStoreSize+' -maxTemporaryStoreSize '+maxStoreSize+' -unlimitedTemporaryStoreSize '+unlimitedStoreSize+' ]')
bus = {}
bus['name'] = busName
bus['type'] = 'internal'
addBus(bus)


buses = config.getElementsByTagName('externalBus')
for i in range(buses.getLength()):
xmle = buses.item(i)
bus = {}
busName = getAttribute(xmle, 'name')
print('Creation du bus externe : ' + busName)
bus['name'] = busName
bus['type'] = 'external'
bus['manager'] = getAttribute(xmle, 'manager')
bus['host'] = getAttribute(xmle, 'host')
bus['port'] = getAttribute(xmle, 'port')
bus['channel'] = getAttribute(xmle, 'channel')
addBus(bus)


#
### JMS Connections Factories
#
wmqRes = '"WebSphere MQ JMS Provider('+scopeResources+'#builtin_mqprovider)"'
cfs = config.getElementsByTagName('jmsConnectionFactory')
for i in range(cfs.getLength()):
xmle = cfs.item(i)
busName = getAttribute(xmle, 'bus')
jmsType = getAttribute(xmle, 'jmsType')
cfName = getAttribute(xmle, 'name')
cfJndiName = getAttribute(xmle, 'jndiName')
cfDesc = getAttributeD(xmle, 'description', '')
nonPersistentMapping=getAttributeD(xmle, 'nonPersistentMapping', 'ExpressNonPersistent')
persistentMapping=getAttributeD(xmle, 'persistentMapping', 'ReliablePersistent')
wmqTransportType=getAttributeD(xmle, 'wmqTransportType', 'BINDINGS_THEN_CLIENT')
print('Creation de la fabrique de connection jms : ' + cfName)
bus = getBus(busName)
if bus['type'] == 'internal':
    AdminTask.createSIBJMSConnectionFactory(scopeConfig, '[-type '+jmsType+' -name '+cfName+' -jndiName '+cfJndiName+' -description "'+cfDesc+'" -category  -busName '+busName+' -nonPersistentMapping '+nonPersistentMapping+' -readAhead Default -tempQueueNamePrefix  -target  -targetType BusMember -targetSignificance Preferred -targetTransportChain  -providerEndPoints  -connectionProximity Bus -authDataAlias  -containerAuthAlias  -mappingAlias  -shareDataSourceWithCMP false -logMissingTransactionContext false -manageCachedHandles false -xaRecoveryAuthAlias  -persistentMapping '+persistentMapping+' -consumerDoesNotModifyPayloadAfterGet false -producerDoesNotModifyPayloadAfterSet false]')
else:
    if jmsType == 'topic':
        cfType = 'TCF'
    else:
        cfType = 'TCF'
    AdminTask.createWMQConnectionFactory(wmqRes, '[-type '+cfType+' -name '+cfName+' -jndiName '+cfJndiName+' -description "'+cfDesc+'" -qmgrName ' +bus['manager']+ ' -wmqTransportType '+wmqTransportType+' -qmgrHostname '+bus['host']+' -qmgrPortNumber '+bus['port']+' -qmgrSvrconnChannel '+bus['channel']+' ]')


#
### Destinations JMS
#
dests = config.getElementsByTagName('jmsDestination')
for i in range(dests.getLength()):
xmle = dests.item(i)
busName = getAttribute(xmle, 'bus')
jmsType = getAttribute(xmle, 'jmsType')
destName = getAttribute(xmle, 'name')
destJndiName = getAttribute(xmle, 'jndiName')
destDest = getAttribute(xmle, 'destination')
destDesc = getAttributeD(xmle, 'description', '')
reliability = getAttributeD(xmle, 'reliability', 'EXPRESS_NONPERSISTENT')
deliveryMode = getAttributeD(xmle, 'deliveryMode', 'NonPersistent')
print('Creation de la destination jms : ' + destName)
bus = getBus(busName)
if bus['type'] == 'internal':
    if jmsType == 'queue':
        sibType = 'Queue'
    elif jmsType == 'topic':
        sibType = 'Topic'
    AdminTask.createSIBDestination('[-bus '+busName+' -name '+destDest+' -type '+sibType+' -reliability '+reliability+' -description "'+destDesc+'" '+scope+' ]')
    if jmsType == 'queue':
        AdminTask.createSIBJMSQueue(scopeConfig, '[-name '+destName+' -jndiName '+destJndiName+' -description "'+destDesc+'" -deliveryMode '+deliveryMode+' -readAhead AsConnection -busName '+busName+' -queueName '+destDest+' -scopeToLocalQP false -producerBind false -producerPreferLocal true -gatherMessages false]')
    elif jmsType == 'topic':
        AdminTask.createSIBJMSTopic(scopeConfig, '[-name '+destName+' -jndiName '+destJndiName+' -description "'+destDesc+'" -topicName -deliveryMode '+deliveryMode+' -readAhead AsConnection -busName '+busName+' -topicSpace '+destDest+']')
else:
    if jmsType == 'queue':
        AdminTask.createWMQQueue(scopeConfig, '[-name '+destName+' -jndiName '+destJndiName+' -queueName '+destDest+' -qmgr  -description "'+destDesc+'" ]')
    elif jmsType == 'topic':
        AdminTask.createWMQTopic(scopeConfig, '[-name '+destName+' -jndiName '+destJndiName+' -topicName '+destDest+' -description "'+destDesc+'" ]')


#
### JMS Activation Specs
#
wmqRes = '"WebSphere MQ JMS Provider('+scopeResources+'#builtin_mqprovider)"'
specs = config.getElementsByTagName('jmsActivationSpec')
for i in range(specs.getLength()):
xmle = specs.item(i)
busName = getAttribute(xmle, 'bus')
specName = getAttribute(xmle, 'name')
specJndiName = getAttribute(xmle, 'jndiName')
jmsType = getAttribute(xmle, 'jmsType')
destJndiName = getAttribute(xmle, 'jndiDestinationName')
specDesc = getAttributeD(xmle, 'description', '')
maxHandlers = getAttributeD(xmle, 'maxHandlers', '4')
wmqTransportType=getAttributeD(xmle, 'wmqTransportType', 'BINDINGS_THEN_CLIENT')
print('Creation de la spec d\'activation jms : ' + specName)
if jmsType == 'queue':
    jmsDestClass = 'Queue'
elif jmsType == 'topic':
    jmsDestClass = 'Topic'
bus = getBus(busName)
if bus['type'] == 'internal':
    AdminTask.createSIBJMSActivationSpec(scopeConfig, '[-name '+specName+' -   jndiName '+specJndiName+' -destinationJndiName '+destJndiName+' -description "'+specDesc+'" -busName '+busName+' -clientId  -durableSubscriptionHome  -destinationType javax.jms.'+jmsDestClass+' -messageSelector  -acknowledgeMode Auto-acknowledge -subscriptionName  -maxBatchSize 1 -maxConcurrency '+maxHandlers+' -subscriptionDurability NonDurable -shareDurableSubscriptions InCluster -authenticationAlias  -readAhead Default -target  -targetType BusMember -targetSignificance Preferred -targetTransportChain  -providerEndPoints  -shareDataSourceWithCMP false -consumerDoesNotModifyPayloadAfterGet false -forwarderDoesNotModifyPayloadAfterSet false -alwaysActivateAllMDBs false -retryInterval 30 -autoStopSequentialMessageFailure 0 -failingMessageDelay 0]')
else:
    AdminTask.createWMQActivationSpec(wmqRes, '[-name '+specName+' -jndiName '+specJndiName+' -description "'+specDesc+'" -destinationJndiName '+destJndiName+' -destinationType javax.jms.'+jmsDestClass+' -qmgrName '+bus['manager']+' -wmqTransportType '+wmqTransportType+' -qmgrHostname '+bus['host']+' -qmgrPortNumber '+bus['port']+' -qmgrSvrconnChannel '+bus['channel']+' ]')



AdminConfig.save()

然后将此代码复制到名为 config.xml 的文件中。

<?xml version="1.0" encoding="UTF-8"?>

<config>

<!-- Definition des propriétés JVM -->
<property 
    name="someproperty" 
    value="myvalue" 
/>
<property 
    description="Different jvm properties"
    name="myproperty" 
    value="true" 
/>

<!-- Définition des sources d'authentification  -->
<authentication
    description="Authentification pour accès DB"
    name="auth"
    user="dbuser"
    password="dbuser"
/>


<!-- Définition des fournisseurs JDBC -->
<jdbcProvider
    description="One-phase commit DB2 JCC provider that supports JDBC 3.0."
    shortName="DB2"
    name="DB2 Universal JDBC Driver Provider"
    databaseType="DB2"
    providerType="DB2 Universal JDBC Driver Provider"
    implementationType="Source de données du pool de connexions"
    classPath="${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc.jar ${UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cu.jar ${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cisuz.jar"
    nativePath="${DB2UNIVERSAL_JDBC_DRIVER_NATIVEPATH}"
/>
<jdbcProvider
    description="Two-phase commit DB2 JCC provider that supports JDBC 3.0."
    shortName="DB2(XA)"
    name="DB2 Universal JDBC Driver Provider (XA)"
    databaseType="DB2"
    providerType="DB2 Universal JDBC Driver Provider"
    implementationType="Source de données XA"
    classPath="${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc.jar ${UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cu.jar ${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cisuz.jar"
    nativePath="${DB2UNIVERSAL_JDBC_DRIVER_NATIVEPATH}"
/>


<!-- Définition des sources de données JDBC --> 
<jdbcDataSource
    description="Sources de données des Demandes"
    name="db_name"
    jndiName="jdbc/db_name"
    jdbcProvider="DB2 Universal JDBC Driver Provider (XA)"
    authentication="auth"
    database="DB2XXXXX"
    host="hostname"
    port="00000"
/>


<!-- Définition des bus internes -->
<internalBus 
    description="Bus Interne"
    name="BusInterne" 
/>

<!-- Définition des bus externes -->
<externalBus 
    description="Serveur Websphere MQ externe"
    name="ServeurMQ" 
    manager="Manager" 
    host="host" 
    port="1414" 
    channel="CLIENT.NAME"
/>

<!-- Définition des Fabriques de Connexions JMS-->
<jmsConnectionFactory 
    description="Queue de rafraichissement des demandes"
    name="QCF" 
    jndiName="jms/QCF" 
    jmsType="queue" 
    bus='BusInterne' 
/>
<jmsConnectionFactory 
    description="Topic "
    name="TCF" 
    jndiName="jms/TCF" 
    jmsType="topic" 
    bus='ServeurMQ' 
/>

<!-- Définition des Destinations JMS -->
<jmsDestination 
    description="Queue "
    name="queue" 
    jndiName="jms/queue" 
    jmsType="queue" 
    bus='BusInterne' 
    destination="Q.NAME" 
/>
<jmsDestination 
    description="Topic 2"
    name="topic2" 
    jndiName="topic2" 
    jmsType="topic" 
    bus='ServeurMQ' 
    destination="Q.TOPIC.NAME" 
/>

<!-- Définition des Spécifications d'Activation JMS -->
<jmsActivationSpec 
    description="Spec"
    name="Specs" 
    jndiName="jms/Specs" 
    jmsType="queue" 
    bus='BusInterne' 
    jndiDestinationName="jms/queue" 
    maxHandlers="4" 
/>

</config>

在 config.xml 文件中定义所有资源后,只需调用以下命令
从命令提示符。确保您有权访问 wsadmin。

wsadmin -lang jython -profileName MyProfile -f config.py config.xml

这会将您的所有资源创建到名为 MyProfile 的配置文件中。

希望有帮助。

Create a file called config.py and paste the follwing into it.

#
## Récupération du fichier de config à partir des paramètres du script
#
import sys
if (len(sys.argv) > 0):
configFile = sys.argv[0]
else:
configFile = 'F:\config.xml'

#
### Variables d'environnement du script
#
server = AdminControl.queryNames('node='+AdminControl.getNode( )+',type=Server,*')
serverName = AdminControl.getAttribute(server, "name")
nodeName = AdminControl.getNode( )
cellName = AdminControl.getCell( )

# scope à remplacer par cluster=clusterName lorsqu'applicable??
scope = ' -node '+nodeName+' -server '+serverName
scopeAlt = ' -scope Node='+nodeName+',Server='+serverName
scopeConfig =       'server(cells/'+cellName+'/nodes/'+nodeName+'/servers/'+serverName+'|server.xml)'
scopeResources = 'cells/'+cellName+'/nodes/'+nodeName+'/servers/'+serverName+'|resources.xml'
authPrefix = nodeName


#
### Fonctions utilitaires
#
def getAttributeD(xmlElement, name, default):
if xmlElement.hasAttribute(name):
    return xmlElement.getAttribute(name)
return default

def getAttribute(xmlElement, name):
return xmlElement.getAttribute(name)

_regBuses = {}
def addBus(bus):
_regBuses[bus['name']] = bus

def getBus(busName):
return _regBuses[busName]

_regDataProviders = {}
def getDataProviderId(providerName):
if providerName in _regDataProviders.keys():
    return _regDataProviders[providerName]
ps = AdminJDBC.listJDBCProviders(providerName)
if len(ps) > 0:
    p = ps[0]
else:
    print("JDBC Provider non trouve : " + providerName)
    p = providerName
_regDataProviders[providerName] = p
return p

#
### Lecture du fichier de config
#
print('Lecture du fichier de config : ' + configFile)
import javax.xml.parsers.DocumentBuilderFactory as DocumentBuilderFactory
dbf = DocumentBuilderFactory.newInstance()
db = dbf.newDocumentBuilder()
document = db.parse(configFile)
config = document.getDocumentElement()


#
### JVM properties
#
jvm = AdminConfig.list('JavaVirtualMachine')
props = config.getElementsByTagName('property')
for i in range(props.getLength()):
xmle = props.item(i)
propName = getAttribute(xmle, 'name')
propValue = getAttribute(xmle, 'value')
propDesc = getAttributeD(xmle, 'description', '')
propRequired = getAttributeD(xmle, 'required', 'false')
print('Creation de la propriete JVM : ' + propName)
AdminConfig.create('Property', jvm, '[[validationExpression ""] [name "'+propName+'"] [description "'+propDesc+'"] [value "'+propValue+'"] [required "'+propRequired+'"]]')


# 
### Authentication
#
auths = config.getElementsByTagName('authentication')
for i in range(auths.getLength()):
xmle = auths.item(i)
name = getAttribute(xmle, 'name')
user = getAttribute(xmle, 'user')
pwd = getAttribute(xmle, 'password')
desc = getAttributeD(xmle, 'description', '')
print('Creation de l\'authentification : ' + name)
AdminTask.createAuthDataEntry('[-alias '+name+' -user '+user+' -password "'+pwd+'" -  description "'+desc+'" ]')


#
### JDBC Providers
#
providers = config.getElementsByTagName('jdbcProvider')
for i in range(providers.getLength()):
xmle = providers.item(i)
name = getAttribute(xmle, 'name')
shortName = getAttributeD(xmle, 'shortName', name)
dbType = getAttribute(xmle, 'databaseType')
providerType = getAttribute(xmle, 'providerType')
implementationType = getAttribute(xmle,  'implementationType')
classPath = getAttribute(xmle,  'classPath')
nativePath = getAttribute(xmle,  'nativePath')
desc = getAttributeD(xmle,  'description', '')
print('Creation du fournisseur JDBC : ' + name)
AdminTask.createJDBCProvider('['+scopeAlt+' -databaseType '+dbType+' -providerType "'+providerType+'" -implementationType "'+implementationType+'" -name "'+name+'" -description "'+desc+'" -classpath ['+classPath+'] -nativePath ['+nativePath+' ] ]')

#
### JDBC Datasources
#
dss = config.getElementsByTagName('jdbcDataSource')
for i in range(dss.getLength()):
xmle = dss.item(i)
name = getAttribute(xmle, 'name')
jndiName = getAttribute(xmle, 'jndiName')
providerName = getAttribute(xmle, 'jdbcProvider')
auth = getAttribute(xmle, 'authentication')
dbName = getAttribute(xmle, 'database')
dbHost = getAttribute(xmle, 'host')
dbPort = getAttribute(xmle, 'port')
dataStoreHelperClassName = getAttributeD(xmle, 'dataStoreHelperClassName', 'com.ibm.websphere.rsadapter.DB2UniversalDataStoreHelper')
print('Creation de la source de données : ' + name)
providerId = getDataProviderId(providerName)
authX = authPrefix + '/' + auth
AdminTask.createDatasource(providerId, '[-name '+name+' -jndiName '+jndiName+' -  dataStoreHelperClassName '+dataStoreHelperClassName+' -containerManagedPersistence false -componentManagedAuthenticationAlias '+authX+' -xaRecoveryAuthAlias '+authX+' -configureResourceProperties [[databaseName java.lang.String '+dbName+'] [driverType java.lang.Integer 4] [serverName java.lang.String '+dbHost+'] [portNumber java.lang.Integer '+dbPort+']]]')


#   
### Internal & External Buses (JMS)
#
buses = config.getElementsByTagName('internalBus')
for i in range(buses.getLength()):
xmle = buses.item(i)
busName = getAttribute(xmle, 'name')
busDesc = getAttributeD(xmle, 'description', '')
logSize = getAttributeD(xmle, 'logSize', '100')
minStoreSize = getAttributeD(xmle, 'minStoreSize', '200')
maxStoreSize = getAttributeD(xmle, 'minStoreSize', '500')
unlimitedStoreSize = getAttributeD(xmle, 'unlimitedStoreSize', 'false')
print('Creation du bus interne : ' + busName)
AdminTask.createSIBus('[-bus '+busName+' -description ['+busDesc+'] -busSecurity false]')
AdminTask.addSIBusMember('[-bus '+busName+' ' + scope + ' -fileStore  -logSize '+logSize+' -minPermanentStoreSize '+minStoreSize+' -maxPermanentStoreSize '+maxStoreSize+' -unlimitedPermanentStoreSize '+unlimitedStoreSize+' -minTemporaryStoreSize '+minStoreSize+' -maxTemporaryStoreSize '+maxStoreSize+' -unlimitedTemporaryStoreSize '+unlimitedStoreSize+' ]')
bus = {}
bus['name'] = busName
bus['type'] = 'internal'
addBus(bus)


buses = config.getElementsByTagName('externalBus')
for i in range(buses.getLength()):
xmle = buses.item(i)
bus = {}
busName = getAttribute(xmle, 'name')
print('Creation du bus externe : ' + busName)
bus['name'] = busName
bus['type'] = 'external'
bus['manager'] = getAttribute(xmle, 'manager')
bus['host'] = getAttribute(xmle, 'host')
bus['port'] = getAttribute(xmle, 'port')
bus['channel'] = getAttribute(xmle, 'channel')
addBus(bus)


#
### JMS Connections Factories
#
wmqRes = '"WebSphere MQ JMS Provider('+scopeResources+'#builtin_mqprovider)"'
cfs = config.getElementsByTagName('jmsConnectionFactory')
for i in range(cfs.getLength()):
xmle = cfs.item(i)
busName = getAttribute(xmle, 'bus')
jmsType = getAttribute(xmle, 'jmsType')
cfName = getAttribute(xmle, 'name')
cfJndiName = getAttribute(xmle, 'jndiName')
cfDesc = getAttributeD(xmle, 'description', '')
nonPersistentMapping=getAttributeD(xmle, 'nonPersistentMapping', 'ExpressNonPersistent')
persistentMapping=getAttributeD(xmle, 'persistentMapping', 'ReliablePersistent')
wmqTransportType=getAttributeD(xmle, 'wmqTransportType', 'BINDINGS_THEN_CLIENT')
print('Creation de la fabrique de connection jms : ' + cfName)
bus = getBus(busName)
if bus['type'] == 'internal':
    AdminTask.createSIBJMSConnectionFactory(scopeConfig, '[-type '+jmsType+' -name '+cfName+' -jndiName '+cfJndiName+' -description "'+cfDesc+'" -category  -busName '+busName+' -nonPersistentMapping '+nonPersistentMapping+' -readAhead Default -tempQueueNamePrefix  -target  -targetType BusMember -targetSignificance Preferred -targetTransportChain  -providerEndPoints  -connectionProximity Bus -authDataAlias  -containerAuthAlias  -mappingAlias  -shareDataSourceWithCMP false -logMissingTransactionContext false -manageCachedHandles false -xaRecoveryAuthAlias  -persistentMapping '+persistentMapping+' -consumerDoesNotModifyPayloadAfterGet false -producerDoesNotModifyPayloadAfterSet false]')
else:
    if jmsType == 'topic':
        cfType = 'TCF'
    else:
        cfType = 'TCF'
    AdminTask.createWMQConnectionFactory(wmqRes, '[-type '+cfType+' -name '+cfName+' -jndiName '+cfJndiName+' -description "'+cfDesc+'" -qmgrName ' +bus['manager']+ ' -wmqTransportType '+wmqTransportType+' -qmgrHostname '+bus['host']+' -qmgrPortNumber '+bus['port']+' -qmgrSvrconnChannel '+bus['channel']+' ]')


#
### Destinations JMS
#
dests = config.getElementsByTagName('jmsDestination')
for i in range(dests.getLength()):
xmle = dests.item(i)
busName = getAttribute(xmle, 'bus')
jmsType = getAttribute(xmle, 'jmsType')
destName = getAttribute(xmle, 'name')
destJndiName = getAttribute(xmle, 'jndiName')
destDest = getAttribute(xmle, 'destination')
destDesc = getAttributeD(xmle, 'description', '')
reliability = getAttributeD(xmle, 'reliability', 'EXPRESS_NONPERSISTENT')
deliveryMode = getAttributeD(xmle, 'deliveryMode', 'NonPersistent')
print('Creation de la destination jms : ' + destName)
bus = getBus(busName)
if bus['type'] == 'internal':
    if jmsType == 'queue':
        sibType = 'Queue'
    elif jmsType == 'topic':
        sibType = 'Topic'
    AdminTask.createSIBDestination('[-bus '+busName+' -name '+destDest+' -type '+sibType+' -reliability '+reliability+' -description "'+destDesc+'" '+scope+' ]')
    if jmsType == 'queue':
        AdminTask.createSIBJMSQueue(scopeConfig, '[-name '+destName+' -jndiName '+destJndiName+' -description "'+destDesc+'" -deliveryMode '+deliveryMode+' -readAhead AsConnection -busName '+busName+' -queueName '+destDest+' -scopeToLocalQP false -producerBind false -producerPreferLocal true -gatherMessages false]')
    elif jmsType == 'topic':
        AdminTask.createSIBJMSTopic(scopeConfig, '[-name '+destName+' -jndiName '+destJndiName+' -description "'+destDesc+'" -topicName -deliveryMode '+deliveryMode+' -readAhead AsConnection -busName '+busName+' -topicSpace '+destDest+']')
else:
    if jmsType == 'queue':
        AdminTask.createWMQQueue(scopeConfig, '[-name '+destName+' -jndiName '+destJndiName+' -queueName '+destDest+' -qmgr  -description "'+destDesc+'" ]')
    elif jmsType == 'topic':
        AdminTask.createWMQTopic(scopeConfig, '[-name '+destName+' -jndiName '+destJndiName+' -topicName '+destDest+' -description "'+destDesc+'" ]')


#
### JMS Activation Specs
#
wmqRes = '"WebSphere MQ JMS Provider('+scopeResources+'#builtin_mqprovider)"'
specs = config.getElementsByTagName('jmsActivationSpec')
for i in range(specs.getLength()):
xmle = specs.item(i)
busName = getAttribute(xmle, 'bus')
specName = getAttribute(xmle, 'name')
specJndiName = getAttribute(xmle, 'jndiName')
jmsType = getAttribute(xmle, 'jmsType')
destJndiName = getAttribute(xmle, 'jndiDestinationName')
specDesc = getAttributeD(xmle, 'description', '')
maxHandlers = getAttributeD(xmle, 'maxHandlers', '4')
wmqTransportType=getAttributeD(xmle, 'wmqTransportType', 'BINDINGS_THEN_CLIENT')
print('Creation de la spec d\'activation jms : ' + specName)
if jmsType == 'queue':
    jmsDestClass = 'Queue'
elif jmsType == 'topic':
    jmsDestClass = 'Topic'
bus = getBus(busName)
if bus['type'] == 'internal':
    AdminTask.createSIBJMSActivationSpec(scopeConfig, '[-name '+specName+' -   jndiName '+specJndiName+' -destinationJndiName '+destJndiName+' -description "'+specDesc+'" -busName '+busName+' -clientId  -durableSubscriptionHome  -destinationType javax.jms.'+jmsDestClass+' -messageSelector  -acknowledgeMode Auto-acknowledge -subscriptionName  -maxBatchSize 1 -maxConcurrency '+maxHandlers+' -subscriptionDurability NonDurable -shareDurableSubscriptions InCluster -authenticationAlias  -readAhead Default -target  -targetType BusMember -targetSignificance Preferred -targetTransportChain  -providerEndPoints  -shareDataSourceWithCMP false -consumerDoesNotModifyPayloadAfterGet false -forwarderDoesNotModifyPayloadAfterSet false -alwaysActivateAllMDBs false -retryInterval 30 -autoStopSequentialMessageFailure 0 -failingMessageDelay 0]')
else:
    AdminTask.createWMQActivationSpec(wmqRes, '[-name '+specName+' -jndiName '+specJndiName+' -description "'+specDesc+'" -destinationJndiName '+destJndiName+' -destinationType javax.jms.'+jmsDestClass+' -qmgrName '+bus['manager']+' -wmqTransportType '+wmqTransportType+' -qmgrHostname '+bus['host']+' -qmgrPortNumber '+bus['port']+' -qmgrSvrconnChannel '+bus['channel']+' ]')



AdminConfig.save()

then copy this code in a file called config.xml

<?xml version="1.0" encoding="UTF-8"?>

<config>

<!-- Definition des propriétés JVM -->
<property 
    name="someproperty" 
    value="myvalue" 
/>
<property 
    description="Different jvm properties"
    name="myproperty" 
    value="true" 
/>

<!-- Définition des sources d'authentification  -->
<authentication
    description="Authentification pour accès DB"
    name="auth"
    user="dbuser"
    password="dbuser"
/>


<!-- Définition des fournisseurs JDBC -->
<jdbcProvider
    description="One-phase commit DB2 JCC provider that supports JDBC 3.0."
    shortName="DB2"
    name="DB2 Universal JDBC Driver Provider"
    databaseType="DB2"
    providerType="DB2 Universal JDBC Driver Provider"
    implementationType="Source de données du pool de connexions"
    classPath="${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc.jar ${UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cu.jar ${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cisuz.jar"
    nativePath="${DB2UNIVERSAL_JDBC_DRIVER_NATIVEPATH}"
/>
<jdbcProvider
    description="Two-phase commit DB2 JCC provider that supports JDBC 3.0."
    shortName="DB2(XA)"
    name="DB2 Universal JDBC Driver Provider (XA)"
    databaseType="DB2"
    providerType="DB2 Universal JDBC Driver Provider"
    implementationType="Source de données XA"
    classPath="${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc.jar ${UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cu.jar ${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cisuz.jar"
    nativePath="${DB2UNIVERSAL_JDBC_DRIVER_NATIVEPATH}"
/>


<!-- Définition des sources de données JDBC --> 
<jdbcDataSource
    description="Sources de données des Demandes"
    name="db_name"
    jndiName="jdbc/db_name"
    jdbcProvider="DB2 Universal JDBC Driver Provider (XA)"
    authentication="auth"
    database="DB2XXXXX"
    host="hostname"
    port="00000"
/>


<!-- Définition des bus internes -->
<internalBus 
    description="Bus Interne"
    name="BusInterne" 
/>

<!-- Définition des bus externes -->
<externalBus 
    description="Serveur Websphere MQ externe"
    name="ServeurMQ" 
    manager="Manager" 
    host="host" 
    port="1414" 
    channel="CLIENT.NAME"
/>

<!-- Définition des Fabriques de Connexions JMS-->
<jmsConnectionFactory 
    description="Queue de rafraichissement des demandes"
    name="QCF" 
    jndiName="jms/QCF" 
    jmsType="queue" 
    bus='BusInterne' 
/>
<jmsConnectionFactory 
    description="Topic "
    name="TCF" 
    jndiName="jms/TCF" 
    jmsType="topic" 
    bus='ServeurMQ' 
/>

<!-- Définition des Destinations JMS -->
<jmsDestination 
    description="Queue "
    name="queue" 
    jndiName="jms/queue" 
    jmsType="queue" 
    bus='BusInterne' 
    destination="Q.NAME" 
/>
<jmsDestination 
    description="Topic 2"
    name="topic2" 
    jndiName="topic2" 
    jmsType="topic" 
    bus='ServeurMQ' 
    destination="Q.TOPIC.NAME" 
/>

<!-- Définition des Spécifications d'Activation JMS -->
<jmsActivationSpec 
    description="Spec"
    name="Specs" 
    jndiName="jms/Specs" 
    jmsType="queue" 
    bus='BusInterne' 
    jndiDestinationName="jms/queue" 
    maxHandlers="4" 
/>

</config>

After all of the resources defined in the config.xml file, simply call the following
from a command prompt. Make sure you have access to wsadmin.

wsadmin -lang jython -profileName MyProfile -f config.py config.xml

This will create all your resources into a profile called MyProfile.

Hope it helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文