def DiscoveryMain(Framework):
    version = Framework.getDestinationAttribute('siebelVersion')
    siebelRootDir = Framework.getDestinationAttribute('siebelInstallDir')

    OSHVResult = ObjectStateHolderVector()
    appServerId = Framework.getDestinationAttribute('id')
    appServerOSH = modeling.createOshByCmdbIdString('siebel_app_server',
                                                    appServerId)
    modeling.setAppServerType(appServerOSH)

    client = None
    try:
        client = Framework.createClient()
        discoverConfigFile(siebelRootDir, appServerOSH, client, version,
                           OSHVResult)
    except:
        errmsg = 'Connection failed: %s' % str(sys.exc_info()[1]).strip()
        Framework.reportError(errmsg)
        logger.debugException(errmsg)

    if (client != None):
        try:
            client.close()
        except:
            pass

    return OSHVResult
Example #2
0
def processWebsphere(context, processName, pattern):
    wasOsh = context.application.getOsh()
    cellName = None
    serverName = None
    process = context.application.getProcess(processName)
    processOriginCmd = process.commandLine
    if processOriginCmd is not None:
        logger.debug('For process id ', process.getPid(),
                     ' found original command line ', processOriginCmd)
        m = re.search(pattern, processOriginCmd)
        if m is not None:
            cellName = m.group(1)
            serverName = m.group(3)
            fullName = ''.join([m.group(2), '_', m.group(3)]).strip()
            logger.debug('Parsed out server name ', serverName, ' in cell ',
                         cellName)
        else:
            logger.debug(
                'Failed to parse out cell name and server name from command line'
            )
    if serverName is not None:
        wasOsh.setStringAttribute('j2eeserver_servername', serverName)
        if fullName:
            wasOsh.setStringAttribute('j2eeserver_fullname', fullName)
        modeling.setJ2eeServerAdminDomain(wasOsh, cellName)
        modeling.setAppServerType(wasOsh)
    else:
        raise IgnoreApplicationException(
            'WebSphere details cannot be acquired, ignoring the application')
def DiscoveryMain(Framework):
	version = Framework.getDestinationAttribute('siebelVersion')
	siebelRootDir = Framework.getDestinationAttribute('siebelInstallDir')

	OSHVResult = ObjectStateHolderVector()
	appServerId = Framework.getDestinationAttribute('id')
	appServerOSH = modeling.createOshByCmdbIdString('siebel_app_server', appServerId)
	modeling.setAppServerType(appServerOSH)

	client = None
	try:
		client = Framework.createClient()
		discoverConfigFile(siebelRootDir,appServerOSH,client,version,OSHVResult)
	except:
		errmsg = 'Connection failed: %s' % str(sys.exc_info()[1]).strip()
		Framework.reportError(errmsg)
		logger.debugException(errmsg)

	if(client != None):
		try:
			client.close()
		except:
			pass

	return OSHVResult
    def enrichAppServerOsh(self, context, processName):
        r'''Goal of this is to set for reported Weblogic AS
         - administrative domain name
         - application type as Application Server (AS)
         @types: applications.ApplicationSignatureContext, str
        '''
        # @types: ProcessObject
        process = context.application.getProcess(processName)
        # compose function to get process by PID required to get
        # domain root directory path
        appComponent = context.application.getApplicationComponent()
        applicationSignature = appComponent.getApplicationSignature()
        processInfoManager = applicationSignature.getProcessesManager()
        # here it is - function accept PID and returns process or None
        getProcessByPid = (processInfoManager
                           and processInfoManager.getProcessByPid
                           or (lambda *args: None)
        )

        # first of all set application type as AS for the server OSH
        serverOsh = context.application.getOsh()
        modeling.setAppServerType(serverOsh)

        # initialize required data
        loadExternalDtd = 0
        shell = context.client # for shell jobs we have shellutils.Shell instance
        fs = file_system.createFileSystem(shell)

        try:
            # find out path of domain root directory
            domainRootPath = weblogic_by_shell.getDomainRootDirPath(shell, fs, process,
                                               getProcessByPid)
        except:
            logger.debug("Domain root directory path cannot be found from the runtime information.")
            return
        domainLayout = weblogic_discoverer.createDomainLayout(fs, domainRootPath)
        parser = weblogic_discoverer.createDomainConfigParserByLayout(domainLayout, loadExternalDtd)
        try:
            domainDescriptorFile = domainLayout.getFileContent(
                        domainLayout.getDomainConfigFilePath()
            )
            domainDescriptor = parser.parseConfiguration(domainDescriptorFile.content)
        except (Exception, JException):
            logger.warnException("Failed to process config.xml")
        else:
            # get version of the platform
            versionInfo = domainDescriptor.versionInfo
            logger.info("Platform version is %s" % versionInfo)
            domainName = domainDescriptor.getName()
            # update server administrative domain attribute
            modeling.setJ2eeServerAdminDomain(serverOsh, domainName)
            servers = domainDescriptor.getServers()
            for server in servers:
                if server.getName() == serverOsh.getAttributeValue('name'):
                    serverFullName = jee.ServerTopologyBuilder()._composeFullName(server)
                    serverOsh.setAttribute('j2eeserver_fullname', serverFullName)
                    break
def processGlassfish(context, processName):
    glassfishOsh = context.application.getOsh()

    logger.debug('Started processing')
    process = context.application.getProcess(processName)
    processOriginCmd = process.commandLine
    if processOriginCmd is not None:
        serverName = None
        serverRuntime = None
        if processOriginCmd.find(
                'com.sun.enterprise.glassfish.bootstrap.ASMain') != -1:
            serverRuntime = glassfish_discoverer.createServerRuntimeV3(
                processOriginCmd, None)
            DescriptorClass = glassfish_discoverer.DomainXmlDescriptorV3
        elif processOriginCmd.find('com.sun.enterprise.server.PELaunch') != -1:
            serverRuntime = glassfish_discoverer.createServerRuntimeV2(
                processOriginCmd, None)
            DescriptorClass = glassfish_discoverer.DomainXmlDescriptorV2

        if serverRuntime:
            serverName = serverRuntime.findServerName()
            globalSettings = GeneralSettingsConfigFile.getInstance()
            loadExternalDTD = globalSettings.getPropertyBooleanValue(
                'loadExternalDTD', 0)

            fs = file_system.createFileSystem(context.client)
            layout = glassfish_discoverer.createServerLayout(serverRuntime, fs)
            domainXmlFile = layout.getFile(layout.getDomainXmlPath())

            xPathParser = glassfish_discoverer.XpathParser(loadExternalDTD)
            descriptor = DescriptorClass(xPathParser, domainXmlFile.content)
            domainName = descriptor.findDomainName()

            nodeName = descriptor.findNodeNameByServerName(serverName)

            if serverName and domainName:
                logger.debug('Reporting serverName %s, domainName %s' %
                             (serverName, domainName))
                glassfishOsh.setStringAttribute('j2eeserver_servername',
                                                serverName)
                modeling.setJ2eeServerAdminDomain(glassfishOsh, domainName)
                modeling.setAppServerType(glassfishOsh)
                # server full name
                nodeNamePart = nodeName and '%s_' % nodeName or ''
                fullName = '%s%s' % (nodeNamePart, serverName)
                glassfishOsh.setAttribute('j2eeserver_fullname', fullName)
            else:
                logger.debug(
                    'Glassfish details cannot be acquired, ignoring the application %s, %s'
                    % (serverName, domainName))
        else:
            logger.debug('Server runtime is not created')
    else:
        logger.debug('No process comman line found for pid: %s' %
                     process.getPid())
def processGlassfish(context, processName):
    glassfishOsh = context.application.getOsh()

    logger.debug('Started processing')
    process = context.application.getProcess(processName)
    processOriginCmd = process.commandLine
    if processOriginCmd is not None:
        serverName = None
        serverRuntime = None
        if processOriginCmd.find('com.sun.enterprise.glassfish.bootstrap.ASMain') != -1:
            serverRuntime = glassfish_discoverer.createServerRuntimeV3(processOriginCmd, None)
            DescriptorClass = glassfish_discoverer.DomainXmlDescriptorV3
        elif processOriginCmd.find('com.sun.enterprise.server.PELaunch') != -1:
            serverRuntime = glassfish_discoverer.createServerRuntimeV2(processOriginCmd, None)
            DescriptorClass = glassfish_discoverer.DomainXmlDescriptorV2

        if serverRuntime:
            serverName = serverRuntime.findServerName()
            globalSettings = GeneralSettingsConfigFile.getInstance()
            loadExternalDTD = globalSettings.getPropertyBooleanValue('loadExternalDTD', 0)

            fs = file_system.createFileSystem(context.client)
            layout = glassfish_discoverer.createServerLayout(serverRuntime, fs)
            domainXmlFile = layout.getFile(layout.getDomainXmlPath())

            xPathParser = glassfish_discoverer.XpathParser(loadExternalDTD)
            descriptor = DescriptorClass(xPathParser, domainXmlFile.content)
            domainName = descriptor.findDomainName()

            nodeName = descriptor.findNodeNameByServerName(serverName)

            if serverName and domainName:
                logger.debug('Reporting serverName %s, domainName %s' % (serverName, domainName))
                glassfishOsh.setStringAttribute('j2eeserver_servername', serverName)
                modeling.setJ2eeServerAdminDomain(glassfishOsh, domainName)
                modeling.setAppServerType(glassfishOsh)
                # server full name
                nodeNamePart = nodeName and '%s_' % nodeName or ''
                fullName = '%s%s' % (nodeNamePart, serverName)
                glassfishOsh.setAttribute('j2eeserver_fullname', fullName)
            else:
                logger.debug('Glassfish details cannot be acquired, ignoring the application %s, %s' % (serverName, domainName))
        else:
            logger.debug('Server runtime is not created')
    else:
        logger.debug('No process comman line found for pid: %s' % process.getPid())
 def process(self, context):
     application = context.application
     osh = application.getOsh()
     process = application.getMainProcesses()[0]
     command_line = process.commandLine
     server_name = 'default'
     p = 'org\.jboss\.Main.*?\s+-{1,2}(?:c\s+|configuration\s*=\s*)([\w_\.-]+)'
     m = re.search(p, command_line)
     if m is not None:
         server_name = m.group(1)
         logger.debug('Found jboss ', server_name, ' configuration')
     else:
         logger.debug('Found jboss default configuration')
     osh.setAttribute('j2eeserver_servername', server_name)
     #TODO: replace to jee.ServerTopologyBuilder._composeFullName
     osh.setAttribute('j2eeserver_fullname', server_name)
     modeling.setJ2eeServerAdminDomain(osh, server_name)
     modeling.setAppServerType(osh)
 def process(self, context):
     application = context.application
     osh = application.getOsh()
     process = application.getMainProcesses()[0]
     command_line = process.commandLine
     server_name = 'default'
     p = 'org\.jboss\.Main.*?\s+-{1,2}(?:c\s+|configuration\s*=\s*)([\w_\.-]+)'
     m = re.search(p, command_line)
     if m is not None:
         server_name = m.group(1)
         logger.debug('Found jboss ', server_name, ' configuration')
     else:
         logger.debug('Found jboss default configuration')
     osh.setAttribute('j2eeserver_servername', server_name)
     #TODO: replace to jee.ServerTopologyBuilder._composeFullName
     osh.setAttribute('j2eeserver_fullname', server_name)
     modeling.setJ2eeServerAdminDomain(osh, server_name)
     modeling.setAppServerType(osh)
 def process(self, context):
     shell = context.client
     fs = file_system.createFileSystem(shell)
     path_util = file_system.getPath(fs)
     application = context.application
     osh = application.getOsh()
     process = application.getMainProcesses()[0]
     cmd_line = process.commandLine
     jvm_cmd_line_descriptor = jee.JvmCommandLineDescriptor(cmd_line)
     cmd_line_elements = jvm_cmd_line_descriptor.parseElements()
     java_options = filter(self.__is_java_option, cmd_line_elements)
     parse_fn = partiallyApply(self.parse_server_name, fptools._, path_util)
     server_name = first(keep(parse_fn, java_options))
     logger.debug('server name: %s' % server_name)
     if server_name is not None:
         osh.setAttribute('j2eeserver_servername', server_name)
         #TODO: replace to jee.ServerTopologyBuilder._composeFullName
         osh.setAttribute('j2eeserver_fullname', server_name)
     modeling.setAppServerType(osh)
 def process(self, context):
     shell = context.client
     fs = file_system.createFileSystem(shell)
     path_util = file_system.getPath(fs)
     application = context.application
     osh = application.getOsh()
     process = application.getMainProcesses()[0]
     cmd_line = process.commandLine
     jvm_cmd_line_descriptor = jee.JvmCommandLineDescriptor(cmd_line)
     cmd_line_elements = jvm_cmd_line_descriptor.parseElements()
     java_options = filter(self.__is_java_option, cmd_line_elements)
     parse_fn = partiallyApply(self.parse_server_name, fptools._, path_util)
     server_name = first(keep(parse_fn, java_options))
     logger.debug('server name: %s' % server_name)
     if server_name is not None:
         osh.setAttribute('j2eeserver_servername', server_name)
         #TODO: replace to jee.ServerTopologyBuilder._composeFullName
         osh.setAttribute('j2eeserver_fullname', server_name)
     modeling.setAppServerType(osh)
 def process(self, context):
     application = context.application
     osh = application.getOsh()
     shell = context.client
     fs = file_system.createFileSystem(shell)
     ip = application.getConnectionIp()
     dns_resolver = jee_discoverer.DnsResolverDecorator(
                             netutils.createDnsResolverByShell(shell), ip)
     process = application.getMainProcesses()[0]
     cmd_line = process.commandLine
     server_runtime = jboss_discoverer.createServerRuntime(cmd_line, ip)
     home_dir = server_runtime.findHomeDirPath()
     config = server_runtime.extractOptionValue('--server-config')
     layout = jboss_discoverer.StandaloneModeLayout(fs, home_dir, config)
     loadDtd = 0
     server_config_parser = jboss_discoverer.ServerConfigParserV7(loadDtd)
     standalone_config_path = layout.getStandaloneConfigPath()
     standalone_config_file = layout.getFileContent(standalone_config_path)
     content = standalone_config_file.content
     standalone_config_with_expressions = (
                 server_config_parser.parseStandaloneServerConfig(content))
     server_properties = jboss_discoverer.SystemProperties()
     properties_from_cmd_line = server_runtime.findJbossProperties()
     server_properties.update(properties_from_cmd_line)
     config_props = standalone_config_with_expressions.getSystemProperties()
     server_properties.update(config_props)
     standalone_config = server_config_parser.resolveStandaloneServerConfig(
                      standalone_config_with_expressions, server_properties)
     server_name = standalone_config.getServerName()
     if not server_name:
         try:
             server_name = dns_resolver.resolveHostnamesByIp(ip)[0]
         except netutils.ResolveException:
             server_name = 'Default'
     if server_name is not None:
         osh.setAttribute('j2eeserver_servername', server_name)
         #TODO: replace to jee.ServerTopologyBuilder._composeFullName
         osh.setAttribute('j2eeserver_fullname', server_name)
         modeling.setJ2eeServerAdminDomain(osh, server_name)
     modeling.setAppServerType(osh)
 def process(self, context):
     application = context.application
     osh = application.getOsh()
     shell = context.client
     fs = file_system.createFileSystem(shell)
     ip = application.getConnectionIp()
     dns_resolver = jee_discoverer.DnsResolverDecorator(
         netutils.createDnsResolverByShell(shell), ip)
     process = application.getMainProcesses()[0]
     cmd_line = process.commandLine
     server_runtime = jboss_discoverer.createServerRuntime(cmd_line, ip)
     home_dir = server_runtime.findHomeDirPath()
     config = server_runtime.extractOptionValue('--server-config')
     layout = jboss_discoverer.StandaloneModeLayout(fs, home_dir, config)
     loadDtd = 0
     server_config_parser = jboss_discoverer.ServerConfigParserV7(loadDtd)
     standalone_config_path = layout.getStandaloneConfigPath()
     standalone_config_file = layout.getFileContent(standalone_config_path)
     content = standalone_config_file.content
     standalone_config_with_expressions = (
         server_config_parser.parseStandaloneServerConfig(content))
     server_properties = jboss_discoverer.SystemProperties()
     properties_from_cmd_line = server_runtime.findJbossProperties()
     server_properties.update(properties_from_cmd_line)
     config_props = standalone_config_with_expressions.getSystemProperties()
     server_properties.update(config_props)
     standalone_config = server_config_parser.resolveStandaloneServerConfig(
         standalone_config_with_expressions, server_properties)
     server_name = standalone_config.getServerName()
     if not server_name:
         try:
             server_name = dns_resolver.resolveHostnamesByIp(ip)[0]
         except netutils.ResolveException:
             server_name = 'Default'
     if server_name is not None:
         osh.setAttribute('j2eeserver_servername', server_name)
         #TODO: replace to jee.ServerTopologyBuilder._composeFullName
         osh.setAttribute('j2eeserver_fullname', server_name)
         modeling.setJ2eeServerAdminDomain(osh, server_name)
     modeling.setAppServerType(osh)
def processWebsphere(context, processName, pattern):
    wasOsh = context.application.getOsh()
    cellName = None
    serverName = None
    process = context.application.getProcess(processName)
    processOriginCmd = process.commandLine
    if processOriginCmd is not None:
        logger.debug("For process id ", process.getPid(), " found original command line ", processOriginCmd)
        m = re.search(pattern, processOriginCmd)
        if m is not None:
            cellName = m.group(1)
            serverName = m.group(3)
            fullName = "".join([m.group(2), "_", m.group(3)]).strip()
            logger.debug("Parsed out server name ", serverName, " in cell ", cellName)
        else:
            logger.debug("Failed to parse out cell name and server name from command line")
    if serverName is not None:
        wasOsh.setStringAttribute("j2eeserver_servername", serverName)
        if fullName:
            wasOsh.setStringAttribute("j2eeserver_fullname", fullName)
        modeling.setJ2eeServerAdminDomain(wasOsh, cellName)
        modeling.setAppServerType(wasOsh)
    else:
        raise IgnoreApplicationException("WebSphere details cannot be acquired, ignoring the application")
    def enrichAppServerOsh(self, context, processName):
        r'''Goal of this is to set for reported Weblogic AS
         - administrative domain name
         - application type as Application Server (AS)
         @types: applications.ApplicationSignatureContext, str
        '''
        # @types: ProcessObject
        process = context.application.getProcess(processName)
        # compose function to get process by PID required to get
        # domain root directory path
        appComponent = context.application.getApplicationComponent()
        applicationSignature = appComponent.getApplicationSignature()
        processInfoManager = applicationSignature.getProcessesManager()
        # here it is - function accept PID and returns process or None
        getProcessByPid = (processInfoManager
                           and processInfoManager.getProcessByPid
                           or (lambda *args: None))

        # first of all set application type as AS for the server OSH
        serverOsh = context.application.getOsh()
        modeling.setAppServerType(serverOsh)

        # initialize required data
        loadExternalDtd = 0
        shell = context.client  # for shell jobs we have shellutils.Shell instance
        fs = file_system.createFileSystem(shell)

        try:
            # find out path of domain root directory
            domainRootPath = weblogic_by_shell.getDomainRootDirPath(
                shell, fs, process, getProcessByPid)
        except:
            logger.debug(
                "Domain root directory path cannot be found from the runtime information."
            )
            return
        domainLayout = weblogic_discoverer.createDomainLayout(
            fs, domainRootPath)
        parser = weblogic_discoverer.createDomainConfigParserByLayout(
            domainLayout, loadExternalDtd)
        try:
            domainDescriptorFile = domainLayout.getFileContent(
                domainLayout.getDomainConfigFilePath())
            domainDescriptor = parser.parseConfiguration(
                domainDescriptorFile.content)
        except (Exception, JException):
            logger.warnException("Failed to process config.xml")
        else:
            # get version of the platform
            versionInfo = domainDescriptor.versionInfo
            logger.info("Platform version is %s" % versionInfo)
            domainName = domainDescriptor.getName()
            # update server administrative domain attribute
            modeling.setJ2eeServerAdminDomain(serverOsh, domainName)
            servers = domainDescriptor.getServers()
            for server in servers:
                if server.getName() == serverOsh.getAttributeValue('name'):
                    serverFullName = jee.ServerTopologyBuilder(
                    )._composeFullName(server)
                    serverOsh.setAttribute('j2eeserver_fullname',
                                           serverFullName)
                    break
def DiscoveryMain(Framework):

	OSHVResult = ObjectStateHolderVector()

	siebelRootDir = Framework.getDestinationAttribute('siebelRootDir')
	protocol = Framework.getDestinationAttribute('Protocol')
	ip_address = Framework.getDestinationAttribute('ip_address')
	dbType = Framework.getDestinationAttribute('siebelappserver_svrdstype')
	dbConnStr = Framework.getDestinationAttribute('siebelappserver_svrdsconnstr')
	dsnName = Framework.getDestinationAttribute('siebelappserver_odbcdsn')

	if not dsnName:
		dsnName = DEFAULT_DSN_NAME

	logger.debug('ODBC discovery started on:', ip_address)

	shellUtils = None
	try:
		try:
			if not dbType:
				raise ValueError, "parameter 'siebelappserver_svrdstype' is empty"

			client = Framework.createClient()
			shellUtils = shellutils.ShellUtils(client)

			appServerId = Framework.getDestinationAttribute('id')
			appServerOSH = modeling.createOshByCmdbIdString('siebel_app_server', appServerId)
			modeling.setAppServerType(appServerOSH)

			odbc_siebel_registry_key_path = None
			dsnName = dsnName and dsnName.strip()
			if dsnName:
				odbc_siebel_registry_key_path = '\\'.join([ODBC_SIEBEL_REGISTRY_KEY_PATH, dsnName])
			else:
				# try this one if the previous is empty
				odbc_siebel_registry_key_path = '\\'.join([ODBC_SIEBEL_REGISTRY_KEY_PATH, dbConnStr])

			if re.search('ORACLE', dbType, re.I):

				dbName = getOracleDBName(protocol, odbc_siebel_registry_key_path, ip_address, Framework, siebelRootDir, shellUtils, dsnName)
				logger.debug('oracle server name is ', dbName)
				logger.debug('discovering Oracle server DB')
				discoverOracleDB(dbName, protocol, ip_address, shellUtils, appServerOSH, Framework, OSHVResult)

			elif re.search('MSSQLSERVER', dbType, re.I):
				if protocol == 'ntcmd':
					logger.debug('discovering MSSQL Server DB')
					discoverSQLServerDB(shellUtils, odbc_siebel_registry_key_path, OSHVResult)
				else:
					raise ValueError, 'MSSQLSERVER discovery is supported on Windows only'

			elif re.search('DB2', dbType, re.I):
				if protocol == 'ntcmd':
					discoverDB2Windows(shellUtils, dbConnStr, appServerOSH, OSHVResult)
				else:
					discoverDB2Unix(siebelRootDir, shellUtils, dsnName, appServerOSH, OSHVResult)
			else:
				raise ValueError, "Database type '%s' is not supported" % dbType

		except JavaException, ex:
			exInfo = ex.getMessage()
			errormessages.resolveAndReport(exInfo, protocol, Framework)
		except Exception, ex:
			logger.debugException('')
			exInfo = str(ex)
			errormessages.resolveAndReport(exInfo, protocol, Framework)
def makeAppServer(client, username, enterprise, serverObj, serverDataRow, siteOSH, Framework, OSHVResult):
	# init return value

	logger.debug('server:', string.join(serverObj), ' dataRow:', serverDataRow)
	datalist = serverObj
	sblsvrName = datalist[0]
	logger.debug('sblsvrName:', sblsvrName)
	hostName = datalist[1]
	installDir = datalist[2]
	sblmgrPID = datalist[3]
	serverID = datalist[9]
	# if no PID, server is not running. send an event on it
	# the message of the event will be everything that follows
	# the PID field
	if string.strip(sblmgrPID) == '':
		logger.debug('problem server:', serverDataRow)
		runningServer = 0
		logger.debug('app server', sblsvrName, ' is not Running')
	else:
		runningServer = 1
		# called status, but actually version details
		status = datalist[8]
		logger.debug('status:', status)
		versionTokens = status.split()
		version = versionTokens[0]
		build = versionTokens[1]
		lang = versionTokens[2]

	# host
	logger.debug('building host:', hostName)
	try:
		ip = netutils.getHostAddress(hostName)
		logger.debug('found ip:', ip, ' for hostName:', hostName)
		if ip == None:
			return None
		if netutils.isLocalIp(ip):
			logger.debug('got loopback ip, probably error.')
			return None
		appServerHostOSH = modeling.createHostOSH(ip)
	except:
		logger.errorException('failed to convert host name:', hostName, ' to IP')
		return None

	# siebel application server
	appServerOSH = modeling.createApplicationOSH('siebel_app_server', sblsvrName, appServerHostOSH, 'Enterprise App', 'oracle_corp')
	appServerOSH.setAttribute('application_ip', ip)
	appServerOSH.setAttribute('application_username', username)
	appServerOSH.setAttribute('install_dir', installDir)
	appServerOSH.setAttribute('svr_id',serverID)

	modeling.setAppServerType(appServerOSH)

	#9.0 workaround
	versionAsDouble = logger.Version().getVersion(Framework)
	if versionAsDouble >= 9:
		appServerOSH.removeAttribute('data_name')
		appServerOSH.setAttribute('name', sblsvrName)
		modeling.setApplicationProductName(appServerOSH, 'Siebel Server')

	OSHVResult.add(appServerHostOSH)
	OSHVResult.add(appServerOSH)

	if runningServer:
		appServerOSH.setAttribute('version', version)
		appServerOSH.setAttribute('application_version', version)
		appServerOSH.setAttribute('build', build)
		appServerOSH.setAttribute('lang', lang)

		# NOTE: setting the current app server so that all info will be only
		# for it
		prompt = client.executeCmd(string.join(['set server ', sblsvrName]), 5000)#@@CMD_PERMISION siebel protocol execution
		logger.debug(prompt)

		# get component groups (and components for each group) for this server
		# NOTE: as far as we know there can't be components that are not under a group
		# if such a situation can exist we won't find such 'leaf' components
		# with the current code

		#
		#
		makeComponentGroups(client, appServerOSH, ip, OSHVResult, enterprise, siteOSH)

		if version[0] == '7' or version[0] == '8':
			# get DB (Data Source) Attributes
			# table[0][0][1] means:
			# [0] - first row (should be only one, we are inside a server context)
			# [0] - first column: the parsed fields (second column is original row for error purposes)
			# [1] - second value in the parsed fields
			try:
				svrdsconnstrTblTxt = client.executeCmd('list parameter DSConnectString for named subsystem ServerDataSrc')#@@CMD_PERMISION siebel protocol execution
				svrdsconnstrTbl = siebel_common.makeTable(svrdsconnstrTblTxt)
				svrdsconnstr = string.upper(svrdsconnstrTbl[0][0][1])
				logger.debug('svrdsconnstr:', svrdsconnstr)
				appServerOSH.setAttribute('srv_ds_conn_str', svrdsconnstr)
			except:
				error_message = 'failed to get DSConnectString (to set attribute srv_ds_conn_str) on server'
				logger.debug(error_message)
				Framework.reportWarning(error_message)
			try:
				svrdstypeTblTxt = client.executeCmd('list parameters DSSQLStyle for named subsystem ServerDataSrc')#@@CMD_PERMISION siebel protocol execution
				svrdstypeTbl = siebel_common.makeTable(svrdstypeTblTxt)
				if svrdstypeTbl:
					svrdstype = svrdstypeTbl[0][0][1]
				else:
					svrdstypeTblTxt = client.executeCmd('list parameters DSDLLName for named subsystem ServerDataSrc')#@@CMD_PERMISION siebel protocol execution
					svrdstypeTbl = siebel_common.makeTable(svrdstypeTblTxt)
					svrdstype = DLL_TO_SQL_TYPE_MAP[svrdstypeTbl[0][0][1]]

				logger.debug('svrdstype:', svrdstype)
				appServerOSH.setAttribute('svr_ds_type', svrdstype)
			except:
				error_message = 'failed to get DSSQLStyle (to set attribute svr_ds_type) on server'
				logger.debugException(error_message)
				Framework.reportWarning(error_message)


			serverType = getSiebelServerType(client)
			if serverType:
				appServerOSH.setStringAttribute('data_description', serverType)
			else:
				logger.warn("Cannot determine the type of server '%s', no required components were found" % sblsvrName)

		if version[0] == '6':
			# in Siebel 2000 (tested with 6.3), we can't obtain some of the parameters using command line API
			# get missing attributes from configuration file
			logger.info('Datasource parameters are not supported in version ', version)
			logger.info('Please run SIEBEL_DIS_APP_SERVER_CONFIG pattern to get server datasource attributes')

		try:
			odbcDSNTblTxt = client.executeCmd('list param connect')#@@CMD_PERMISION siebel protocol execution
			odbcDSNTbl = siebel_common.makeTable(odbcDSNTblTxt)
			odbcDSN = odbcDSNTbl[0][0][1]
			logger.debug('odbcDSN:', odbcDSN)
			appServerOSH.setAttribute('odbc_dsn', odbcDSN)
		except:
			error_message = 'failed to get ODBC DSN (connect param (to set attribute odbc_dsn) on server'
			logger.debug(error_message)
			Framework.reportWarning(error_message)

		# NOTE: unsetting the current app server
		prompt = client.executeCmd('unset server', 3000)#@@CMD_PERMISION siebel protocol execution
		logger.debug(prompt)

	return appServerOSH
Example #17
0
def DiscoveryMain(Framework):

    OSHVResult = ObjectStateHolderVector()

    siebelRootDir = Framework.getDestinationAttribute('siebelRootDir')
    protocol = Framework.getDestinationAttribute('Protocol')
    ip_address = Framework.getDestinationAttribute('ip_address')
    dbType = Framework.getDestinationAttribute('siebelappserver_svrdstype')
    dbConnStr = Framework.getDestinationAttribute(
        'siebelappserver_svrdsconnstr')
    dsnName = Framework.getDestinationAttribute('siebelappserver_odbcdsn')

    if not dsnName:
        dsnName = DEFAULT_DSN_NAME

    logger.debug('ODBC discovery started on:', ip_address)

    shellUtils = None
    try:
        try:
            if not dbType:
                raise ValueError, "parameter 'siebelappserver_svrdstype' is empty"

            client = Framework.createClient()
            shellUtils = shellutils.ShellUtils(client)

            appServerId = Framework.getDestinationAttribute('id')
            appServerOSH = modeling.createOshByCmdbIdString(
                'siebel_app_server', appServerId)
            modeling.setAppServerType(appServerOSH)

            odbc_siebel_registry_key_path = None
            dsnName = dsnName and dsnName.strip()
            if dsnName:
                odbc_siebel_registry_key_path = '\\'.join(
                    [ODBC_SIEBEL_REGISTRY_KEY_PATH, dsnName])
            else:
                # try this one if the previous is empty
                odbc_siebel_registry_key_path = '\\'.join(
                    [ODBC_SIEBEL_REGISTRY_KEY_PATH, dbConnStr])

            if re.search('ORACLE', dbType, re.I):

                dbName = getOracleDBName(protocol,
                                         odbc_siebel_registry_key_path,
                                         ip_address, Framework, siebelRootDir,
                                         shellUtils, dsnName)
                logger.debug('oracle server name is ', dbName)
                logger.debug('discovering Oracle server DB')
                discoverOracleDB(dbName, protocol, ip_address, shellUtils,
                                 appServerOSH, Framework, OSHVResult)

            elif re.search('MSSQLSERVER', dbType, re.I):
                if protocol == 'ntcmd':
                    logger.debug('discovering MSSQL Server DB')
                    discoverSQLServerDB(shellUtils,
                                        odbc_siebel_registry_key_path,
                                        OSHVResult)
                else:
                    raise ValueError, 'MSSQLSERVER discovery is supported on Windows only'

            elif re.search('DB2', dbType, re.I):
                if protocol == 'ntcmd':
                    discoverDB2Windows(shellUtils, dbConnStr, appServerOSH,
                                       OSHVResult)
                else:
                    discoverDB2Unix(siebelRootDir, shellUtils, dsnName,
                                    appServerOSH, OSHVResult)
            else:
                raise ValueError, "Database type '%s' is not supported" % dbType

        except JavaException, ex:
            exInfo = ex.getMessage()
            errormessages.resolveAndReport(exInfo, protocol, Framework)
        except Exception, ex:
            logger.debugException('')
            exInfo = str(ex)
            errormessages.resolveAndReport(exInfo, protocol, Framework)