Loading ccnode/interface.py +4 −4 Original line number Diff line number Diff line Loading @@ -180,7 +180,7 @@ class HVStorage(object): def get_storage_pools(self): ''' Returns a list of storage pools bound to the host Returns a dict of storage pools bound to the host ''' pass Loading Loading @@ -239,12 +239,12 @@ class HVStorage(object): def find_space(self, new_space): ''' Tries to find a suitable chunk of space to store new_space. Tries to find a suitable chunk of space for volume allocation. :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 :return: a :class:`tuple` of best location or :class:`False` if no pool is suitable ''' def get_pool_info(self, pool): Loading ccnode/libvirtwrapper.py +9 −15 Original line number Diff line number Diff line Loading @@ -330,11 +330,11 @@ class LibvirtHVStorage(HVStorage): pools = [] pools.extend(self.hv_handle._con_handle.listDefinedStoragePools()) pools.extend(self.hv_handle._con_handle.listStoragePools()) self._pools = [] self._pools.extend(pool_obj(self.hv_handle._con_handle, pool) for pool in pools) self._pools = dict([(p, pool_obj(self.hv_handle._con_handle, p)) \ for p in pools]) def get_storage_pools(self): return [pool.name() for pool in self._pools] return self._pools def get_pool_info(self, pool): pool_info = {} Loading Loading @@ -408,23 +408,17 @@ class LibvirtHVStorage(HVStorage): def find_space(self, new_space): ''' Tries to find a suitable chunk of space to store new_space. Tries to find a suitable chunk of space for volume allocation. :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 :return: a :class:`tuple` of best location or :class:`False` if no pool is suitable ''' pool_names = self.hv_handle._con_handle.listStoragePools() for pool_name in pool_names: for pool in self._pools.iteritems(): 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) if new_space * GIGABYTE_DIV < pool[1].info()[3]: return (pool) except libvirt.libvirtError as e: raise StorageError("Can't query pool informations (%s)" % e) return False Loading Loading
ccnode/interface.py +4 −4 Original line number Diff line number Diff line Loading @@ -180,7 +180,7 @@ class HVStorage(object): def get_storage_pools(self): ''' Returns a list of storage pools bound to the host Returns a dict of storage pools bound to the host ''' pass Loading Loading @@ -239,12 +239,12 @@ class HVStorage(object): def find_space(self, new_space): ''' Tries to find a suitable chunk of space to store new_space. Tries to find a suitable chunk of space for volume allocation. :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 :return: a :class:`tuple` of best location or :class:`False` if no pool is suitable ''' def get_pool_info(self, pool): Loading
ccnode/libvirtwrapper.py +9 −15 Original line number Diff line number Diff line Loading @@ -330,11 +330,11 @@ class LibvirtHVStorage(HVStorage): pools = [] pools.extend(self.hv_handle._con_handle.listDefinedStoragePools()) pools.extend(self.hv_handle._con_handle.listStoragePools()) self._pools = [] self._pools.extend(pool_obj(self.hv_handle._con_handle, pool) for pool in pools) self._pools = dict([(p, pool_obj(self.hv_handle._con_handle, p)) \ for p in pools]) def get_storage_pools(self): return [pool.name() for pool in self._pools] return self._pools def get_pool_info(self, pool): pool_info = {} Loading Loading @@ -408,23 +408,17 @@ class LibvirtHVStorage(HVStorage): def find_space(self, new_space): ''' Tries to find a suitable chunk of space to store new_space. Tries to find a suitable chunk of space for volume allocation. :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 :return: a :class:`tuple` of best location or :class:`False` if no pool is suitable ''' pool_names = self.hv_handle._con_handle.listStoragePools() for pool_name in pool_names: for pool in self._pools.iteritems(): 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) if new_space * GIGABYTE_DIV < pool[1].info()[3]: return (pool) except libvirt.libvirtError as e: raise StorageError("Can't query pool informations (%s)" % e) return False Loading