|
|
|
Chgports
Action : wls.chgports (Category : wls, Name : chgports, By : kikonf)
Complete Name : wls.chgports.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 chgports plugin : Changes a JVM ports The following shows the main Source Code File for the Action : wls.chgports 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 Chgports(wlsAction): def extract(self, scope_attrs=None, **keywords): self_funct='extract' self.verbose(scope_attrs) scope_id, scope_attrs, scope=self.getScope(scope_attrs=scope_attrs, indent=self.getIndent()) indent=self.getIndent() + 3*' ' chgports_node=self.newTop() #-- because in extract mode, each call returns a new blank top node. cmo=cd('/Servers/' + scope_attrs['server']) verbose('Server:' + scope_attrs['server'] + ' retreived.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile()) if cmo.isIIOPEnabled():chgports_node.setAttrs(enable_iiop='true') mkNodeScope(chgports_node, scope_attrs, isUnique=True) #-- creates a scope node. self.extPorts(scope_attrs['server'], chgports_node, level=self.getVerbose(), indent=indent, logFile=self.getLogFile()) verbose('Server:' + scope_attrs['server'] + ' modified.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile()) def inject(self): self_funct='inject' chgports_node = self.getTop() #-- Grabs top node chgports_attrs = chgports_node.getAttrs() scope_id, scope_attrs, scope=self.getScope(parent_node=chgports_node, indent=self.getIndent()) #-- Retreives scope self.verbose(scope_attrs) indent=self.getIndent() + 3*' ' if chgports_attrs.enable_iiop=='true': cmo=cd('/Servers/' + scope_attrs['server']) cmo.setIIOPEnabled(True) starting_port=None if chgports_attrs.starting_port!=None:starting_port=int(chgports_attrs.starting_port) port_nodes=chgports_node.getNode('port') for port_node in port_nodes: port_attrs=port_node.getdAttrs() if starting_port!=None:port_attrs['port']=starting_port setPorts(scope_attrs['server'], port_attrs, level=self.getVerbose(), indent=indent, logFile=self.getLogFile()) verbose('Protocol/Channel:' + port_attrs['protocol'] + '/' + port_attrs['channel'] + ' set to:' + str(port_attrs['port']) + '.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile()) if starting_port!=None:starting_port+=1 verbose('Server:' + scope_attrs['server'] + ' modified.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile()) def extPorts(self, server, parent_node, level=None, indent=None, logFile=None): attrs={} cmo=cd('/Servers/' + server) # - gets channel aps=cmo.getNetworkAccessPoints() for ap in aps: attrs['channel']=ap.getName() cmo=cd('/Servers/' + server + '/NetworkAccessPoints/' + attrs['channel']) # - gets protocol attrs['protocol']=cmo.getProtocol() # - gets host attrs['host']=cmo.getListenAddress() # - gets port attrs['port']=cmo.getListenPort() # - gets enable if cmo.isEnabled():attrs['enable']='true' # - gets enable_http if cmo.isHttpEnabledForThisProtocol():attrs['enable_http']='true' # - gets enable_tuneling if cmo.isTunnelingEnabled():attrs['enable_tuneling']='true' # - gets enable_ssl if cmo.isTwoWaySSLEnabled():attrs['enable_ssl']='true' # - gets ssl_client_auth if cmo.isClientCertificateEnforced():attrs['ssl_client_auth']='true' parent_node.newNode('ports', **attrs) def verbose(self, scope_attrs): scope=str(scope_attrs).replace("'", '')[1:-1] verbose('JVM Ports at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent()) def setPorts(server, attrs, level=None, indent=None, logFile=None): channel=attrs['channel'] if channel==None:channel=attrs['channel']='channel_' + attrs['protocol'] # - sets channel try: cmo=cd('/Servers/' + server + '/NetworkAccessPoints/' + channel) except: cmo=cd('/Servers/' + server) cmo.createNetworkAccessPoint(channel) cmo=cd('/Servers/' + server + '/NetworkAccessPoints/' + channel) # - sets protocol cmo.setProtocol(attrs['protocol']) # - sets host cmo.setListenAddress(attrs['host']) # - sets port cmo.setListenPort(attrs['port']) # - sets enable if attrs['enable']=='true':cmo.setEnabled(True) else:cmo.setEnabled(False) # - sets enable_http if attrs['enable_http']=='true':cmo.setHttpEnabledForThisProtocol(True) else:cmo.setHttpEnabledForThisProtocol(False) # - sets enable_ssl if attrs['enable_ssl']=='true': cmo.setTwoWaySSLEnabled(True) cmo.setEnabled(True) else: cmo.setTwoWaySSLEnabled(False) cmo.setEnabled(False) # - sets enable_tuneling if attrs['enable_tuneling']=='true': if not (attrs['enable_http'], attrs['enable_ssl'])==('true', 'true'): verbose('enable_tuneling is ignored because enable_http and enable_ssl are not set together !', level=level, ifLevel=3, indent=indent + 3*' ', logFile=logFile) else:cmo.setTunnelingEnabled(True) else:cmo.setTunnelingEnabled(False) # - sets ssl_client_auth if attrs['ssl_client_auth']=='true':cmo.setClientCertificateEnforced(True) else:cmo.setClientCertificateEnforced(False)
Trademarks :
|