|
|
|
Custservice
Action : was.custservice (Category : was, Name : custservice, By : kikonf)
Complete Name : was.custservice.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 custservice plugin : Creates a new Custom Service into the target Server The following shows the main Source Code File for the Action : was.custservice 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 Custservice(wasAction): def extract(self, scope_attrs=None, name=None, **keywords): self_funct='extract' scope_id, scope_attrs, scope=self.getScope(scope_attrs=scope_attrs, indent=self.getIndent()) self.verbose(scope_attrs, name=name) indent=self.getIndent() + 3*' ' verbose('CustomService listing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile()) cs=split(AdminConfig.list('CustomService', scope_id)) for c in cs: custom_services=getShowAsDict(AdminConfig.show(c)) cname=custom_services['displayName'] if name!=None and name==cname \ or name==None: verbose('CustomService:' + cname + ' listed.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile()) attrs={} attrs['name']=cname attrs['enable']=custom_services['enable'] attrs['class']=custom_services['classname'] attrs['classpath']=custom_services['classpath'] if custom_services.has_key('description') and custom_services['description']!=None:attrs['desc']=custom_services['description'][1:-1] else:attrs['desc']=None if attrs['desc']==DESIGN_NOTICE:attrs['desc']=None custsrv_node=self.newTop() #-- because in extract mode, each call returns a new blank top node. custsrv_node.setAttrs(**attrs) #-- creates a scope node. mkNodeScope(custsrv_node, scope_attrs) #-- creates a scope node. ps=split(custom_services['properties']) if len(ps)>0:properties_node=custsrv_node.newNode('properties') for p in ps: properties=getShowAsDict(AdminConfig.show(p)) attrs={} attrs['name']=properties['name'] attrs['required']=properties['required'] attrs['value']=properties['value'] if properties.has_key('description') and properties['description']!=None:attrs['desc']=properties['description'][1:-1] else:attrs['desc']=None if attrs['desc']==DESIGN_NOTICE:attrs['desc']=None verbose('Property:' + properties['name'] + ' listed.', level=self.getVerbose(), ifLevel=3, indent=indent + 3*' ') properties_node.newNode('property', **attrs) def remove(self, no_name, no_name_no_prefix): custservice_node = self.getTop() custservice_attrs = custservice_node.getAttrs() scope_id, scope_attrs, scope=self.getScope(parent_node=custservice_node, indent=self.getIndent()) #-- Retreives scope # no_name/no_name_no_prefix name=custservice_attrs.name if no_name or no_name_no_prefix:name=None self.verbose(scope_attrs, name=name) indent=self.getIndent() + 3*' ' self.rmvCustService(name=name, indent=indent) def inject(self): self_funct='inject' custservice_node = self.getTop() custservice_attrs = custservice_node.getAttrs() scope_id, scope_attrs, scope=self.getScope(parent_node=custservice_node, indent=self.getIndent()) #-- Retreives scope self.verbose(scope_attrs, name=custservice_attrs.name) indent=self.getIndent() + 3*' ' self.rmvCustService(custservice_attrs.name, indent=indent) #-- remove first cmdvalues=[] cmdvalues.append(['displayName', custservice_attrs.name]) cmdvalues.append(['enable', custservice_attrs.enable]) cmdvalues.append(['classname', getattr(custservice_attrs, 'class')]) cmdvalues.append(['classpath', custservice_attrs.classpath]) if custservice_attrs.desc!=None:cmdvalues.append(['description', custservice_attrs.desc]) else:cmdvalues.append(['description', DESIGN_NOTICE]) # Creates verbose('CustomService:' + custservice_attrs.name + ' creating.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile()) custservice=AdminConfig.create('CustomService', scope_id, cmdvalues) verbose('CustomService:' + custservice_attrs.name + ' created.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile()) #-- properties if custservice_node.hasNode('properties'): properties_node=custservice_node.getNode('properties')[0] self.runProps(properties_node, custservice, indent=indent + 3*' ') def runProps(self, properties_node, custservice, indent=None): scope_id, scope_attrs, scope=self.getScope() ps=properties_node.getNodes() for property_node in ps: property_attrs=property_node.getAttrs() cmdvalues=[] cmdvalues.append(['name', property_attrs.name]) cmdvalues.append(['required', property_attrs.required]) cmdvalues.append(['value', property_attrs.value]) if property_attrs.desc!=None:cmdvalues.append(['description', property_attrs.desc]) else:cmdvalues.append(['description', DESIGN_NOTICE]) verbose('Property creating.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile()) propid=AdminConfig.create("Property", custservice, cmdvalues) verbose('Property:' + property_attrs.name + ' created.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile()) def rmvCustService(self, name=None, indent=None): scope_id, scope_attrs, scope=self.getScope() verbose('CustomService listing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile()) cs=split(AdminConfig.list('CustomService', scope_id)) cname=None for c in cs: if name!=None: cname=AdminConfig.showAttribute(c, 'displayName') if name!=None and name==cname \ or name==None: verbose('CustomServicee:' + cname + ' removing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile()) AdminConfig.remove(c) verbose('CustomService:' + cname + ' removed.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile()) def verbose(self, scope_attrs, name=None): scope=str(scope_attrs).replace("'", '')[1:-1] if name!=None:verbose('CustomService:' + name + ', at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent()) else:verbose('CustomServices at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent())
Trademarks :
|