def __getconfigid__(self, id = None): if self.__wasid is None: for tp in AdminConfig.list(self.__was_cfg_type__, self.parent.__getconfigid__()).splitlines(): if AdminConfig.showAttribute(tp, 'name') == self.name: self.__wasid = tp break return self.__wasid
def __getconfigid__(self): for librefId in AdminConfig.list(self.__was_cfg_type__).splitlines(): libName = AdminConfig.showAttribute(librefId, 'libraryName') if (libName == self.libraryName and librefId.find(self.targetResourceName) != -1): return librefId return None
def getThreadPools(self): tps = {} def getTpName(x): return x.split('(')[0] for name in map(getTpName, AdminConfig.list('ThreadPool', AdminConfig.getid(self.__was_cfg_path__))): tps[name] = self.getThreadPool(name) return tps
def addApplicationFirstClassLoader(self): classLoaderIds = AdminConfig.list('Classloader', self.__getconfigid__()).splitlines() logging.debug('%i classloader(s) is defined on server %s' % (len(classLoaderIds), self.serverName)) if (len(classLoaderIds) > 2): raise IllegalStateException, 'There is more than two classloader on server %s. another classloader cannot be added for safety reasons' % ( self.id) if (len(classLoaderIds) == 2): raise IllegalStateException, 'CSE WAS Automation FW does not support several classloader for server.. please contact architecture team' if (len(classLoaderIds) == 1): classLoaderMode = AdminConfig.showAttribute( classLoaderIds[0], 'mode') logging.debug('server %s already has one %s classloader defined' % (self.serverName, classLoaderMode)) if (classLoaderMode == 'PARENT_LAST'): logging.info( 'a PARENT_LAST ClassLoader already exist on this server.. there is no need to create another one' ) if (classLoaderMode == 'PARENT_FIRST'): raise IllegalStateException, 'CSE WAS Automation FW does not support several classloader for server.. please contact architecture team' if (len(classLoaderIds) == 0): #TODO refactoring on class loader class to have proper scope SERVER other than application logging.debug( 'about to create a new classloader PARENT_LAST on server %s' % (self.__getconfigid__())) AdminConfig.create('Classloader', self.getApplicationServerId(), [['mode', 'PARENT_LAST']])
def __getconfigid__(self, id=None): if self.__wasid is None: for tp in AdminConfig.list( self.__was_cfg_type__, self.parent.__getconfigid__()).splitlines(): if AdminConfig.showAttribute(tp, 'name') == self.name: self.__wasid = tp break return self.__wasid
def remove(self): for busMemberId in AdminConfig.showAttribute(self.__getconfigid__(), 'busMembers')[1:-1].splitlines(): node = AdminConfig.showAttribute(busMemberId, 'node') server = AdminConfig.showAttribute(busMemberId, 'server') # Remove associated DataSource dsName = '_%s.%s-%s' % (node, server, self.bus) ds = DataSource(dsName) ds.remove() Resource.remove(self)
def __loadattrs__(self): Resource.__loadattrs__(self) if not self.exists(): return id = AdminConfig.showAttribute(self.__getconfigid__(), 'claims') if not id is None: self.claims = CommonSecureInterop(id, self) id = AdminConfig.showAttribute(self.__getconfigid__(), 'performs') if not id is None: self.performs = CommonSecureInterop(id, self)
def getVariableValue(self, _symbolicName, parentConfigId): variableSubstitutionEntries = AdminConfig.list( 'VariableSubstitutionEntry', parentConfigId) value = None for variableSubstitutionEntry in variableSubstitutionEntries.splitlines( ): symbolicName = AdminConfig.showAttribute(variableSubstitutionEntry, 'symbolicName') if (symbolicName == _symbolicName): value = AdminConfig.showAttribute(variableSubstitutionEntry, 'value') return value
def unsetVariable(self, name, ignored, scope=None, type=None): """Remove a Variable under the given scope or under all scopes if scope = None""" if scope is None or type is None: self.__call(self.unsetVariable, name, ignored, scope, type) if self.vms[type][scope]['vars'].has_key(name): AdminConfig.remove(self.vms[type][scope]['vars'][name]['id']) del self.vms[type][scope]['vars'][name] print "Variable '%s' removed under scope '%s'." % (name, scope) return 1 == 1 return None
def getThreadPools(self): tps = {} def getTpName(x): return x.split('(')[0] for name in map( getTpName, AdminConfig.list('ThreadPool', AdminConfig.getid(self.__was_cfg_path__))): tps[name] = self.getThreadPool(name) return tps
def updateVariable(self, name, value, scope=None, type=None): """Update variables under given scope of on every scope if this is None""" if scope is None or type is None: self.__call(self.updateVariable, name, value, scope, type) if self.vms[type][scope]['vars'].has_key(name): self.vms[type][scope]['vars'][name]['value'] = value AdminConfig.modify(self.vms[type][scope]['vars'][name]['id'], [['value', value]]) print "Variable '%s' to '%s' updated under scope '%s'." % ( name, value, scope) return 1 == 1 # True, variable updated successfully return None #False, not updated
def getTransportLayer(self): id = filter( lambda x: x.find('TransportLayer') > 0, AdminConfig.showAttribute(self.__getconfigid__(), 'layers')[1:-1].split() )[0] return TransportLayer(id, self)
def __getconfigid__(self): id = AdminConfig.list(self.__was_cfg_type__, self.parent.__getconfigid__()) if (id is None) or (id == ''): return None else: return id
def __getconfigid__(self): for pid in AdminConfig.list( Property.__was_cfg_type__, self.parent.__getconfigid__()).splitlines(): if pid.startswith(self.name): return pid return None
def __getconfigid__(self, id=None): for lpid in AdminConfig.list( self.__was_cfg_type__, self.parent.__getconfigid__()).splitlines(): if lpid.startswith(self.name): return lpid return None
def __getconfigid__(self): id = None virtualHosts = AdminConfig.list('VirtualHost').splitlines() for virtualHostId in virtualHosts: if (virtualHostId.find(self.virtualHostName) != -1): id = virtualHostId break return id
def getNodeId(serverId): nodeName = getNodeName(serverId) nodeList = AdminConfig.list('Node').splitlines() nodeId = None for node in nodeList: if (node.find(nodeName) != -1): nodeId = node return nodeId
def __init__(self): self.vms = {'cells': {}, 'clusters': {}, 'nodes': {}, 'servers': {}} for vmid in AdminConfig.list('VariableMap').splitlines(): vars = {} for varid in AdminConfig.list('VariableSubstitutionEntry', vmid).splitlines(): name = AdminConfig.showAttribute(varid, 'symbolicName') vars[name] = { 'id': varid, 'name': name, 'value': AdminConfig.showAttribute(varid, 'value') } scope = vmid.split('/')[-1].split('|')[0] type = vmid.split('/')[-2].replace('(', '') self.vms[type][scope] = {'id': vmid, 'vars': vars}
def __getconfigid__(self): id = None virtualHosts = AdminConfig.list('VirtualHost').splitlines() for virtualHostId in virtualHosts: if ( virtualHostId.find(self.virtualHostName) != -1 ): id = virtualHostId break return id
def getListenerPorts(self): lps = {} if not self.exists(): return lps #Nothing to do as there is no MessageListenerService available on this server for lpname in map(lambda x: x.split('(')[0], AdminConfig.list('ListenerPort', self.__getconfigid__()).splitlines()): lps[lpname] = ListenerPort(lpname, self) return lps
def addApplicationFirstClassLoader(self): classLoaderIds = AdminConfig.list('Classloader',self.__getconfigid__()).splitlines() logging.debug('%i classloader(s) is defined on server %s' % (len(classLoaderIds), self.serverName)) if(len(classLoaderIds)>2): raise IllegalStateException, 'There is more than two classloader on server %s. another classloader cannot be added for safety reasons' % (self.id) if(len(classLoaderIds)==2): raise IllegalStateException, 'CSE WAS Automation FW does not support several classloader for server.. please contact architecture team' if(len(classLoaderIds)==1): classLoaderMode = AdminConfig.showAttribute(classLoaderIds[0],'mode') logging.debug('server %s already has one %s classloader defined' % (self.serverName, classLoaderMode)) if (classLoaderMode=='PARENT_LAST'): logging.info('a PARENT_LAST ClassLoader already exist on this server.. there is no need to create another one') if (classLoaderMode=='PARENT_FIRST'): raise IllegalStateException, 'CSE WAS Automation FW does not support several classloader for server.. please contact architecture team' if(len(classLoaderIds)==0): #TODO refactoring on class loader class to have proper scope SERVER other than application logging.debug('about to create a new classloader PARENT_LAST on server %s' % (self.__getconfigid__())) AdminConfig.create('Classloader',self.getApplicationServerId(),[['mode','PARENT_LAST']])
def __wasinit__(self): clusters = AdminConfig.list('ServerCluster').splitlines() for clusterId in clusters: clusterName = getClusterName(clusterId) if clusterName == self.name: self.clusterId = clusterId if (self.clusterId is None): raise IllegalArgumentException, "No cluster '%s' was found in cell '%s'" % (self.name, self.cell.name)
def testAllDataSourcesInCurrentCell(): print "Testing all DataSource..." for dsName in map(lambda x: x.split('(')[0], AdminConfig.list('DataSource').splitlines()): try: ds = DataSource() ds.name = dsName testDataSource(ds) except: print >> sys.stderr, "ERROR: datasource '%s' is not working properly. Exception is: %s" % (dsName, sys.exc_info())
def __wasinit__(self): clusters = AdminConfig.list('ServerCluster').splitlines() for clusterId in clusters: clusterName = getClusterName(clusterId) if clusterName == self.name: self.clusterId = clusterId if (self.clusterId is None): raise IllegalArgumentException, "No cluster '%s' was found in cell '%s'" % ( self.name, self.cell.name)
def __loadattrs__(self, skip_attrs = []): Resource.__loadattrs__(self, skip_attrs) if not self.exists(): return for serverId in AdminConfig.list('Server', self.__was_cfg_path__).splitlines(): server = None if isNodeAgentServer(serverId): server = NodeAgent(serverId, self) else: server = Node(serverId, self) self.__servers.append(server)
def removeAll(self): map( lambda x: Library(x).remove(), # remove library by given name map( lambda x: x.split('(')[0].split(Library.__NAMEPREFIX__)[ 1], # get library name from ID filter( lambda x: x.startswith(Library.__NAMEPREFIX__ ), # get only custom libraries AdminConfig.list(self.__was_cfg_type__).splitlines())))
def getListenerPorts(self): lps = {} if not self.exists(): return lps #Nothing to do as there is no MessageListenerService available on this server for lpname in map( lambda x: x.split('(')[0], AdminConfig.list('ListenerPort', self.__getconfigid__()).splitlines()): lps[lpname] = ListenerPort(lpname, self) return lps
def removeAll(self): map( lambda x: Library(x).remove(), # remove library by given name map( lambda x: x.split('(')[0].split(Library.__NAMEPREFIX__)[1], # get library name from ID filter( lambda x: x.startswith(Library.__NAMEPREFIX__), # get only custom libraries AdminConfig.list(self.__was_cfg_type__).splitlines() ) ) )
def __loadattrs__(self, skip_attrs=[]): Resource.__loadattrs__(self, skip_attrs) if not self.exists(): return for serverId in AdminConfig.list('Server', self.__was_cfg_path__).splitlines(): server = None if isNodeAgentServer(serverId): server = NodeAgent(serverId, self) else: server = Node(serverId, self) self.__servers.append(server)
def __getconfigid__(self): if not self.__wasid is None: return self.__wasid for targetName, id in map( lambda x: [x.split('|')[0].split('/')[-1], x], AdminConfig.list(self.__was_cfg_type__).splitlines()): if targetName == self.targetResourceName: self.__wasid = id break return self.__wasid
def __getconfigid__(self): if not self.__wasid is None: return self.__wasid for targetName, id in map( lambda x: [x.split('|')[0].split('/')[-1], x], AdminConfig.list(self.__was_cfg_type__).splitlines() ): if targetName == self.targetResourceName: self.__wasid = id break return self.__wasid
def __loadattrs__(self): def excludes(x): return not { 'threadPool': None, 'listenerPorts': None }.has_key(x[0]) if self.exists(): for name, value in filter( excludes, map(splitAttrs, AdminConfig.show( self.__getconfigid__()).splitlines())): self.__was_cfg_attrmap__[name] = self.__parseattr__( name, value)
def setVariable(self, name, value, scope, type): """Creates or updates a Variable on a given scope or on every scope if scope == None""" if scope is None or type is None: self.__call(self.setVariable, name, value, scope, type) if not self.updateVariable(name, value, scope, type): id = AdminConfig.create('VariableSubstitutionEntry', self.vms[type][scope]['id'], [['symbolicName', name], ['value', value]]) self.vms[type][scope]['vars'][name] = { 'id': id, 'name': name, 'value': value } print "New variable '%s' to '%s' created under scope '%s'." % ( name, value, scope) return 1 == 1 # True
def __getconfigid__(self): for p in AdminConfig.getid(self.__was_cfg_path__).splitlines(): if self.name == p.split('(')[0]: return p return None
def removeHostAliases(self): for hostAliasId in self.getHostAliasIds(): AdminConfig.remove(hostAliasId)
def __getconfigid__(self, id = None): return AdminConfig.list(self.__was_cfg_type__, self.parent.__getconfigid__()).splitlines()[0]
def __getconfigid__(self): for pid in AdminConfig.list(Property.__was_cfg_type__, self.parent.__getconfigid__()).splitlines(): if pid.startswith(self.name): return pid return None
def __loadattrs__(self): def excludes(x): return not {'threadPool' : None, 'listenerPorts':None}.has_key(x[0]) if self.exists(): for name, value in filter(excludes, map(splitAttrs, AdminConfig.show(self.__getconfigid__()).splitlines())): self.__was_cfg_attrmap__[name] = self.__parseattr__(name, value)
def __loadattrs__(self): Resource.__loadattrs__(self) if not self.exists(): return classloader = AdminConfig.showAttribute(self.__getconfigid__(), 'classloader') self.__classloader = ClassLoader()
def getHostAliasIds(self): return AdminConfig.list('HostAlias', self.__was_cfg_path__)
def __getconfigid__(self): return AdminConfig.getid(self.__was_cfg_path__)
def __getconfigid__(self, id=None): return AdminConfig.list(self.__was_cfg_type__, self.parent.__getconfigid__()).splitlines()[0]
def __getserverids__(self): return AdminConfig.list('Server', self.__was_cfg_path__).splitlines()
def getNodeAgentServers(self): return map(NodeAgent, filter(isNodeAgentServer, AdminConfig.list('Server').splitlines()))
def __loadattrs__(self): Resource.__loadattrs__(self) if not self.exists(): return deployedObj = AdminConfig.showAttribute(self.__getconfigid__(), 'deployedObject') self.__deployedObject = DeployedObject(deployedObj, self)
def getSharedLibraryReferenceIds(self): return AdminConfig.list('LibraryRef', self.__was_cfg_path__).splitlines()
def __getconfigid__(self): for librefId in AdminConfig.list(self.__was_cfg_type__).splitlines(): libName = AdminConfig.showAttribute(librefId, 'libraryName') if (libName == self.libraryName and librefId.find(self.targetResourceName)!=-1 ): return librefId return None
def __getconfigid__(self, id = None): for lpid in AdminConfig.list(self.__was_cfg_type__, self.parent.__getconfigid__()).splitlines(): if lpid.startswith(self.name): return lpid return None
def remove(self): for librefId in AdminConfig.list('LibraryRef').splitlines(): libName = AdminConfig.showAttribute(librefId, 'libraryName') if self.name == libName: AdminConfig.remove(librefId) Resource.remove(self)
def addHostAlias(self, hostName, portNumber): AdminConfig.create('HostAlias', self.id, [['hostname',hostName],['port',`portNumber`]])
def __getconfigid__(self): return AdminConfig.list(self.__was_cfg_type__, self.__was_cfg_path__).splitlines()[0]