How to use the blivet.udev.settle function in blivet

To help you get started, we’ve selected a few blivet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github storaged-project / blivet / blivet / iscsi.py View on Github external
def stabilize(self):
        # Wait for udev to create the devices for the just added disks

        # It is possible when we get here the events for the new devices
        # are not send yet, so sleep to make sure the events are fired
        time.sleep(2)
        udev.settle()
github storaged-project / blivet / blivet / devices / dm.py View on Github external
def _teardown(self, recursive=False):
        self.teardown_partitions()
        udev.settle()
        blockdev.dm.remove(self.name)
        udev.settle()
github storaged-project / blivet / blivet / devices / disk.py View on Github external
def _post_setup(self):
        StorageDevice._post_setup(self)
        self.setup_partitions()
        udev.settle()
github storaged-project / blivet / blivet / populator.py View on Github external
log.info("scanning %s (%s)...", name, sysfs_path)
        device = self.getDeviceByName(name)
        if device is None and udev.device_is_md(info):

            # If the md name is None, then some udev info is missing. Likely,
            # this is because the array is degraded, and mdadm has deactivated
            # it. Try to activate it and re-get the udev info.
            if flags.allow_imperfect_devices and udev.device_get_md_name(info) is None:
                devname = udev.device_get_devname(info)
                if devname:
                    try:
                        blockdev.md.run(devname)
                    except blockdev.MDRaidError as e:
                        log.warning("Failed to start possibly degraded md array: %s", e)
                    else:
                        udev.settle()
                        info = udev.get_device(sysfs_path)
                else:
                    log.warning("Failed to get devname for possibly degraded md array.")

            md_name = udev.device_get_md_name(info)
            if md_name is None:
                log.warning("No name for possibly degraded md array.")
            else:
                device = self.getDeviceByName(md_name, incomplete=flags.allow_imperfect_devices)

            if device and not isinstance(device, MDRaidArrayDevice):
                log.warning("Found device %s, but it turns out not be an md array device after all.", device.name)
                device = None

        if device and device.isDisk and \
           blockdev.mpath.is_mpath_member(device.path):
github storaged-project / blivet / blivet / devices / partition.py View on Github external
def _postDestroy(self):
        super(PartitionDevice, self)._postDestroy()
        if isinstance(self.disk, DMDevice):
            udev.settle()
            # self.exists has been unset, so don't use self.status
            if os.path.exists(self.path):
                try:
                    blockdev.dm.remove(self.name)
                except blockdev.DMError:
                    pass
github storaged-project / blivet / blivet / zfcp.py View on Github external
f = open(online, "r")
            devonline = f.readline().strip()
            f.close()
            if devonline != "1":
                logged_write_line_to_file(online, "1")
        except IOError as e:
            raise ValueError(_("Could not set zFCP device %(devnum)s "
                               "online (%(e)s).")
                             % {'devnum': self.devnum, 'e': e})

        if not os.path.exists(portdir):
            if os.path.exists(portadd):
                # older zfcp sysfs interface
                try:
                    logged_write_line_to_file(portadd, self.wwpn)
                    udev.settle()
                except IOError as e:
                    raise ValueError(_("Could not add WWPN %(wwpn)s to zFCP "
                                       "device %(devnum)s (%(e)s).")
                                     % {'wwpn': self.wwpn,
                                         'devnum': self.devnum,
                                         'e': e})
            else:
                # newer zfcp sysfs interface with auto port scan
                raise ValueError(_("WWPN %(wwpn)s not found at zFCP device "
                                   "%(devnum)s.") % {'wwpn': self.wwpn,
                                                     'devnum': self.devnum})
        else:
            if os.path.exists(portadd):
                # older zfcp sysfs interface
                log.info("WWPN %(wwpn)s at zFCP device %(devnum)s already "
                         "there.", {'wwpn': self.wwpn,
github storaged-project / blivet / blivet / devices / md.py View on Github external
def _create(self):
        """ Create the device. """
        log_method_call(self, self.name, status=self.status)
        disks = [disk.path for disk in self.members]
        spares = len(self.members) - self.memberDevices
        level = None
        if self.level:
            level = str(self.level)
        blockdev.md.create(self.path, level, disks, spares,
                           version=self.metadataVersion,
                           bitmap=self.createBitmap)
        udev.settle()
github storaged-project / blivet / blivet / devices / dm.py View on Github external
def setup_partitions(self):
        log_method_call(self, name=self.name)
        rc = util.run_program(["kpartx", "-a", "-s", self.path])
        if rc:
            raise errors.DMError("partition activation failed for '%s'" % self.name)
        udev.settle()