Exemplo n.º 1
0
 def default_inputbus(self):
     if self._os:
         fltr = libosinfo.Filter()
         fltr.add_constraint("class", "input")
         devs = self._os.get_all_devices(fltr)
         if devs.get_length():
             return devs.get_nth(0).get_bus_type()
     return "ps2"
Exemplo n.º 2
0
 def _get_inputtype(self):
     if not self._os:
         return _SENTINEL
     fltr = libosinfo.Filter()
     fltr.add_constraint("class", "input")
     devs = self._os.get_all_devices(fltr)
     if devs.get_length():
         return devs.get_nth(0).get_name()
     return _SENTINEL
Exemplo n.º 3
0
    def supports_virtiorng(self):
        if self._os:
            fltr = libosinfo.Filter()
            fltr.add_constraint("class", "rng")
            devs = self._os.get_all_devices(fltr)
            for dev in range(devs.get_length()):
                d = devs.get_nth(dev)
                if d.get_name() == "virtio-rng":
                    return True

        return False
Exemplo n.º 4
0
    def supports_usbtablet(self):
        if not self._os:
            return False

        fltr = libosinfo.Filter()
        fltr.add_constraint("class", "input")
        fltr.add_constraint("name", "tablet")
        devs = self._os.get_all_devices(fltr)
        for idx in range(devs.get_length()):
            if devs.get_nth(idx).get_bus_type() == "usb":
                return True
        return False
Exemplo n.º 5
0
    def _get_netmodel(self):
        if not self._os:
            return _SENTINEL

        if self._os.get_distro() == "fedora":
            return _SENTINEL

        fltr = libosinfo.Filter()
        fltr.add_constraint("class", "net")
        devs = self._os.get_all_devices(fltr)
        if devs.get_length():
            return devs.get_nth(0).get_name()
        return _SENTINEL
Exemplo n.º 6
0
    def lookup_os(self, key, raise_error=False):
        if key == self._os_generic.name:
            return self._os_generic

        flt = Libosinfo.Filter()
        flt.add_constraint(Libosinfo.PRODUCT_PROP_SHORT_ID, key)
        oslist = self._os_db.get_os_list().new_filtered(flt).get_elements()
        if len(oslist) == 0:
            if raise_error:
                raise ValueError(
                    _("Unknown OS name '%s'. "
                      "See `osinfo-query os` for valid values.") % key)
            return None
        return _OsVariant(oslist[0])
Exemplo n.º 7
0
    def run(self, terms, variables, **kwargs):
        ret = []
        for term in terms:
            filter = osinfo.Filter()
            filter.add_constraint(osinfo.PRODUCT_PROP_SHORT_ID, term)
            oses = db.get_os_list().new_filtered(filter)
            if oses.get_length() > 0:
                os = OsInfoGObjectProxy(oses.get_nth(0),
                                        root_path="[" + term + "]")
                ret.append(os)
            else:
                ret.append({"name": term})

        return ret
Exemplo n.º 8
0
    def default_netmodel(self):
        """
        Default non-virtio net-model, since we check for that separately
        """
        if not self._os:
            return None

        fltr = libosinfo.Filter()
        fltr.add_constraint("class", "net")
        devs = self._os.get_all_devices(fltr)
        for idx in range(devs.get_length()):
            devname = devs.get_nth(idx).get_name()
            if devname in ["pcnet", "ne2k_pci", "rtl8139", "e1000"]:
                return devname
        return None
Exemplo n.º 9
0
    def _is_virtionet(self):
        if not self._os:
            return _SENTINEL
        if self._os.get_distro() == "fedora":
            if self._os.get_version() == "unknown":
                return _SENTINEL
            return int(self._os.get_version() >= 9) or _SENTINEL

        fltr = libosinfo.Filter()
        fltr.add_constraint("class", "net")
        devs = self._os.get_all_devices(fltr)
        for dev in range(devs.get_length()):
            d = devs.get_nth(dev)
            if d.get_name() == "virtio-net":
                return True
        return _SENTINEL
Exemplo n.º 10
0
    def run(self, terms, variables, **kwargs):
        ret = []
        for term in terms:
            filter = osinfo.Filter()
            if "=" in term:
                prop, value = term.split("=", 1)
                filter.add_constraint(prop, value)
            else:
                filter.add_constraint(osinfo.PRODUCT_PROP_SHORT_ID, term)
            oses = db.get_os_list().new_filtered(filter)
            if oses.get_length() > 0:
                for idx in range(oses.get_length()):
                    os = OsInfoGObjectProxy(oses.get_nth(idx),
                                            root_path="[" + term + "]")
                    ret.append(os)
            else:
                print("OS {} not found".format(term))
                ret.append({"name": term})

        return ret
Exemplo n.º 11
0
    def get_location(self, arch):
        if not self._os:
            return None

        treefilter = libosinfo.Filter()
        treefilter.add_constraint(libosinfo.TREE_PROP_ARCHITECTURE, arch)

        treelist = self._os.get_tree_list()
        if treelist.get_length() < 1:
            raise RuntimeError(
                _("%s does not have a URL location") % self.name)

        filtered_treelist = treelist.new_filtered(treefilter)
        if filtered_treelist.get_length() < 1:
            raise RuntimeError(
                _("%s does not have a URL location for the %s architecture") %
                (self.name, arch))

        # Some distros have more than one URL for a specific architecture,
        # which is the case for Fedora and different variants (Server,
        # Workstation). Later on, we'll have to differentiate that and return
        # the right one.
        return filtered_treelist.get_nth(0).get_url()
Exemplo n.º 12
0
hvnames = db.unique_values_for_property_in_platform("short-id")
hvnames.sort()

print "All HV short IDs"
for name in hvnames:
    print ("  HV short id " + name)

osid = "http://fedoraproject.org/fedora-11"
hvid = "http://qemu.org/qemu-kvm-0.11.0"
drvclass = "net"
#drvclass = "audio"

os = db.get_os(osid)
hv = db.get_platform(hvid)

dep = db.find_deployment(os, hv)

fltr = osinfo.Filter()
fltr.add_constraint("class", drvclass)
link = dep.get_preferred_device_link(osinfo.DeviceLinkFilter(target_filter = fltr))
dev = link.get_target()
animals = os.get_param_value_list("x-animal")
zoo = str.join(",", animals)
print ("For OS '" + os.get_name() + "' " +
       "fruit '" + os.get_param_value("x-fruit") + "' " +
       "zoo '" + zoo + "' " +
       "with HV '" + hv.get_name() + "' " +
       "for class '" + drvclass + "' " +
       "use device '" + dev.get_name() + "' " +
       "with HV driver '" + link.get_driver() + "'")