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の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>
というファイルにこのコードをコピーしてください。 wsadminにアクセスできることを確認してください。
wsadmin -lang jython -profileName MyProfile -f config.py config.xml
これにより、すべてのリソースがMyProfileという名前のプロファイルに作成されます。
希望します。