Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Human-friendly WebSphere scripting tool/library?

I'm developing lots of scripts for managing WAS infrastructure and I'm getting an impression that somebody at IBM has screwed up wsadmin on purpose. It couldn't be an accident.

Here's a "simple" example:

for node in AdminConfig.list('Node').splitlines():
    nodeName = AdminConfig.showAttribute(node, 'name')
    for srv in AdminConfig.list('Server', node).splitlines():
        if AdminConfig.showAttribute(srv, 'serverType') == 'APPLICATION_SERVER':
            serverName = AdminConfig.showAttribute(srv, 'name')
            prop = AdminConfig.getid('/Node:%s/Server:%s/JavaProcessDef:/JavaVirtualMachine:/Property:java.awt.headless/' % (nodeName, serverName))
            if prop:
                AdminConfig.modify(prop, [ ['value','true'] ])
            else:
                jvm = AdminConfig.getid('/Node:%s/Server:%s/JavaProcessDef:/JavaVirtualMachine:/' % (nodeName, serverName))
                AdminConfig.create('Property', jvm, [ ['name', 'java.awt.headless'], ['value', 'true'] ], 'systemProperties')

The above script is not only not maintainable, it's just unreadable. The wsadmin tool is a write-only tool! One writes a script and on next day can't understand how it works or even what it does!

Wouldn't it be easier like this?:

for node in list('Node'):
    nodeName = node.name
    for srv in node.list('Server'):
        if srv.serverType == 'APPLICATION_SERVER':
            jvm = srv.processDefinitions[0].jvmEntries[0]
            jvm.createOrModify('Property', { 'name': 'java.awt.headless' }, { 'value': 'true' })

... one could easily figure out what the script does without spending minutes on trying to understand that hectic API if only WAS scripting was friendlier. Not to mention the ease of maintenance.

Has anybody ever seen/attempted to implement a friendlier administration tool (or wsadmin library)?

I'm asking because I'm actually planning to do develop a friendly Jython library, I'd just like to avoid reinventing the wheel.

I've seen plenty of task-oriented Jython libraries. Some of them are available in newer versions of WAS, others have been published on IBM developerWorks, some libraries are available on the web. To me, they're yet another API to learn and they're only useful for limited set of tasks. I'm rather looking for general-purpose WAS scripting tool/library.

Edit: This question was part of a research preceding a larger WebSphere automation project. Library I was asking about did not exist at that time, therefore I've started developing WDR. You may find it here: http://wdr.github.io/WDR/.

like image 467
Marcin Płonka Avatar asked Nov 26 '12 19:11

Marcin Płonka


People also ask

What is JACL script?

Jacl scripts are a non-graphical alternative that you can use to configure and manage the Sametime Gateway Server. The WebSphere® administrative scripting tool, wsadmin, is a non-graphical command interpreter environment enabling you to run administrative operations on a server in Jacl.

What is wsadmin scripting tool?

The wsadmin tool removes any leading and trailing space including \n , \r , \t , \f and space when parsing a string to avoid any user errors. For example, someone might accidentally hit the spacebar key or the Tab key and add extra space to the command string.

Where is wsadmin located?

The wsadmin Qshell command is located in the app_server_root /bin directory.

How do I log into wsadmin?

Run wsadmin with an option other than -f or -c or without an option. The wsadmin tool starts and displays an interactive shell with a wsadmin prompt. From the wsadmin prompt, enter any Jacl or Jython command. You can also invoke commands using the AdminControl, AdminApp, AdminConfig, AdminTask, or Help wsadmin objects.


1 Answers

IBM developerWorks has an unofficial (and so, is unsupported) library called wsadminlib. I found out about this from another question here on stackoverflow, answered by BradT: wsadmin-jython-restart-was-appserver. The library was created by a few IBM developers who felt the same way about wsadmin jython syntax as you do.

Since this library is just another jython file, you can import it into your own scripts, and call the methods directly. Here's an example for starting an application server, taken from the wsadminlib-blog:

execfile('/tmp/wsadminlib.py')

servername = 'server1'
nodename = 'node1'

startServer(nodename,servername)

You can find more information in library here and here. Again, these links are in BradT's answer to another question above.

like image 81
armstrhb Avatar answered Oct 06 '22 10:10

armstrhb