Exemple #1
0
 def setUp(self):
     super(BlivetResetTestCase, self).setUp()  # pylint: disable=bad-super-call
     vg_name = self.blivet.vgs[0].name
     util.run_program(["lvcreate", "-n", "raid", "--type", "raid1",
                       "-L", "100%", vg_name])
     self.device_attr_dicts = []
     self.collect_expected_data()
Exemple #2
0
def online_dasd(dev):
    """ Given a device number, switch the device to be online.

        :param str dev: a DASD device number

        Raises a ValueError if a device with that number does not exist,
        is already online, or can not be put online.
    """
    online = "/sys/bus/ccw/drivers/dasd-eckd/%s/online" % (dev)

    if not os.path.exists(online):
        log.info("Freeing DASD device %s", dev)
        util.run_program(["dasd_cio_free", "-d", dev])

    if not os.path.exists(online):
        raise ValueError(_("DASD device %s not found, not even in device ignore list.")
            % dev)

    try:
        with open(online, "r") as f:
            devonline = f.readline().strip()
        if devonline == "1":
            raise ValueError(_("Device %s is already online.") % dev)
        else:
            with open(online, "w") as f:
                log.debug("echo %s > %s", "1", online)
                f.write("%s\n" % ("1"))
    except IOError as e:
        raise ValueError(_("Could not set DASD device %(dev)s online (%(e)s).") \
                        % {'dev': dev, 'e': e})
Exemple #3
0
def online_dasd(dev):
    """ Given a device number, switch the device to be online.

        :param str dev: a DASD device number

        Raises a ValueError if a device with that number does not exist,
        is already online, or can not be put online.
    """
    online = "/sys/bus/ccw/drivers/dasd-eckd/%s/online" % (dev)

    if not os.path.exists(online):
        log.info("Freeing DASD device %s", dev)
        util.run_program(["dasd_cio_free", "-d", dev])

    if not os.path.exists(online):
        raise ValueError(_("DASD device %s not found, not even in device ignore list.")
            % dev)

    try:
        with open(online, "r") as f:
            devonline = f.readline().strip()
        if devonline == "1":
            raise ValueError(_("Device %s is already online.") % dev)
        else:
            with open(online, "w") as f:
                log.debug("echo %s > %s", "1", online)
                f.write("%s\n" % ("1"))
    except IOError as e:
        raise ValueError(_("Could not set DASD device %(dev)s online (%(e)s).") \
                        % {'dev': dev, 'e': e})
Exemple #4
0
def turn_on_filesystems(storage, callbacks=None):
    """Perform installer-specific activation of storage configuration.

    :param storage: the storage object
    :type storage: :class:`~.storage.InstallerStorage`
    :param callbacks: callbacks to be invoked when actions are executed
    :type callbacks: return value of the :func:`blivet.callbacks.create_new_callbacks_register`
    """
    # FIXME: This is a temporary workaround for live OS.
    if conf.system._is_live_os and conf.target.is_hardware and not storage.fsset.active:
        # turn off any swaps that we didn't turn on
        # needed for live installs
        blivet_util.run_program(["swapoff", "-a"])

    storage.devicetree.teardown_all()

    try:
        storage.do_it(callbacks)
    except (FSResizeError, FormatResizeError) as e:
        if error_handler.cb(e) == ERROR_RAISE:
            raise

    storage.turn_on_swap()
Exemple #5
0
def format_dasd(dasd):
    """ Run dasdfmt on a DASD. Aside from one type of device noted below, this
        function _does not_ check if a DASD needs to be formatted, but rather,
        assumes the list passed needs formatting.

        We don't need to show or update any progress bars, since disk actions
        will be taking place all in the progress hub, which is just one big
        progress bar.
    """
    try:
        rc = util.run_program(["/sbin/dasdfmt", "-y", "-d", "cdl", "-b", "4096", "/dev/" + dasd])
    except Exception as err:
        raise DasdFormatError(err)

    if rc:
        raise DasdFormatError("dasdfmt failed: %s" % rc)
Exemple #6
0
def format_dasd(dasd):
    """ Run dasdfmt on a DASD. Aside from one type of device noted below, this
        function _does not_ check if a DASD needs to be formatted, but rather,
        assumes the list passed needs formatting.

        We don't need to show or update any progress bars, since disk actions
        will be taking place all in the progress hub, which is just one big
        progress bar.
    """
    try:
        rc = util.run_program(["/sbin/dasdfmt", "-y", "-d", "cdl", "-b", "4096", "/dev/" + dasd])
    except Exception as err:
        raise DasdFormatError(err)

    if rc:
        raise DasdFormatError("dasdfmt failed: %s" % rc)
Exemple #7
0
 def test_detect_virt(self):
     in_virt = not util.run_program(["systemd-detect-virt", "--vm"])
     self.assertEqual(util.detect_virt(), in_virt)