Пример #1
0
	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
Пример #2
0
 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
Пример #3
0
 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
Пример #4
0
 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']])
Пример #5
0
 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
Пример #6
0
	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)
Пример #7
0
	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)
Пример #8
0
 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
Пример #9
0
    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
Пример #10
0
    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
Пример #11
0
    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
Пример #12
0
	def getTransportLayer(self):
		id = filter(
			lambda x: x.find('TransportLayer') > 0,
			AdminConfig.showAttribute(self.__getconfigid__(), 'layers')[1:-1].split()
		)[0]
		
		return TransportLayer(id, self)
Пример #13
0
 def __getconfigid__(self):
     id = AdminConfig.list(self.__was_cfg_type__,
                           self.parent.__getconfigid__())
     if (id is None) or (id == ''):
         return None
     else:
         return id
Пример #14
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
Пример #15
0
 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
Пример #16
0
 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
Пример #17
0
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    
Пример #18
0
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
Пример #19
0
    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}
Пример #20
0
 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
Пример #21
0
	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
Пример #22
0
 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']])
Пример #23
0
 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)
Пример #24
0
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())
Пример #25
0
    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)
Пример #26
0
 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)
Пример #27
0
 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())))
Пример #28
0
    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
Пример #29
0
	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()
				)
			)
		)
Пример #30
0
 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)
Пример #31
0
    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
Пример #32
0
	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
Пример #33
0
    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)
Пример #34
0
    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
Пример #35
0
	def __getconfigid__(self):
		for p in AdminConfig.getid(self.__was_cfg_path__).splitlines():
			if self.name == p.split('(')[0]:
				return p
		return None
Пример #36
0
 def removeHostAliases(self):
     for hostAliasId in self.getHostAliasIds():
         AdminConfig.remove(hostAliasId)
Пример #37
0
	def __getconfigid__(self, id = None):
		return AdminConfig.list(self.__was_cfg_type__, self.parent.__getconfigid__()).splitlines()[0]
Пример #38
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
Пример #39
0
	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)
Пример #40
0
 def __loadattrs__(self):
     Resource.__loadattrs__(self)
     if not self.exists(): return
     classloader = AdminConfig.showAttribute(self.__getconfigid__(),
                                             'classloader')
     self.__classloader = ClassLoader()
Пример #41
0
 def getHostAliasIds(self):
     return AdminConfig.list('HostAlias', self.__was_cfg_path__)
Пример #42
0
 def __getconfigid__(self):
     return AdminConfig.getid(self.__was_cfg_path__)
Пример #43
0
 def __getconfigid__(self, id=None):
     return AdminConfig.list(self.__was_cfg_type__,
                             self.parent.__getconfigid__()).splitlines()[0]
Пример #44
0
 def __getserverids__(self):
     return AdminConfig.list('Server', self.__was_cfg_path__).splitlines()
Пример #45
0
 def getHostAliasIds(self):
     return AdminConfig.list('HostAlias', self.__was_cfg_path__)
Пример #46
0
 def removeHostAliases(self):
     for hostAliasId in self.getHostAliasIds():
         AdminConfig.remove(hostAliasId)
Пример #47
0
 def getNodeAgentServers(self):
     return map(NodeAgent, filter(isNodeAgentServer, AdminConfig.list('Server').splitlines()))
Пример #48
0
	def __loadattrs__(self):
		Resource.__loadattrs__(self)
		if not self.exists(): return
		deployedObj           = AdminConfig.showAttribute(self.__getconfigid__(), 'deployedObject')
		self.__deployedObject = DeployedObject(deployedObj, self)
Пример #49
0
 def getSharedLibraryReferenceIds(self):
     return AdminConfig.list('LibraryRef', self.__was_cfg_path__).splitlines()
Пример #50
0
	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
Пример #51
0
	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
Пример #52
0
	def __loadattrs__(self):
		Resource.__loadattrs__(self)
		if not self.exists(): return
		classloader        = AdminConfig.showAttribute(self.__getconfigid__(), 'classloader')
		self.__classloader = ClassLoader()
Пример #53
0
	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)
Пример #54
0
 def addHostAlias(self, hostName, portNumber):
     AdminConfig.create('HostAlias', self.id, [['hostname',hostName],['port',`portNumber`]])
Пример #55
0
 def __loadattrs__(self):
     Resource.__loadattrs__(self)
     if not self.exists(): return
     deployedObj = AdminConfig.showAttribute(self.__getconfigid__(),
                                             'deployedObject')
     self.__deployedObject = DeployedObject(deployedObj, self)
Пример #56
0
	def __getconfigid__(self):
		return AdminConfig.list(self.__was_cfg_type__, self.__was_cfg_path__).splitlines()[0]
Пример #57
0
	def __getconfigid__(self):
		id = AdminConfig.list(self.__was_cfg_type__, self.parent.__getconfigid__())
		if (id is None) or (id == ''):
			return None
		else:
			return id