def DiscoveryMain(Framework): Framework = jee_connection.EnhancedFramework(Framework) port = entity.WeakNumeric(int) port.set(Framework.getDestinationAttribute('port')) version = Framework.getDestinationAttribute('version') resultVector = ObjectStateHolderVector() isAppResourcesDiscoveryEnabled = Boolean.valueOf(Framework.getParameter('discoverAppResources')) isJMSResourcesDiscoveryEnabled = Boolean.valueOf(Framework.getParameter('discoverJMSResources')) discoverDeployedOnlyApplications = Boolean.valueOf(Framework.getParameter("discoverDeployedOnlyApplications")) protocolType = (Framework.getDestinationAttribute('protocol') or ClientsConsts.HTTP_PROTOCOL_NAME) properties = Properties() properties.put(CollectorsConstants.PROTOCOL_ATTRIBUTE_PORT, str(port.value())) properties.put(AgentConstants.VERSION_PROPERTY, version) properties.put(AgentConstants.PROP_WEBLOGIC_PROTOCOL, protocolType) platform = jee.Platform.WEBLOGIC try: client = Framework.createClient(properties) except (Exception, JException), exc: logger.warnException("Failed to establish connection") jee_connection.reportError(Framework, str(exc), platform.getName())
def DiscoveryMain(Framework): Framework = jee_connection.EnhancedFramework(Framework) port = entity.WeakNumeric(int) port.set(Framework.getDestinationAttribute('port')) version = Framework.getDestinationAttribute('version') resultVector = ObjectStateHolderVector() isAppResourcesDiscoveryEnabled = Boolean.valueOf( Framework.getParameter('discoverAppResources')) isJMSResourcesDiscoveryEnabled = Boolean.valueOf( Framework.getParameter('discoverJMSResources')) discoverDeployedOnlyApplications = Boolean.valueOf( Framework.getParameter("discoverDeployedOnlyApplications")) protocolType = (Framework.getDestinationAttribute('protocol') or ClientsConsts.HTTP_PROTOCOL_NAME) properties = Properties() properties.put(CollectorsConstants.PROTOCOL_ATTRIBUTE_PORT, str(port.value())) properties.put(AgentConstants.VERSION_PROPERTY, version) properties.put(AgentConstants.PROP_WEBLOGIC_PROTOCOL, protocolType) platform = jee.Platform.WEBLOGIC try: client = Framework.createClient(properties) except (Exception, JException), exc: logger.warnException("Failed to establish connection") jee_connection.reportError(Framework, str(exc), platform.getName())
def DiscoveryMain(Framework): Framework = jee_connection.EnhancedFramework(Framework) isAppResourcesDiscoveryEnabled = _asBoolean(Framework.getParameter('discoverAppResources')) isJmsResourcesDiscoveryEnabled = _asBoolean(Framework.getParameter('discoverJMSResources')) platform = jee.Platform.JBOSS try: r'''In addition to the credentials we have to specify port number and version of the platform. Credentials may be defined without such information that is very important for establishing connections ''' port = entity.WeakNumeric(int) port.set(Framework.getDestinationAttribute('port')) version = Framework.getDestinationAttribute('version') properties = Properties() properties.put(CollectorsConstants.PROTOCOL_ATTRIBUTE_PORT, str(port.value())) properties.put(AgentConstants.VERSION_PROPERTY, version) client = Framework.createClient(properties) jmxProvider = jmx.Provider(client) except (Exception, JException), exc: logger.warnException("Failed to establish connection") jee_connection.reportError(Framework, str(exc), platform.getName())
def DiscoveryMain(Framework): Framework = jee_connection.EnhancedFramework(Framework) platform = jee.Platform.WEBLOGIC try: # establish connection client = Framework.createClient() shell = shellutils.ShellFactory().createShell(client) # prepare components for topology discoverer fs = file_system.createFileSystem(shell) processDiscoverer = process_discoverer.getDiscovererByShell(shell) except (Exception, JException), exc: logger.warnException(str(exc)) jee_connection.reportError(Framework, str(exc), platform.getName())
def DiscoveryMain(Framework): Framework = jee_connection.EnhancedFramework(Framework) ''' create client make discovery of domain and servers ''' platform = jee.Platform.WEBSPHERE properties = Properties() properties.put('server_was_config', 'services:connectors:SOAP_CONNECTOR_ADDRESS:host,services:connectors:SOAP_CONNECTOR_ADDRESS:port,clusterName') properties.put('datasource_was_config', 'jndiName,URL,propertySet,connectionPool') try: client = Framework.createClient(properties) except (Exception, JException), exc: logger.warnException("Failed to establish connection") jee_connection.reportError(Framework, str(exc), platform.getName())
def DiscoveryMain(Framework): Framework = jee_connection.EnhancedFramework(Framework) platform = jee.Platform.WEBSPHERE shell = None try: try: # ======================= Establish connection ===================== client = Framework.createClient() shell = shellutils.ShellFactory().createShell(client) # create FS fs = _createFileSystemRecursiveSearchEnabled(file_system.createFileSystem(shell)) pathUtil = file_system.getPath(fs) except (Exception, JException), exc: logger.warnException(str(exc)) jee_connection.reportError(Framework, str(exc), platform.getName()) else:
def DiscoveryMain(Framework): Framework = jee_connection.EnhancedFramework(Framework) platform = jee.Platform.WEBSPHERE shell = None try: try: # ======================= Establish connection ===================== client = Framework.createClient() shell = shellutils.ShellFactory().createShell(client) # create FS fs = _createFileSystemRecursiveSearchEnabled( file_system.createFileSystem(shell)) pathUtil = file_system.getPath(fs) except (Exception, JException), exc: logger.warnException(str(exc)) jee_connection.reportError(Framework, str(exc), platform.getName()) else:
def DiscoveryMain(Framework): Framework = jee_connection.EnhancedFramework(Framework) """ create client make discovery of domain and servers """ platform = jee.Platform.WEBSPHERE properties = Properties() properties.put( "server_was_config", "services:connectors:SOAP_CONNECTOR_ADDRESS:host,services:connectors:SOAP_CONNECTOR_ADDRESS:port,clusterName", ) properties.put("datasource_was_config", "jndiName,URL,propertySet,connectionPool") try: client = Framework.createClient(properties) except (Exception, JException), exc: logger.warnException("Failed to establish connection") jee_connection.reportError(Framework, str(exc), platform.getName())
def DiscoveryMain(Framework): # import must be placed here as they are conflicts with import list in checkcred.py import jee import jee_connection import jmx import jee_discoverer import jboss import jboss_discoverer Framework = jee_connection.EnhancedFramework(Framework) resultVector = ObjectStateHolderVector() protocolName = ClientsConsts.JBOSS_PROTOCOL_NAME platform = jee.Platform.JBOSS try: ports = jee_connection.getDestinationPorts(Framework) ip, domain = jee_connection.getIpAndDomain(Framework) ip = jee.IpDescriptor(ip) protocols = jee_connection.getAvailableProtocols(Framework, protocolName, ip.value()) except (Exception, JException), exc: logger.warnException(str(exc)) jee_connection.reportError(Framework, str(exc), platform.getName())
if not discoverDeployedOnlyApplications: # report the rest of applications that are not currently deployed (backward compatibility) appVector = ObjectStateHolderVector() for app in appByName.values(): if not reportedAppByName.get(app.getName()): appVector.addAll(applicationReporter.reportApplications(domain, None, app)) #resultVector.addAll( appVector ) appVector.addAll(domainVector) _sendVectorImmediately(Framework, appVector) if not Framework.getSentObjectsCount(): logger.reportWarning('%s: No data collected' % platform.getName()) except (Exception, JException), exc: logger.warnException("Failed to discover") jee_connection.reportError(Framework, str(exc), platform.getName()) return resultVector#ObjectStateHolderVector() def discoverDomainAdministrativeIps(allservers, dnsResolver): r''' Discover administrative IP address in two ways # 1) find server with admin-role and get server's IP or hostname (role contains port) # 2) try to find the same information between managed-servers @types: list[jee.Server], jee.DnsResolver -> list[str]''' domainIpAddresses = [] isAdminServer = lambda server: server.hasRole(jee.AdminServerRole) isManagedServer = lambda server: server.hasRole(weblogic.ManagedServerRole) logger.debug( 'all servers', allservers ) adminServers = filter(isAdminServer, allservers) logger.debug( 'admin servers', adminServers ) if adminServers:
logger.warnException("Failed to discover %s" % module) vector = ObjectStateHolderVector() # for each target report separate application with modules running on that target for target, modules in modulesByTarget.items(): if target.getOsh() is None: logger.warn("Deployment target %s is not built for application %s" % (target, application)) else: appToReport = copy.copy(application) for module in modules: module = modulesByName.get(module.getName()) or module appToReport.addModule(module) vector.addAll(applicationReporter.reportApplications(domain, target, appToReport)) # send vector if application is built if vector.size(): vector.addAll( domainVector ) _sendVectorImmediately(Framework, vector) vector = serverTopologyReporter.reportNodesInDomain(domain, node) _sendVectorImmediately(Framework, vector) if not Framework.getSentObjectsCount(): logger.reportWarning('%s: No data collected' % platform.getName()) except (Exception, JException), exc: logger.warnException("Failed to discover") jee_connection.reportError(Framework, str(exc), platform.getName()) finally: client and client.close() return ObjectStateHolderVector()
reporter = jee.ServerTopologyReporter(weblogic.ServerTopologyBuilder()) # maker domain topology discovery discoverer = weblogic_discoverer.ServerDiscovererByJmx(jmx.Provider(client)) domain = discoverer.discoverRunningServersInDomain() resultVector.addAll( jee_discoverer.discoverDomainTopology( config.portNumber.value(), client.getIpAddress(), domain, dnsResolver, credentialsfulServerRole, weblogic.ServerRole, reporter, ) ) configManager.processAsSuccessful(config) except (Exception, JException), exc: logger.warnException("Failed to make a discovery") discoveryFailedMsgs.append(str(exc)) finally: if client is not None: client.close() else: if not resultVector.size(): for msg in connectionFailedMsgs: errobj = errorobject.createError(errorcodes.CONNECTION_FAILED, [protocolName], msg) logger.reportErrorObject(errobj) for msg in discoveryFailedMsgs: jee_connection.reportError(Framework, msg, platform.getName()) return resultVector
# prepare builders and reporters reporter = jee.ServerTopologyReporter( weblogic.ServerTopologyBuilder()) # maker domain topology discovery discoverer = weblogic_discoverer.ServerDiscovererByJmx( jmx.Provider(client)) domain = discoverer.discoverRunningServersInDomain() resultVector.addAll( jee_discoverer.discoverDomainTopology( config.portNumber.value(), client.getIpAddress(), domain, dnsResolver, credentialsfulServerRole, weblogic.ServerRole, reporter)) configManager.processAsSuccessful(config) except (Exception, JException), exc: logger.warnException("Failed to make a discovery") discoveryFailedMsgs.append(str(exc)) finally: if client is not None: client.close() else: if not resultVector.size(): for msg in connectionFailedMsgs: errobj = errorobject.createError( errorcodes.CONNECTION_FAILED, [protocolName], msg) logger.reportErrorObject(errobj) for msg in discoveryFailedMsgs: jee_connection.reportError(Framework, msg, platform.getName()) return resultVector