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







Crtcluster

print

Action : was.crtcluster   (Category : was, Name : crtcluster, By : kikonf)
Complete Name : was.crtcluster.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 crtcluster plugin : Creates a new Cluster

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

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

    def extract(self, name=None, **keywords):
        self_funct='extract'
        self.verbose(name=name)
        indent=self.getIndent() + 3*' '
        
        if name!=None:
            verbose('ServerCluster retreiving.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
            cs=getStartByNameAsDict([AdminConfig.getid('/ServerCluster:' + name)])
        else:
            verbose('ServerCluster retreiving.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
            cs=getStartByNameAsDict(split(AdminConfig.getid('/Cell:localhostCell01/ServerCluster:/')))
        
        for cname in cs.keys():
            if name!=None and name==cname \
            or name==None:
                verbose('ServerCluster' + cname + ' retreiving.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
                c=getShowAsDict(AdminConfig.show(cs[cname]))
                verbose('ServerCluster' + cname + ' retreived.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())
                crtcluster_node=self.newTop()
                
                enable_ha=c['enableHA']
                node_group=c['nodeGroupName']
                
                if c.has_key('description') and c['description']!=None:desc=c['description'][1:-1]
                else:desc==None
                if desc==DESIGN_NOTICE:desc=None

                crtcluster_node.setAttrs(name=name, enable_ha=enable_ha, node_group=node_group, desc=desc)

    def remove(self, no_name, no_name_no_prefix):
        crtcluster_node = self.getTop()        
        crtcluster_attrs = crtcluster_node.getAttrs()
        self.verbose(name=crtcluster_attrs.name)
        indent=self.getIndent() + 3*' '
        
        self.rmvCluster(crtcluster_attrs.name, indent=indent)
        
    def inject(self):
        self_funct='inject'
        crtcluster_node = self.getTop()        
        crtcluster_attrs = crtcluster_node.getAttrs()
        self.verbose(name=crtcluster_attrs.name)
        indent=self.getIndent() + 3*' '
        
        self.rmvCluster(crtcluster_attrs.name, indent=indent) #-- remove first
                
        cmdvalues=[]
        cmdvalues.append(['name', crtcluster_attrs.name,])
        cmdvalues.append(['enableHA', crtcluster_attrs.enable_ha])
        cmdvalues.append(['nodeGroupName', crtcluster_attrs.node_group])
        
        if crtcluster_attrs.desc!=None:cmdvalues.append(['description', crtcluster_attrs.desc])
        else:cmdvalues.append(['description', DESIGN_NOTICE])

        verbose('ServerCluster:' + crtcluster_attrs.name + ' creating.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        AdminConfig.create('ServerCluster', AdminConfig.getid('/Cell:'+ self.getCell()), cmdvalues)
        verbose('ServerCluster:' + crtcluster_attrs.name + ' created.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())
        
    def rmvCluster(self, name, indent=None):
        c=AdminConfig.getid('/ServerCluster:' + name)
        if c=='':
            return        
        c=AdminConfig.getid('/ServerCluster:' + name)
        mbrs=split(AdminConfig.showAttribute(c, 'members'))
        
        for mbr in mbrs: #-- remove JVMs first.
            members=getShowAsDict(AdminConfig.show(mbr))
            server=members['memberName']
            node=members['nodeName']
            verbose('ClusterMember retreiving.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
            srv=AdminConfig.getid('/Cell:' + self.getCell() + '/Node:' + node + '/Server:' + server + '/')
            
            verbose('ClusterMember removing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
            AdminConfig.remove(srv)
            verbose('ClusterMember:' + server + ' removed.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())
        
        verbose('ServerCluster:' + name + ' removing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        AdminConfig.remove(c)
        verbose('ServerCluster:' + name + ' removed.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())
        
    def verbose(self, name=None, logFile=None):
        if name!=None:verbose('Cluster:' + name + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent(), level=self.getVerbose(), ifLevel=2, indent=self.getIndent(), logFile=self.getLogFile())
        else:verbose('Clusters.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent(), logFile=self.getLogFile())
							
(Source: <KIKONF_INSTALLATION_DIR>/plugins/actions/was/crtcluster/by/kikonf/crtcluster.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