def pcicType(test = 0): devs = kudzu.probe(kudzu.CLASS_SOCKET, kudzu.BUS_PCI, 0) if devs: log("Found a pcic controller of type: yenta_socket") return "yenta_socket" # lets look for non-PCI socket controllers now devs = kudzu.probe(kudzu.CLASS_SOCKET, kudzu.BUS_MISC, 0) if devs and devs[0].driver not in ["ignore", "unknown", "disabled"]: log("Found a pcic controller of type: %s", devs[0].driver) return devs[0].driver log("No pcic controller detected") return None
def get_device_list(): result = [] hd_list = kudzu.probe( kudzu.CLASS_HD, kudzu.BUS_IDE | kudzu.BUS_SCSI | kudzu.BUS_MISC, kudzu.PROBE_ALL) print hd_list
def probe (self): lst = kudzu.probe(kudzu.CLASS_UNSPEC, kudzu.BUS_PCI, kudzu.PROBE_ALL) for card in lst: (device, driver, descr) = card if descr == "IBM Remote Supervisor Adapter (RSA)": self.deviceExist = 1
def hasFloppyDevice(): try: for dev in kudzu.probe(kudzu.CLASS_FLOPPY, kudzu.BUS_UNSPEC, kudzu.PROBE_ALL): if not dev.detached: return True except: return False return False
def __init__(self, forceDriver=None): cards = kudzu.probe(kudzu.CLASS_VIDEO, kudzu.BUS_UNSPEC, kudzu.PROBE_ALL) # just use first video card we recognize # store as a list of class VideoCard self.videocards = [] self.primary = None index = 0 prependedOne = False for card in cards: vc = VideoCard() vc.setDevice(card.device) vc.setDescription(card.desc) if card.bus == kudzu.BUS_PCI: vc.setPCIBus(card.pcibus) vc.setPCIDev(card.pcidev) vc.setPCIFn(card.pcifn) if forceDriver: vc.setDriver(forceDriver) self.videocards.append(vc) elif card.xdriver: vc.setDriver(card.xdriver) # Only prepend one card that has a driver, rather than all. if not prependedOne: self.videocards = [vc] + self.videocards prependedOne = True else: self.videocards.append(vc) else: # insert a best guess at a card if os.uname()[4].count("ppc") > 0: vc.setDriver('fbdev') else: vc.setDriver('vesa') self.videocards.append(vc) if len(self.videocards) > 0: self.primary = 0
def probe (self, frob = 0): list = kudzu.probe(kudzu.CLASS_MOUSE, kudzu.BUS_UNSPEC, kudzu.PROBE_ALL) self.probedList = list #XXX fixme: Some laptops (HP/IBM) report two PS2 mice one generic one synaptics. if (list): l = list[0] if l.device == "sunmouse": self.setMouse("sun", 0) elif l.bus == kudzu.BUS_PSAUX: if l.driver == "synaptics": self.setMouse("synaptics", 0) elif l.driver == "msintellips/2": self.setMouse("genericwheelps/2", 0) else: self.setMouse("generic3ps/2",0) elif l.bus == kudzu.BUS_USB: if l.driver == "generic3usb" or l.driver == "mousedev": self.setMouse("generic3usb", 0) elif l.driver == "genericusb": self.setMouse("genericusb", 1) else: self.setMouse("generic", 1) # RH#492565 # Force a check for the American Megatrends KVM and if it # exists, add it to the list of devices. kvm_device = self.probeKVM() if kvm_device: self.probedList.append(kvm_device) self.device = l.device self.wasProbed = 1 return 1 else: self.setMouse("none") self.device = None self.wasProbed = 0 return 0
def probeFloppyDevice(): fdDevice = "fd0" # we now have nifty kudzu code that does all of the heavy lifting # and properly detects detached floppy drives, ide floppies, and # even usb floppies devices = kudzu.probe(kudzu.CLASS_FLOPPY, kudzu.BUS_IDE | kudzu.BUS_MISC | kudzu.BUS_SCSI, kudzu.PROBE_ALL) if not devices: log.warning("no floppy devices found but we'll try fd0 anyway") return fdDevice for device in devices: if device.detached: continue log.info("anaconda floppy device %s" % (device.device)) return device.device log.info("anaconda floppy device is %s", fdDevice) return fdDevice
def __init__(self): self.type = "PC" self.beenset = 0 self.info = {} # default to us self.info["KEYTABLE"] = "us" list = kudzu.probe(kudzu.CLASS_KEYBOARD, kudzu.BUS_UNSPEC, kudzu.PROBE_ONE) if list: (device, module, desc) = list[0] if desc.startswith("Serial console"): self.type = "Serial" # XXX no sparc handling here, but we'll pretend for the time being elif desc.startswith("Sun Type"): self.type = "Sun" if self.type == "Sun": self.info["KEYBOARDTYPE"] = "sun" elif self.type != "Serial": self.info["KEYBOARDTYPE"] = "pc" self._mods = keyboard_models.KeyboardModels()
def driveDict(klassArg): import parted global cachedDrives if cachedDrives is None: # FIXME: need to add dasd probing to kudzu devs = kudzu.probe(kudzu.CLASS_HD | kudzu.CLASS_CDROM | \ kudzu.CLASS_FLOPPY | kudzu.CLASS_TAPE, kudzu.BUS_UNSPEC, kudzu.PROBE_SAFE) new = {} for dev in devs: device = dev.device if device is None: # none devices make no sense # kudzu is unable to determine the device for tape drives w/ 2.6 if dev.deviceclass == classMap["tape"]: tapedevs = filter(lambda d: d.startswith("st"), new.keys()) device = "st%d" % (len(tapedevs),) else: continue if dev.deviceclass != classMap["disk"]: new[device] = dev continue try: devName = "/dev/%s" % (device,) makeDevInode(device, devName) if not mediaPresent (device) or deviceIsReadOnly(device): new[device] = dev continue if device.startswith("sd"): peddev = parted.PedDevice.get(devName) model = peddev.model # blacklist *STMF on power5 iSeries boxes if rhpl.getArch() == "ppc" and \ model.find("IBM *STMF KERNEL") != -1: log.info("%s looks like STMF, ignoring" % (device,)) del peddev continue # blacklist DGC/EMC LUNs for which we have no ACL. # We should be ignoring LUN_Z for all vendors, but I # don't know how (if) other vendors encode this into # the model info. # # XXX I need to work some SCC2 LUN mode page detection # into libbdevid, and then this should use that instead. # -- pjones if str(peddev.model) == "DGC LUNZ": log.info("%s looks like a LUN_Z device, ignoring" % \ (device,)) del peddev continue del peddev new[device] = dev except Exception, e: log.debug("exception checking disk blacklist on %s: %s" % \ (device, e)) cachedDrives = new
def switchMedia(self, mediano, filename=""): log.info("switching from CD %s to %s for %s" %(self.currentMedia, mediano, filename)) if mediano in self.currentMedia: return if os.access("/mnt/source/.discinfo", os.R_OK): f = open("/mnt/source/.discinfo") timestamp = f.readline().strip() f.close() else: timestamp = self.timestamp if self.timestamp is None: self.timestamp = timestamp needed = mediano # if self.currentMedia is empty, then we shouldn't have anything # mounted. double-check by trying to unmount, but we don't want # to get into a loop of trying to unmount forever. if # self.currentMedia is set, then it should still be mounted and # we want to loop until it unmounts successfully if not self.currentMedia: try: isys.umount("/mnt/source") except: pass else: self.unmountCD() done = 0 cdlist = [] for (dev, something, descript) in \ kudzu.probe(kudzu.CLASS_CDROM, kudzu.BUS_UNSPEC, 0): cdlist.append(dev) for dev in cdlist: try: if not isys.mount(dev, "/mnt/source", fstype = "iso9660", readOnly = 1): if os.access("/mnt/source/.discinfo", os.R_OK): f = open("/mnt/source/.discinfo") newStamp = f.readline().strip() try: descr = f.readline().strip() except: descr = None try: arch = f.readline().strip() except: arch = None try: discNum = getDiscNums(f.readline().strip()) except: discNum = [ 0 ] f.close() if (newStamp == timestamp and arch == _arch and needed in discNum): done = 1 self.currentMedia = discNum if not done: isys.umount("/mnt/source") except: pass if done: break if not done: if self.noeject: log.info("noeject in effect, not ejecting cdrom") else: isys.ejectCdrom(self.device) while not done: if self.intf is not None: self.intf.beep() self.messageWindow(_("Change CDROM"), _("Please insert %s disc %d to continue.") % (productName, needed)) try: if isys.mount(self.device, "/mnt/source", fstype = "iso9660", readOnly = 1): time.sleep(3) isys.mount(self.device, "/mnt/source", fstype = "iso9660", readOnly = 1) if os.access("/mnt/source/.discinfo", os.R_OK): f = open("/mnt/source/.discinfo") newStamp = f.readline().strip() try: descr = f.readline().strip() except: descr = None try: arch = f.readline().strip() except: arch = None try: discNum = getDiscNums(f.readline().strip()) except: discNum = [ 0 ] f.close() if (newStamp == timestamp and arch == _arch and needed in discNum): done = 1 self.currentMedia = discNum # make /tmp/cdrom again so cd gets ejected isys.makeDevInode(self.device, "/tmp/cdrom") if not done: self.messageWindow(_("Wrong CDROM"), _("That's not the correct %s CDROM.") % (productName,)) isys.umount("/mnt/source") if self.noeject: log.info("noeject in effect, not ejecting cdrom") else: isys.ejectCdrom(self.device) except: self.messageWindow(_("Error"), _("Unable to access the CDROM."))
def __init__(self): self.firstnetdevice = None self.netdevices = {} self.gateway = "" self.primaryNS = "" self.secondaryNS = "" self.ternaryNS = "" self.domains = [] self.isConfigured = 0 self.hostname = "localhost.localdomain" # if we specify a hostname and are using dhcp, do an override # originally used by the gui but overloaded now # we also test in places if the hostname is localhost.localdomain # to see if its been override. Need some consolidation in future. self.overrideDHCPhostname = 0 try: f = open("/tmp/netinfo", "r") except: pass else: lines = f.readlines() f.close() info = {} self.isConfigured = 1 for line in lines: netinf = string.splitfields(line, '=') info[netinf[0]] = string.strip(netinf[1]) self.netdevices[info["DEVICE"]] = NetworkDevice(info["DEVICE"]) for key in ("IPADDR", "NETMASK", "BOOTPROTO", "ONBOOT", "MTU", "REMIP"): if info.has_key(key): self.netdevices[info["DEVICE"]].set((key, info[key])) if info.has_key("GATEWAY"): self.gateway = info["GATEWAY"] if info.has_key("DOMAIN"): self.domains.append(info["DOMAIN"]) if info.has_key("HOSTNAME"): self.hostname = info["HOSTNAME"] try: f = open("/etc/resolv.conf", "r") except: pass else: lines = f.readlines() f.close() for line in lines: resolv = string.split(line) if resolv and resolv[0] == 'nameserver': if self.primaryNS == "": self.primaryNS = resolv[1] elif self.secondaryNS == "": self.secondaryNS = resolv[1] elif self.ternaryNS == "": self.ternaryNS = resolv[1] # now initialize remaining devices # XXX we just throw return away, the method initialize a # object member so we dont need to available_devices = self.available() if len(available_devices) > 0: # set first device to start up onboot oneactive = 0 for dev in available_devices.keys(): try: if available_devices[dev].get("onboot") == "yes": oneactive = 1 break except: continue if not oneactive: self.netdevices[self.firstnetdevice].set(("onboot", "yes")) # assign description to each device based on kudzu information probedevs = kudzu.probe(kudzu.CLASS_NETWORK, kudzu.CLASS_UNSPEC, 0) for netdev in probedevs: device = netdev.device if device in self.netdevices.keys(): desc = netdev.desc if desc is not None and len(desc) > 0: self.netdevices[device].set(("desc", desc)) # add hwaddr hwaddr = isys.getMacAddress(device) if hwaddr and hwaddr != "00:00:00:00:00:00": self.netdevices[device].set(("hwaddr", hwaddr))
def __init__(self): self.firstnetdevice = None self.netdevices = {} self.gateway = "" self.primaryNS = "" self.secondaryNS = "" self.domains = [] self.isConfigured = 0 self.hostname = "localhost.localdomain" self.query = False # if we specify a hostname and are using dhcp, do an override # originally used by the gui but overloaded now # we also test in places if the hostname is localhost.localdomain # to see if its been override. Need some consolidation in future. self.overrideDHCPhostname = 0 if flags.rootpath: self.isConfigured = 1 try: f = open("/tmp/netinfo", "r") except: pass else: lines = f.readlines() f.close() info = {} self.isConfigured = 1 for line in lines: netinf = string.splitfields(line, '=') if len(netinf) >= 3: info[netinf[0]] = '='.join([string.strip(s) for s in netinf[1:]]) elif len(netinf) >= 2: info [netinf[0]] = string.strip(netinf[1]) self.netdevices [info["DEVICE"]] = NetworkDevice(info["DEVICE"]) self.firstnetdevice = info["DEVICE"] for key in ("IPADDR", "NETMASK", "BOOTPROTO", "ONBOOT", "MTU", "NETTYPE", "SUBCHANNELS", "PORTNAME", "CTCPROT", "PEERID", "ESSID", "KEY", "IPV6ADDR", "IPV6_AUTOCONF", "OPTIONS", "ARP", "MACADDR"): if info.has_key(key): self.netdevices [info["DEVICE"]].set((key, info[key])) osa_opts = [] for key in ("LAYER2", "PORTNO"): if info.has_key(key) and info[key] == "1": osa_opts.append(key.lower() + "=" + info[key]) if osa_opts: self.netdevices[info["DEVICE"]].set(("OPTIONS", " ".join(osa_opts))) self.netdevices [info["DEVICE"]].set(('useIPv4', flags.useIPv4)) self.netdevices [info["DEVICE"]].set(('useIPv6', flags.useIPv6)) if info.has_key("GATEWAY"): self.gateway = info["GATEWAY"] if info.has_key("DOMAIN"): self.domains.append(info["DOMAIN"]) if info.has_key("HOSTNAME"): self.hostname = info["HOSTNAME"] if not info.has_key("BOOTPROTO"): if not info.has_key("IPADDR"): self.netdevices [info["DEVICE"]].set(('useIPv4', False)) if not (info.has_key("IPV6ADDR") and info.has_key("IPV6_AUTOCONF")): self.netdevices [info["DEVICE"]].set(('useIPv6', False)) try: f = open("/etc/resolv.conf", "r") except: pass else: lines = f.readlines() f.close() for line in lines: resolv = string.split(line) if resolv and resolv[0] == 'nameserver': if self.primaryNS == "": self.primaryNS = resolv[1] elif self.secondaryNS == "": self.secondaryNS = resolv[1] # now initialize remaining devices # XXX we just throw return away, the method initialize a # object member so we dont need to available_devices = self.available() if len(available_devices) > 0: # set first device to start up onboot oneactive = 0 for dev in available_devices.keys(): try: if available_devices[dev].get("onboot") == "yes": oneactive = 1 break except: continue if not oneactive: self.netdevices[self.firstnetdevice].set(("onboot", "yes")) # assign description to each device based on kudzu information probedevs = kudzu.probe(kudzu.CLASS_NETWORK, kudzu.BUS_UNSPEC, 0) for netdev in probedevs: device = netdev.device if device in self.netdevices.keys(): desc = netdev.desc if desc is not None and len(desc) > 0: self.netdevices[device].set(("desc", desc)) # hwaddr for qeth doesn't make sense (#135023) if netdev.driver == "qeth": continue # add hwaddr hwaddr = isys.getMacAddress(device) if hwaddr and hwaddr != "00:00:00:00:00:00" and hwaddr != "ff:ff:ff:ff:ff:ff": self.netdevices[device].set(("hwaddr", hwaddr))
def getRPMFilename(self, h, timer, callback=None): if h[1000002] == None or 1000002 not in h.keys(): log ("header for %s has no disc location tag, assuming it's" "on the current CD" %(h[1000000],)) elif h[1000002] not in self.currentDisc: timer.stop() log("switching from iso %s to %s for %s-%s-%s.%s" %(self.currentDisc, h[1000002], h['name'], h['version'], h['release'], h['arch'])) if os.access("/mnt/source/.discinfo", os.R_OK): f = open("/mnt/source/.discinfo") timestamp = f.readline().strip() f.close() else: timestamp = self.timestamp if self.timestamp is None: self.timestamp = timestamp needed = h[1000002] # if self.currentDisc is empty, then we shouldn't have anything # mounted. double-check by trying to unmount, but we don't want # to get into a loop of trying to unmount forever. if # self.currentDisc is set, then it should still be mounted and # we want to loop until it unmounts successfully if not self.currentDisc: try: isys.umount("/mnt/source") except: pass else: self.unmountCD() done = 0 cdlist = [] for (dev, something, descript) in \ kudzu.probe(kudzu.CLASS_CDROM, kudzu.BUS_UNSPEC, 0): cdlist.append(dev) for dev in cdlist: try: if not isys.mount(dev, "/mnt/source", fstype = "iso9660", readOnly = 1): if os.access("/mnt/source/.discinfo", os.R_OK): f = open("/mnt/source/.discinfo") newStamp = f.readline().strip() try: descr = f.readline().strip() except: descr = None try: arch = f.readline().strip() except: arch = None try: discNum = getDiscNums(f.readline().strip()) except: discNum = [ 0 ] f.close() if (newStamp == timestamp and arch == _arch and needed in discNum): done = 1 self.currentDisc = discNum if not done: isys.umount("/mnt/source") except: pass if done: break if not done: isys.ejectCdrom(self.device) while not done: self.messageWindow(_("Change CDROM"), _("Please insert disc %d to continue.") % needed) try: if isys.mount(self.device, "/mnt/source", fstype = "iso9660", readOnly = 1): time.sleep(3) isys.mount(self.device, "/mnt/source", fstype = "iso9660", readOnly = 1) if os.access("/mnt/source/.discinfo", os.R_OK): f = open("/mnt/source/.discinfo") newStamp = f.readline().strip() try: descr = f.readline().strip() except: descr = None try: arch = f.readline().strip() except: arch = None try: discNum = getDiscNums(f.readline().strip()) except: discNum = [ 0 ] f.close() if (newStamp == timestamp and arch == _arch and needed in discNum): done = 1 self.currentDisc = discNum # make /tmp/cdrom again so cd gets ejected isys.makeDevInode(self.device, "/tmp/cdrom") if not done: self.messageWindow(_("Wrong CDROM"), _("That's not the correct %s CDROM.") % (productName,)) isys.umount("/mnt/source") isys.ejectCdrom(self.device) except: self.messageWindow(_("Error"), _("The CDROM could not be mounted.")) timer.start() # if we haven't read a timestamp yet, let's try to get one if (self.timestamp is None and os.access("/mnt/source/.discinfo", os.R_OK)): try: f = open("/mnt/source/.discinfo") self.timestamp = f.readline().strip() f.close() except: pass tmppath = self.getTempPath() tries = 0 # FIXME: should retry a few times then prompt for new cd while tries < 5: try: shutil.copy("%s/%s/RPMS/%s" % (self.tree, productPath, h[1000000]), tmppath + h[1000000]) except IOError, (errnum, msg): log("IOError %s occurred copying %s: %s", errnum, h[1000000], str(msg)) time.sleep(5) else: break tries = tries + 1
def getCDDev(): drives = kudzu.probe(kudzu.CLASS_CDROM, kudzu.BUS_UNSPEC, kudzu.PROBE_ALL) return map (lambda d: d.device, drives)
def __init__(self): self.firstnetdevice = None self.netdevices = {} self.gateway = "" self.primaryNS = "" self.secondaryNS = "" self.domains = [] self.isConfigured = 0 self.hostname = "localhost.localdomain" self.query = False # if we specify a hostname and are using dhcp, do an override # originally used by the gui but overloaded now # we also test in places if the hostname is localhost.localdomain # to see if its been override. Need some consolidation in future. self.overrideDHCPhostname = 0 if flags.rootpath: self.isConfigured = 1 try: f = open("/tmp/netinfo", "r") except: pass else: lines = f.readlines() f.close() info = {} self.isConfigured = 1 for line in lines: netinf = string.splitfields(line, '=') if len(netinf) >= 3: info[netinf[0]] = '='.join( [string.strip(s) for s in netinf[1:]]) elif len(netinf) >= 2: info[netinf[0]] = string.strip(netinf[1]) self.netdevices[info["DEVICE"]] = NetworkDevice(info["DEVICE"]) self.firstnetdevice = info["DEVICE"] for key in ("IPADDR", "NETMASK", "BOOTPROTO", "ONBOOT", "MTU", "NETTYPE", "SUBCHANNELS", "PORTNAME", "CTCPROT", "PEERID", "ESSID", "KEY", "IPV6ADDR", "IPV6_AUTOCONF", "OPTIONS", "ARP", "MACADDR"): if info.has_key(key): self.netdevices[info["DEVICE"]].set((key, info[key])) osa_opts = [] for key in ("LAYER2", "PORTNO"): if info.has_key(key) and info[key] == "1": osa_opts.append(key.lower() + "=" + info[key]) if osa_opts: self.netdevices[info["DEVICE"]].set( ("OPTIONS", " ".join(osa_opts))) self.netdevices[info["DEVICE"]].set(('useIPv4', flags.useIPv4)) self.netdevices[info["DEVICE"]].set(('useIPv6', flags.useIPv6)) if info.has_key("GATEWAY"): self.gateway = info["GATEWAY"] if info.has_key("DOMAIN"): self.domains.append(info["DOMAIN"]) if info.has_key("HOSTNAME"): self.hostname = info["HOSTNAME"] if not info.has_key("BOOTPROTO"): if not info.has_key("IPADDR"): self.netdevices[info["DEVICE"]].set(('useIPv4', False)) if not (info.has_key("IPV6ADDR") and info.has_key("IPV6_AUTOCONF")): self.netdevices[info["DEVICE"]].set(('useIPv6', False)) try: f = open("/etc/resolv.conf", "r") except: pass else: lines = f.readlines() f.close() for line in lines: resolv = string.split(line) if resolv and resolv[0] == 'nameserver': if self.primaryNS == "": self.primaryNS = resolv[1] elif self.secondaryNS == "": self.secondaryNS = resolv[1] # now initialize remaining devices # XXX we just throw return away, the method initialize a # object member so we dont need to available_devices = self.available() if len(available_devices) > 0: # set first device to start up onboot oneactive = 0 for dev in available_devices.keys(): try: if available_devices[dev].get("onboot") == "yes": oneactive = 1 break except: continue if not oneactive: self.netdevices[self.firstnetdevice].set(("onboot", "yes")) # assign description to each device based on kudzu information probedevs = kudzu.probe(kudzu.CLASS_NETWORK, kudzu.BUS_UNSPEC, 0) for netdev in probedevs: device = netdev.device if device in self.netdevices.keys(): self.netdevices[device].set(("useIPv4", flags.useIPv4)) self.netdevices[device].set(("useIPv6", flags.useIPv6)) desc = netdev.desc if desc is not None and len(desc) > 0: self.netdevices[device].set(("desc", desc)) # hwaddr for qeth doesn't make sense (#135023) if netdev.driver == "qeth": continue # add hwaddr hwaddr = isys.getMacAddress(device) if hwaddr and hwaddr != "00:00:00:00:00:00" and hwaddr != "ff:ff:ff:ff:ff:ff": self.netdevices[device].set(("hwaddr", hwaddr))
def get_device_list(): result = [] hd_list = kudzu.probe(kudzu.CLASS_HD, kudzu.BUS_IDE | kudzu.BUS_SCSI | kudzu.BUS_MISC, kudzu.PROBE_ALL) print hd_list