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







Sharedlib

print

Action : was.sharedlib   (Category : was, Name : sharedlib, By : kikonf)
Complete Name : was.sharedlib.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 sharedlib plugin : Creates a shared library

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

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 Sharedlib(wasAction):
    
    def extract(self, scope_attrs=None, name=None, prefix=None, **keywords):
        scope_id, scope_attrs, scope=self.getScope(scope_attrs=scope_attrs, indent=self.getIndent())
        self.verbose(scope_attrs, name=name, prefix=prefix)
        indent=self.getIndent() + 3*' '
        from os import path

        verbose('Library listing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        shs=getStartByNameAsDict(split( AdminConfig.getid(self.getScopeCP() + '/Library:/') ))
        for shname in shs.keys():
            
            if not(prefix!=None and name!=None and shname==prefix + '_' + name 
            or prefix==None and name!=None and name==shname \
            or prefix!=None and name==None and shname.startswith(prefix) \
            or prefix==None and name==None):continue
            
            sharedlibs=getShowAsDict(AdminConfig.show(shs[shname]))
            verbose('Library:' + shname + ' retreived.', level=self.getVerbose(), ifLevel=2, indent=indent)
            
            cps=sharedlibs['classPath']
            cps=cps.split(';')
        
            sharedlib_node=self.newTop() #-- because in extract mode, each call returns a new blank top node.
            
            desc=None
            if sharedlibs.has_key('description') and sharedlibs['description']!=None:desc=sharedlibs['description'][1:-1]
            if desc==DESIGN_NOTICE:desc==None

            _name=shname
            if prefix!=None:_name=shname.split(prefix + '_')[1]
            
            sharedlib_node.setAttrs(name=_name, desc=desc)
            
            mkNodeScope(sharedlib_node, scope_attrs, isUnique=True) #-- creates a scope node.
            
            classpath_node=sharedlib_node.newNode('classpath')
            for cp in cps:
                classpath_node.addText(cp)
    
    def remove(self, no_name, no_name_no_prefix):
        sharedlib_node = self.getTop()     
        sharedlib_attrs = sharedlib_node.getAttrs()
        scope_id, scope_attrs, scope=self.getScope(parent_node=sharedlib_node, indent=self.getIndent()) #-- Retreives scope
        indent=self.getIndent() + 3*' '

        # no_name/no_name_no_prefix
        prefix=sharedlib_attrs.prefix        
        name=sharedlib_attrs.name
        if no_name or no_name_no_prefix:name=None
        if no_name_no_prefix:prefix=None        
        self.verbose(scope_attrs, name=name, prefix=prefix)
        indent=self.getIndent() + 3*' '
        
        self.rmvSharedLib(name=name, prefix=sharedlib_attrs.prefix, indent=indent)
        
    def inject(self):
        self_funct='inject'
        sharedlib_node = self.getTop()        
        sharedlib_attrs = sharedlib_node.getAttrs()
        scope_id, scope_attrs, scope=self.getScope(parent_node=sharedlib_node, indent=self.getIndent()) #-- Retreives scope
        self.verbose(scope_attrs, name=sharedlib_attrs.name, prefix=sharedlib_attrs.prefix)
        indent=self.getIndent() + 3*' '
        
        self.rmvSharedLib(name=sharedlib_attrs.name, prefix=sharedlib_attrs.prefix, indent=indent)  # remove first
        
        #-- name
        if sharedlib_attrs.prefix==None:name=sharedlib_attrs.name
        else:name=sharedlib_attrs.prefix + '_' + sharedlib_attrs.name

        if not sharedlib_node.hasNode('classpath'):raise xception.kikonfActionSystemException(self, self_funct, 'Tag Classptah is required !')
        cps=sharedlib_node.getNode('classpath')[0].getText()
        if len(cps)==0:raise xception.kikonfActionSystemException(self, self_funct, 'Classptah is required !')
        elif len(cps)==1:classpath=cps[0]
        else:classpath=';'.join(cps)
        
        if sharedlib_attrs.desc!=None:desc=sharedlib_attrs.desc
        else:desc=DESIGN_NOTICE

        verbose('Library:' + name + ' creating.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        AdminConfig.create("Library", scope_id, 'name', name], ['classPath', classpath], ['description', desc)
        verbose('Library:' + name + ' created.', level=self.getVerbose(), ifLevel=3, indent=indent)
        
    def rmvSharedLib(self, name, prefix=None, indent=None):
        scope_id, scope_attrs, scope=self.getScope()
        
        verbose('Library retreiving.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        shs=getStartByNameAsDict(split( AdminConfig.getid(self.getScopeCP() + '/Library:/') ))
        
        for shname in shs.keys():
            if prefix!=None and shname.startswith(prefix) \
            or prefix==None and name!=None and name==shname \
            or prefix==None and name==None:
            
                verbose('Library:' + shname + ' removing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
                AdminConfig.remove(shs[shname])
                verbose('Library:' + shname + ' removed.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())

    def verbose(self, scope_attrs, name=None, prefix=None):
        scope=str(scope_attrs).replace("'", '')[1:-1]
        
        if name!=None:verbose('Libraries:' + name + ', at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent())
        elif prefix!=None:verbose('Libraries under prefix:' + prefix + ', at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent())
        else:verbose('Libraries at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent())
							
(Source: <KIKONF_INSTALLATION_DIR>/plugins/actions/was/sharedlib/by/kikonf/sharedlib.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