Esempio n. 1
0
    def get_common_version(self):
        def _vers_tuple(ver):
            return tuple([int(x) for x in ver.split(".")])

        reg = base.VersionedObjectRegistry.obj_classes()

        if self.vif_object_name not in reg:
            raise exception.NoMatchingVIFClass(vif_name=self.vif_object_name)

        gotvers = []
        for regobj in reg[self.vif_object_name]:
            gotvers.append(regobj.VERSION)
            got = _vers_tuple(regobj.VERSION)
            minwant = _vers_tuple(self.min_version)
            maxwant = _vers_tuple(self.max_version)

            if minwant <= got <= maxwant:
                return regobj.VERSION

        raise exception.NoSupportedVIFVersion(vif_name=self.vif_object_name,
                                              got_versions=",".join(gotvers),
                                              min_version=self.min_version,
                                              max_version=self.max_version)
Esempio n. 2
0
    def get_vif(self, name):
        for vif in self.vif_info:
            if vif.vif_object_name == name:
                return vif

        raise exception.NoMatchingVIFClass(vif_name=name)