Loading ccnode/interface.py +22 −0 Original line number Diff line number Diff line Loading @@ -289,3 +289,25 @@ class HVStorage(object): :type volume_name: :class:`str` :return: :class:`str` path to the volume file ''' def get_volume_allocation(self, pool, vol_name): ''' Returns the pool space used by this volume in bytes :param pool: the pool containing this volume from :type pool: :class:`virStoragePool` :param vol_name: name of the volume to query :type vol_name: :class:`str` :return: :class:`int` of allocation in bytes ''' def get_volume_capacity(self, pool, vol_name): ''' Returns the capacity (usable space) of this volume in bytes :param pool: the pool containing this volume from :type pool: :class:`virStoragePool` :param vol_name: name of the volume to query :type vol_name: :class:`str` :return: :class:`int` of capacity in bytes ''' ccnode/libvirtwrapper.py +37 −0 Original line number Diff line number Diff line Loading @@ -504,6 +504,43 @@ class LibvirtHVStorage(HVStorage): except libvirt.libvirtError as e: raise StorageError("Volume has no path information (%s)" % e) def get_volume_allocation(self, pool, vol_name): ''' Returns the pool space used by this volume in bytes :param pool: the pool containing this volume from :type pool: :class:`virStoragePool` :param vol_name: name of the volume to query :type vol_name: :class:`str` :return: :class:`int` of allocation in bytes ''' try: vol = pool.storageVolLookupByName(vol_name) except libvirt.libvirtError as e: raise StorageError("Volume not found (%s)" % e) try: return vol.info()[2] except libvirt.libvirtError as e: raise StorageError("Volume has no allocation information (%s)" % e) def get_volume_capacity(self, pool, vol_name): ''' Returns the capacity (usable space) of this volume in bytes :param pool: the pool containing this volume from :type pool: :class:`virStoragePool` :param vol_name: name of the volume to query :type vol_name: :class:`str` :return: :class:`int` of capacity in bytes ''' try: vol = pool.storageVolLookupByName(vol_name) except libvirt.libvirtError as e: raise StorageError("Volume not found (%s)" % e) try: return vol.info()[1] except libvirt.libvirtError as e: raise StorageError("Volume has no capacity information (%s)" % e) #### Helper functions Loading Loading
ccnode/interface.py +22 −0 Original line number Diff line number Diff line Loading @@ -289,3 +289,25 @@ class HVStorage(object): :type volume_name: :class:`str` :return: :class:`str` path to the volume file ''' def get_volume_allocation(self, pool, vol_name): ''' Returns the pool space used by this volume in bytes :param pool: the pool containing this volume from :type pool: :class:`virStoragePool` :param vol_name: name of the volume to query :type vol_name: :class:`str` :return: :class:`int` of allocation in bytes ''' def get_volume_capacity(self, pool, vol_name): ''' Returns the capacity (usable space) of this volume in bytes :param pool: the pool containing this volume from :type pool: :class:`virStoragePool` :param vol_name: name of the volume to query :type vol_name: :class:`str` :return: :class:`int` of capacity in bytes '''
ccnode/libvirtwrapper.py +37 −0 Original line number Diff line number Diff line Loading @@ -504,6 +504,43 @@ class LibvirtHVStorage(HVStorage): except libvirt.libvirtError as e: raise StorageError("Volume has no path information (%s)" % e) def get_volume_allocation(self, pool, vol_name): ''' Returns the pool space used by this volume in bytes :param pool: the pool containing this volume from :type pool: :class:`virStoragePool` :param vol_name: name of the volume to query :type vol_name: :class:`str` :return: :class:`int` of allocation in bytes ''' try: vol = pool.storageVolLookupByName(vol_name) except libvirt.libvirtError as e: raise StorageError("Volume not found (%s)" % e) try: return vol.info()[2] except libvirt.libvirtError as e: raise StorageError("Volume has no allocation information (%s)" % e) def get_volume_capacity(self, pool, vol_name): ''' Returns the capacity (usable space) of this volume in bytes :param pool: the pool containing this volume from :type pool: :class:`virStoragePool` :param vol_name: name of the volume to query :type vol_name: :class:`str` :return: :class:`int` of capacity in bytes ''' try: vol = pool.storageVolLookupByName(vol_name) except libvirt.libvirtError as e: raise StorageError("Volume not found (%s)" % e) try: return vol.info()[1] except libvirt.libvirtError as e: raise StorageError("Volume has no capacity information (%s)" % e) #### Helper functions Loading