Exemplo n.º 1
0
def disLinux(hostObj, client, Framework=None, langBund=None, packageToCmdLine=None, cmdLineToInstalledSoftware=None):

    myVec = ObjectStateHolderVector()
    cmd = "rpm -qa --qf '%{NAME}~%{VERSION}~%{GROUP}~%{VENDOR}~%{installtime:date}~%{INSTALLTID}\\n'"
    r = client.execCmd(cmd, client.getDefaultCommandTimeout() * 4)  # V@@CMD_PERMISION tty protocol execution
    if r == None:
        return myVec

    lines = ""
    if re.search("\r\n", r):
        lines = r.split("\r\n")
    elif re.search("\n", r):
        lines = r.split("\n")
    else:
        return myVec
    if len(lines) == 0 or r.strip() == "":
        return myVec
    for line in lines:
        token = line.split("~")
        if token == None or len(token) < 3:
            continue
        # Does the package not have a vendor?  If so, make blank
        if len(token) == 3:
            token.append("")
        if token[0]:
            softwareOSH = hostresource.makeSoftwareOSH2(
                createHostOSH(hostObj), token[0], token[3], token[1], "", token[5], token[2], token[4]
            )

            if packageToCmdLine != None and cmdLineToInstalledSoftware != None and token[0] in packageToCmdLine:
                cmdLineToInstalledSoftware[packageToCmdLine[token[0]]] = softwareOSH

            myVec.add(softwareOSH)

    return myVec
Exemplo n.º 2
0
def disFreeBSD(hostObj, client, Framework=None, langBund=None):

    myVec = ObjectStateHolderVector()

    r = client.execCmd("pkg_info -a -I")  # V@@CMD_PERMISION tty protocol execution
    if r == None:
        return myVec

    if re.search("pkg_info: no packages installed", r):
        return myVec

    lines = ""
    if re.search("\r\n", r):
        lines = r.split("\r\n")
    elif re.search("\n", r):
        lines = r.split("\n")
    else:
        return myVec

    for line in lines:
        token = line.split("-", 2)
        if len(token) == 2:
            if token[0]:
                subt = token[1].split()
                myVec.add(hostresource.makeSoftwareOSH2(createHostOSH(hostObj), token[0], "", subt[0]))

    return myVec
Exemplo n.º 3
0
def disFreeBSD(hostObj, client, Framework=None, langBund=None):

    myVec = ObjectStateHolderVector()

    r = client.execCmd(
        'pkg_info -a -I')  # V@@CMD_PERMISION tty protocol execution
    if r == None:
        return myVec

    if (re.search('pkg_info: no packages installed', r)):
        return myVec

    lines = ''
    if (re.search('\r\n', r)):
        lines = r.split('\r\n')
    elif (re.search('\n', r)):
        lines = r.split('\n')
    else:
        return myVec

    for line in lines:
        token = line.split('-', 2)
        if (len(token) == 2):
            if token[0]:
                subt = token[1].split()
                myVec.add(
                    hostresource.makeSoftwareOSH2(createHostOSH(hostObj),
                                                  token[0], '', subt[0]))

    return myVec
Exemplo n.º 4
0
def disHPUX(hostObj, client, Framework=None, langBund=None):

    myVec = ObjectStateHolderVector()
    r = client.execCmd(
        '/usr/sbin/swlist -a name -a revision -a title -a install_date -a vendor_tag'
    )  # V@@CMD_PERMISION tty protocol execution
    if r == None:
        return myVec

    lines = ''
    if (re.search('\r\n', r)):
        lines = r.split('\r\n')
    elif (re.search('\n', r)):
        lines = r.split('\n')
    else:
        return myVec

    for line in lines:
        if ((len(line) < 2) or (line[0] == '#')):
            continue
        res = re.search(
            '([0-9a-zA-Z_.\-\(\),+:/\;=&]+)\s+([0-9a-zA-Z_.\-\(\),+:/\;=]+)\s+([0-9a-zA-Z_.\-\(\),+:/ \;=&\'\#\[\]]+)\s+(\d{8})\d+\.\d+\s+([0-9a-zA-Z_.\-\(\),+:/ \;=&]+)',
            line)
        if (res):
            swName = res.group(1)
            if swName:
                myVec.add(
                    hostresource.makeSoftwareOSH2(createHostOSH(hostObj),
                                                  swName, res.group(5),
                                                  res.group(2), '', '', '',
                                                  res.group(4), res.group(3)))

    return myVec
Exemplo n.º 5
0
def disSunOS(hostObj,
             client,
             Framework=None,
             langBund=None,
             packageToCmdLine=None,
             cmdLineToInstalledSoftware=None):

    myVec = ObjectStateHolderVector()
    r = client.execCmd('pkginfo -l',
                       client.getDefaultCommandTimeout() *
                       12)  # V@@CMD_PERMISION tty protocol execution
    if r == None:
        return myVec
    reg = langBund.getString(
        'sun_pkginfo_reg_pkginst_name_category_version_vendor')

    tokens = r.split('PKGINST')

    for token in tokens:
        currBuffer = 'PKGINST' + token

        res = re.search(reg, currBuffer, re.DOTALL)
        if res:
            swName = res.group(1)
            if swName:
                vendor = res.group(5) or ''
                if vendor:
                    vendor = vendor.strip()
                installDate = ''
                # Can be not fix the problem if from console was got already corrupted text
                if re.match('[\w\s/.,:-]+$', res.group(6)):
                    installDate = res.group(6)
                else:
                    logger.warn(
                        "Install software date attribute include non-English character. Ignored."
                    )
                softwareOSH = hostresource.makeSoftwareOSH2(
                    createHostOSH(hostObj), swName, vendor, res.group(4), '',
                    '', res.group(3), installDate)

                if swName and packageToCmdLine != None and cmdLineToInstalledSoftware != None and swName.strip(
                ) in packageToCmdLine:
                    cmdLineToInstalledSoftware[packageToCmdLine[
                        swName.strip()]] = softwareOSH

                myVec.add(softwareOSH)
    return myVec
Exemplo n.º 6
0
def disLinux(hostObj,
             client,
             Framework=None,
             langBund=None,
             packageToCmdLine=None,
             cmdLineToInstalledSoftware=None):

    myVec = ObjectStateHolderVector()
    cmd = "rpm -qa --qf '%{NAME}~%{VERSION}~%{GROUP}~%{VENDOR}~%{installtime:date}~%{INSTALLTID}\\n'"
    r = client.execCmd(cmd,
                       client.getDefaultCommandTimeout() *
                       4)  # V@@CMD_PERMISION tty protocol execution
    if r == None:
        return myVec

    lines = ''
    if (re.search('\r\n', r)):
        lines = r.split('\r\n')
    elif (re.search('\n', r)):
        lines = r.split('\n')
    else:
        return myVec
    if (len(lines) == 0 or r.strip() == ''):
        return myVec
    for line in lines:
        token = line.split('~')
        if (token == None or len(token) < 3):
            continue
        # Does the package not have a vendor?  If so, make blank
        if (len(token) == 3):
            token.append('')
        if token[0]:
            softwareOSH = hostresource.makeSoftwareOSH2(
                createHostOSH(hostObj), token[0], token[3], token[1], '',
                token[5], token[2], token[4])

            if packageToCmdLine != None and cmdLineToInstalledSoftware != None and token[
                    0] in packageToCmdLine:
                cmdLineToInstalledSoftware[packageToCmdLine[
                    token[0]]] = softwareOSH

            myVec.add(softwareOSH)

    return myVec
Exemplo n.º 7
0
def disAIX(hostObj, client, Framework=None, langBund=None):
    myVec = ObjectStateHolderVector()

    r = client.execCmd(
        'lslpp -Lc -q')  # V@@CMD_PERMISION tty protocol execution
    if r == None:
        return myVec

    lines = ''
    if (re.search('\r\n', r)):
        lines = r.split('\r\n')
    elif (re.search('\n', r)):
        lines = r.split('\n')
    else:
        return myVec

    for line in lines:
        token = line.split(':')
        try:
            if (len(token) > 8) and token[
                    1]:  # check that we have enough data to create installed software
                swPath = ''
                swDate = ''
                if (len(token) > 16) and token[16] and (
                        not (token[16] in [None, '(none)', '/'])
                ):  # check that there's an installation path for installed software - in this case we will report it
                    swPath = token[16]
                if len(token
                       ) > 17:  # check that there's a date of installation
                    swDate = ':'.join(token[17:])
                    if len(
                            swDate
                    ) < 8:  # obviously it's not enough to have less than 8 characters to keep the installation date
                        swDate = ''
                myVec.add(
                    hostresource.makeSoftwareOSH2(createHostOSH(hostObj),
                                                  token[1], '', token[2],
                                                  swPath, '', token[0], swDate,
                                                  token[7]))
        except:
            continue

    return myVec
Exemplo n.º 8
0
def disHPUX(hostObj, client, Framework=None, langBund=None):

    myVec = ObjectStateHolderVector()
    r = client.execCmd(
        "/usr/sbin/swlist -a name -a revision -a title -a install_date -a vendor_tag"
    )  # V@@CMD_PERMISION tty protocol execution
    if r == None:
        return myVec

    lines = ""
    if re.search("\r\n", r):
        lines = r.split("\r\n")
    elif re.search("\n", r):
        lines = r.split("\n")
    else:
        return myVec

    for line in lines:
        if (len(line) < 2) or (line[0] == "#"):
            continue
        res = re.search(
            "([0-9a-zA-Z_.\-\(\),+:/\;=&]+)\s+([0-9a-zA-Z_.\-\(\),+:/\;=]+)\s+([0-9a-zA-Z_.\-\(\),+:/ \;=&'\#\[\]]+)\s+(\d{8})\d+\.\d+\s+([0-9a-zA-Z_.\-\(\),+:/ \;=&]+)",
            line,
        )
        if res:
            swName = res.group(1)
            if swName:
                myVec.add(
                    hostresource.makeSoftwareOSH2(
                        createHostOSH(hostObj),
                        swName,
                        res.group(5),
                        res.group(2),
                        "",
                        "",
                        "",
                        res.group(4),
                        res.group(3),
                    )
                )

    return myVec
Exemplo n.º 9
0
def disAIX(hostObj, client, Framework=None, langBund=None):
    myVec = ObjectStateHolderVector()

    r = client.execCmd("lslpp -Lc -q")  # V@@CMD_PERMISION tty protocol execution
    if r == None:
        return myVec

    lines = ""
    if re.search("\r\n", r):
        lines = r.split("\r\n")
    elif re.search("\n", r):
        lines = r.split("\n")
    else:
        return myVec

    for line in lines:
        token = line.split(":")
        try:
            if (len(token) > 8) and token[1]:  # check that we have enough data to create installed software
                swPath = ""
                swDate = ""
                if (
                    (len(token) > 16) and token[16] and (not (token[16] in [None, "(none)", "/"]))
                ):  # check that there's an installation path for installed software - in this case we will report it
                    swPath = token[16]
                if len(token) > 17:  # check that there's a date of installation
                    swDate = ":".join(token[17:])
                    if (
                        len(swDate) < 8
                    ):  # obviously it's not enough to have less than 8 characters to keep the installation date
                        swDate = ""
                myVec.add(
                    hostresource.makeSoftwareOSH2(
                        createHostOSH(hostObj), token[1], "", token[2], swPath, "", token[0], swDate, token[7]
                    )
                )
        except:
            continue

    return myVec
Exemplo n.º 10
0
def disSunOS(hostObj, client, Framework=None, langBund=None, packageToCmdLine=None, cmdLineToInstalledSoftware=None):

    myVec = ObjectStateHolderVector()
    r = client.execCmd("pkginfo -l", client.getDefaultCommandTimeout() * 12)  # V@@CMD_PERMISION tty protocol execution
    if r == None:
        return myVec
    reg = langBund.getString("sun_pkginfo_reg_pkginst_name_category_version_vendor")

    tokens = r.split("PKGINST")

    for token in tokens:
        currBuffer = "PKGINST" + token

        res = re.search(reg, currBuffer, re.DOTALL)
        if res:
            swName = res.group(1)
            if swName:
                vendor = res.group(5) or ""
                if vendor:
                    vendor = vendor.strip()
                installDate = ""
                # Can be not fix the problem if from console was got already corrupted text
                if re.match("[\w\s/.,:-]+$", res.group(6)):
                    installDate = res.group(6)
                else:
                    logger.warn("Install software date attribute include non-English character. Ignored.")
                softwareOSH = hostresource.makeSoftwareOSH2(
                    createHostOSH(hostObj), swName, vendor, res.group(4), "", "", res.group(3), installDate
                )

                if (
                    swName
                    and packageToCmdLine != None
                    and cmdLineToInstalledSoftware != None
                    and swName.strip() in packageToCmdLine
                ):
                    cmdLineToInstalledSoftware[packageToCmdLine[swName.strip()]] = softwareOSH

                myVec.add(softwareOSH)
    return myVec