cle_clock
Home > wikikonf >  was/actions/by kikonf > session







Session

print

Action : was.session   (Category : was, Name : session, By : kikonf)
Complete Name : was.session.by.kikonf
Version : 5.0        License : Modified BSD License

Purpose of the was category :
Easy to customize. This category use in background the wsadmin command in jython mode (through AdminConfig, AdminControl and AdminTask), to drive WebSphere Application Server ® configuration.
You can use it to manage the whole WebSphere ® architecture.

Purpose of this session plugin : Tune a Session Manager

The following shows the main Source Code File for the Action : was.session

Toggle lines
##  Copyright (c) 2008, Patrick Germain Placidoux
##  All rights reserved.
##
##  This file is part of Kikonf Public Software.
##
##  Kikonf Public Software is released under the modified BSD License,
##  which should accompany it or any part of it in the file "COPYING".
##  If you do not have this file you can access the license 
##  through the WWW at http://www.kikonf.org/license/bsd/license.txt.
## 
##  Home: http://www.kikonf.org
##  Contact: kikonf@gmx.com



from actions.was.tools import *



class Session(wasAction):
    
    def extract(self, scope_attrs=None, **keywords):
        self_funct='extract'
        self.verbose(scope_attrs)
        dct={'server': None, 'node': None, 'application': None, 'war': None}
        dct.update(scope_attrs)
        scope_attrs=dct
        scope_id, scope_attrs, scope=self.getScope(scope_attrs=scope_attrs, indent=self.getIndent())
        indent=self.getIndent() + 3*' '

        if scope_attrs.has_key('application') and scope_attrs['application']!=None:
            verbose('deployedObject retreiving.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
            dep=AdminConfig.showAttribute(scope_id, 'deployedObject')
            
            if scope_attrs['war']==None:
                cfgs=split(AdminConfig.showAttribute(dep, 'configs'))
                if len(cfgs)==0:
                    xception.kikonfActionInformation(self, self_funct, 'Application:' + scope_attrs['application'] + ' has no specific Session Management definition.').warn(self.getVerbose())
                    return
            else:
                mods=split(AdminConfig.showAttribute(dep, 'modules'))
                uris=[]
                found=False
                for mod in mods:
                    uri=AdminConfig.showAttribute(mod, 'uri')
                    uris.append(uri)
                    if uri==scope_attrs['war']:
                        found=True
                        break
                if not found:raise xception.kikonfActionSystemException(self, self_funct, 'Web Module:' + scope_attrs['war'] + ', of Application:' + scope_attrs['application'] + ' not found ! Found uris are:' + str(uris) + '.')    
                cfgs=split(AdminConfig.showAttribute(mod, "configs"))
                if len(cfgs)==0:
                    xception.kikonfActionInformation(self, self_funct, 'Web Module:' + scope_attrs['war'] + ', of Application:' + scope_attrs['application'] + ' has no specific Session Management definition.').warn(self.getVerbose())
                    return
                
            sm=AdminConfig.showAttribute(cfgs[0], "sessionManagement")
        else:
            verbose('WebContainer listing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
            wc = AdminConfig.list('WebContainer', scope_id)
            
            verbose('SessionManager listing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
            sm = AdminConfig.list('SessionManager', wc)
            
        sessmgrs=getShowAsDict(AdminConfig.show(sm))
        verbose('sessionManagement retreived.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent())
        
        session_node=self.newTop() #-- because in extract mode, each call returns a new blank top node.
        attrs={
            'enable':sessmgrs['enable'],
            'do_cookies':sessmgrs['enableCookies'],                             # Tag: session
            'do_ssl_tracking':sessmgrs['enableSSLTracking'],
            'do_security':sessmgrs['enableSecurityIntegration'],
            'do_url_rewriting':sessmgrs['enableUrlRewriting'],
            'max_wait':sessmgrs['maxWaitTime']
        }
        session_node.setAttrs(**attrs)
        
        mkNodeScope(session_node, scope_attrs, isUnique=True) #-- creates a scope node.

                                                                                # Tag: tuning
        tunings=getShowAsDict(AdminConfig.show(AdminConfig.showAttribute(sm, 'tuningParams')))        
        attrs={
            'allow_overflow':tunings['allowOverflow'],
            'invalidation_timeout':tunings['invalidationTimeout'],
            'max_in_memory':tunings['maxInMemorySessionCount'],
            'schedule_invalidation':tunings['scheduleInvalidation']
        }
        session_node.newNode('tuning', **attrs)
    
                                                                                # Tag: cookie
        cookies=getShowAsDict(AdminConfig.show(AdminConfig.showAttribute(sm, 'defaultCookieSettings')))    
        attrs={
            'name':cookies['name'],
            'path':cookies['path'],
            'maximum_age':cookies['maximumAge'],
            'secure':cookies['secure']
        }
        session_node.newNode('cookie', **attrs)
    
    def inject(self):
        self_funct='inject'
        session_node = self.getTop()        
        session_attrs = session_node.getAttrs()
        scope_id, scope_attrs, scope=self.getScope(parent_node=session_node, indent=self.getIndent()) #-- Retreives scope
        
        self.verbose(scope_attrs)
        indent=self.getIndent() + 3*' '

        if scope_attrs['application']!=None:
            dep=AdminConfig.showAttribute(scope_id, 'deployedObject')
            
            if scope_attrs['war']==None:
                cfgs=split(AdminConfig.showAttribute(dep, 'configs'))
            else:
                mods=split(AdminConfig.showAttribute(dep, 'modules'))
                uris=[]
                found=False
                for mod in mods:
                    uri=AdminConfig.showAttribute(mod, 'uri')
                    uris.append(uri)
                    if uri==scope_attrs['war']:
                        found=True
                        break
                if not found:raise xception.kikonfActionSystemException(self, self_funct, 'Web Module:' + scope_attrs['war'] + ', of Application:' + scope_attrs['application'] + ' not found ! Found uris:' + str(uris) + '.')    

                cfgs=split(AdminConfig.showAttribute(mod, 'configs'))
                
            # Destroy previous
            for cfg in cfgs:AdminConfig.remove(cfg)
        else:
            verbose('WebContainer listing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
            wc = AdminConfig.list('WebContainer', scope_id)
            
            verbose('SessionManager listing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
            sm = AdminConfig.list('SessionManager', wc)

        cmdvalues=[]                                                            # Tag: session

        if scope_attrs['server']==None:
            cmdvalues.append(['enable', session_attrs.enable])
            
        cmdvalues.append(['enableCookies', session_attrs.do_cookies])
        cmdvalues.append(['enableProtocolSwitchRewriting', 'false'])
        cmdvalues.append(['enableSSLTracking', session_attrs.do_ssl_tracking])
        cmdvalues.append(['enableSecurityIntegration', session_attrs.do_security])
        cmdvalues.append(['enableUrlRewriting', session_attrs.do_url_rewriting])
        cmdvalues.append(['maxWaitTime', session_attrs.max_wait])
        cmdvalues.append(['sessionPersistenceMode', 'NONE'])


        tps=[]                                                                  # Tag: tuning
        cmdvalues.append(['tuningParams', tps])
        
        if not session_node.hasNode('tuning'):raise xception.kikonfActionSystemException(self, self_funct, 'Tag: tuning is required ! Advice: at least add a dummy "<tuning/>" tag into your action file.')                                    
        tuning_node=session_node.getNode('tuning')[0]
        tuning_attrs = tuning_node.getAttrs()
        
        tps.append(['allowOverflow', tuning_attrs.allow_overflow])
        tps.append(['invalidationTimeout', tuning_attrs.invalidation_timeout])
        tps.append(['maxInMemorySessionCount', tuning_attrs.max_in_memory])
        tps.append(['scheduleInvalidation', tuning_attrs.schedule_invalidation])

        
        cks=[]                                                                  # Tag: Cookie
        cmdvalues.append(['defaultCookieSettings', cks])
        
        if not session_node.hasNode('cookie'):raise xception.kikonfActionSystemException(self, self_funct, 'Tag: cookie is required ! Advice: at least add a dummy "<cookie/>" tag into your action file.')                                    
        cookie_node=session_node.getNode('cookie')[0]
        cookie_attrs = cookie_node.getAttrs()
        
        cks.append(['name', cookie_attrs.name])
        cks.append(['path', cookie_attrs.path])
        cks.append(['maximumAge', cookie_attrs.maximum_age]) 
        cks.append(['secure', cookie_attrs.secure])

        # Creating
        verbose('sessionManagement modifying.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        if scope_attrs['war']!=None:
            cfgs=split(AdminConfig.showAttribute(mod, "configs"))
            for config in cfgs:AdminConfig.remove(config)            
            AdminConfig.create('ApplicationConfig', mod, 'sessionManagement', cmdvalues, 'configs')        
        elif scope_attrs['application']!=None:
            cfgs=split(AdminConfig.showAttribute(dep, 'configs'))
            for config in cfgs:AdminConfig.remove(config)            
            AdminConfig.create('ApplicationConfig', dep, 'sessionManagement', cmdvalues, 'configs')            
        else:
            AdminConfig.modify(sm, cmdvalues)
        verbose('sessionManagement modified.', level=self.getVerbose(), ifLevel=3, indent=indent)
        
    def verbose(self, scope_attrs):
        scope=str(scope_attrs).replace("'", '')[1:-1]
        
        verbose('Session at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent())
							
(Source: <KIKONF_INSTALLATION_DIR>/plugins/actions/was/session/by/kikonf/session.py)


  • Line 1 to 3 say something , say something , say something
  • Line 10 to 17 say something , say something , say something , say something , say something
  • Line 20 to 25 say something



Trademarks :
  • "IBM", "WebSphere", "WebSphere Aplication Server", "WAS" are registred trademarks of International Business Machines Corporation.
  • "Java" and "JVM" are a registred trademarks of Oracle and/or its affiliates.
  • Other names may be trademarks of their respective owners.

Copyright © 2011 - Patrick Placidoux, Hélène Malamoud