How to use the blivet.util.run_program 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 / devicelibs / swap.py View on Github external
if buf is not None and len(buf) == pagesize:
        sig = buf[pagesize - 10:]
        if sig == 'SWAP-SPACE':
            raise OldSwapError
        if sig == 'S1SUSPEND\x00' or sig == 'S2SUSPEND\x00':
            raise SuspendError

    if sig != 'SWAPSPACE2':
        raise UnknownSwapError

    argv = []
    if isinstance(priority, int) and 0 <= priority <= 32767:
        argv.extend(["-p", "%d" % priority])
    argv.append(device)

    rc = util.run_program(["swapon"] + argv)

    if rc:
        raise SwapError("swapon failed for '%s'" % device)
github storaged-project / blivet / blivet / udev.py View on Github external
def settle(quiet=False):
    """ Wait for the udev queue to settle.

        :keyword bool quiet: bypass :meth:`blivet.util.run_program`
    """
    # wait maximal 300 seconds for udev to be done running blkid, lvm,
    # mdadm etc. This large timeout is needed when running on machines with
    # lots of disks, or with slow disks
    argv = ["udevadm", "settle", "--timeout=300"]
    if quiet:
        subprocess.call(argv, close_fds=True)
    else:
        util.run_program(argv)
github storaged-project / blivet / blivet / devices / optical.py View on Github external
def eject(self):
        """ Eject the drawer. """
        log_method_call(self, self.name, status=self.status)
        if not self.exists:
            raise errors.DeviceError("device has not been created", self.name)

        # try to umount and close device before ejecting
        self.teardown()

        try:
            util.run_program(["eject", self.name])
        except OSError as e:
            log.warning("error ejecting cdrom %s: %s", self.name, e)
github storaged-project / blivet / blivet / iscsi.py View on Github external
['ifaces','isns','nodes','send_targets','slp','static']):
            if not os.path.isdir(fulldir):
                os.makedirs(fulldir, 0o755)

        log.info("iSCSI startup")
        util.run_program(['modprobe', '-a'] + ISCSI_MODULES)
        # iscsiuio is needed by Broadcom offload cards (bnx2i). Currently
        # not present in iscsi-initiator-utils for Fedora.
        try:
            iscsiuio = util.find_program_in_path('iscsiuio',
                                                   raise_on_error=True)
        except RuntimeError:
            log.info("iscsi: iscsiuio not found.")
        else:
            log.debug("iscsi: iscsiuio is at %s", iscsiuio)
            util.run_program([iscsiuio])
        # run the daemon
        util.run_program([ISCSID])
        time.sleep(1)

        self._startIBFT()
        self.started = True
github storaged-project / blivet / blivet / devicelibs / dm.py View on Github external
def dm_setup(args):
    ret = util.run_program(["dmsetup"] + args)
    if ret:
        raise DMError("Failed to run dmsetup %s" % " ".join(args))
github storaged-project / blivet / blivet / osinstall.py View on Github external
"""
    Perform installer-specific activation of storage configuration.

    :param callbacks: callbacks to be invoked when actions are executed
    :type callbacks: return value of the :func:`~.callbacks.create_new_callbacks_register`

    """

    if not flags.installer_mode:
        return

    if not mountOnly:
        if (flags.live_install and not flags.image_install and not storage.fsset.active):
            # turn off any swaps that we didn't turn on
            # needed for live installs
            util.run_program(["swapoff", "-a"])
        storage.devicetree.teardownAll()

        try:
            storage.doIt(callbacks)
        except FSResizeError as e:
            if errorHandler.cb(e) == ERROR_RAISE:
                raise
        except Exception as e:
            raise

        storage.turnOnSwap()
    # FIXME:  For livecd, skipRoot needs to be True.
    storage.mountFilesystems()

    if not mountOnly:
        writeEscrowPackets(storage)
github storaged-project / blivet / blivet / tasks / fsmkfs.py View on Github external
def do_task(self, options=None, label=False):
        """Create the format on the device and label if possible and desired.

           :param options: any special options, may be None
           :type options: list of str or NoneType
           :param bool label: whether to label while creating, default is False
        """
        # pylint: disable=arguments-differ
        error_msgs = self.availability_errors
        if error_msgs:
            raise FSError("\n".join(error_msgs))

        options = options or []
        try:
            ret = util.run_program(self._mkfs_command(options, label))
        except OSError as e:
            raise FSError(e)

        if ret:
            raise FSError("format failed: %s" % ret)