The results of some commands, such as the AdminConfig.showAttribute method, requires you to remove the first open square brace ("[") and last close square brace ("]") and then use the .split(" ") method to obtain a functional list.
apps = AdminApp.list()[0] #?PROBLEM? (jacl 123) previous LINDEX \ may need variable.split("xx")
serverID = AdminConfig.getid("/Node/myNode/Server:myServer/") services = AdminConfig.showAttribute(serverID,"services") for service in services: #?PROBLEM? (jacl 123) previous \ FOR ITEM IN LIST may need variable.split("xx")To simplify the conversion of Jacl wsadmin scripts, the Jacl2Jython program inserts the following utility method into all converted Jython scripts:
def wsadminToList(inStr): outList=[] if (len(inStr)>0 and inStr[0]=='[' and inStr[-1]==']'): inStr = inStr[1:-1] tmpList = inStr.split(" ") else: tmpList = inStr.split("\n") #splits for Windows or Linux for item in tmpList: item = item.rstrip(); #removes any Windows "\r" if (len(item)>0): outList.append(item) return outList #endDefThe following are examples of modifying the preliminary Jython script file. In addition, provides the optional script choices:
apps = AdminApp.list() #Option 1: Choose this option if you want to use the wsadminToList() utility method. # This option is platform-independant appsList = wsadminToList(apps) #Option 2: Choose this option if the application server is on Linux. appsList = apps.split("\n") #Option 3: Choose this option if the application server is on Windows. appsList = apps.split("\r\n") # Option 4: Choose this option if the client's and server's JVM are on the same operating system. appsList = apps.split(java.lang.System.getProperty("line.separator") app = appsList[0]
serverID = AdminConfig.getid("/Node/myNode/Server:myServer/") services = AdminConfig.showAttribute(serverID,"services") #Option 1: Choose this option if you want to use the wsadminToList() utility method. servicesList = wsadminToList(services) #Option 2: Choose this option if you do not want to use the wsadminToList() utility method. servicesList = services[1:-1].split(" ") for service in servicesList:Tip: You are not required to use the wsadminToList() utility method. You can edit your Jython scripts to perform the required and appropriate splits, assuming you know the operating system your application server is running for theNewLine object splits. However, using the utility method might be helpful in the beginning to get your converted Jython scripts running, and in addition defines a server platform portability solution.