Commit c73ef58c authored by Antoine Millet's avatar Antoine Millet
Browse files

Added a special storage for standalone volumes

parent e501f741
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -149,6 +149,8 @@ class Handler(HostHandler):

        # unregister tags that will be re registered later
        for storage in self.hypervisor.storage.storages:
            if storage.name.startswith('_'):
                continue  # Ignore internal storages
            self.tag_db.remove_tags((
                'sto%s_state' % storage,
                'sto%s_size' % storage,
+5 −0
Original line number Diff line number Diff line
@@ -286,6 +286,9 @@ class VirtualMachine(object):
                pool = d.find('source').get('pool')
                vol = d.find('source').get('volume')
                volume = self.hypervisor.storage.get_volume_by_pool(pool, vol)
            elif type_ == 'network':
                vol = d.find('source').get('name')
                volume = self.hypervisor.storage.get_volume_by_pool('_standalone', vol)
            else:
                continue

@@ -600,6 +603,8 @@ class VirtualMachine(object):

        # Refresh shared pools on the destination to avoid unknown volumes:
        for pool_name in shared_pools:
            if pool_name.startswith('_'):
                continue  # Ignore internal storages
            pool = dconn.storagePoolLookupByName(pool_name)
            pool.refresh()

+30 −0
Original line number Diff line number Diff line
@@ -346,6 +346,10 @@ class StorageIndex(object):
                    Tag('sto%s_shared' % s.name, partial(lambda x: {True: 'yes', False: 'no'}[s.is_shared], s)),
                ))

        # Add a special storage for standalone drives:
        if '_standalone' not in self.storages:
            self.storages['_standalone'] = DummyStorage('_standalone')

        self.update_path_index()

    def update_path_index(self):
@@ -510,6 +514,32 @@ class SharedStorage(Storage):
        pass  # Do nothing.


class DummyStorage(Storage):
    """Dummy storage abstraction."""

    def __init__(self, name, shared=True):
        """
        :param lv_storage: Libvirt pool storage instance
        """
        self.uuid = None
        self.name = name
        self.shared = shared

        self.state, self.capacity = None, None
        self.allocation, self.available = None, None

        self.type = 'dummy'

        self.volumes = DummyStorageVolumeDispenser(self)

    @property
    def is_shared(self):
        return self.shared

    def update(self, retry=1):
        pass  # Do nothing


class Volume(object):
    """Volume abstraction."""
    def __init__(self, storage, lv_volume):