Пример #1
0
def getAttribute(defaultsStr, attrStr):
    if defaultsStr is not None:
        attrPattern = Pattern(''.join([attrStr, '\s*=\s*([^\s]*)']))
        match = attrPattern.matcher(defaultsStr)
        if match.find() == 1:
            return match.group(1) and match.group(1).strip()
    return ''
Пример #2
0
def findTNSEntriesStr(tns_buffer):
    entryPatten = Pattern('([\w\d.]*)\s*=\s*\(DESCRIPTION')
    match = entryPatten.matcher(tns_buffer)
    tns_start_indices = []
    tns_entries_str = []
    while match.find() == 1:
        tns_start_indices += [match.start()]

    # split buffer
    totalIndices = len(tns_start_indices)
    if totalIndices < 1:
        logger.info('no TNS entries found in file, or failed getting file')
        return []# return on error

    logger.debug('totalIndices', totalIndices)
    counter = 0
    curIndex = 0
    nextIndex = 0
    while counter < totalIndices - 1:
        curIndex = tns_start_indices[counter]
        nextIndex = tns_start_indices[counter+1]
        entry = tns_buffer[curIndex:nextIndex-1]
        tns_entries_str += [entry]
        counter += 1
    tns_entries_str += [tns_buffer[tns_start_indices[totalIndices-1]:]]
    return tns_entries_str
Пример #3
0
def findTNSEntriesStr(tns_buffer):
    entryPatten = Pattern('([\w\d.]*)\s*=\s*\(DESCRIPTION')
    match = entryPatten.matcher(tns_buffer)
    tns_start_indices = []
    tns_entries_str = []
    while match.find() == 1:
        tns_start_indices += [match.start()]

    # split buffer
    totalIndices = len(tns_start_indices)
    if totalIndices < 1:
        logger.info('no TNS entries found in file, or failed getting file')
        return []  # return on error

    logger.debug('totalIndices', totalIndices)
    counter = 0
    curIndex = 0
    nextIndex = 0
    while counter < totalIndices - 1:
        curIndex = tns_start_indices[counter]
        nextIndex = tns_start_indices[counter + 1]
        entry = tns_buffer[curIndex:nextIndex - 1]
        tns_entries_str += [entry]
        counter += 1
    tns_entries_str += [tns_buffer[tns_start_indices[totalIndices - 1]:]]
    return tns_entries_str
Пример #4
0
def getAttribute(defaultsStr, attrStr):
	if defaultsStr is not None:
		attrPattern = Pattern(''.join([attrStr, '\s*=\s*([^\s]*)']))
		match = attrPattern.matcher(defaultsStr)
		if match.find() == 1:
			return match.group(1) and match.group(1).strip()
	return ''
Пример #5
0
def getProfileName(site, fullPath):
    name = fullPath
    pattern = Pattern('[\s]*[^\s]*(' + site + '[^\s]*)')
    match = pattern.matcher(fullPath)
    if match.find() >= 1:
        name = match.group(1)
    return name
Пример #6
0
def getOracleHomeUnix(shellUtils):
	oracleHome = ''
	# 1. try env ORACLE_HOME
	env = shellUtils.execCmd('env')#@@CMD_PERMISION siebel protocol execution
	lines = env.split('\n')
	for line in lines:
		if line and line.find('ORACLE_HOME') > -1:
			logger.debug('found ORACLE_HOME env var', line)
			oraHome = getAttribute(line, 'ORACLE_HOME')
			logger.debug('oraHome=', oraHome)
			if oraHome != '':
				oracleHome = oraHome
				logger.debug('oracleHome found:', oracleHome)
				break
		if line and line.find('TNS_ADMIN') > -1:
			logger.debug('found TNS_ADMIN env var', line)
			tnsLoc = getAttribute(line, 'TNS_ADMIN')
			if tnsLoc != '':
				oraHome = tnsLoc

				networkAdminIndex = tnsLoc.find('/network/admin')
				if networkAdminIndex >= 0:
					oraHome = oraHome[:networkAdminIndex]

				oracleHome = oraHome
				logger.debug('oracleHome found:', oracleHome)
				break
	# if we didn't find it in env
	if oracleHome == '':
		logger.debug('looking for oracle home in /var/opt/oracle')
		# 2. try /var/opt/oracle
		oraInstLoc = ''
		try:
			oraInstLoc = shellUtils.safecat('/var/opt/oracle/oraInst.loc')
			logger.debug('oraInstLoc', oraInstLoc)
		except:
			logger.debug('Failed to get oraIns.loc')
		if oraInstLoc != '':

			inventoryLoc = getAttribute(oraInstLoc, 'inventory_loc')
			if inventoryLoc != '':
				oraProductPath = inventoryLoc[:inventoryLoc.find('/oraInventory')]
				lsCmd = ' '.join(['ls ', oraProductPath])
				dirList = shellUtils.execCmd(lsCmd)#@@CMD_PERMISION siebel protocol execution
				logger.debug('dirList', dirList)
				files = dirList.split()
				for file in files:
					logger.debug('file', file)
					versionPattern = Pattern('\d+.\d+.\d+.\d+')
					match = versionPattern.matcher(file)
					if match.find() == 1:
						logger.debug('found version dir')
						versionDir = match.group(0)
						logger.debug('versionDir', versionDir)
						oracleHome = ''.join([oraProductPath, '/', versionDir])
						break

	logger.debug('returning oracleHome', oracleHome)
	return oracleHome
Пример #7
0
def getApps(data):
    apps = []
    pattern = Pattern('(\[/[^\[]*)')
    matcher = pattern.matcher(data)
    while matcher.find() == 1:
        app = matcher.group(1)
        apps += [app]
    return apps
Пример #8
0
def getINIFileEntries(data):
	entries = []
	pattern = Pattern('(\[[^\[]*)')
	matcher = pattern.matcher(data)
	while matcher.find() == 1:
		entry = matcher.group(1)
		entries += [entry]
	return entries
Пример #9
0
def getApps(data):
	apps = []
	pattern = Pattern('(\[/[^\[]*)')
	matcher = pattern.matcher(data)
	while matcher.find() == 1:
		app = matcher.group(1)
		apps += [app]
	return apps
Пример #10
0
def getTNSAttribute(tns_entry_str, attrStrs):
    for attrStr in attrStrs:
        attrPattern = Pattern(string.join([attrStr, '\s*=\s*([^\)]*)'], ''))
        logger.debug('attrPattern', attrPattern)
        match = attrPattern.matcher(tns_entry_str)
        if match.find() == 1:
            return string.strip(match.group(1))
    return ''
Пример #11
0
def getINIFileEntries(data):
    entries = []
    pattern = Pattern('(\[[^\[]*)')
    matcher = pattern.matcher(data)
    while matcher.find() == 1:
        entry = matcher.group(1)
        entries += [entry]
    return entries
Пример #12
0
def getTNSAttribute(tns_entry_str, attrStrs):
    for attrStr in attrStrs:
        attrPattern = Pattern(string.join([attrStr, '\s*=\s*([^\)]*)'], ''))
        logger.debug('attrPattern', attrPattern)
        match = attrPattern.matcher(tns_entry_str)
        if match.find() == 1:
            return string.strip(match.group(1))
    return ''
Пример #13
0
def stripNtcmdHeaders(data):
    pattern = Pattern(
        'Connecting to remote service ... Ok(.*)Remote command returned 0',
        REFlags.DOTALL)
    match = pattern.matcher(data)
    if match.find() == 1:
        return string.strip(match.group(1))
    return None
Пример #14
0
def getClientInstallFolderUnix(driverPath):
	profilePath = None
	#/home/db2cl8d/sqllib/lib/db2.o
	pattern = Pattern('[\s]*([^\s]*sqllib/)')
	matcher = pattern.matcher(driverPath)
	while matcher.find() == 1:
		path = matcher.group(1)
		profilePath = path + 'db2profile'
	return profilePath
Пример #15
0
def getClientInstallFolderUnix(driverPath):
    profilePath = None
    #/home/db2cl8d/sqllib/lib/db2.o
    pattern = Pattern('[\s]*([^\s]*sqllib/)')
    matcher = pattern.matcher(driverPath)
    while matcher.find() == 1:
        path = matcher.group(1)
        profilePath = path + 'db2profile'
    return profilePath
Пример #16
0
def getAttributes(defaultsStr, startStr):
    mapAttrToValue = HashMap()
    attrPattern = Pattern('(VirtualServer[^\s]*)\s*=\s*([^\s]*)')
    match = attrPattern.matcher(defaultsStr)
    while match.find() > 0:
        key = match.group(1)
        value = match.group(2)
        mapAttrToValue.put(key, value)
    return mapAttrToValue
Пример #17
0
def getTNSAttributeList(tns_entry_str, attrStrs):
    result = []
    for attrStr in attrStrs:
        attrPattern = Pattern(string.join(['(?<![\w_.])',attrStr, '\s*=\s*([^\)]*)'], ''))
        logger.debug(' attrPattern ', attrPattern, ' str ', tns_entry_str)
        match = attrPattern.matcher(tns_entry_str)
        while match.find() == 1:
            result += [string.strip(match.group(1))]
    return result
Пример #18
0
def getAttributes(defaultsStr, startStr):
	mapAttrToValue = HashMap()
	attrPattern = Pattern('(VirtualServer[^\s]*)\s*=\s*([^\s]*)')
	match = attrPattern.matcher(defaultsStr)
	while match.find() > 0:
		key = match.group(1)
		value = match.group(2)
		mapAttrToValue.put(key,value)
	return mapAttrToValue
Пример #19
0
def getTNSAttributeList(tns_entry_str, attrStrs):
    result = []
    for attrStr in attrStrs:
        attrPattern = Pattern(
            string.join(['(?<![\w_.])', attrStr, '\s*=\s*([^\)]*)'], ''))
        logger.debug(' attrPattern ', attrPattern, ' str ', tns_entry_str)
        match = attrPattern.matcher(tns_entry_str)
        while match.find() == 1:
            result += [string.strip(match.group(1))]
    return result
Пример #20
0
def parseTNSNames(tns_buffer, db_domain, shell=None):
    tns_entries = []
    tns_buffer = tns_buffer.upper()
    tns_buffer = stripCommentLines(tns_buffer, '#')
    logger.debug('tns_buffer')
    logger.debug(tns_buffer)
    tns_entries_str = findTNSEntriesStr(tns_buffer)
    if tns_entries_str == []:
        return []  # error, no entries

    startPattern = Pattern('([\w\d.]*)\s*=\s*\(DESCRIPTION')
    for tns_entry_str in tns_entries_str:
        host_names = getTNSAttributeList(tns_entry_str, ['HOST'])
        for host_name in host_names:
            tns_entry = []
            logger.debug('tns_entry_str', tns_entry_str)
            match = startPattern.matcher(tns_entry_str)
            if match.find() == 1:
                tns_name = string.strip(match.group(1))
                logger.debug('tns_name', tns_name)
                tns_entry += [tns_name]
            logger.debug('host_name', host_name)
            tns_entry += [host_name]
            port = getTNSAttribute(tns_entry_str, ['PORT'])
            logger.debug('port', port)
            tns_entry += [port]
            sid = getTNSAttribute(tns_entry_str, ['SID'])
            if sid == '':
                sid = getTNSAttribute(tns_entry_str,
                                      ['SERVICE_NAME', 'service_name'])
                if sid == '':
                    sid = getTNSAttribute(tns_entry_str, ['GLOBAL_DBNAME'])
            tns_name = stripDomain(tns_name, db_domain)
            sid = stripDomain(sid, db_domain)
            logger.debug('sid', sid)
            tns_entry += [sid]
            tns_entry += [tns_name]
            host_ip = ''
            if shell:
                try:
                    resolver = netutils.DNSResolver(shell)
                    ips = resolver.resolveIpByNsLookup(host_name)
                    host_ip = ips and ips[
                        0] or resolver.resolveHostIpByHostsFile(host_name)
                except:
                    logger.warn('Failed to resolve host ip throught nslookup')
                    host_ip = host_name
            else:
                host_ip = netutils.getHostAddress(host_name, host_name)
            tns_entry += [host_ip]
            tns_entries += [tns_entry]
            logger.debug(tns_entry)

    return tns_entries
Пример #21
0
def parseWSESettings(data, siebelwseOSH):
    pattern = Pattern('\[wse\]([^\[]*)\[')
    match = pattern.matcher(data)
    if match.find() == 1:
        settingsStr = match.group(1)

        lang = getAttribute(settingsStr, 'Language')
        log = getAttribute(settingsStr, 'Log')
        logger.debug('swe settings:', lang, log)
        siebelwseOSH.setAttribute('language', lang)
        siebelwseOSH.setAttribute('loglevel', log)
Пример #22
0
def parseWSESettings(data, siebelwseOSH):
	pattern = Pattern('\[wse\]([^\[]*)\[')
	match = pattern.matcher(data)
	if match.find() == 1:
		settingsStr = match.group(1)

		lang = getAttribute(settingsStr, 'Language')
		log = getAttribute(settingsStr, 'Log')
		logger.debug('swe settings:', lang, log)
		siebelwseOSH.setAttribute('language', lang)
		siebelwseOSH.setAttribute('loglevel', log)
Пример #23
0
def parseInstallPath(installStr):
	sweapp = None
	pattern = Pattern('\s*([^\s]*SWEApp)\s*')
	match = pattern.matcher(installStr)
	if match.find() == 1:
		sweapp = match.group(1)
		sweapp = sweapp.replace('\\',CollectorsParameters.FILE_SEPARATOR)
		sweapp = sweapp.replace('/',CollectorsParameters.FILE_SEPARATOR)
		logger.debug('parseInstallPath: found installation path [', sweapp, ']')
	else:
		logger.warn('parseInstallPath: installation path was not found in [', installStr, ']')
	return sweapp
Пример #24
0
def parseTNSNames(tns_buffer, db_domain, shell = None):
    tns_entries = []
    tns_buffer = tns_buffer.upper()
    tns_buffer = stripCommentLines(tns_buffer, '#')
    logger.debug('tns_buffer')
    logger.debug(tns_buffer)
    tns_entries_str = findTNSEntriesStr(tns_buffer)
    if tns_entries_str == []:
        return [] # error, no entries

    startPattern = Pattern('([\w\d.]*)\s*=\s*\(DESCRIPTION')
    for tns_entry_str in tns_entries_str:
        host_names = getTNSAttributeList(tns_entry_str, ['HOST'])
        for host_name in host_names:
            tns_entry = []
            logger.debug('tns_entry_str', tns_entry_str)
            match = startPattern.matcher(tns_entry_str)
            if match.find() == 1:
                tns_name = string.strip(match.group(1))
                logger.debug('tns_name', tns_name)
                tns_entry += [tns_name]
            logger.debug('host_name', host_name)
            tns_entry += [host_name]
            port = getTNSAttribute(tns_entry_str, ['PORT'])
            logger.debug('port', port)
            tns_entry += [port]
            sid = getTNSAttribute(tns_entry_str, ['SID'])
            if sid == '':
                sid = getTNSAttribute(tns_entry_str, ['SERVICE_NAME','service_name'])
                if sid == '':
                    sid = getTNSAttribute(tns_entry_str, ['GLOBAL_DBNAME'])
            tns_name = stripDomain(tns_name,db_domain)
            sid = stripDomain(sid,db_domain)
            logger.debug('sid', sid)
            tns_entry += [sid]
            tns_entry += [tns_name]
            host_ip = ''
            if shell:
                try:
                    resolver = netutils.DNSResolver(shell)
                    ips = resolver.resolveIpByNsLookup(host_name)
                    host_ip = ips and ips[0] or resolver.resolveHostIpByHostsFile(host_name)
                except:
                    logger.warn('Failed to resolve host ip throught nslookup')
                    host_ip = host_name
            else:
                host_ip = netutils.getHostAddress(host_name, host_name)
            tns_entry += [host_ip]
            tns_entries += [tns_entry]
            logger.debug(tns_entry)

    return tns_entries
Пример #25
0
def parseInstallPath(installStr):
    sweapp = None
    pattern = Pattern('\s*([^\s]*SWEApp)\s*')
    match = pattern.matcher(installStr)
    if match.find() == 1:
        sweapp = match.group(1)
        sweapp = sweapp.replace('\\', CollectorsParameters.FILE_SEPARATOR)
        sweapp = sweapp.replace('/', CollectorsParameters.FILE_SEPARATOR)
        logger.debug('parseInstallPath: found installation path [', sweapp,
                     ']')
    else:
        logger.warn('parseInstallPath: installation path was not found in [',
                    installStr, ']')
    return sweapp
Пример #26
0
def parseWSEDefaults(data, siebelwseOSH):
	pattern = Pattern('\[defaults\]([^\[]*)\[')
	match = pattern.matcher(data)
	if match.find() == 1:
		defaultsStr = match.group(1)

		anonUserName = getAttribute(defaultsStr, 'AnonUserName')
		httpPort = getAttribute(defaultsStr, 'HTTPPort')
		httpsPort = getAttribute(defaultsStr, 'HTTPSPort')
		doCompress = getAttribute(defaultsStr, 'DoCompression')
		guestSessionTO = getAttribute(defaultsStr, 'GuestSessionTimeout')
		sessionTO = getAttribute(defaultsStr, 'SessionTimeout')
		logger.debug('swe defaults:', anonUserName, httpPort, httpsPort, doCompress, guestSessionTO, sessionTO)
		siebelwseOSH.setAttribute('anon_user_name', anonUserName)
		siebelwseOSH.setLongAttribute('http_port', httpPort)
		siebelwseOSH.setLongAttribute('https_port', httpsPort)
		siebelwseOSH.setBoolAttribute('do_compress', doCompress)
		siebelwseOSH.setLongAttribute('guest_session_timeout', guestSessionTO)
		siebelwseOSH.setLongAttribute('session_time_out', sessionTO)
Пример #27
0
def parseWSEDefaults(data, siebelwseOSH):
    pattern = Pattern('\[defaults\]([^\[]*)\[')
    match = pattern.matcher(data)
    if match.find() == 1:
        defaultsStr = match.group(1)

        anonUserName = getAttribute(defaultsStr, 'AnonUserName')
        httpPort = getAttribute(defaultsStr, 'HTTPPort')
        httpsPort = getAttribute(defaultsStr, 'HTTPSPort')
        doCompress = getAttribute(defaultsStr, 'DoCompression')
        guestSessionTO = getAttribute(defaultsStr, 'GuestSessionTimeout')
        sessionTO = getAttribute(defaultsStr, 'SessionTimeout')
        logger.debug('swe defaults:', anonUserName, httpPort, httpsPort,
                     doCompress, guestSessionTO, sessionTO)
        siebelwseOSH.setAttribute('anon_user_name', anonUserName)
        siebelwseOSH.setLongAttribute('http_port', httpPort)
        siebelwseOSH.setLongAttribute('https_port', httpsPort)
        siebelwseOSH.setBoolAttribute('do_compress', doCompress)
        siebelwseOSH.setLongAttribute('guest_session_timeout', guestSessionTO)
        siebelwseOSH.setLongAttribute('session_time_out', sessionTO)
def updateMissingAttributes(cfgFile,appServerOSH,OSHVResult):
	dataSourcesSection = getIniSection(cfgFile,'DataSources')
	if dataSourcesSection == None:
		logger.error('failed to find datasources section')
		return

	serverDS = getKeyByValue(dataSourcesSection,'Server')
	if serverDS == None:
		logger.error('failed to find server key in datasource section')
		return

	entryPatten = Pattern('\[' + serverDS + '\]([^\[]*)\[')
	match = entryPatten.matcher(cfgFile)
	if match.find() == 1:
		defaultsStr = match.group(1)
		logger.debug('updating svrdsconnstr and svrdstype attributes')
		sqlStyle = getAttribute(defaultsStr, 'SqlStyle')
		connectString = getAttribute(defaultsStr, 'ConnectString')
		appServerOSH.setAttribute('srv_ds_conn_str', connectString)
		appServerOSH.setAttribute('svr_ds_type', sqlStyle)
		OSHVResult.add(appServerOSH)
def updateMissingAttributes(cfgFile, appServerOSH, OSHVResult):
    dataSourcesSection = getIniSection(cfgFile, 'DataSources')
    if dataSourcesSection == None:
        logger.error('failed to find datasources section')
        return

    serverDS = getKeyByValue(dataSourcesSection, 'Server')
    if serverDS == None:
        logger.error('failed to find server key in datasource section')
        return

    entryPatten = Pattern('\[' + serverDS + '\]([^\[]*)\[')
    match = entryPatten.matcher(cfgFile)
    if match.find() == 1:
        defaultsStr = match.group(1)
        logger.debug('updating svrdsconnstr and svrdstype attributes')
        sqlStyle = getAttribute(defaultsStr, 'SqlStyle')
        connectString = getAttribute(defaultsStr, 'ConnectString')
        appServerOSH.setAttribute('srv_ds_conn_str', connectString)
        appServerOSH.setAttribute('svr_ds_type', sqlStyle)
        OSHVResult.add(appServerOSH)
Пример #30
0
def getOracleDefaultDomain(oraHome, protocol, shellUtils):
    oracleSqlNamesPath = ''
    separator = '/'
    if protocol == 'ntcmd':
        separator = '\\'
        oracleSqlNamesPath = ORACLE_SQLNET_PATH
    else:
        oracleSqlNamesPath = ORACLE_SQLNET_PATH.replace('\\', '/')

    domain = ''
    sqlnetPath = ''.join([oraHome, separator, oracleSqlNamesPath])

    try:
        sqlnet_buffer = shellUtils.safecat(sqlnetPath)

        pattern = Pattern('NAMES.DEFAULT_DOMAIN\s+=\s+(.*)')
        matcher = pattern.matcher(sqlnet_buffer)
        if matcher.find() == 1:
            domain = matcher.group(1)
            domain = domain and domain.strip()
            domain = domain and domain.upper()
    except:
        logger.debug('Failed to discover doamin name')
    return domain
Пример #31
0
def getOracleDefaultDomain(oraHome, protocol, shellUtils):
	oracleSqlNamesPath = ''
	separator = '/'
	if protocol == 'ntcmd':
		separator = '\\'
		oracleSqlNamesPath = ORACLE_SQLNET_PATH
	else:
		oracleSqlNamesPath = ORACLE_SQLNET_PATH.replace('\\','/')

	domain = ''
	sqlnetPath = ''.join([oraHome, separator , oracleSqlNamesPath])

	try:
		sqlnet_buffer = shellUtils.safecat(sqlnetPath)

		pattern = Pattern('NAMES.DEFAULT_DOMAIN\s+=\s+(.*)')
		matcher = pattern.matcher(sqlnet_buffer)
		if matcher.find() == 1:
			domain = matcher.group(1)
			domain = domain and domain.strip()
			domain = domain and domain.upper()
	except:
		logger.debug('Failed to discover doamin name')
	return domain
def getAttribute(defaultsStr, attrStr):
	attrPattern = Pattern(attrStr + '\s*=\s*([^\s]*)')
	match = attrPattern.matcher(defaultsStr)
	if match.find() == 1:
		return string.strip(match.group(1))
	return None
def getIniSection(data,sectionName):
	entryPatten = Pattern('\[' + sectionName + '\]([^\[]*)\[')
	match = entryPatten.matcher(data)
	if match.find() == 1:
		return match.group(1)
	return None
Пример #34
0
def parseCfgFileData(data, installPath, sarmLogFolder, shellUtils,
                     webserverOSH, OSHVResult, HOST_ID, Framework):
    # create siebel web server extension
    siebelwseOSH = ObjectStateHolder('siebel_wse')
    siebelwseOSH.setContainer(webserverOSH)
    siebelwseOSH.setAttribute('data_name', 'Siebel WSE')
    siebelwseOSH.setAttribute('install_path', installPath)

    # try to get some general info on the SWE
    try:
        parseWSEDefaults(data, siebelwseOSH)
    except:
        logger.debug('failed getting wse defaults')

    OSHVResult.add(siebelwseOSH)

    configFileOsh = modeling.createConfigurationDocumentOSH(
        'eapps.cfg', installPath, data, siebelwseOSH, modeling.MIME_TEXT_PLAIN,
        None, "Siebel Webserver Extention file")
    OSHVResult.add(configFileOsh)

    mapKeyToAppServers = None
    enableVirtualHosts = getAttribute(data, 'EnableVirtualHosts')
    if (enableVirtualHosts.lower() == 'true'):
        virtualHostsFile = getAttribute(data, 'VirtualHostsFile')
        if virtualHostsFile != None:
            virtualHostsFileData = None
            try:
                virtualHostsFileData = shellUtils.safecat(virtualHostsFile)
                if not virtualHostsFileData:
                    raise ValueError
            except:
                logger.warn("Failed reading virtual host file '%s'" %
                            virtualHostsFile)
            else:
                pattern = Pattern('([^\s]*)[\\\/]([^\s.]*).([^\s]*)')
                matcher = pattern.matcher(virtualHostsFile)
                if matcher.find() == 1:
                    path = matcher.group(1)
                    filename = matcher.group(2)
                    extension = matcher.group(3)

                    configFileName = "%s.%s" % (filename, extension)
                    configFileOsh = modeling.createConfigurationDocumentOSH(
                        configFileName, path, virtualHostsFileData,
                        siebelwseOSH, modeling.MIME_TEXT_PLAIN, None,
                        'Load Balancer configuration file')
                    OSHVResult.add(configFileOsh)

                    mapKeyToAppServers = getAttributes(virtualHostsFileData,
                                                       'VirtualServer')

    # get web applications data
    apps = getApps(data)

    gatewayIpToOsh = {}
    siteNameToOsh = {}

    for app in apps:

        appName = app[app.find('[/') + 2:app.find(']')]
        connStr = getAttribute(app, 'ConnectString')

        # sample line: siebel.TCPIP.None.None://sblgw:2320/siebel/CRAObjMgr_cht/sblapp1_AS
        # sample line: siebel.TCPIP.None.None://cannon:2320/siebel/ERMObjMgr_chs/cannon
        gtwyHost = ''
        gtwyPort = ''
        siebelSite = ''
        componentName = ''
        appSvrName = ''
        appSvrIP = ''
        ip = ''

        tokens = connStr.split('/')
        numOfTokens = len(tokens)
        if numOfTokens > 2:
            if (enableVirtualHosts.lower() == 'true'):
                appServers = mapKeyToAppServers.get(tokens[2])
                if appServers != None:
                    serversStr = appServers.split(';')
                    for serverStr in serversStr:
                        if serverStr != '':
                            serverStrTokens = serverStr.split(':')
                            if appSvrName != '':
                                appSvrName += ','
                            if appSvrIP != '':
                                appSvrIP += ','
                            serverName = serverStrTokens[1]
                            appSvrName += serverName
                            appSvrIP += netutils.getHostAddress(
                                serverName, serverName)
            else:
                gtwyConn = tokens[2].split(':')
                gtwyHost = gtwyConn[0]
                gtwyPort = gtwyConn[1]
                if not netutils.isValidIp(gtwyHost):
                    ip = resolveHostname(gtwyHost, shellUtils, '')
                else:
                    ip = gtwyHost

        if numOfTokens > 3:
            siebelSite = tokens[3]
        if numOfTokens > 4:
            componentName = tokens[4]
        if numOfTokens > 5:
            appSvrName = tokens[5]
        else:
            if appSvrIP == '':
                appSvrIP = ip
            gtwyHost = None

        if gtwyHost and ip and not gatewayIpToOsh.has_key(ip):

            gatewayOsh = createGatewayOsh(ip, gtwyPort, OSHVResult, Framework)
            OSHVResult.add(gatewayOsh)

            routeLinkOSH = modeling.createLinkOSH('depend', gatewayOsh,
                                                  siebelwseOSH)
            OSHVResult.add(routeLinkOSH)

            gatewayIpToOsh[ip] = gatewayOsh

            if siebelSite and not siteNameToOsh.has_key(siebelSite):
                logger.debug('found siebel site:', siebelSite)
                siteOSH = ObjectStateHolder('siebel_site')
                siteOSH.setAttribute('gateway_address', ip)
                siteOSH.setAttribute('data_name', siebelSite)
                modeling.setAppSystemVendor(siteOSH)
                OSHVResult.add(siteOSH)
                siteNameToOsh[siebelSite] = siteOSH

        # create a siebel application object
        webappOSH = ObjectStateHolder('siebel_web_app')
        webappOSH.setAttribute('data_name', appName)
        webappOSH.setAttribute('site', siebelSite)
        webappOSH.setAttribute('app_srv_name', appSvrName)
        webappOSH.setAttribute('app_srv_ip', appSvrIP)
        webappOSH.setAttribute('component_name', componentName)

        # application contained in webserver extension
        webappOSH.setContainer(siebelwseOSH)

        OSHVResult.add(webappOSH)
Пример #35
0
def getAttribute(defaultsStr, attrStr):
	attrPattern = Pattern(string.join([attrStr, '\s*=\s*([^\s]*)'], ''))
	match = attrPattern.matcher(defaultsStr)
	if match.find() == 1:
		return string.strip(match.group(1))
	return ''
Пример #36
0
def stripNtcmdHeaders(data):
    pattern = Pattern('Connecting to remote service ... Ok(.*)Remote command returned 0', REFlags.DOTALL)
    match = pattern.matcher(data)
    if match.find() == 1:
        return string.strip(match.group(1))
    return None
Пример #37
0
def getServicesAttribute(defaultsStr, attrStr):
    attrPattern = Pattern(''.join([attrStr, '\s*([^\s]*)/']))
    match = attrPattern.matcher(defaultsStr)
    if match.find() == 1:
        return match.group(1) and match.group(1).strip()
    return ''
def getKeyByValue(str, value):
    attrPattern = Pattern('([^\s]*)\s*=\s*' + value)
    match = attrPattern.matcher(str)
    if match.find() == 1:
        return string.strip(match.group(1))
    return None
def getIniSection(data, sectionName):
    entryPatten = Pattern('\[' + sectionName + '\]([^\[]*)\[')
    match = entryPatten.matcher(data)
    if match.find() == 1:
        return match.group(1)
    return None
Пример #40
0
def getServicesAttribute(defaultsStr, attrStr):
	attrPattern = Pattern(''.join([attrStr, '\s*([^\s]*)/']))
	match = attrPattern.matcher(defaultsStr)
	if match.find() == 1:
		return match.group(1) and match.group(1).strip()
	return ''
Пример #41
0
def getAttribute(defaultsStr, attrStr):
    attrPattern = Pattern(string.join([attrStr, '\s*([^\s~]*)'], ''))
    match = attrPattern.matcher(defaultsStr)
    if match.find() == 1:
        return string.strip(match.group(1))
    return ''
Пример #42
0
def findRootPath(installPath):
    pattern = Pattern('\s*([^\r\t\n]*)programs')
    match = pattern.matcher(installPath)
    if match.find() == 1:
        return string.strip(match.group(1))
    return None
def getKeyByValue(str,value):
	attrPattern = Pattern('([^\s]*)\s*=\s*' + value)
	match = attrPattern.matcher(str)
	if match.find() == 1:
		return string.strip(match.group(1))
	return None
Пример #44
0
def getInstallPathUnix(webserver_name, shellUtils):
	path = '/opt/sadmin/sweapp/bin'
	if string.find(webserver_name, 'Netscape-Enterprise') >= 0:
		data = shellUtils.execCmd('ps -ef | grep ns-http')#@@CMD_PERMISION siebel protocol execution

		rows = string.split(data, '\n')
		# can be more than one process for each server - keep only one path
		paths = HashMap()
		for row in rows:
			pattern = Pattern('\s*-d\s*([^\s]*)')
			match = pattern.matcher(row)
			if match.find() == 1:
				configPath = match.group(1)
				paths.put(configPath,configPath)

		it = paths.keySet().iterator()
		while it.hasNext():
			path = it.next()
			confFile = None
			confFilePath = path + '/obj.conf'
			try:
				confFile = shellUtils.safecat(confFilePath)
				if not confFile:
					raise ValueError
			except:
				logger.debug("Failed reading config file '%s'" % confFilePath)
			else:
				pattern	= Pattern('\s*dir\s*=\s*"([^\s]*sweapp[^\s/]*)')
				match = pattern.matcher(confFile)
				if match.find() == 1:
					path = match.group(1)
					if path != '':
						path = path + '/bin'
						break
	else:
		data = shellUtils.execCmd('ps -ef | grep httpd')#@@CMD_PERMISION siebel protocol execution
		paths = HashMap()
		pattern = Pattern('\s*-d\s*([^\s]*)')
		match = pattern.matcher(data)
		while match.find() == 1:
			configPath = match.group(1)
			paths.put(configPath,configPath)
		logger.debug(paths)
		it = paths.keySet().iterator()
		while it.hasNext():
			path = it.next()
			configFilePath = path + '/conf/httpd.conf'
			confFile = None
			try:
				confFile = shellUtils.safecat(configFilePath)
				if not confFile:
					raise ValueError
			except:
				logger.debug("Failed reading config file '%s'" % configFilePath)
			else:
				pattern	= Pattern('\sSiebelHome\s*([^\s]*)')
				match = pattern.matcher(confFile)
				if match.find() == 1:
					path = match.group(1)
					if path != '':
						path = path + '/bin'
						break

	return path
Пример #45
0
def findRootPath(installPath):
    pattern = Pattern('\s*([^\r\t\n]*)programs')
    match = pattern.matcher(installPath)
    if match.find() == 1:
        return string.strip(match.group(1))
    return None
def getAttribute(defaultsStr, attrStr):
    attrPattern = Pattern(attrStr + '\s*=\s*([^\s]*)')
    match = attrPattern.matcher(defaultsStr)
    if match.find() == 1:
        return string.strip(match.group(1))
    return None
Пример #47
0
def getInstallPathUnix(webserver_name, shellUtils):
    path = '/opt/sadmin/sweapp/bin'
    if string.find(webserver_name, 'Netscape-Enterprise') >= 0:
        data = shellUtils.execCmd('ps -ef | grep ns-http'
                                  )  #@@CMD_PERMISION siebel protocol execution

        rows = string.split(data, '\n')
        # can be more than one process for each server - keep only one path
        paths = HashMap()
        for row in rows:
            pattern = Pattern('\s*-d\s*([^\s]*)')
            match = pattern.matcher(row)
            if match.find() == 1:
                configPath = match.group(1)
                paths.put(configPath, configPath)

        it = paths.keySet().iterator()
        while it.hasNext():
            path = it.next()
            confFile = None
            confFilePath = path + '/obj.conf'
            try:
                confFile = shellUtils.safecat(confFilePath)
                if not confFile:
                    raise ValueError
            except:
                logger.debug("Failed reading config file '%s'" % confFilePath)
            else:
                pattern = Pattern('\s*dir\s*=\s*"([^\s]*sweapp[^\s/]*)')
                match = pattern.matcher(confFile)
                if match.find() == 1:
                    path = match.group(1)
                    if path != '':
                        path = path + '/bin'
                        break
    else:
        data = shellUtils.execCmd(
            'ps -ef | grep httpd')  #@@CMD_PERMISION siebel protocol execution
        paths = HashMap()
        pattern = Pattern('\s*-d\s*([^\s]*)')
        match = pattern.matcher(data)
        while match.find() == 1:
            configPath = match.group(1)
            paths.put(configPath, configPath)
        logger.debug(paths)
        it = paths.keySet().iterator()
        while it.hasNext():
            path = it.next()
            configFilePath = path + '/conf/httpd.conf'
            confFile = None
            try:
                confFile = shellUtils.safecat(configFilePath)
                if not confFile:
                    raise ValueError
            except:
                logger.debug("Failed reading config file '%s'" %
                             configFilePath)
            else:
                pattern = Pattern('\sSiebelHome\s*([^\s]*)')
                match = pattern.matcher(confFile)
                if match.find() == 1:
                    path = match.group(1)
                    if path != '':
                        path = path + '/bin'
                        break

    return path
Пример #48
0
def parseCfgFileData(data, installPath, sarmLogFolder, shellUtils, webserverOSH, OSHVResult, HOST_ID, Framework):
	# create siebel web server extension
	siebelwseOSH = ObjectStateHolder('siebel_wse')
	siebelwseOSH.setContainer(webserverOSH)
	siebelwseOSH.setAttribute('data_name', 'Siebel WSE')
	siebelwseOSH.setAttribute('install_path', installPath)

	# try to get some general info on the SWE
	try:
		parseWSEDefaults(data, siebelwseOSH)
	except:
		logger.debug('failed getting wse defaults')

	OSHVResult.add(siebelwseOSH)

	configFileOsh = modeling.createConfigurationDocumentOSH('eapps.cfg', installPath, data, siebelwseOSH, modeling.MIME_TEXT_PLAIN, None, "Siebel Webserver Extention file")
	OSHVResult.add(configFileOsh)


	mapKeyToAppServers = None
	enableVirtualHosts = getAttribute(data, 'EnableVirtualHosts')
	if (enableVirtualHosts.lower() == 'true'):
		virtualHostsFile = getAttribute(data, 'VirtualHostsFile')
		if virtualHostsFile != None:
			virtualHostsFileData = None
			try:
				virtualHostsFileData = shellUtils.safecat(virtualHostsFile)
				if not virtualHostsFileData:
					raise ValueError
			except:
				logger.warn("Failed reading virtual host file '%s'" % virtualHostsFile)
			else:
				pattern = Pattern('([^\s]*)[\\\/]([^\s.]*).([^\s]*)')
				matcher = pattern.matcher(virtualHostsFile)
				if matcher.find()== 1:
					path = matcher.group(1)
					filename = matcher.group(2)
					extension = matcher.group(3)

					configFileName = "%s.%s" % (filename, extension)
					configFileOsh = modeling.createConfigurationDocumentOSH(configFileName, path, virtualHostsFileData, siebelwseOSH, modeling.MIME_TEXT_PLAIN, None, 'Load Balancer configuration file')
					OSHVResult.add(configFileOsh)

					mapKeyToAppServers = getAttributes(virtualHostsFileData,'VirtualServer')


	# get web applications data
	apps = getApps(data)

	gatewayIpToOsh = {}
	siteNameToOsh = {}

	for app in apps:

		appName = app[app.find('[/')+2:app.find(']')]
		connStr = getAttribute(app, 'ConnectString')

		# sample line: siebel.TCPIP.None.None://sblgw:2320/siebel/CRAObjMgr_cht/sblapp1_AS
		# sample line: siebel.TCPIP.None.None://cannon:2320/siebel/ERMObjMgr_chs/cannon
		gtwyHost = ''
		gtwyPort = ''
		siebelSite = ''
		componentName = ''
		appSvrName = ''
		appSvrIP = ''
		ip = ''

		tokens = connStr.split('/')
		numOfTokens = len(tokens)
		if numOfTokens > 2:
			if (enableVirtualHosts.lower() == 'true'):
				appServers = mapKeyToAppServers.get(tokens[2])
				if appServers != None:
					serversStr = appServers.split(';')
					for serverStr in serversStr:
						if serverStr != '':
							serverStrTokens = serverStr.split(':')
							if appSvrName != '':
								appSvrName += ','
							if appSvrIP != '':
								appSvrIP += ','
							serverName = serverStrTokens[1]
							appSvrName += serverName
							appSvrIP += netutils.getHostAddress(serverName, serverName)
			else:
				gtwyConn = tokens[2].split(':')
				gtwyHost = gtwyConn[0]
				gtwyPort = gtwyConn[1]
				if not netutils.isValidIp(gtwyHost):
					ip = resolveHostname(gtwyHost, shellUtils, '')
				else:
					ip = gtwyHost

		if numOfTokens > 3:
			siebelSite = tokens[3]
		if numOfTokens > 4:
			componentName = tokens[4]
		if numOfTokens > 5:
			appSvrName = tokens[5]
		else:
			if appSvrIP == '':
				appSvrIP = ip
			gtwyHost = None


		if gtwyHost and ip and not gatewayIpToOsh.has_key(ip):

			gatewayOsh = createGatewayOsh(ip, gtwyPort, OSHVResult, Framework)
			OSHVResult.add(gatewayOsh)

			routeLinkOSH = modeling.createLinkOSH('depend', gatewayOsh, siebelwseOSH)
			OSHVResult.add(routeLinkOSH)

			gatewayIpToOsh[ip] = gatewayOsh

			if siebelSite and not siteNameToOsh.has_key(siebelSite):
				logger.debug('found siebel site:', siebelSite)
				siteOSH = ObjectStateHolder('siebel_site')
				siteOSH.setAttribute('gateway_address', ip)
				siteOSH.setAttribute('data_name', siebelSite)
				modeling.setAppSystemVendor(siteOSH)
				OSHVResult.add(siteOSH)
				siteNameToOsh[siebelSite] = siteOSH

		# create a siebel application object
		webappOSH = ObjectStateHolder('siebel_web_app')
		webappOSH.setAttribute('data_name', appName)
		webappOSH.setAttribute('site', siebelSite)
		webappOSH.setAttribute('app_srv_name', appSvrName)
		webappOSH.setAttribute('app_srv_ip', appSvrIP)
		webappOSH.setAttribute('component_name', componentName)

		# application contained in webserver extension
		webappOSH.setContainer(siebelwseOSH)

		OSHVResult.add(webappOSH)
Пример #49
0
def getOracleHomeUnix(shellUtils):
    oracleHome = ''
    # 1. try env ORACLE_HOME
    env = shellUtils.execCmd('env')  #@@CMD_PERMISION siebel protocol execution
    lines = env.split('\n')
    for line in lines:
        if line and line.find('ORACLE_HOME') > -1:
            logger.debug('found ORACLE_HOME env var', line)
            oraHome = getAttribute(line, 'ORACLE_HOME')
            logger.debug('oraHome=', oraHome)
            if oraHome != '':
                oracleHome = oraHome
                logger.debug('oracleHome found:', oracleHome)
                break
        if line and line.find('TNS_ADMIN') > -1:
            logger.debug('found TNS_ADMIN env var', line)
            tnsLoc = getAttribute(line, 'TNS_ADMIN')
            if tnsLoc != '':
                oraHome = tnsLoc

                networkAdminIndex = tnsLoc.find('/network/admin')
                if networkAdminIndex >= 0:
                    oraHome = oraHome[:networkAdminIndex]

                oracleHome = oraHome
                logger.debug('oracleHome found:', oracleHome)
                break
    # if we didn't find it in env
    if oracleHome == '':
        logger.debug('looking for oracle home in /var/opt/oracle')
        # 2. try /var/opt/oracle
        oraInstLoc = ''
        try:
            oraInstLoc = shellUtils.safecat('/var/opt/oracle/oraInst.loc')
            logger.debug('oraInstLoc', oraInstLoc)
        except:
            logger.debug('Failed to get oraIns.loc')
        if oraInstLoc != '':

            inventoryLoc = getAttribute(oraInstLoc, 'inventory_loc')
            if inventoryLoc != '':
                oraProductPath = inventoryLoc[:inventoryLoc.
                                              find('/oraInventory')]
                lsCmd = ' '.join(['ls ', oraProductPath])
                dirList = shellUtils.execCmd(
                    lsCmd)  #@@CMD_PERMISION siebel protocol execution
                logger.debug('dirList', dirList)
                files = dirList.split()
                for file in files:
                    logger.debug('file', file)
                    versionPattern = Pattern('\d+.\d+.\d+.\d+')
                    match = versionPattern.matcher(file)
                    if match.find() == 1:
                        logger.debug('found version dir')
                        versionDir = match.group(0)
                        logger.debug('versionDir', versionDir)
                        oracleHome = ''.join([oraProductPath, '/', versionDir])
                        break

    logger.debug('returning oracleHome', oracleHome)
    return oracleHome