cle_clock
Home > wikikonf >  wls/actions/by kikonf > crtserver







Crtserver

print

Action : wls.crtserver   (Category : wls, Name : crtserver, By : kikonf)
Complete Name : wls.crtserver.by.kikonf
Version : 4.0        License : Modified BSD License

Purpose of the wls category :
Easy to customize. This category use in background the wlst command in jython mode, to drive WebLogic Server configuration.
You can use it to manage the whole WebLogic architecture.

Purpose of this crtserver plugin : Creates a new Server

The following shows the main Source Code File for the Action : wls.crtserver

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.wls.tools import *



class Crtserver(wlsAction):

    def extract(self, scope_attrs=None, **keywords):
        self_funct='extract'
        dct={'server': None, 'cluster': None}
        dct.update(scope_attrs)
        scope_attrs=dct        
        server, cluster = scope_attrs['server'], scope_attrs['cluster']
        self.verbose(scope_attrs)
        indent=self.getIndent() + 3*' '

        if server!=None:
            cmo=cd('/')
            srv=cmo.lookupServer(server)
            if srv==None:raise xception.kikonfActionParameterException(self, self_funct, 'Scope: Unable to retreive server:' + server + '. Your scope:' + str({'server':server, 'cluster':cluster}) + '.')
            
            if cluster!=None:
                cl=srv.getCluster()
                if cl==None or cl.getName()!=cluster:raise xception.kikonfActionParameterException(self, self_funct, 'Scope: Unable to retreive cluster:' + cluster + '. Your scope:' + str({'server':server, 'cluster':cluster}) + '.')

            cluster, attrs=extServer(server, level=self.getVerbose(), indent=indent, logFile=self.getLogFile())
            
            server_node=self.newTop()
            mkNodeScope(server_node, {'cluster':cluster, 'server':server}, isUnique=True) #-- creates a scope node.
            server_node.setAttrs(**attrs)
            
        elif cluster!=None:
            try:
                cmo=cd('/Clusters/' + cluster)
            except:
                raise xception.kikonfActionParameterException(self, self_funct, 'Scope: Unable to retreive cluster:' + cluster + '. Your scope:' + str({'server':server, 'cluster':cluster}) + '.')
            
            srvs=cmo.getServers()
            for srv in srvs:
                sname=srv.getName()
                desc=srv.getNotes()
                if desc==DESIGN_NOTICE:desc=None
                cluster, attrs=extServer(sname)
                
                server_node=self.newTop()
                mkNodeScope(server_node, {'cluster':cluster, 'server':sname}, isUnique=True,desc=desc) #-- creates a scope node.
                server_node.setAttrs(**attrs)
        else:
            cluster, attrs=extServer(server)
            
            server_node=self.newTop()
            mkNodeScope(server_node, {'cluster':cluster, 'server':sname}, isUnique=True) #-- creates a scope node.
            server_node.setAttrs(**attrs)

    def remove(self, no_name, no_name_no_prefix):
        crtserver_node = self.getTop()        
        crtserver_attrs = crtserver_node.getAttrs()
        if not crtserver_node.hasNode('scope'):raise xception.kikonfActionSystemException(self, self_funct, 'Node scope is required !')
        scope_attrs=crtserver_node.getNode('scope')[0].getAttrs()
        self.verbose({'server': scope_attrs.server, 'cluster': scope_attrs.cluster})
        indent=self.getIndent() + 3*' '
        
        self.rmvSrv(scope_attrs, indent=indent)
        
    def inject(self):
        self_funct='inject'
        crtserver_node = self.getTop()        
        crtserver_attrs = crtserver_node.getAttrs()        
        if not crtserver_node.hasNode('scope'):raise xception.kikonfActionSystemException(self, self_funct, 'Node scope is required !') 
        scope_attrs=crtserver_node.getNode('scope')[0].getAttrs()
        if scope_attrs.server==None:raise xception.kikonfActionSystemException(self, self_funct, 'Scope: server is required. Your scope:' + str({'cluster':scope_attrs.cluster, 'server': scope_attrs.server}))
        self.verbose({'server': scope_attrs.server, 'cluster': scope_attrs.cluster})
        indent=self.getIndent() + 3*' '
        
        #-- remove first
        self.rmvSrv(scope_attrs, indent=indent)
        
        verbose('Creating Server:' + scope_attrs.server + '.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        cmo=cd('/')
        cmo.createServer(scope_attrs.server)

        # - sets host
        cmo=cd('/Servers/' + scope_attrs.server)
        cmo.setListenAddress(crtserver_attrs.host)
        # - sets port
        cmo.setListenPort(crtserver_attrs.port)
        # - sets enable_client_cert_proxy
        if crtserver_attrs.enable_client_cert_proxy=='true':cmo.setClientCertProxyEnabled(True)
        else:cmo.setClientCertProxyEnabled(False)
        # - sets cluster
        if scope_attrs.cluster!=None:
            cls=getMBean('/Clusters/' + scope_attrs.cluster)
            if cls==None:raise xception.kikonfActionSystemException(self, self_funct, 'Cluster:' + scope_attrs.cluster + ' not found !')
            cmo.setCluster(cls)
        else:
            cmo.unSet('Cluster')
        # - sets machine
        if crtserver_attrs.machine!=None:
            mc=getMBean('/Machines/' + crtserver_attrs.machine)
            if mc==None:raise xception.kikonfActionSystemException(self, self_funct, 'Machine:' + scope_attrs.machine + ' not found !')
            cmo.setMachine(mc)
        else:cmo.unSet('Machine')
        # - sets desc
        if crtserver_attrs.desc==None:desc=DESIGN_NOTICE
        else:desc=crtserver_attrs.desc
        cmo.setNotes(desc)
        # - sets ssl
        cmo=cd('/Servers/' + scope_attrs.server + '/SSL/' + scope_attrs.server)
        if  crtserver_attrs.enable_ssl=='true':
            cmo.setTwoWaySSLEnabled(True)
            cmo.setEnabled(True)
            if crtserver_attrs.ssl_port!=None:cmo.setListenPort(crtserver_attrs.ssl_port)
        else:
            cmo.setTwoWaySSLEnabled(False)
            cmo.setEnabled(False)
            cmo.unSet('ListenPort')
        
        verbose('Server:' + scope_attrs.server + ' created.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())
            
    def rmvSrv(self, scope_attrs, indent=None):  
        cmo=cd('/')
        srv=cmo.lookupServer(scope_attrs.server)
        if srv==None:return
        
        verbose('Server:' + scope_attrs.server + ' removing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        cmo=cd('/Servers/' + scope_attrs.server)
        cmo.setCluster(None)
        cmo.setMachine(None)
        editService.getConfigurationManager().removeReferencesToBean(srv)
        cmo=cd('/')
        cmo.destroyServer(srv)
        verbose('Server:' + scope_attrs.server + ' removed.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())

    def verbose(self, scope_attrs):  
        verbose('Application Server at scope: server:' + str(scope_attrs['server']) + ' cluster:' + str(scope_attrs['cluster']) + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent())



def extServer(server, level=None, indent=None, logFile=None):
    attrs={}
    verbose('Server:' + server + ' retreiving.', level=level, ifLevel=4, indent=indent, logFile=logFile)

    # - gets host
    cmo=cd('/Servers/' + server)
    attrs['host']=cmo.getListenAddress()
    # - gets port
    attrs['port']=cmo.getListenPort()
    # - gets enable_client_cert_proxy
    if cmo.isClientCertProxyEnabled():attrs['enable_client_cert_proxy']='true'
    # - gets cluster
    cluster=cmo.getCluster()
    if cluster!=None:cluster=cluster.getName()
    # - gets machine
    attrs['machine']=cmo.getMachine().getName()
    # - gets ssl
    cmo=cd('/Servers/' + server + '/SSL/' + server)
    if cmo.isEnabled():attrs['enable_ssl']='true'
    attrs['ssl_port']=cmo.getListenPort()

    return cluster, attrs
							
(Source: <KIKONF_INSTALLATION_DIR>/plugins/actions/wls/crtserver/by/kikonf/crtserver.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 :
  • "oracle", "Weblogic", "Weblogic Server", "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