Loading ccnode/interface.py +33 −30 Original line number Diff line number Diff line Loading @@ -172,25 +172,13 @@ class HVStorage(object): :param hypervisor: in instance of :class:`Hypervisor` ''' def get_backend_type(self): ''' Returns the type of backend used for storage ''' pass def get_storage_pools(self): def get_pools(self): ''' Returns a dict of storage pools bound to the host ''' pass def get_space_statistics(self): ''' Returns informations about space available in the storage object ''' pass def get_storage_volumes(self, pool=None): def get_volumes(self, pool=None): ''' Returns volumes stored in pool or all pools ''' Loading Loading @@ -218,7 +206,7 @@ class HVStorage(object): Adds a volume to the specified pool :param pool: the pool in which to create the volume :type pool: :class:`str` :type pool: :class:`virStoragePool` :param name: name of the new volume :type name: :class:`str` :param space: size of the new volume in gigabytes Loading @@ -231,7 +219,7 @@ class HVStorage(object): Deletes a volume in the specified pool :param pool: the pool in which delete the volume :type pool: :class:`str` :type pool: :class:`virStoragePool` :param name: the name of the volume :type name: :class:`str` ''' Loading @@ -247,22 +235,37 @@ class HVStorage(object): pool is suitable ''' def get_pool_info(self, pool): def get_pool_state(self, pool): ''' Returns informations about the pool ''' pass Returns the running state of the pool def get_vol_info(self, vol): :param pool: the storage pool name :type pool: libvirt.`virStoragePool` ''' Returns informations about the volume ''' def get_pool_total_space(self, pool): ''' Returns the storage capacity of this pool in gigabytes :param pool: the pool to get information from :type pool: :class:`virStoragePool` :return: :class:`int` of capacity in gigabytes ''' def get_pool_available_space(self, pool): ''' Returns available space of this storage pool in gigabytes :param pool: the pool to get information from :type pool: :class:`virStoragePool` :return: :class:`int` of available free space in gigabytes ''' def get_pool_used_space(self, pool): ''' Returns current storage pool usage in gigabytes :param pool: the pool to get information from :type pool: :class:`virStoragePool` :return: :class:`int` of used space in gigabytes ''' ccnode/libvirtwrapper.py +51 −24 Original line number Diff line number Diff line Loading @@ -333,35 +333,23 @@ class LibvirtHVStorage(HVStorage): self._pools = dict([(p, pool_obj(self.hv_handle._con_handle, p)) \ for p in pools]) def get_storage_pools(self): return self._pools def get_pool_info(self, pool): pool_info = {} pool_info[POOL_NAME] = pool.name() pool_info[POOL_STATUS] = self.get_pool_state(pool) pool_info[POOL_TOTAL_SIZE] = self.get_pool_size(pool) / GIGABYTE_DIV return pool_info def get_pool_size(self, pool): def get_pools(self): ''' Returns total logical size of the pool :param pool: the storage pool :type pool: :class:`libvirt.virStoragePool` Returns a dict of storage pools bound to the host ''' return pool.info()[1] return self._pools def get_pool_state(self, pool): def get_volumes(self, pool=None): ''' Returns the running state of the pool :param pool: the storage pool name :type pool: libvirt.`virStoragePool` Returns volumes stored in pool or all pools ''' return POOL_STATE[pool.info()[0]] volumes = [] if pool is None: for pool in self._pools.iteritems(): volumes.extend(pool[1].listVolumes()) else: volumes = pool.listVolumes() return volumes def add_volume(self, pool, name, space): ''' Loading Loading @@ -423,6 +411,45 @@ class LibvirtHVStorage(HVStorage): raise StorageError("Can't query pool informations (%s)" % e) return False def get_pool_state(self, pool): ''' Returns the running state of the pool :param pool: the storage pool name :type pool: libvirt.`virStoragePool` ''' return POOL_STATE[pool.info()[0]] def get_pool_total_space(self, pool): ''' Returns the storage capacity of this pool in gigabytes :param pool: the pool to get information from :type pool: :class:`virStoragePool` :return: :class:`int` of capacity in gigabytes ''' return pool.info()[1]; def get_pool_available_space(self, pool): ''' Returns available space of this storage pool in gigabytes :param pool: the pool to get information from :type pool: :class:`virStoragePool` :return: :class:`int` of available free space in gigabytes ''' return pool.info()[2]; def get_pool_used_space(self, pool): ''' Returns current storage pool usage in gigabytes :param pool: the pool to get information from :type pool: :class:`virStoragePool` :return: :class:`int` of used space in gigabytes ''' return pool.info()[3]; #### Helper functions Loading Loading
ccnode/interface.py +33 −30 Original line number Diff line number Diff line Loading @@ -172,25 +172,13 @@ class HVStorage(object): :param hypervisor: in instance of :class:`Hypervisor` ''' def get_backend_type(self): ''' Returns the type of backend used for storage ''' pass def get_storage_pools(self): def get_pools(self): ''' Returns a dict of storage pools bound to the host ''' pass def get_space_statistics(self): ''' Returns informations about space available in the storage object ''' pass def get_storage_volumes(self, pool=None): def get_volumes(self, pool=None): ''' Returns volumes stored in pool or all pools ''' Loading Loading @@ -218,7 +206,7 @@ class HVStorage(object): Adds a volume to the specified pool :param pool: the pool in which to create the volume :type pool: :class:`str` :type pool: :class:`virStoragePool` :param name: name of the new volume :type name: :class:`str` :param space: size of the new volume in gigabytes Loading @@ -231,7 +219,7 @@ class HVStorage(object): Deletes a volume in the specified pool :param pool: the pool in which delete the volume :type pool: :class:`str` :type pool: :class:`virStoragePool` :param name: the name of the volume :type name: :class:`str` ''' Loading @@ -247,22 +235,37 @@ class HVStorage(object): pool is suitable ''' def get_pool_info(self, pool): def get_pool_state(self, pool): ''' Returns informations about the pool ''' pass Returns the running state of the pool def get_vol_info(self, vol): :param pool: the storage pool name :type pool: libvirt.`virStoragePool` ''' Returns informations about the volume ''' def get_pool_total_space(self, pool): ''' Returns the storage capacity of this pool in gigabytes :param pool: the pool to get information from :type pool: :class:`virStoragePool` :return: :class:`int` of capacity in gigabytes ''' def get_pool_available_space(self, pool): ''' Returns available space of this storage pool in gigabytes :param pool: the pool to get information from :type pool: :class:`virStoragePool` :return: :class:`int` of available free space in gigabytes ''' def get_pool_used_space(self, pool): ''' Returns current storage pool usage in gigabytes :param pool: the pool to get information from :type pool: :class:`virStoragePool` :return: :class:`int` of used space in gigabytes '''
ccnode/libvirtwrapper.py +51 −24 Original line number Diff line number Diff line Loading @@ -333,35 +333,23 @@ class LibvirtHVStorage(HVStorage): self._pools = dict([(p, pool_obj(self.hv_handle._con_handle, p)) \ for p in pools]) def get_storage_pools(self): return self._pools def get_pool_info(self, pool): pool_info = {} pool_info[POOL_NAME] = pool.name() pool_info[POOL_STATUS] = self.get_pool_state(pool) pool_info[POOL_TOTAL_SIZE] = self.get_pool_size(pool) / GIGABYTE_DIV return pool_info def get_pool_size(self, pool): def get_pools(self): ''' Returns total logical size of the pool :param pool: the storage pool :type pool: :class:`libvirt.virStoragePool` Returns a dict of storage pools bound to the host ''' return pool.info()[1] return self._pools def get_pool_state(self, pool): def get_volumes(self, pool=None): ''' Returns the running state of the pool :param pool: the storage pool name :type pool: libvirt.`virStoragePool` Returns volumes stored in pool or all pools ''' return POOL_STATE[pool.info()[0]] volumes = [] if pool is None: for pool in self._pools.iteritems(): volumes.extend(pool[1].listVolumes()) else: volumes = pool.listVolumes() return volumes def add_volume(self, pool, name, space): ''' Loading Loading @@ -423,6 +411,45 @@ class LibvirtHVStorage(HVStorage): raise StorageError("Can't query pool informations (%s)" % e) return False def get_pool_state(self, pool): ''' Returns the running state of the pool :param pool: the storage pool name :type pool: libvirt.`virStoragePool` ''' return POOL_STATE[pool.info()[0]] def get_pool_total_space(self, pool): ''' Returns the storage capacity of this pool in gigabytes :param pool: the pool to get information from :type pool: :class:`virStoragePool` :return: :class:`int` of capacity in gigabytes ''' return pool.info()[1]; def get_pool_available_space(self, pool): ''' Returns available space of this storage pool in gigabytes :param pool: the pool to get information from :type pool: :class:`virStoragePool` :return: :class:`int` of available free space in gigabytes ''' return pool.info()[2]; def get_pool_used_space(self, pool): ''' Returns current storage pool usage in gigabytes :param pool: the pool to get information from :type pool: :class:`virStoragePool` :return: :class:`int` of used space in gigabytes ''' return pool.info()[3]; #### Helper functions Loading