How to use the blivet.arch 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 QubesOS / qubes-installer-qubes-os / anaconda / pyanaconda / network.py View on Github external
values.append(['connection', 'id', devname, 's'])
        values.append(['connection', 'interface-name', devname, 's'])

        dev_spec = None
    # type "802-3-ethernet"
    else:
        mac = _bound_hwaddr_of_device(devname)
        if mac:
            mac = [int(b, 16) for b in mac.split(":")]
            values.append(['802-3-ethernet', 'mac-address', mac, 'ay'])

        values.append(['connection', 'type', '802-3-ethernet', 's'])
        values.append(['connection', 'id', devname, 's'])
        values.append(['connection', 'interface-name', devname, 's'])

        if blivet.arch.is_s390():
            # Add s390 settings
            s390cfg = _get_s390_settings(devname)
            if s390cfg['SUBCHANNELS']:
                subchannels = s390cfg['SUBCHANNELS'].split(",")
                values.append(['802-3-ethernet', 's390-subchannels', subchannels, 'as'])
            if s390cfg['NETTYPE']:
                values.append(['802-3-ethernet', 's390-nettype', s390cfg['NETTYPE'], 's'])
            if s390cfg['OPTIONS']:
                opts = s390cfg['OPTIONS'].split(" ")
                opts_dict = {k:v for k,v in (o.split("=") for o in opts)}
                values.append(['802-3-ethernet', 's390-options', opts_dict, 'a{ss}'])

        dev_spec = devname

    try:
        nm.nm_add_connection(values)
github storaged-project / blivet / blivet / nvdimm.py View on Github external
from . import arch
from . import util

import logging
log = logging.getLogger("blivet")
program_log = logging.getLogger("program")


log_bd_message = lambda level, msg: program_log.info(msg)


_HAVE_NVDIMM = False

# do not try to load nvdimm plugin on other architectures than x86_64
# nvdimm (both hardware and plugin) is not availble on other architectures
if arch.isX86(bits=64):
    _REQUESTED_PLUGINS = BlockDev.plugin_specs_from_names(("nvdimm",))
    try:
        # do not check for dependencies during libblockdev initializtion, do runtime
        # checks instead
        BlockDev.switch_init_checks(False)
        succ_, avail_plugs = BlockDev.try_reinit(require_plugins=_REQUESTED_PLUGINS,
                                                 reload=False,
                                                 log_func=log_bd_message)
    except GLib.GError as err:
        log.error("Failed to intialize the libblockdev library: %s", err)
    else:
        _HAVE_NVDIMM = "nvdimm" in avail_plugs


class NVDIMMDependencyGuard(util.DependencyGuard):
    error_msg = "libblockdev NVDIMM functionality not available"
github storaged-project / blivet / blivet / devicetree.py View on Github external
def make_unformatted_dasd_list(self, dasds):
        """ Create a list of DASDs which are detected to require dasdfmt.

            :param list dasds: a list of DASD devices
            :returns: a list of DASDs which need dasdfmt in order to be used
            :rtype: list of :class:
        """
        if not arch.isS390():
            return

        unformatted = []

        for dasd in dasds:
            if blockdev.s390.dasd_needs_format(dasd.busid):
                unformatted.append(dasd)

        return unformatted
github rhinstaller / anaconda / pyanaconda / payload / image.py View on Github external
from pyanaconda import isys
from pyanaconda.errors import errorHandler, ERROR_RAISE, InvalidImageSizeError, MissingImageError
from pyanaconda.modules.common.constants.objects import DEVICE_TREE
from pyanaconda.modules.common.constants.services import STORAGE
from pyanaconda.modules.common.errors.storage import MountFilesystemError
from pyanaconda.modules.common.structures.storage import DeviceData, DeviceFormatData
from pyanaconda.payload import utils as payload_utils
from pyanaconda.payload.install_tree_metadata import InstallTreeMetadata

from productmd.discinfo import DiscInfo

from pyanaconda.anaconda_loggers import get_module_logger
log = get_module_logger(__name__)

_arch = blivet.arch.get_arch()


def find_first_iso_image(path, mount_path="/mnt/install/cdimage"):
    """Find the first iso image in path.

    :param str path: path to the directory with iso image(s); this also supports pointing to
        a specific .iso image
    :param str mount_path: path for mounting the ISO when checking it is valid

    FIXME once payloads are modularized:
      - this should move somewhere else
      - mount_path should lose the legacy default

    :return: basename of the image - file name without path
    :rtype: str or None
    """
github storaged-project / blivet / blivet / platform.py View on Github external
def get_platform():
    """Check the architecture of the system and return an instance of a
       Platform subclass to match.  If the architecture could not be determined,
       raise an exception."""
    if arch.is_ppc():
        ppc_machine = arch.get_ppc_machine()

        if (ppc_machine == "PMac" and arch.get_ppc_mac_gen() == "NewWorld"):
            return NewWorldPPC()
        elif ppc_machine in ["iSeries", "pSeries"]:
            return IPSeriesPPC()
        elif ppc_machine == "PS3":
            return PS3()
        else:
            raise SystemError("Unsupported PPC machine type: %s" % ppc_machine)
    elif arch.is_s390():
        return S390()
    elif arch.is_efi():
        if arch.is_mactel():
            return MacEFI()
        elif arch.is_aarch64():
            return Aarch64EFI()
github rhinstaller / anaconda / pyanaconda / bootloader / execution.py View on Github external
def _is_usable_disk(self, d):
        """Is the disk usable for the bootloader?

        Throw out drives that don't exist or cannot be used
        (iSCSI device on an s390 machine).
        """
        return \
            not d.format.hidden and \
            not d.protected and \
            not (blivet.arch.is_s390() and isinstance(d, iScsiDiskDevice))
github rhinstaller / anaconda / pyanaconda / packaging / yumpayload.py View on Github external
def _replaceVars(self, url):
        """ Replace url variables with their values

            :param url: url string to do replacement on
            :type url:  string
            :returns:   string with variables substituted
            :rtype:     string or None

            Currently supports $releasever and $basearch
        """
        if not url:
            return url

        with _yum_lock:
            url = url.replace("$releasever", self._yum.conf.yumvar['releasever'])
        url = url.replace("$basearch", blivet.arch.getArch())

        return url
github storaged-project / blivet / blivet / formats / biosboot.py View on Github external
def supported(self):
        return super(BIOSBoot, self).supported and arch.is_x86() and not arch.is_efi()
github storaged-project / blivet / blivet / platform.py View on Github external
elif ppc_machine in ["iSeries", "pSeries"]:
            return IPSeriesPPC()
        elif ppc_machine == "PS3":
            return PS3()
        else:
            raise SystemError("Unsupported PPC machine type: %s" % ppc_machine)
    elif arch.is_s390():
        return S390()
    elif arch.is_efi():
        if arch.is_mactel():
            return MacEFI()
        elif arch.is_aarch64():
            return Aarch64EFI()
        else:
            return EFI()
    elif arch.is_x86():
        return X86()
    elif arch.is_arm():
        arm_machine = arch.get_arm_machine()
        if arm_machine == "omap":
            return omapARM()
        else:
            return ARM()
    else:
        raise SystemError("Could not determine system architecture.")
github QubesOS / qubes-installer-qubes-os / anaconda / pyanaconda / packaging / __init__.py View on Github external
def kernelPackages(self):
        if "kernel" in self.data.packages.excludedList:
            return []

        kernels = ["kernel"]

        if blivet.arch.is_x86(32) and isys.isPaeAvailable():
            kernels.insert(0, "kernel-PAE")

        # most ARM systems use platform-specific kernels
        if blivet.arch.is_arm():
            if platform.arm_machine is not None:
                kernels = ["kernel-%s" % platform.arm_machine]

            if isys.isLpaeAvailable():
                kernels.insert(0, "kernel-lpae")

        return kernels