def __init__(self, gate, uuid): cpuInfo = read_cpuinfo() memory = read_memory() self.UUID = uuid self.os = gate.process('distro', software.read_os(), WITHHELD_MAGIC_STRING) self.defaultRunlevel = gate.process('run_level', software.read_runlevel(), -1) self.bogomips = gate.process('cpu', cpuInfo.get('bogomips', 0), 0) self.cpuVendor = gate.process('cpu', cpuInfo.get('type', ''), WITHHELD_MAGIC_STRING) self.cpuModel = gate.process('cpu', cpuInfo.get('model', ''), WITHHELD_MAGIC_STRING) self.cpu_stepping = gate.process('cpu', cpuInfo.get('cpu_stepping', 0), 0) self.cpu_family = gate.process('cpu', cpuInfo.get('cpu_family', ''), '') self.cpu_model_num = gate.process('cpu', cpuInfo.get('cpu_model_num', 0), 0) self.numCpus = gate.process('cpu', cpuInfo.get('count', 0), 0) self.cpuSpeed = gate.process('cpu', cpuInfo.get('speed', 0), 0) self.systemMemory = gate.process('ram_size', memory['ram'], 0) self.systemSwap = gate.process('swap_size', memory['swap'], 0) self.kernelVersion = gate.process('kernel', os.uname()[2], WITHHELD_MAGIC_STRING) if gate.grants('language'): try: self.language = os.environ['LANG'] except KeyError: try: status, lang = commands.getstatusoutput("grep LANG /etc/sysconfig/i18n") if status == 0: self.language = lang.split('"')[1] else: self.language = 'Unknown' except: self.language = 'Unknown' else: self.language = WITHHELD_MAGIC_STRING tempform = platform.machine() self.platform = gate.process('arch', tempform, WITHHELD_MAGIC_STRING) if gate.grants('vendor'): #self.systemVendor = hostInfo.get('system.vendor' try: self.systemVendor = cat('/sys/devices/virtual/dmi/id/sys_vendor')[0].strip() except: self.systemVendor = 'Unknown' else: self.systemVendor = WITHHELD_MAGIC_STRING if gate.grants('model'): try: self.systemModel = cat('/sys/devices/virtual/dmi/id/product_name')[0].strip() + ' ' + cat('/sys/devices/virtual/dmi/id/product_version')[0].strip() except: self.systemModel = 'Unknown' #hostInfo was removed with the hal restructure #if not self.systemModel: #self.systemModel = hostInfo.get('system.hardware.product') #if hostInfo.get('system.hardware.version'): #self.systemModel += ' ' + hostInfo.get('system.hardware.version') #if not self.systemModel: #self.systemModel = 'Unknown' else: self.systemModel = WITHHELD_MAGIC_STRING if gate.grants('form_factor'): try: formfactor_id = int(cat('/sys/devices/virtual/dmi/id/chassis_type')[0].strip()) self.formfactor = FORMFACTOR_LIST[formfactor_id] except: self.formfactor = 'Unknown' else: self.formfactor = WITHHELD_MAGIC_STRING if tempform == 'ppc64': if hostInfo.get('openfirmware.model'): if hostInfo['openfirmware.model'][:3] == 'IBM': self.systemVendor = 'IBM' model = hostInfo['openfirmware.model'][4:8] model_map = { '8842':'JS20', '6779':'JS21', '6778':'JS21', '7988':'JS21', '8844':'JS21', '0200':'QS20', '0792':'QS21', } try: model_name = model_map[model] self.systemModel = gate.process('model', model_name) self.formfactor = gate.process('form_factor', 'Blade') except KeyError: pass if gate.grants('selinux'): try: import selinux try: if selinux.is_selinux_enabled() == 1: self.selinux_enabled = SELINUX_ENABLED else: self.selinux_enabled = SELINUX_DISABLED except: self.selinux_enabled = SELINUX_DISABLED try: self.selinux_policy = selinux.selinux_getpolicytype()[1] except: self.selinux_policy = "Unknown" try: enforce = selinux.security_getenforce() if enforce == 0: self.selinux_enforce = "Permissive" elif enforce == 1: self.selinux_enforce = "Enforcing" elif enforce == -1: self.selinux_enforce = "Disabled" else: self.selinux_enforce = "FUBARD" except: self.selinux_enforce = "Unknown" except ImportError: self.selinux_enabled = SELINUX_DISABLED self.selinux_policy = "Not Installed" self.selinux_enforce = "Not Installed" else: self.selinux_enabled = SELINUX_WITHHELD self.selinux_policy = WITHHELD_MAGIC_STRING self.selinux_enforce = WITHHELD_MAGIC_STRING
def __init__(self, gate, uuid): cpuInfo = read_cpuinfo() memory = read_memory() self.UUID = uuid self.os = gate.process('distro', software.read_os(), WITHHELD_MAGIC_STRING) self.defaultRunlevel = gate.process('run_level', software.read_runlevel(), -1) self.bogomips = gate.process('cpu', cpuInfo.get('bogomips', 0), 0) self.cpuVendor = gate.process('cpu', cpuInfo.get('type', ''), WITHHELD_MAGIC_STRING) self.cpuModel = gate.process('cpu', cpuInfo.get('model', ''), WITHHELD_MAGIC_STRING) self.cpu_stepping = gate.process('cpu', cpuInfo.get('cpu_stepping', 0), 0) self.cpu_family = gate.process('cpu', cpuInfo.get('cpu_family', ''), '') self.cpu_model_num = gate.process('cpu', cpuInfo.get('cpu_model_num', 0), 0) self.numCpus = gate.process('cpu', cpuInfo.get('count', 0), 0) self.cpuSpeed = gate.process('cpu', cpuInfo.get('speed', 0), 0) self.systemMemory = gate.process('ram_size', memory['ram'], 0) self.systemSwap = gate.process('swap_size', memory['swap'], 0) self.kernelVersion = gate.process('kernel', os.uname()[2], WITHHELD_MAGIC_STRING) if gate.grants('language'): try: self.language = os.environ['LANG'] except KeyError: try: status, lang = commands.getstatusoutput( "grep LANG /etc/sysconfig/i18n") if status == 0: self.language = lang.split('"')[1] else: self.language = 'Unknown' except: self.language = 'Unknown' else: self.language = WITHHELD_MAGIC_STRING tempform = platform.machine() self.platform = gate.process('arch', tempform, WITHHELD_MAGIC_STRING) if gate.grants('vendor'): #self.systemVendor = hostInfo.get('system.vendor' try: self.systemVendor = cat( '/sys/devices/virtual/dmi/id/sys_vendor')[0].strip() except: self.systemVendor = 'Unknown' else: self.systemVendor = WITHHELD_MAGIC_STRING if gate.grants('model'): try: self.systemModel = cat( '/sys/devices/virtual/dmi/id/product_name' )[0].strip() + ' ' + cat( '/sys/devices/virtual/dmi/id/product_version')[0].strip() except: self.systemModel = 'Unknown' #hostInfo was removed with the hal restructure #if not self.systemModel: #self.systemModel = hostInfo.get('system.hardware.product') #if hostInfo.get('system.hardware.version'): #self.systemModel += ' ' + hostInfo.get('system.hardware.version') #if not self.systemModel: #self.systemModel = 'Unknown' else: self.systemModel = WITHHELD_MAGIC_STRING if gate.grants('form_factor'): try: formfactor_id = int( cat('/sys/devices/virtual/dmi/id/chassis_type')[0].strip()) self.formfactor = FORMFACTOR_LIST[formfactor_id] except: self.formfactor = 'Unknown' else: self.formfactor = WITHHELD_MAGIC_STRING if tempform == 'ppc64': if hostInfo.get('openfirmware.model'): if hostInfo['openfirmware.model'][:3] == 'IBM': self.systemVendor = 'IBM' model = hostInfo['openfirmware.model'][4:8] model_map = { '8842': 'JS20', '6779': 'JS21', '6778': 'JS21', '7988': 'JS21', '8844': 'JS21', '0200': 'QS20', '0792': 'QS21', } try: model_name = model_map[model] self.systemModel = gate.process('model', model_name) self.formfactor = gate.process('form_factor', 'Blade') except KeyError: pass if gate.grants('selinux'): try: import selinux try: if selinux.is_selinux_enabled() == 1: self.selinux_enabled = SELINUX_ENABLED else: self.selinux_enabled = SELINUX_DISABLED except: self.selinux_enabled = SELINUX_DISABLED try: self.selinux_policy = selinux.selinux_getpolicytype()[1] except: self.selinux_policy = "Unknown" try: enforce = selinux.security_getenforce() if enforce == 0: self.selinux_enforce = "Permissive" elif enforce == 1: self.selinux_enforce = "Enforcing" elif enforce == -1: self.selinux_enforce = "Disabled" else: self.selinux_enforce = "FUBARD" except: self.selinux_enforce = "Unknown" except ImportError: self.selinux_enabled = SELINUX_DISABLED self.selinux_policy = "Not Installed" self.selinux_enforce = "Not Installed" else: self.selinux_enabled = SELINUX_WITHHELD self.selinux_policy = WITHHELD_MAGIC_STRING self.selinux_enforce = WITHHELD_MAGIC_STRING
def __init__(self, hostInfo): cpuInfo = read_cpuinfo() memory = read_memory() self.UUID = getUUID() self.os = Gate().process('distro', software.read_os(), WITHHELD_MAGIC_STRING) self.defaultRunlevel = Gate().process('run_level', software.read_runlevel(), -1) self.bogomips = Gate().process('cpu', cpuInfo['bogomips'], 0) self.cpuVendor = Gate().process('cpu', cpuInfo['type'], WITHHELD_MAGIC_STRING) self.cpuModel = Gate().process('cpu', cpuInfo['model'], WITHHELD_MAGIC_STRING) self.cpu_stepping = Gate().process('cpu', cpuInfo['cpu_stepping'], 0) self.cpu_family = Gate().process('cpu', cpuInfo['cpu_family'], 0) self.cpu_model_num = Gate().process('cpu', cpuInfo['cpu_model_num'], 0) self.numCpus = Gate().process('cpu', cpuInfo['count'], 0) self.cpuSpeed = Gate().process('cpu', cpuInfo['speed'], 0) self.systemMemory = Gate().process('ram_size', memory['ram'], 0) self.systemSwap = Gate().process('swap_size', memory['swap'], 0) self.kernelVersion = Gate().process('kernel', os.uname()[2], WITHHELD_MAGIC_STRING) if Gate().grants('language'): try: self.language = os.environ['LANG'] except KeyError: self.language = 'Unknown' else: self.language = WITHHELD_MAGIC_STRING try: tempform = hostInfo['system.kernel.machine'] except KeyError: tempform = 'Unknown' self.platform = Gate().process('arch', tempform, WITHHELD_MAGIC_STRING) if Gate().grants('vendor'): self.systemVendor = hostInfo.get('system.vendor') if not self.systemVendor: self.systemVendor = hostInfo.get('system.hardware.vendor') if not self.systemVendor: self.systemVendor = 'Unknown' else: self.systemVendor = WITHHELD_MAGIC_STRING if Gate().grants('model'): self.systemModel = hostInfo.get('system.product') if not self.systemModel: self.systemModel = hostInfo.get('system.hardware.product') if hostInfo.get('system.hardware.version'): self.systemModel += ' ' + hostInfo.get('system.hardware.version') if not self.systemModel: self.systemModel = 'Unknown' else: self.systemModel = WITHHELD_MAGIC_STRING if Gate().grants('form_factor'): try: self.formfactor = hostInfo['system.formfactor'] except: self.formfactor = 'Unknown' else: self.formfactor = WITHHELD_MAGIC_STRING if tempform == 'ppc64': if hostInfo.get('openfirmware.model'): if hostInfo['openfirmware.model'][:3] == 'IBM': self.systemVendor = 'IBM' model = hostInfo['openfirmware.model'][4:8] model_map = { '8842':'JS20', '6779':'JS21', '6778':'JS21', '7988':'JS21', '8844':'JS21', '0200':'QS20', '0792':'QS21', } try: model_name = model_map[model] self.systemModel = Gate().process('model', model_name) self.formfactor = Gate().process('form_factor', 'Blade') except KeyError: pass if Gate().grants('selinux'): try: import selinux try: if selinux.is_selinux_enabled() == 1: self.selinux_enabled = SELINUX_ENABLED else: self.selinux_enabled = SELINUX_DISABLED except: self.selinux_enabled = SELINUX_DISABLED try: self.selinux_policy = selinux.selinux_getpolicytype()[1] except: self.selinux_policy = "Unknown" try: enforce = selinux.security_getenforce() if enforce == 0: self.selinux_enforce = "Permissive" elif enforce == 1: self.selinux_enforce = "Enforcing" elif enforce == -1: self.selinux_enforce = "Disabled" else: self.selinux_enforce = "FUBARD" except: self.selinux_enforce = "Unknown" except ImportError: self.selinux_enabled = SELINUX_DISABLED self.selinux_policy = "Not Installed" self.selinux_enforce = "Not Installed" else: self.selinux_enabled = SELINUX_WITHHELD self.selinux_policy = WITHHELD_MAGIC_STRING self.selinux_enforce = WITHHELD_MAGIC_STRING