Marcin Płonka
Marcin Płonka

Reputation: 2950

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/.

Upvotes: 10

Views: 5690

Answers (2)

armstrhb
armstrhb

Reputation: 4152

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.

Upvotes: 4

Nick Roth
Nick Roth

Reputation: 3077

The only tool I know of is Rational Automation Framework. It's designed to help automate deployment, configuration and administration of lots of different middleware components.

http://www-01.ibm.com/software/rational/products/framework/

I have not worked directly with this tool itself but my understanding is that you won't need to write any scripts to manage your servers. You can essentially 'export' a WAS configuration from one environment (dev or testing) and 'import' that into another environment. It can even keep a version history of your configurations.

I would be interested in knowing about any other tools though that you come across.

Upvotes: 0

Related Questions