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







Wasvars

print

Action : was.wasvars   (Category : was, Name : wasvars, By : kikonf)
Complete Name : was.wasvars.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 wasvars plugin : Creates a WebSphere Variable

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

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 Wasvars(wasAction):

    def extract(self, scope_attrs=None, prefix=None, **keywords):
        scope_id, scope_attrs, scope=self.getScope(scope_attrs=scope_attrs, indent=self.getIndent())
        self.verbose(scope_attrs, prefix=prefix)
        indent=self.getIndent() + 3*' '
        
        wasvars_node=self.newTop() # because in extract, this return a blank wasvars node.
        wasvars_node.setAttrs(prefix=prefix) # feeding it with attributes.
        mkNodeScope(wasvars_node, scope_attrs, isUnique=True)                   ## tag: scope

        verbose('VariableMap listing.', level=self.getVerbose(), ifLevel=4, indent=indent)        
        vmap=AdminConfig.list('VariableMap', scope_id)        

        verbose('VariableSubstitutionEntry listing.', level=self.getVerbose(), ifLevel=4, indent=indent)                
        vs=split(AdminConfig.list('VariableSubstitutionEntry', vmap))        

        for v in vs:
            attrs={}
            
            vars=getShowAsDict(AdminConfig.show(v))
            vname=attrs['name']=vars['symbolicName']
            
            if prefix!=None and vname.startswith(prefix) \
            or prefix==None:
                verbose('VariableSubstitutionEntry:' + vname + ' listed.', level=self.getVerbose(), ifLevel=3, indent=indent)        
                
                attrs['value']=vars['value']
                
                if vars.has_key('description') and vars['description']!=None:attrs['desc']=vars['description'][1:-1]
                else:attrs['desc']=None
                if attrs['desc']==DESIGN_NOTICE:attrs['desc']=None
            
                wasvars_node.newNode('var', **attrs)

    def remove(self, no_name, no_name_no_prefix):
        wasvars_node = self.getTop()        
        wasvars_attrs = wasvars_node.getAttrs()
        scope_id, scope_attrs, scope=self.getScope(parent_node=wasvars_node, indent=self.getIndent()) #-- Retreives scope
        self.verbose(scope_attrs, prefix=wasvars_attrs.prefix)
        indent=self.getIndent() + 3*' '
        
        # no_name/no_name_no_prefix
        prefix=wasvars_attrs.prefix        
        if no_name_no_prefix:prefix=None
        
        if no_name_no_prefix or prefix!=None:self.rmvVar(prefix=prefix, indent=indent)
        else:
            if wasvars_node.hasNode('var'):            
                var_nodes=wasvars_node.getNode('var')
                
                for var_node in var_nodes:
                    var_attrs = var_node.getAttrs()
                    self.rmvVar(name=var_attrs.name, indent=indent)
            
    def inject(self):
        self_funct='inject'
        wasvars_node = self.getTop()        
        wasvars_attrs = wasvars_node.getAttrs()
        scope_id, scope_attrs, scope=self.getScope(parent_node=wasvars_node, indent=self.getIndent()) #-- Retreives scope
        self.verbose(scope_attrs, prefix=wasvars_attrs.prefix)
        indent=self.getIndent() + 3*' '

        if wasvars_attrs.prefix!=None:self.rmvVar(prefix=wasvars_attrs.prefix, indent=indent)

        if wasvars_node.hasNode('var'):            
            var_nodes=wasvars_node.getNode('var')
            
            for var_node in var_nodes:
                var_attrs = var_node.getAttrs()
                
                # - name
                if wasvars_attrs.prefix==None:name=var_attrs.name
                else:name=wasvars_attrs.prefix + '_' + var_attrs.name       
                
                self.rmvVar(name=name, indent=indent)          
                
                cmdvalues=[]
                cmdvalues.append(['symbolicName', name])       
                     
                if var_attrs.desc!=None:cmdvalues.append(['description', var_attrs.desc])
                else:cmdvalues.append(['description', DESIGN_NOTICE])
                
                cmdvalues.append(['value', var_attrs.value])            
                
                verbose('VariableMap listing.', level=self.getVerbose(), ifLevel=4, indent=indent)        
                vmap=AdminConfig.list('VariableMap', scope_id)
                verbose('VariableSubstitutionEntry:' + name + ' creating.', level=self.getVerbose(), ifLevel=4, indent=indent)        
                AdminConfig.create('VariableSubstitutionEntry', vmap, cmdvalues)
                verbose('VariableSubstitutionEntry:' + name + ' created.', level=self.getVerbose(), ifLevel=3, indent=indent)        
                
    def rmvVar(self, name=None, prefix=None, indent=None):
        scope_id, scope_attrs, scope=self.getScope()
        
        verbose('VariableMap listing.', level=self.getVerbose(), ifLevel=4, indent=indent)        
        vmap=AdminConfig.list('VariableMap', scope_id)
        verbose('VariableSubstitutionEntry listing.', level=self.getVerbose(), ifLevel=4, indent=indent)        
        vs=split(AdminConfig.list('VariableSubstitutionEntry', vmap))
        
        for v in vs:
            vname=AdminConfig.showAttribute(v, 'symbolicName')            
            
            if prefix!=None and vname.startswith(prefix) \
            or prefix==None and name!=None and name==vname \
            or prefix==None and name==None:
                verbose('VariableSubstitutionEntry:' + vname + ' removing.', level=self.getVerbose(), ifLevel=4, indent=indent)                    
                AdminConfig.remove(v)
                verbose('VariableSubstitutionEntry:' + vname + ' removed.', level=self.getVerbose(), ifLevel=3, indent=indent)        
                
    def verbose(self, scope_attrs, prefix=None):
        scope=str(scope_attrs).replace("'", '')[1:-1]
        
        if prefix!=None:verbose('VariableSubstitutionEntrys under prefix:' + prefix + ', at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent())
        else:verbose('VariableSubstitutionEntrys at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent())
							
(Source: <KIKONF_INSTALLATION_DIR>/plugins/actions/was/wasvars/by/kikonf/wasvars.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