|
|
|
Websrv
Action : was.websrv (Category : was, Name : websrv, By : kikonf)
Complete Name : was.websrv.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 websrv plugin : Creates a WebSphere Configuration for a WebServer The following shows the main Source Code File for the Action : was.websrv 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 Websrv(wasAction): def extract(self, scope_attrs=None, **keywords): self_funct='extract' self.verbose(scope_attrs) if scope_attrs['node']==None or scope_attrs['server']==None:raise xception.kikonfActionSystemException(self, self_funct, 'Scope: Attributes "node" and "server" are required !') self.verbose(scope_attrs) indent=self.getIndent() + 3*' ' verbose('WebServer listing.', level=self.getVerbose(), ifLevel=4, indent=indent) ws=getStartByNameAsDict(split( AdminConfig.list('WebServer', AdminConfig.getid('/Node:' + scope_attrs['node'])) )) for wname in ws.keys(): if wname==scope_attrs['server']: webservers=getShowAsDict(AdminConfig.show(ws[wname])) verbose('WebServer:' + wname + ' listed.', level=self.getVerbose(), ifLevel=3, indent=indent) websrv_node=self.newTop() # because in extract, this return a blank cache node. websrv_node.setAttrs() # feeding it with attributes. mkNodeScope(websrv_node, scope_attrs, isUnique=True) ## tag: scope self.extWebSrv(websrv_node, webservers, indent=indent) def remove(self, no_name, no_name_no_prefix): self_funct='inject' websrv_node = self.getTop() websrv_attrs = websrv_node.getAttrs() if not websrv_node.hasNode('scope'):raise xception.kikonfActionSystemException(self, self_funct, 'Node scope is required !') scope_attrs=websrv_node.getNode('scope')[0].getAttrs() self.verbose(scope_attrs) indent=self.getIndent() + 3*' ' self.rmvWebsrv(scope_attrs, indent=indent) def inject(self): self_funct='inject' websrv_node = self.getTop() websrv_attrs = websrv_node.getAttrs() if not websrv_node.hasNode('scope'):raise xception.kikonfActionSystemException(self, self_funct, 'Node scope is required !') scope_attrs=websrv_node.getNode('scope')[0].getAttrs() self.verbose(scope_attrs) indent=self.getIndent() + 3*' ' # - remove first. self.rmvWebsrv(scope_attrs, indent=indent) # Specified paths if websrv_node.hasNode('files'): files_attrs=jvm_node.getNode('files')[0].getdAttrs() if websrv_attrs.conf_path!=None or websrv_attrs.log_path!=None:raise xception.kikonfActionSystemException(self, self_funct, 'Tag:websrv, if tag:files is guiven Attributes:conf_path and log_path cannot be guiven !' ) conf_file=files_attrs.conf_file access_file=files_attrs.access_file error_file=files_attrs.error_file plg_conf_file=files_attrs.plg_conf_file plg_key_file=files_attrs.plg_key_file plg_log_file=files_attrs.plg_log_file # Generic paths else: if websrv_attrs.conf_path==None or websrv_attrs.log_path==None:raise xception.kikonfActionSystemException(self, self_funct, 'Tag:websrv, both Attributes:conf_path and log_path are required if tag: files is not guiven ! Your values conf_path:' + websrv_attrs.conf_path + ', log_path:' + websrv_attrs.log_path + '.' ) conf_file=websrv_attrs.conf_path + '/httpd.conf' access_file=websrv_attrs.log_path + '/access_log' error_file=websrv_attrs.log_path + '/error_log' plg_conf_file=websrv_attrs.conf_path + '/plugin-cfg.xml' plg_key_file=websrv_attrs.conf_path + '/plugin-key.kdb' plg_log_file=websrv_attrs.log_path + '/http_plugin.log' # - create Webserver cmdvalues=[] cmdvalues.append(['name', scope_attrs.server]) srvcfgs=[] cmdvalues.append(['serverConfig', srvcfgs]) srvcfgs.append(['webInstallRoot', self.getCAttr('software_ihs_home')]) srvcfgs.append(['configurationFile', conf_file]) # was6:configurationFilename: ATTENTION! srvcfgs.append(['accessLogfile', access_file]) # was6:logFilenameAccess srvcfgs.append(['errorLogfile', error_file]) # was6:logFilenameError srvcfgs.append(['webAppMapping', 'NONE']) # was6:absent verbose('WebServer:' + scope_attrs.server +' creating.', level=self.getVerbose(), ifLevel=4, indent=indent) cmdvalues=trsToAdminTask(cmdvalues) ws=AdminTask.createWebServer(scope_attrs.node, cmdvalues) verbose('WebServer:' + scope_attrs.server +' created.', level=self.getVerbose(), ifLevel=3, indent=indent) # - create plugin cmdvalues=[] cmdvalues.append(['PluginInstallRoot', self.getCAttr('software_ihs_home') + '/Plugin']) cmdvalues.append(['RemoteConfigFilename', plg_conf_file]) cmdvalues.append(['RemoteKeyRingFilename', plg_key_file]) cmdvalues.append(['LogFilename', plg_log_file]) cmp=split(AdminConfig.showAttribute(ws, 'components'))[0] pps=split(AdminConfig.showAttribute(cmp, 'pluginProperties'))[0] verbose('pluginProperties modifying.', level=self.getVerbose(), ifLevel=4, indent=indent) AdminConfig.modify(pps, cmdvalues) verbose('pluginProperties modified.', level=self.getVerbose(), ifLevel=3, indent=indent) def rmvWebsrv(self, scope_attrs, indent=None): self_funct='rmvWebsrv' sv=AdminConfig.getid('/Cell:' + self.getCell() + '/Node:' + scope_attrs.node + '/Server:' + scope_attrs.server + '/') if sv=='':return server_type=AdminConfig.showAttribute(sv, 'serverType') if server_type!='WEB_SERVER':raise xception.kikonfActionSystemException(self, self_funct, 'Wrong Server type found:' + server_type + ', expected Server type:WEB_SERVER ! Wont remove.') verbose('WebServer:' + scope_attrs.server + ' removing.', level=self.getVerbose(), ifLevel=4, indent=indent) AdminConfig.remove(sv) verbose('WebServer:' + scope_attrs.server + ' removed.', level=self.getVerbose(), ifLevel=3, indent=indent) def extWebSrv(self, parent_node, webservers, indent=None): from os import path if path.normpath(webservers['webserverInstallRoot'])!=path.normpath(self.getCAttr('software_ihs_home')): print indent + ' Found WebServer:' + webservers['name'] + ' supporting an unknown binary root:' + webservers['webserverInstallRoot'] + '. Known binary root is:' + self.getCAttr('software_ihs_home') + '. Skipped.' attrs={} # - retreive webserver attrs['conf_file']=path.normpath(webservers['configurationFilename']) attrs['access_file']=path.normpath(webservers['logFilenameAccess']) attrs['error_file']=path.normpath(webservers['logFilenameError']) # - retreive plugin plugin_props=getShowAsDict(AdminConfig.show(split(webservers['pluginProperties'])[0])) attrs['plg_conf_file']=path.normpath(plugin_props['RemoteConfigFilename']) attrs['plg_key_file']=path.normpath(plugin_props['RemoteKeyRingFilename']) attrs['plg_log_file']=path.normpath(plugin_props['LogFilename']) parent_node.newNode('files', **attrs) def verbose(self, scope_attrs): scope=str(scope_attrs).replace("'", '')[1:-1] verbose('WebServers at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent())
Trademarks :
|