def discoverConfigFile(siebelRootDir, appServerOSH, client, version, OSHVResult): shellUtils = ShellUtils(client) relativePaths = [''] protocolType = client.getClientType() if protocolType == ClientsConsts.NTCMD_PROTOCOL_NAME: relativePaths = ['\\bin\\ENU\\', '\\bin\\'] else: relativePaths = ['/bin/enu/', '/bin/ENU/', '/bin/'] found = 0 for relativePath in relativePaths: path = siebelRootDir + relativePath + 'siebel.cfg' try: data = shellUtils.safecat(path) if not error(data, protocolType): found = 1 break except: pass if found == 0: logger.error('Failed getting configuration file') return if version != None and version != '' and (version[0] == '6' or version.find('7.8') == 0): updateMissingAttributes(data, appServerOSH, OSHVResult) lastUpdateTime = file_ver_lib.getFileLastModificationTime(shellUtils, path) configfile = modeling.createConfigurationDocumentOSH( 'siebel.cfg', '', data, appServerOSH, modeling.MIME_TEXT_PLAIN, lastUpdateTime, "Configuration file of siebel application server") logger.debug('found siebel config file:') OSHVResult.add(configfile)
def discoverConfigFile(siebelRootDir,appServerOSH,client,version,OSHVResult): shellUtils = ShellUtils(client) relativePaths = [''] protocolType = client.getClientType() if protocolType == ClientsConsts.NTCMD_PROTOCOL_NAME: relativePaths = ['\\bin\\ENU\\','\\bin\\'] else: relativePaths = ['/bin/enu/','/bin/ENU/','/bin/'] found = 0 for relativePath in relativePaths: path = siebelRootDir + relativePath + 'siebel.cfg' try: data = shellUtils.safecat(path) if not error(data,protocolType): found = 1 break except: pass if found==0: logger.error('Failed getting configuration file') return if version != None and version != '' and (version[0] == '6' or version.find('7.8') == 0): updateMissingAttributes(data,appServerOSH,OSHVResult) lastUpdateTime = file_ver_lib.getFileLastModificationTime(shellUtils, path) configfile = modeling.createConfigurationDocumentOSH('siebel.cfg', '', data, appServerOSH, modeling.MIME_TEXT_PLAIN, lastUpdateTime, "Configuration file of siebel application server") logger.debug('found siebel config file:') OSHVResult.add(configfile)
def DiscoveryMain(Framework): OSHVResult = ObjectStateHolderVector() protocol = Framework.getDestinationAttribute('Protocol') DEFAULT_MAIN_FC_PATH = '' #this default value would be used as last resort in case the file main.cf will not be found if protocol == 'ntcmd': DEFAULT_MAIN_FC_PATH = 'c:\\program Files\\VERITAS\\cluster server\\conf\config\\' else: DEFAULT_MAIN_FC_PATH = '/etc/VRTSvcs/conf/config/' # take the following parameter from the section 'destinationData name' ${PARAMETERS.<paramname>) defined in the pattern's xml file main_cf_path = Framework.getParameter('main_cf_path') properties = Properties() # Set codepage codePage = Framework.getCodePage() properties.put( BaseAgent.ENCODING, codePage) try: # Connect to the SSH/TELNET/NTCMD agent client = Framework.createClient(properties) clientShUtils = shellutils.ShellUtils(client) except: msg = sys.exc_info()[1] strmsg = '%s' % msg if (strmsg.lower().find('timeout') > -1): errobj = errorobject.createError(errorcodes.CONNECTION_TIMEOUT_NO_PROTOCOL, None, 'Connection timed out - reactivate with larger timeout value') logger.reportErrorObject(errobj) logger.debugException('Connection timed out') else: errobj = errormessages.resolveError(strmsg, 'shell') logger.reportErrorObject(errobj) logger.errorException(strmsg) else: # Get main.cf path if ((main_cf_path == None) or (main_cf_path == 'NA')) and (protocol != 'ntcmd'): main_cf_path = getMainCFPath(clientShUtils) if (main_cf_path == None) or (main_cf_path == 'NA'): main_cf_path = DEFAULT_MAIN_FC_PATH if ((main_cf_path == None) or (main_cf_path == 'NA')) and (protocol == 'ntcmd'): main_cf_path = DEFAULT_MAIN_FC_PATH # Assemble the main.cf command cfFullPath = main_cf_path + 'main.cf' try: resBuffer = clientShUtils.safecat(cfFullPath) except: errorMessage = 'Failed to get configuration file:' + cfFullPath logger.debugException(errorMessage) errobj = errorobject.createError(errorcodes.FAILED_FINDING_CONFIGURATION_FILE, [cfFullPath], errorMessage) logger.reportErrorObject(errobj) else: if resBuffer.find('Permission denied') > -1: errobj = errorobject.createError(errorcodes.PERMISSION_DENIED_NO_PROTOCOL_WITH_DETAILS, ['User has no permissions to read main.cf file'], 'User has no permissions to read main.cf file') logger.reportErrorObject(errobj) else: lastUpdateTime = file_ver_lib.getFileLastModificationTime(clientShUtils, cfFullPath) mainFunction(resBuffer, main_cf_path, clientShUtils, OSHVResult, protocol, Framework, lastUpdateTime) try: clientShUtils and clientShUtils.closeClient() except: logger.debugException('') logger.error('Unable to close shell') return OSHVResult
def DiscoveryMain(Framework): OSHVResult = ObjectStateHolderVector() protocol = Framework.getDestinationAttribute('Protocol') DEFAULT_MAIN_FC_PATH = '' #this default value would be used as last resort in case the file main.cf will not be found if protocol == 'ntcmd': DEFAULT_MAIN_FC_PATH = 'c:\\program Files\\VERITAS\\cluster server\\conf\config\\' else: DEFAULT_MAIN_FC_PATH = '/etc/VRTSvcs/conf/config/' # take the following parameter from the section 'destinationData name' ${PARAMETERS.<paramname>) defined in the pattern's xml file main_cf_path = Framework.getParameter('main_cf_path') properties = Properties() # Set codepage codePage = Framework.getCodePage() properties.put(BaseAgent.ENCODING, codePage) try: # Connect to the SSH/TELNET/NTCMD agent client = Framework.createClient(properties) clientShUtils = shellutils.ShellUtils(client) except: msg = sys.exc_info()[1] strmsg = '%s' % msg if (strmsg.lower().find('timeout') > -1): errobj = errorobject.createError( errorcodes.CONNECTION_TIMEOUT_NO_PROTOCOL, None, 'Connection timed out - reactivate with larger timeout value') logger.reportErrorObject(errobj) logger.debugException('Connection timed out') else: errobj = errormessages.resolveError(strmsg, 'shell') logger.reportErrorObject(errobj) logger.errorException(strmsg) else: # Get main.cf path if ((main_cf_path == None) or (main_cf_path == 'NA')) and (protocol != 'ntcmd'): main_cf_path = getMainCFPath(clientShUtils) if (main_cf_path == None) or (main_cf_path == 'NA'): main_cf_path = DEFAULT_MAIN_FC_PATH if ((main_cf_path == None) or (main_cf_path == 'NA')) and (protocol == 'ntcmd'): main_cf_path = DEFAULT_MAIN_FC_PATH # Assemble the main.cf command cfFullPath = main_cf_path + 'main.cf' try: resBuffer = clientShUtils.safecat(cfFullPath) except: errorMessage = 'Failed to get configuration file:' + cfFullPath logger.debugException(errorMessage) errobj = errorobject.createError( errorcodes.FAILED_FINDING_CONFIGURATION_FILE, [cfFullPath], errorMessage) logger.reportErrorObject(errobj) else: if resBuffer.find('Permission denied') > -1: errobj = errorobject.createError( errorcodes.PERMISSION_DENIED_NO_PROTOCOL_WITH_DETAILS, ['User has no permissions to read main.cf file'], 'User has no permissions to read main.cf file') logger.reportErrorObject(errobj) else: lastUpdateTime = file_ver_lib.getFileLastModificationTime( clientShUtils, cfFullPath) mainFunction(resBuffer, main_cf_path, clientShUtils, OSHVResult, protocol, Framework, lastUpdateTime) try: clientShUtils and clientShUtils.closeClient() except: logger.debugException('') logger.error('Unable to close shell') return OSHVResult