Human-friendly WebSphere scripting tool/library?
Asked Answered
R

2

10

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

Rosellaroselle answered 26/11, 2012 at 19:51 Comment(7)
For background, wsadmin started with only Jacl, which is a string-based language. When Jython support was added, the bindings for AdminConfig etc were reused as-is, which means you have to interact with the string-based bindings in Jython. I agree this is very unnatural. I could never wrap my brain around it, which is why I still do all my wsadmin scripting in Jacl, even though Jython itself is a much nicer language...Moonier
Exactly, and now with that Jacl-legacy we have to do all that splitline() calls and lots of other hacks to handle lists of config-ids and MBean-ids. It's actually quite funny that Jacl has been deprecated in wsadmin (since WAS 5.1?) and remained the default. Even in the latest-and-greatest WAS 8.5...Rolanda
Jacl used to be "deprecated", but it was changed to "stabilized" in 7.0 and is still stabilized as of 8.5 (pic.dhe.ibm.com/infocenter/wasinfo/v8r5/topic/…). "deprecated" means IBM might remove the feature, but no sooner than two major releases after it is marked as deprecated. "stabilized" means IBM has no intention of removing the feature, but they also have no intention of making significant enhancements.Moonier
You're right! It was "undeprecated"! Quite interesting how Jacl's status was changing from release to release: WAS7: pic.dhe.ibm.com/infocenter/wasinfo/v7r0/topic/… WAS 6.1: pic.dhe.ibm.com/infocenter/wasinfo/v6r1/topic/… WAS 6.0: pic.dhe.ibm.com/infocenter/wasinfo/v6r0/topic/…Rolanda
After reading about that "undeprecation" I've considered Jacl as THE language for a while. But then I recollected that pain with "$AdminControl invoke_jmx" and accessing Java APIs from Jacl. If I have to choose between 2002 vintage Jython and 2005 vintage Jacl, I'll rather stay with Jython anyway...Rolanda
It seems that no tool like this exists yet, therefore I started developing one for myself: github.com/mplonka/WDR. The current version is just a Jython library that makes wsadmin more 'pythonic'. I'm still considering reimplementing it in Groovy&Java.Rolanda
Interesting, thanks for the link.Moonier
G
4

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.

Glycogen answered 12/12, 2012 at 15:56 Comment(1)
wsadminlib is not exactly what I was looking for. I was rather interested in a tool that simplifies WAS scripting in general. `wsadminlib' is a list of recipes for specific tasks.Rolanda
K
0

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.

Kellsie answered 26/11, 2012 at 20:22 Comment(7)
Thanks Nick. The tool I'm looking for must be scripted. Fancy GUIs just won't work. It doesn't have to be Jython though.Rolanda
Actually it would be nice to use something newer than WAS-built-in-Jython 2.1 from 2002 (or even more ancient Jacl). There's no chance to parse any XML/YAML/JSON in that languages, and generally all Python projects stopped supporting Python 2.1 years ago. That's another pain in wsadmin...Rolanda
Hey, you helped me to understand why wsadmin is so discouraging. It might have been done so on purpose. Who would consider purchase of RAF if wsadmin was more convenient and established?Rolanda
Well for some history on RAF, it was not initially developed by IBM. It was initially created by another company and then IBM bought it to develop it further.Kellsie
I'm curious now though why it has to be a scripted solution. If you're looking to integrate your solution into a build or deployment process I'm quite sure RAF can integrate with them while saving you the time of having to write the wsadmin scripts.Kellsie
The idea is to have a tool that could apply configuration changes incrementally with the application and keep dev/test/prod environments consistent without comparing. I've looked at RAF documentation and I'm seeing that for complex scenarios one needs to resort to wsadmin or ws_ant. I was looking at Groovy's support for JMX groovy.codehaus.org/Groovy+and+JMX. Groovy would be much more flexible than Jython 2.1, but it still lacks some features, mainly it doesn't understand WAS ConfigService. Also has some issues with overloaded JMX operations (for example NodeAgent.lauchProcess).Rolanda
(reached 600 characters limit in my previous comment) On the other hand Groovy does support XML, YAML & JSON. Parsing some enviroment-specific files is a must in order to reuse scripts across environments. Also, I don't want to be restricted to features which are currently implemented in RAF. With wsadmin it's possible to code almost everything, however that ridiculously designed API makes maintenance of scripts virtually impossible in long run. So - I'm still looking for a tool which is more powerful than RAF and more friendly than wsadmin's API (on top of prehistorical Jython 2.1).Rolanda

© 2022 - 2024 — McMap. All rights reserved.