コード例 #1
0
ファイル: validityCheck.py プロジェクト: azimkhatri/hostinfo
def hardwareCheck(host):
    """ Check things based on the hardware """

    if hostinfo[host]["hardware"] and not hostinfo[host]["hwdesc"]:
        whinge(
            "Host %s has a hardware of %s but no hwdesc defined" % (host, hostinfo[host]["hardware"]),
            "hostinfo_addvalue hwdesc=%s %s" % (hostinfo[host]["hardware"], host),
        )

    if hostinfo[host]["hwdesc"]:
        testtype, testhardware = hardware.getHardware(hostinfo[host]["hwdesc"])

        if testtype == "unknown":
            return

        if not hostinfo[host]["hardware"]:
            whinge(
                "Host %s has a hwdesc of %s but no hardware defined" % (host, hostinfo[host]["hwdesc"]),
                "hostinfo_addvalue hardware=%s %s" % (testhardware, host),
            )

        if hostinfo[host]["hardware"] != testhardware:
            whinge(
                "Host %s has a hardware of %s but should be %s based on hwdesc of %s"
                % (host, hostinfo[host]["hardware"], testhardware, hostinfo[host]["hwdesc"]),
                "hostinfo_addvalue --update hardware=%s %s" % (testhardware, host),
            )

        if hostinfo[host]["type"] != testtype:
            whinge(
                "Host %s has a type of %s but should be %s based on hwdesc of %s"
                % (host, hostinfo[host]["type"], testtype, hostinfo[host]["hwdesc"]),
                "hostinfo_addvalue --update type=%s %s" % (testtype, host),
            )
コード例 #2
0
ファイル: hostdet.py プロジェクト: dwagon/explorertools
 def getHardware(self, hwdesc):
     hwdesc = hwdesc.replace('IBM IBM', 'IBM')
     hwdesc = hwdesc.replace('sun4u', '')
     if hwdesc.startswith('"') or hwdesc.startswith("'"):
         hwdesc = hwdesc[1:]
     if hwdesc.endswith('"') or hwdesc.endswith("'"):
         hwdesc = hwdesc[:-1]
     hwdesc = hwdesc.strip()
     try:
         hwtype, hwname = hardware.getHardware(hwdesc)
     except hardware.UnknownHardware:
         self.Warning("Unknown hardware: %s" % hwdesc)
         hwtype = "unknown"
         hwname = "unknown"
     return hwtype, hwname
コード例 #3
0
def convertHwdesc(value):
    """ Keep the hardware description, but have the side effect of generating
    strings for hardware and type
    """
    if value and 'virtual' in value:
        return {'type': 'virtual', 'vmtype': 'vmware'}
    if value == None or value == 'none' or value == '???':
        return {}
    try:
        hwtype, hwname = hardware.getHardware(value)
    except hardware.UnknownHardware:
        warning("Unknown hardware: %s" % value.lower())
        return {}
    d = {}
    if hwname != 'unknown':
        d['hardware'] = hwname
    if hwtype != 'unknown':
        d['type'] = hwtype
    d['hwdesc'] = value.replace(' ', '_')
    return d
コード例 #4
0
ファイル: xls2hostinfo.py プロジェクト: AZaugg/Hostinfo
def convertHwdesc(value):
    """ Keep the hardware description, but have the side effect of generating
    strings for hardware and type
    """
    if value and 'virtual' in value:
    	return { 'type': 'virtual', 'vmtype': 'vmware' }
    if value==None or value=='none' or value=='???':
    	return {}
    try:
	hwtype,hwname=hardware.getHardware(value)
    except hardware.UnknownHardware:
    	warning("Unknown hardware: %s" % value.lower())
	return {}
    d={}
    if hwname!='unknown':
    	d['hardware']=hwname
    if hwtype!='unknown':
    	d['type']=hwtype
    d['hwdesc']=value.replace(' ','_')
    return d