1
votes

I need to find the way to get the object-id of a specific config object and I can't seem to be able to get the result I want.

Consider the code below:

wsadmin>print AdminConfig.list('SessionManager')
(cells/labwas11Node01Cell/applications/isclite.ear/deployments/isclite|deployment.xml#SessionManager_1162483845425)
(cells/labwas11Node01Cell/nodes/labwas11/servers/server1|server.xml#SessionManager_1183122130078)

Is there a way to obtain only the second line with a crafty AdminConfig.getid?

I just read a nice article about object name and containment path, which helped a bit understanding my problem, but not providing with a solution.

http://blog.xebia.com/2009/11/23/websphere-scripting-with-wsadmin-containment-paths-configuration-ids-and-object-names/

I have found a way to get my info, but I'm sure there is a better way... if someone can help it would be great.

So I want the session manager of my server, but I have another session manager that is defined for an application.

So AdminConfig.list is not good enough

What I can do is that the session manager I want has an attribute that reflect it's context. ( I have removed some lines for clarity)

print AdminConfig.show('SessionManager(cells/labwas11Node01Cell/nodes/labwas11/servers/server1|server.xml#SessionManager_1183122130078)')
[accessSessionOnTimeout true]
[allowSerializedSessionAccess false]
[context (cells/labwas11Node01Cell/nodes/labwas11/servers/server1|server.xml#WebContainer_1183122130078)]
[enable true]
[enableCookies true]
[enableProtocolSwitchRewriting false]
[enableSSLTracking false]
[enableSecurityIntegration true]
[enableUrlRewriting false]
[maxWaitTime 5]
[properties []]
[sessionPersistenceMode NONE]

The context object is the WebContainer to which this session manager apply.

so I should be able to compare these two and find the session manager I want.

SesMgrList = AdminConfig.list('SessionManager').splitlines()
for SesMgr in SesMgrList:
    if AdminConfig.showAttribute( SesMgr, 'context') == AdminConfig.list('WebContainer'):
        Modify my session manager custom properties

But thats not elegant at all... anyone has a better way?

2

2 Answers

2
votes

Some WebSphere objects can be difficult to obtain using only containment path. In your specific case it is probably better to start from Server object, find WebContainer and then find its SessionManager. Once you get there, you'll be able to modify session managements settings:

server = AdminConfig.getid('/Cell:labwas11Node01Cell/Node:labwas11/Server:server1/')
webContainer = AdminConfig.list('WebContainer', server)
sessionManager = AdminConfig.list('SessionManager', webContainer)
tuningParams = AdminConfig.showAttribute(sessionManager, 'tuningParams')
print AdminConfig.showAttribute(tuningParams, 'maxInMemorySessionCount')
AdminConfig.modify(tuningParams, [ ['maxInMemorySessionCount', '1234'] ])
print AdminConfig.showAttribute(tuningParams, 'maxInMemorySessionCount')
# AdminConfig.save() # when uncommented - changes will be saved

You may also have a look at WDR library at https://github.com/WDR/WDR/ (and its documentation at http://wdr.github.io/WDR/) which makes the script more readable and maintainable:

server = getid1('/Cell:labwas11Node01Cell/Node:labwas11/Server:server1/')
webContainer = server.listConfigObjects('WebContainer')[0]
sessionManager = webContainer.listConfigObjects('SessionManager')[0]
tuningParams = sessionManager.tuningParams
print tuningParams.maxInMemorySessionCount
tuningParams.maxInMemorySessionCount = 1234
# since in WDR is type-aware, you can even do that:
tuningParams.maxInMemorySessionCount += 10
print tuningParams.maxInMemorySessionCount
# save() ; sync() # when uncommented - changes will be saved and synchronized
1
votes

As I'm currently implementing a set of scripts for automating WebSphere deployment these days, I tend to aim for as systematic a way to navigate the configuration as possible. In that context, I was looking to retrieve Web Container and Session Manager through containment path. The reason I favor this over the approach of Marcin is that it's a single call to retrieve the element I want.

This is what I found works:

AdminConfig.getid('/Cell:/Node:/Server:/ApplicationServer:/WebContainer:/SessionManager:/')

You can of course add the name of Node and Server to find the specific element you're looking for.