Loading ccnode/libvirtwrapper.py +23 −0 Original line number Diff line number Diff line Loading @@ -406,6 +406,29 @@ class LibvirtHVStorage(HVStorage): except libvirt.libvirtError as e: raise StorageError("Failed to delete the volume (%s)" % e) def find_space(self, new_space): ''' Tries to find a suitable chunk of space to store new_space. :param new_space: a space size in gigabytes :type new_space: :class:`str` :return: a :class:`tuple` of possible locations or :class:`False` if no space is suitable ''' pool_names = self.hv_handle._con_handle.listStoragePools() for pool_name in pool_names: try: pool = self.hv_handle._con_handle \ .storagePoolLookupByName(pool_name) except libvirt.libvirtError as e: raise StorageError("Failed to fetch pool data (%s)" % e) try: if new_space * GIGABYTE_DIV < pool.info()[3]: return (pool_name) except libvirt.libvirtError as e: raise StorageError("Can't query pool informations (%s)" % e) return False #### Helper functions Loading Loading
ccnode/libvirtwrapper.py +23 −0 Original line number Diff line number Diff line Loading @@ -406,6 +406,29 @@ class LibvirtHVStorage(HVStorage): except libvirt.libvirtError as e: raise StorageError("Failed to delete the volume (%s)" % e) def find_space(self, new_space): ''' Tries to find a suitable chunk of space to store new_space. :param new_space: a space size in gigabytes :type new_space: :class:`str` :return: a :class:`tuple` of possible locations or :class:`False` if no space is suitable ''' pool_names = self.hv_handle._con_handle.listStoragePools() for pool_name in pool_names: try: pool = self.hv_handle._con_handle \ .storagePoolLookupByName(pool_name) except libvirt.libvirtError as e: raise StorageError("Failed to fetch pool data (%s)" % e) try: if new_space * GIGABYTE_DIV < pool.info()[3]: return (pool_name) except libvirt.libvirtError as e: raise StorageError("Can't query pool informations (%s)" % e) return False #### Helper functions Loading