Exemple #1
0
        raise NotImplementedError('Override in MetaDBOperations specific class')

    def load(self, dbg, uri):
        raise NotImplementedError('Override in MetaDBOperations specific class')

    def dump(self, dbg, uri, db):
        raise NotImplementedError('Override in MetaDBOperations specific class')

    def lock(self, dbg, uri):
        raise NotImplementedError('Override in MetaDBOperations specific class')

    def unlock(self, dbg, uri):
        raise NotImplementedError('Override in MetaDBOperations specific class')


plugin_specific_meta = module_exists("xapi.storage.libs.xcpng.lib%s.meta" % xapi.storage.libs.xcpng.globalvars.plugin_type)
if plugin_specific_meta:
    _MetaDBOperations_ = getattr(plugin_specific_meta, 'MetaDBOperations')
else:
    _MetaDBOperations_ = MetaDBOperations


class MetadataHandler(object):

    def __new__(cls, *args, **kwargs):
        if not hasattr(cls,'_inst'):
            cls._inst = super(MetadataHandler, cls).__new__(cls, *args, **kwargs)
        else:
            def init_pass(self, *dt, **mp): pass
            cls.__init__ = init_pass
                            REF_COUNT_TAG] = volume_meta[REF_COUNT_TAG] - 1
                    self.MetadataHandler.update_vdi_meta(dbg, uri, new_meta)

                if chained:
                    if PARENT_URI_TAG in volume_meta:
                        self.unmap_vol(dbg, volume_meta[PARENT_URI_TAG][0],
                                       chained)
            except Exception as e:
                log.error(
                    "%s: xcpng.datapath.DatapathOperations.unmap_vol: Failed to unmap volume: uri: %s"
                    % (dbg, uri))
                raise Exception(e)


plugin_specific_datapath = module_exists(
    "xapi.storage.libs.xcpng.lib%s.datapath" %
    xapi.storage.libs.xcpng.globalvars.plugin_type)
if plugin_specific_datapath:
    _DatapathOperations_ = getattr(plugin_specific_datapath,
                                   'DatapathOperations')
else:
    _DatapathOperations_ = DatapathOperations


class Datapath(object):
    def __init__(self):
        self.MetadataHandler = MetadataHandler()
        self.DatapathOpsHandler = _DatapathOperations_()

    def _relink(self, dbg, uri, child, parent, domain):
        raise NotImplementedError('Override in Datapath specifc class')
Exemple #3
0
        image2_uuid = volume2_meta[IMAGE_UUID_TAG]
        volume1_meta = {IMAGE_UUID_TAG: image2_uuid}
        volume2_meta = {IMAGE_UUID_TAG: image1_uuid}
        log.debug("%s: xcpng.volume.VolumeOperations.swap: after image_uuid1: %s image_uudi2: %s" %
                  (dbg, volume1_meta[IMAGE_UUID_TAG], volume2_meta[IMAGE_UUID_TAG]))
        self.MetadataHandler.update_vdi_meta(dbg, uri1, volume1_meta)
        self.MetadataHandler.update_vdi_meta(dbg, uri2, volume2_meta)

    def get_phisical_utilization(self, dbg, uri):
        raise NotImplementedError('Override in VolumeOperations specifc class')

    def roundup_size(self, dbg, size):
        raise NotImplementedError('Override in VolumeOperations specifc class')


plugin_specific_volume = module_exists("xapi.storage.libs.xcpng.lib%s.volume" % xapi.storage.libs.xcpng.globalvars.plugin_type)
if plugin_specific_volume:
    _VolumeOperations_ = getattr(plugin_specific_volume, 'VolumeOperations')
else:
    _VolumeOperations_ = VolumeOperations


class Volume(object):

    def __init__(self):
        self.MetadataHandler = MetadataHandler()
        self.VolOpsHendler = _VolumeOperations_()
        self.Datapathes = DATAPATHES

        for k, v in DATAPATHES.iteritems():
            self.Datapathes[k] = v()
class LocksOpsMgr(object):
    def __init__(self):
        self.__lhs = {}

    def lock(self, dbg, uri, timeout=10):
        raise NotImplementedError(
            'Override in MetaDBOperations specific class')

    def unlock(self, dbg, uri):
        raise NotImplementedError(
            'Override in MetaDBOperations specific class')


plugin_specific_metadb_ops = module_exists(
    "xapi.storage.libs.xcpng.lib%s.meta" %
    xapi.storage.libs.xcpng.globalvars.plugin_type)
if plugin_specific_metadb_ops:
    _MetaDBOperations_ = getattr(plugin_specific_metadb_ops,
                                 'MetaDBOperations')
else:
    _MetaDBOperations_ = MetaDBOperations

#plugin_specific_metadb_cs = module_exists("xapi.storage.libs.xcpng.cluster_stack.%s.tinydb_storage"
#                                          % xapi.storage.libs.xcpng.globalvars.cluster_stack)
plugin_specific_metadb_cs = module_exists(
    "xapi.storage.libs.xcpng.cluster_stack.%s.tinydb_storage" % "consul")

if plugin_specific_metadb_cs:
    _Storage_ = getattr(plugin_specific_metadb_cs, 'Storage')
    _StorageProxy_ = getattr(plugin_specific_metadb_cs, 'StorageProxy')