Date Created: Thu 19-Feb-2009

Related Document Categories:


    Advanced listing of Server using Jython in WebSphere 7

    def convertToList( inlist ):
    outlist = []
    if (len(inlist) > 0):
    if (inlist[0] == '[' and inlist[len(inlist) - 1] == ']'):
    # Special checking when the config name contain space
    if (inlist[1] == "\"" and inlist[len(inlist)-2] == "\""):
    clist = inlist[1:len(inlist) -1].split(")\" ")
    else:
    clist = inlist[1:len(inlist) - 1].split(" ")
    #endIf
    else:
    clist = inlist.split(java.lang.System.getProperty("line.separator"))
    #endIf

    for elem in clist:
    elem = elem.rstrip();
    if (len(elem) > 0):
    if (elem[0] == "\"" and elem[len(elem) -1] != "\""):
    elem = elem+")\""
    #endIf
    outlist.append(elem)
    #endIf
    #endFor
    #endIf
    return outlist
    #endDef


    # List servers with specified server type
    servers = AdminTask.listServers('[-serverType APPLICATION_SERVER ]')
    # Convert Jython string to list
    servers = AdminUtilities.convertToList(servers)

    # Loop through each server in server list
    newServerList = []
    for aServer in servers:
    # Obtain server and node names
    sname = aServer[0:aServer.find("(")]
    print "Server name="+sname+"\n"
    print sname
    nname = aServer[aServer.find("nodes/")+6:aServer.find("servers/")-1]
    print "Node name="+nname+"\n"
    # Retrieve the server config id
    sid = AdminConfig.getid("/Node:"+nname+"/Server:"+sname)
    print "Server id="+sid+"\n"
    if (newServerList .count(sid) <= 0):
    newServerList .append(sid)
    #endFor
    print newServerList

Middleware Mentor - Steven Charles Robinson

About Me

Steve Robinson has been working in IT for over 15 years and has provided solutions for many large-enterprise corporate companies across the world. Steve specialises in Java and Middleware consulting. Steve comes from both an administration and development background.

Before moving to JEE, Steve was an accomplished developer and consultant for both IBM Lotus Notes and Microsoft .NET Technologies.

Follow Steve as @stevencrobinson on twitter.

Read my books?

IBM WebSphere Application Server 8.0 Administration Guide

IBM WebSphere Application Server 8.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Categories

Oracle WebLogic Categories

JBoss Categories

Other Categories