Example #1
0
def osh_createDb2Tablespace(db2SubsystemOsh, tb):
    str_name = 'name'
    if UCMDB_VERSION < 9:
        str_name = 'data_name'

    if isNotNull(tb) and isNotNull(tb[0]):
        tbOsh = ObjectStateHolder('mainframe_db2_tablespace')
        tbOsh.setAttribute(str_name, tb[0])
        tbOsh.setAttribute('dbtablespace_status', tb[1])
        tbOsh.setAttribute('type', tb[2])
        tbOsh.setAttribute('encoding_scheme', tb[3])
        tbOsh.setAttribute('dbtablespace_initialextent', tb[4])
        if isNotNull(tb[5]) and isnumeric(tb[5]):
            tbOsh.setIntegerAttribute('max_dataset_size', int(tb[5]))
        if isNotNull(tb[6]) and isnumeric(tb[6]):
            tbOsh.setIntegerAttribute('number_tables', int(tb[6]))
        if isNotNull(tb[7]) and isnumeric(tb[7]):
            tbOsh.setIntegerAttribute('number_partitions', int(tb[7]))
        try:
            if len(tb[8]) > 19:
                tb[8] = tb[8][0:18]
                created = modeling.getDateFromString(tb[8], 'yyyy-MM-dd-kk.mm.ss', None)
                tbOsh.setDateAttribute('create_date', created)
        except:
            logger.debug("Ignoring create_date. Unable to parse date string")
        tbOsh.setContainer(db2SubsystemOsh)
        return tbOsh
    return None
Example #2
0
def osh_createDb2Tablespace(db2SubsystemOsh, tb):
    str_name = 'name'
    if UCMDB_VERSION < 9:
        str_name = 'data_name'

    if isNotNull(tb) and isNotNull(tb[0]):
        tbOsh = ObjectStateHolder('mainframe_db2_tablespace')
        tbOsh.setAttribute(str_name, tb[0])
        tbOsh.setAttribute('dbtablespace_status', tb[1])
        tbOsh.setAttribute('type', tb[2])
        tbOsh.setAttribute('encoding_scheme', tb[3])
        tbOsh.setAttribute('dbtablespace_initialextent', tb[4])
        if isNotNull(tb[5]) and isnumeric(tb[5]):
            tbOsh.setIntegerAttribute('max_dataset_size', int(tb[5]))
        if isNotNull(tb[6]) and isnumeric(tb[6]):
            tbOsh.setIntegerAttribute('number_tables', int(tb[6]))
        if isNotNull(tb[7]) and isnumeric(tb[7]):
            tbOsh.setIntegerAttribute('number_partitions', int(tb[7]))
        try:
            if len(tb[8]) > 19:
                tb[8] = tb[8][0:18]
                created = modeling.getDateFromString(tb[8],
                                                     'yyyy-MM-dd-kk.mm.ss',
                                                     None)
                tbOsh.setDateAttribute('create_date', created)
        except:
            logger.debug("Ignoring create_date. Unable to parse date string")
        tbOsh.setContainer(db2SubsystemOsh)
        return tbOsh
    return None
Example #3
0
def ev2_getIplInfoOutput(ls):
    # process IPL Info ---------------------------------------------------------
    zOsRelease = ''
    ieasymList = ''
    ieasysList = ''
    machineBootDate = ''
    try:
        output = ls.evMvsCmd(_CMD_D_IPLINFO)
        if isNotNull(output) and output.isSuccess() and len(output.cmdResponseList) > 0:
            releaseList = output.getValuesFromLineList('s', output.cmdResponseList, 'RELEASE z/OS', 'LICENSE')
            if len(releaseList) > 0 and len(releaseList[0]) == 3:
                zOsRelease = releaseList[0][1] or ''
            ieasymList = output.getValuesFromLineList('s', output.cmdResponseList, 'IEASYM LIST =')
            if len(ieasymList) > 0 and len(ieasymList[0]) == 2:
                ieasymList = ieasymList[0][1] or ''
            ieasysList = output.getValuesFromLineList('s', output.cmdResponseList, 'IEASYS LIST =')
            if len(ieasymList) > 0 and len(ieasymList[0]) == 2:
                ieasysList = ieasysList[0][1] or ''
            bootList = output.getValuesFromLineList('s', output.cmdResponseList, 'SYSTEM IPLED AT', 'ON')
            if len(bootList) > 0 and len(bootList[0]) == 2:
                bootTime = bootList[0][1] or ''
                bootDate = bootList[0][2] or ''
                if eview_lib.isNotNull(bootDate) and eview_lib.isNotNull(bootTime):
                    machineBootDate = modeling.getDateFromString('%s %s' % (bootDate, bootTime), 'MM/dd/yyyy kk.mm.ss')
        else:
            logger.reportWarning('Unable to get output for command - %s' % _CMD_D_IPLINFO)
    except:
        errMsg = 'Failure in method ev2_getIplInfoOutput()'
        logger.error(errMsg)
        logger.reportError(errMsg)

    return (zOsRelease, ieasymList, ieasysList, machineBootDate)
    def findAllProcessesByPs(self, timeZone = None):
        ''''@types: java.util.TimeZone -> list(Process)
        @command: ps -eo user,pid,lstart,command --cols 4000 --no-headers
        '''
        processes = []

        # output = self._getShell().execCmd('ps -eo user,pid,lstart,command --cols 4000 --no-headers')#V@@CMD_PERMISION tty protocol execution
        # JDS changes to ps formatting, done to resolve USD SD3185855 - Ian MA JDS Services
        output = self._getShell().execCmd('ps -eo user,pid,lstart,command --cols 8000 --no-headers')#V@@CMD_PERMISION tty protocol execution
        if not output:
            return processes

        lines = re.split(r"\n", output)
        for line in lines:
            line = line and line.strip()
            if not line: continue

            matcher = re.match('([\w\-_\.]+)\s+(\d+)\s+\w{3}\s+(\w{3}\s+\d+\s+\d{2}:\d{2}:\d{2}\s+\d{4})\s+(.+)$', line)
            if not matcher:
                continue
            owner = matcher.group(1).strip()
            pid = matcher.group(2).strip()
            dateStr = matcher.group(3).strip()
            commandLine = matcher.group(4).strip()

            startupDate = None
            if timeZone is not None and dateStr:
                try:
                    startupDate = modeling.getDateFromString(dateStr, 'MMM dd HH:mm:ss yyyy', timeZone)
                except:
                    logger.warn("Failed to parse startup time from value '%s'" % dateStr)

            fullCommand = None
            argumentsLine = None

            if commandLine:
                tokens = re.split(r"\s+", commandLine, 1)
                fullCommand = tokens[0]
                if len(tokens) > 1:
                    argumentsLine = tokens[1]

            commandName = fullCommand
            commandPath = None

            if not re.match(r"\[", fullCommand):
                matcher = re.match(r"(.*/)([^/]+)$", fullCommand)
                if matcher:
                    commandPath = fullCommand
                    commandName = matcher.group(2)

            process = process_module.Process(commandName, pid, commandLine)
            process.argumentLine = argumentsLine
            process.owner = owner
            if startupDate:
                process.setStartupTime(startupDate)
            process.executablePath = commandPath
            processes.append(process)
        return processes
Example #5
0
def __getSunLinuxFileLastModificationTime(shell, fileName, command):
    buffer = shell.execCmd(command)
    if buffer and shell.getLastCmdReturnCode() == 0:
        matcher = re.match(".*?(\d{4}\-\d{2}\-\d{2} \d{2}\:\d{2}:\d{2}\.\d{3})\d+\s+([+\- ]\d{2})(\d{2})\s+" + fileName, buffer)
        if matcher:
            dateString = matcher.group(1)
            timezoneOffsetStringHours = matcher.group(2)
            timezoneOffsetStringMinutes = matcher.group(3)
            timezoneMillis = ((int(timezoneOffsetStringHours) * 60) + int(timezoneOffsetStringMinutes)) * 60 * 1000
            timezone = SimpleTimeZone(timezoneMillis, '')
            utcDateFormatString = 'yyyy-MM-dd HH:mm:ss.SSS'
            return getDateFromString(dateString, utcDateFormatString, timezone)
    else:
        raise ValueError("Output is empty or error code is not zero. File name: %s" % fileName)
Example #6
0
def __getWindowsVbsFileLastModificationTime(shell, fileName):
    remoteFile = shell.copyFileIfNeeded(__VBS_LOCAL_FILE_PATH)
    if not remoteFile:
        raise ValueError("Failed copying file %s" % __VBS_LOCAL_FILE_PATH)

    command = 'Cscript.exe /nologo "%s" "%s"' % (remoteFile, fileName)
    buffer = shell.execCmd(command)
    #TODO: vbs should be modified to exit with non-zero exit code when failing
    if buffer and shell.getLastCmdReturnCode() == 0 and buffer.find(__ERROR_STRING) == -1:
        matcher = re.match("\s*(\d{4}\-\d{2}-\d{2} \d{2}\:\d{2}\:\d{2}).*", buffer)
        if matcher:
            dateString = matcher.group(1)
            dateFormatString = 'yyyy-MM-dd HH:mm:ss'
            return getDateFromString(dateString, dateFormatString)
    else:
        raise ValueError("Output is empty or error code is not zero. File name: %s" % fileName)
Example #7
0
    def findAllProcessesByPs(self, timeZone=None):
        ''''@types: java.util.TimeZone -> list(Process)
        @command: ps -eo user,pid,lstart,command --cols 4096 --no-headers
        '''
        processes = []

        output = self._getShell().execCmd(
            'ps -eo user,pid,lstart,command --cols 4096 --no-headers'
        )  #V@@CMD_PERMISION tty protocol execution
        if not output:
            return processes

        lines = re.split(r"\n", output)
        for line in lines:
            line = line and line.strip()
            if not line: continue

            matcher = re.match(
                '([\w\-_\.\+]+)\s+(\d+)\s+\w{3}\s+(\w{3}\s+\d+\s+\d{2}:\d{2}:\d{2}\s+\d{4})\s+(.+)$',
                line)
            if not matcher:
                continue
            owner = matcher.group(1).strip()
            pid = matcher.group(2).strip()
            dateStr = matcher.group(3).strip()
            commandLine = matcher.group(4).strip()

            startupDate = None
            if timeZone is not None and dateStr:
                try:
                    startupDate = modeling.getDateFromString(
                        dateStr, 'MMM dd HH:mm:ss yyyy', timeZone)
                except:
                    logger.warn(
                        "Failed to parse startup time from value '%s'" %
                        dateStr)

            fullCommand = None
            argumentsLine = None

            if commandLine:
                tokens = re.split(r"\s+", commandLine, 1)
                fullCommand = tokens[0]
                if len(tokens) > 1:
                    argumentsLine = tokens[1]

            commandName = fullCommand
            commandPath = None

            if not re.match(r"\[", fullCommand):
                matcher = re.match(r"(.*/)([^/]+)$", fullCommand)
                if matcher:
                    commandPath = fullCommand
                    commandName = matcher.group(2)

            process = process_module.Process(commandName, pid, commandLine)
            process.argumentLine = argumentsLine
            process.owner = owner
            if startupDate:
                process.setStartupTime(startupDate)
            process.executablePath = commandPath
            processes.append(process)
        return processes
Example #8
0
		pdu = processdbutils.ProcessDbUtils(Framework)
		hostOSH = None
		for line in lines:
			line = line.strip()
			
			matcher = re.match('([\w\-_\.\+]+)\s+(\d+)\s+\w{3}\s+(\w{3}\s+\d+\s+\d{2}:\d{2}:\d{2}\s+\d{4})\s+(.+)$', line)
			if matcher:
				owner = matcher.group(1).strip()
				pid = matcher.group(2).strip()
				dateStr = matcher.group(3).strip()
				command = matcher.group(4).strip()
				
				startuptime = None
				if timezone:
					try:
						startupDate = modeling.getDateFromString(dateStr, 'MMM dd HH:mm:ss yyyy', timezone)
						startuptime = startupDate.getTime()
					except:
						msg = "Process startup time attribute is not set due to error while parsing date string '%s'" % dateStr
						if protocol:
							msg = "%s: %s" % (protocol, msg)
							errobj = errorobject.createError(errorcodes.PROCESS_STARTUP_TIME_ATTR_NOT_SET, [protocol, dateStr], msg)
							logger.reportWarningObject(errobj)
						else:
							errobj = errorobject.createError(errorcodes.PROCESS_STARTUP_TIME_ATTR_NOT_SET_NO_PROTOCOL, [dateStr], msg)
							logger.reportWarningObject(errobj)
				
				spaceIndex = command.find(' ')
				commAndPath = ''
				cleanArgs = ''