#!/usr/bin/python
# createManagedServer.py
import time
import getopt
import sys
import re
# Obtenemos la ubicacion del archivo de propiedades.
properties = ''
try:
opts, args = getopt.getopt(sys.argv[1:],"p:h::",["properies="])
except getopt.GetoptError:
print 'createManagedServer.py -p '
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print 'createManagedServer.py -p '
sys.exit()
elif opt in ("-p", "--properties"):
properties = arg
print 'properties=', properties
# Cargamos el archivo de propiedades.
from java.io import FileInputStream
propInputStream = FileInputStream(properties)
configProps = Properties()
configProps.load(propInputStream)
# Seteamos las variables con sus respectivos valores.
adminUsername=configProps.get("admin.username")
adminPassword=configProps.get("admin.password")
adminURL=configProps.get("admin.url")
msName=configProps.get("ms.name")
msAddress=configProps.get("ms.address")
msPort=configProps.get("ms.port")
msCluster=configProps.get("ms.cluster")
msSSLPort=configProps.get("ms.sslport")
msMachine=configProps.get("ms.machine")
# mostramos los valores de las variables.
print 'adminUsername=', adminUsername
print 'adminPassword=', adminPassword
print 'adminURL=', adminURL
print 'msName=', msName
print 'msAddress=', msAddress
print 'msPort=', msPort
print 'msMachine=', msMachine
# Nos conectamos al AdminServer.
connect(adminUsername, adminPassword, adminURL)
edit()
startEdit()
# Creamos el managed Server.
cd('/')
cmo.createServer(msName)
cd('/Servers/' + msName)
cmo.setListenAddress(msAddress)
cmo.setListenPort(int(msPort))
# Salida stdout / stderr.
cd('/Servers/' + msName + '/Log/' + msName)
cmo.setRedirectStderrToServerLogEnabled(true)
cmo.setRedirectStdoutToServerLogEnabled(true)
cmo.setMemoryBufferSeverity('Debug')
# Asociamos el Manejado a una maquina.
cd('/Servers/' + msName)
cmo.setMachine(getMBean('/Machines/' + msMachine))
# logging de Managed Server.
cd('/Servers/' + msName + '/Log/' + msName)
cmo.setRotationType('byTime')
cmo.setFileCount(30)
cmo.setRedirectStderrToServerLogEnabled(true)
cmo.setRedirectStdoutToServerLogEnabled(true)
cmo.setMemoryBufferSeverity('Debug')
cmo.setLogFileSeverity('Notice')
save()
activate()
disconnect()
exit()