-
1. Re: Using CLI from jython
rodakr May 10, 2012 9:35 AM (in response to rodakr)... looks like I have to answer to myself :-)
The answer is yes.
Here small example howto
import sys
import org.jboss.as.cli.CommandContextFactory
# let's try to connect to jboss..
def connectAS7(host,port):
ctx = org.jboss.as.cli.CommandContextFactory.getInstance().newCommandContext()
ctx.handleSafe("connect "+host+":"+port);
return ctx
host = "localhost"
port = "9999"
ctx = connectAS7(host,port)
connectStatus = ctx.getExitCode()
if connectStatus != 0:
print "failed to connect to "+host+":"+port+" exit code is"+connectStatus+" , check if jboss is running!"
else:
print "successfully conected to "+host+":"+port
ctx.handle("ls")
To output should be something like this:
10.05.2012 15:04:40 org.xnio.Xnio <clinit>
INFO: XNIO Version 3.0.3.GA-redhat-1
10.05.2012 15:04:40 org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.0.3.GA-redhat-1
10.05.2012 15:04:40 org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 3.2.2.GA-redhat-1
successfully conected to localhost:9999
core-service
deployment
extension
interface
path
socket-binding-group
subsystem
system-property
launch-type=STANDALONE
management-major-version=1
management-minor-version=0
name=cl0037
namespaces=[]
process-type=Server
product-name=EAP
product-version=6.0.0.Beta1
profile-name=undefined
release-codename=Thunder
release-version=7.1.0.Final-redhat-1
running-mode=NORMAL
schema-locations=[]
server-state=running
P.S:
Make shure JBOSS_HOME is set in environment and you have some jar files from jboss modules in your jython CLASSPATH