Commit 2796f3e3 authored by Antoine Millet's avatar Antoine Millet
Browse files

Implement volumes disks

parent d76cda50
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -235,10 +235,19 @@ class VirtualMachine(object):

            type_ = d.get('type')

            if type_ not in ('file', 'block'):
            if type_ in ('file', 'block'):
                path = d.find('source').get(dict(file='file', block='dev')[type_])
                volume = self.hypervisor.storage.get_volume(path)
                if volume is None:
                    continue
            elif type_ == 'volume':
                pool = d.find('source').get('pool')
                vol = d.find('source').get('volume')
                volume = self.hypervisor.storage.get_volume_by_pool(pool, vol)
            else:
                continue

            path = d.find('source').get(dict(file='file', block='dev')[type_])
            path = volume.path

            # update cache behaviour
            driver = d.find('driver')
@@ -246,10 +255,6 @@ class VirtualMachine(object):
                driver = {}
            self.cache_behaviour[path] = driver.get('cache', 'default')

            volume = self.hypervisor.storage.get_volume(path)
            if volume is None:
                continue

            yield volume

    @property
+4 −0
Original line number Diff line number Diff line
@@ -355,6 +355,10 @@ class StorageIndex(object):
    def get_volume(self, path):
        return self.paths.get(path)

    def get_volume_by_pool(self, pool, vol):
        storage = self.get_storage(pool)
        return storage.volumes.get(vol)

    def get_storage(self, name):
        return self.storages.get(name)