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







Crtserver

print

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

Purpose of the jbs category :
Easy to customize. This category use in background the Kikonf Repoz tools to configure JBOSS server resources.

Purpose of this crtserver plugin : Create a JBoss server instance

The following shows the main Source Code File for the Action : jbs.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



#------#
# Main #
#------#


# Stores the Action File's Processor Alias
var source_action_alias=ro['alias']

# Stores the Action File's First Node <=> self_action.getTop()
:ls
source_action_node=ro[0]


try:
    from StringIO import StringIO
    from os import path
    from os import listdir
    import shutil
    import os

    
    ## Retreives the Scope
    action_node=self_action.getTop()
    action_attrs=action_node.getAttrs()
    scope_attrs=action_node.getNode('scope')[0].getAttrs()
    sbase=path.normpath(path.realpath(scope_attrs.sbase))
    jhome=self_action.getCAttr('software_jbs_home')
    indent=self_action.getIndent() + 3*' '
    

    ## Check first
    plateform=getOsType()    
    if plateform=='windows':suffix='bat'
    else:suffix='sh'
    server_base=path.normpath(path.realpath(jhome + '/server/all'))
    
    
    ## Destroys first
    print    
    print '## Destroys first'    
    verbose('sbase: ' + sbase + ' Removing.', level=self_action.getVerbose(), ifLevel=4, indent=indent, logFile=self_action.getLogFile())
    if not self_action.getCAttr('test'):
        if path.isdir(sbase):
            shutil.rmtree(sbase, ignore_errors=False)
            verbose('sbase: ' + sbase + ' Removed.', level=self_action.getVerbose(), ifLevel=3, indent=indent, logFile=self_action.getLogFile())
    else:
        message=xception.kikonfActionInformation(self_action, 'inject', 'sbase: ' + sbase + ' Not removed, because Action is running in test mode.').warn(verbose=self_action.getVerbose(), doPrint=False)
        verbose(message, level=self_action.getVerbose(), ifLevel=3, indent=indent, logFile=self_action.getLogFile())
    
    
    ## Creates the Catalina_base
    print
    print '## Creates the Catalina_base'    
    verbose('sbase: ' + sbase + ' Creating.', level=self_action.getVerbose(), ifLevel=4, indent=indent, logFile=self_action.getLogFile())
    if not self_action.getCAttr('test'):
        #-- Create sbase
        if path.isdir(sbase):raise xception.kikonfActionSystemException(self_action, 'inject', 'sbase: ' + sbase + ' should not exist at this step !')
        os.makedirs(sbase, action_attrs.mode)
        #-- Create sub dirs
        ld=listdir(path.normpath(server_base))
        for dir in ld:
            sdir=path.normpath(server_base + '/' + dir)
            if not path.isdir(sdir):continue
            verbose('Sub directory: ' + dir + ' Created.', level=self_action.getVerbose(), ifLevel=5, indent=indent + 3*' ', logFile=self_action.getLogFile())
            shutil.copytree(sdir, path.normpath(sbase + '/' + dir))        
        verbose('sbase: ' + sbase + ' Created.', level=self_action.getVerbose(), ifLevel=3, indent=indent, logFile=self_action.getLogFile())
    else:
        message=xception.kikonfActionInformation(self_action, 'inject', 'sbase: ' + sbase + ' Not created, because Action is running in test mode.').warn(verbose=self_action.getVerbose(), doPrint=False)
        verbose(message, level=self_action.getVerbose(), ifLevel=3, indent=indent, logFile=self_action.getLogFile())
    
    if self_action.getCAttr('test'):
        exit

    verbose('Now you can launch or stop this instance running ' + 'catalina.' + suffix + ' from sbase: ' + sbase + ' !', level=self_action.getVerbose(), ifLevel=3, indent=indent, logFile=self_action.getLogFile())    
    
    ## Retreives the Scope
    print
    print '## Retreives the Scope'
    scope_name, scope_attrs, scope=self_action.getScope(parent_node=self_action.getTop(), indent=self_action.getIndent())
    self_action.verbose(scope_name=scope_name, scope_attrs=scope_attrs)    


    ## Stores the target Scope Processor Alias and mount it
    print '## Stores the target Scope Processor Alias and mount it'
    var target_scope_alias=scope.pc_ro['alias']
    :mount $target_scope_alias
    :ls
    target_node=ro[0]
    
    print '#-- Set Engine@jvmRoute'
    var jvm_route = action_attrs.jvm_route
    :set jvmRoute = $jvm_route


except Exception, e:
    
    _e=xception.kikonfActionSystemException(self_action, 'inject', 'An exception occures ! SubException is:' + str(e) + ' !')
    _e.setSubException(e)
    REPOZ.recordSessionException(self_action.getName(), _e)
    if self_action.getVerbose()>=10:raise
    # Dont forget to skipt a strict empty line at the end to let the Interpretor to interprete the End of the bloc !

							
(Source: <KIKONF_INSTALLATION_DIR>/plugins/actions/jbs/crtserver/by/kikonf/crtserver.inject.repoz)


  • 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 :
  • "JBoss" and "JBoss AS" are trademarks or registered trademarks of Red Hat.
  • "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