|
|
|
Url
Action : was.url (Category : was, Name : url, By : kikonf)
Complete Name : was.url.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 url plugin : Creates a Java Url The following shows the main Source Code File for the Action : was.url 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 Url(wasAction): PROVIDER='Default URL Provider' def extract(self, scope_attrs=None, name=None, prefix=None, **keywords): scope_id, scope_attrs, scope=self.getScope(scope_attrs=scope_attrs, indent=self.getIndent()) self.verbose(scope_attrs, name=name, prefix=prefix) indent=self.getIndent() + 3*' ' url_node=self.newTop() # because in extract, this return a blank url node. url_node.setAttrs(prefix=prefix) # feeding it with attributes. mkNodeScope(url_node, scope_attrs, isUnique=True) ## tag: scope verbose('URL listing.', level=self.getVerbose(), ifLevel=4, indent=indent) us=getStartByNameAsDict(split(AdminConfig.list('URL', scope_id))) for uname in us.keys(): if prefix!=None and name!=None and uname==prefix + '_' + name \ or prefix==None and name!=None and name==uname \ or prefix!=None and name==None and uname.startswith(prefix) \ or prefix==None and name==None: verbose('URL:' + uname + ' listed.', level=self.getVerbose(), ifLevel=3, indent=indent) urls=getShowAsDict(AdminConfig.show(us[uname])) spl=urls['spec'].split('//') if len(spl)!=2:raise xception.kikonfActionSystemException(self, self_funct, 'Unable to find a decent protocol for Url:' + uname + '. Known protocols are: file://, ftp://, and htpp:// !') if urls.has_key('description') and urls['description']!=None:desc=urls['description'][1:-1] else:desc=None if desc==DESIGN_NOTICE:desc=None url_node.setAttrs(name=uname, jndi_name=urls['jndiName'], protocol=spl[0] + '//', file=spl[1], prefix=prefix, desc=desc) def remove(self, no_name, no_name_no_prefix): url_node = self.getTop() url_attrs = url_node.getAttrs() scope_id, scope_attrs, scope=self.getScope(parent_node=url_node, indent=self.getIndent()) #-- Retreives scope if no_name_no_prefix:prefix=None self.verbose(scope_attrs, name=url_attrs.name, prefix=url_attrs.prefix) indent=self.getIndent() + 3*' ' # no_name/no_name_no_prefix prefix=url_attrs.prefix name=url_attrs.name if no_name or no_name_no_prefix:name=None if no_name_no_prefix:prefix=None self.rmvUrl(name=name, prefix=url_attrs.prefix, indent=indent) def inject(self): self_funct='inject' url_node = self.getTop() url_attrs = url_node.getAttrs() scope_id, scope_attrs, scope=self.getScope(parent_node=url_node, indent=self.getIndent()) #-- Retreives scope self.verbose(scope_attrs, name=url_attrs.name, prefix=url_attrs.prefix) indent=self.getIndent() + 3*' ' # - remove first self.rmvUrl(name=url_attrs.name, prefix=url_attrs.prefix, indent=indent) # - name if url_attrs.prefix==None:name=url_attrs.name else:name=url_attrs.prefix + '_' + url_attrs.name cmdvalues=[] cmdvalues.append(['name', name]) cmdvalues.append(['jndiName', url_attrs.jndi_name]) cmdvalues.append(['spec', url_attrs.protocol + url_attrs.file]) if url_attrs.desc!=None:cmdvalues.append(['description', url_attrs.desc]) else:cmdvalues.append(['description', DESIGN_NOTICE]) verbose('URL retreiving.', level=self.getVerbose(), ifLevel=4, indent=indent) AdminConfig.create('URL', AdminConfig.getid(self.getScopeCP() + '/URLProvider:' + self.PROVIDER + '/'), cmdvalues) verbose('URL:' + name + ' created', level=self.getVerbose(), ifLevel=3, indent=indent) def rmvUrl(self, name=None, prefix=None, indent=None): scope_id, scope_attrs, scope=self.getScope() verbose('URL listing.', level=self.getVerbose(), ifLevel=4, indent=indent) us=getStartByNameAsDict(split(AdminConfig.list('URL', scope_id))) for uname in us.keys(): if prefix!=None and uname.startswith(prefix) \ or prefix==None and name!=None and name==uname \ or prefix==None and name==None: verbose('URL:' + uname + ' removing.', level=self.getVerbose(), ifLevel=4, indent=indent) AdminConfig.remove(us[uname]) verbose('URL:' + uname + ' removed.', level=self.getVerbose(), ifLevel=3, indent=indent) def verbose(self, scope_attrs, name=None, prefix=None): scope=str(scope_attrs).replace("'", '')[1:-1] if name!=None:verbose('URL:' + name + ', at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent()) elif prefix!=None:verbose('URLs under prefix:' + prefix + ', at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent()) else:verbose('URLs at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent())
Trademarks :
|