diff --git a/cloudcontrol/node/hypervisor/domains/__init__.py b/cloudcontrol/node/hypervisor/domains/__init__.py index 345e6c015fa4d6b736cf9273af98e0e207977939..fdbcb3fc1b1144b6f0f247f66b91b891205cbaca 100644 --- a/cloudcontrol/node/hypervisor/domains/__init__.py +++ b/cloudcontrol/node/hypervisor/domains/__init__.py @@ -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 diff --git a/cloudcontrol/node/hypervisor/lib.py b/cloudcontrol/node/hypervisor/lib.py index fdbffa628888ee034d6ab533873d7bd33bcc44ff..55f52a8e2c61b8ce1ce3eadc801b171e1f78e22b 100644 --- a/cloudcontrol/node/hypervisor/lib.py +++ b/cloudcontrol/node/hypervisor/lib.py @@ -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)