Exemplo n.º 1
0
 def _set_os_variant(self, val):
     logging.debug("Setting Guest.os_variant to '%s'", val)
     val = val.lower()
     if osdict.lookup_os(val) is None:
         raise ValueError(_("Distro '%s' does not exist in our dictionary")
                          % val)
     self._os_variant = val
Exemplo n.º 2
0
def export_os_params(vm):
    """
    Export OS-specific parameters.
    """
    from virtinst import osdict

    os = osdict.lookup_os(vm.os_variant)

    def get_os_val(key, default):
        val = None
        if os:
            val = os.to_dict().get(key)
        if val is None:
            val = default
        return val

    acpi = ""
    if vm.noacpi is False and get_os_val("acpi", True):
        acpi = "<acpi />"

    apic = ""
    if vm.noapic is False and get_os_val("apic", False):
        apic = "<apic />"

    return acpi, apic
Exemplo n.º 3
0
def getDistroStore(guest, fetcher):
    stores = []
    logging.debug("Finding distro store for location=%s", fetcher.location)

    arch = guest.os.arch
    _type = guest.os.os_type

    urldistro = None
    if guest.os_variant:
        urldistro = osdict.lookup_os(guest.os_variant).urldistro

    dist = _distroFromTreeinfo(fetcher, arch, _type)
    if dist:
        return dist

    # FIXME: This 'distro ==' doesn't cut it. 'distro' is from our os
    # dictionary, so would look like 'fedora9' or 'rhel5', so this needs
    # to be a bit more intelligent
    stores = _allstores[:]

    # If user manually specified an os_distro, bump it's URL class
    # to the top of the list
    if urldistro:
        for store in stores:
            if store.urldistro == urldistro:
                logging.debug("Prioritizing distro store=%s", store)
                stores.remove(store)
                stores.insert(0, store)
                break

    # Always stick GenericDistro at the end, since it's a catchall
    stores.remove(GenericDistro)
    stores.append(GenericDistro)

    for sclass in stores:
        store = sclass(fetcher, arch, _type)
        # We already tried the treeinfo short circuit, so skip it here
        store.uses_treeinfo = False
        if store.isValidStore():
            logging.debug("Detected distro name=%s osvariant=%s",
                          store.name, store.os_variant)
            return store

    raise ValueError(
        _("Could not find an installable distribution at '%s'\n"
          "The location must be the root directory of an install tree." %
          fetcher.location))
Exemplo n.º 4
0
 def _check_osvariant_valid(self, os_variant):
     return osdict.lookup_os(os_variant) is not None