wsadmin metodo di chiamata script jython nello script

Sep 25 2020

C'è un modo per chiamare funzioni specifiche in uno script jython tramite il programma wsadmin?

# BusAndBusMemeber.py

def devCreateBus:
    AdminTask.createSIBus('[-bus intjmsbus -description [SIBus intjmsbus] -busSecurity false]')
    AdminTask.addSIBusMember('[-bus intjmsbus -node ctgNode01 -server MXServer]')
    AdminConfig.save()

def devDeleteBus:
    AdminTask.deleteSIBus('[-bus intjmsbus]')
    AdminConfig.save()

dal prompt cmd del server:

C: \ IBM \ WebSphere .... \ bin> wsadmin -conntype SOAP -user myUsername -password myPassword -lang jython -f BusAndBusMember.py devCreateBus

O

C: \ IBM \ WebSphere .... \ bin> wsadmin -conntype SOAP -user myUsername -password myPassword -lang jython -f BusAndBusMember.py [devCreateBus]

finora l'unico modo in cui sono stato in grado di eseguire lo script jython è semplicemente scrivere gli AdminTasks.

Grazie.

Risposte

1 covener Sep 25 2020 at 21:32

È un po 'un trucco ma puoi aggiungerlo al tuo script:

globals()[sys.argv[0]]()

Un'alternativa è mantenere le tue funzioni in questo file e scrivere un secondo script Python che fa la logica di quali funzioni chiamare:

import sys
execfile("BusAndBusMemeber.py")
if sys.argv[0] == "devCreateBus":
  devCreateBus();
else:
  print("Unknown arg %s" % sys.argv[0])
1 ScottKurz Sep 25 2020 at 22:16

Puoi anche combinare le opzioni -profilee -ccome:

.wsadmin.sh -profile "functions.py" -c "print devCreateBus ()"

Continuerà a funzionare attraverso l'intero script -profile quindi probabilmente vuoi solo funzioni lì non un "main".