return OSError(msg, errno=ret)
-def cstr(val, name, encoding="utf-8", opt=False):
+def cstr(val, name, encoding="utf-8", opt=False) -> Optional[bytes]:
"""
Create a byte string from a Python string
:param str name: Name of the string parameter, for exceptions
:param str encoding: Encoding to use
:param bool opt: If True, None is allowed
- :rtype: bytes
:raises: :class:`InvalidArgument`
"""
if opt and val is None:
return [cstr(s, name) for s in list_str]
-def decode_cstr(val, encoding="utf-8"):
+def decode_cstr(val, encoding="utf-8") -> Optional[str]:
"""
Decode a byte string into a Python string.
:param bytes val: byte string
- :rtype: str or None
"""
if val is None:
return None
:param option: which option to read
- :returns: str - value of the option or None
+ :returns: value of the option or None
:raises: :class:`TypeError`
"""
self.require_state("configuring", "connected")
This tells you total space, space used, space available, and number
of objects. These are not updated immediately when data is written,
they are eventually consistent.
-
- :returns: dict - contains the following keys:
+ :returns: contains the following keys:
- ``kb`` (int) - total space
:param pool_name: name of the pool to check
:raises: :class:`TypeError`, :class:`Error`
- :returns: bool - whether the pool exists, false otherwise.
+ :returns: whether the pool exists, false otherwise.
"""
self.require_state("connected")
:param pool_name: name of the pool to look up
:raises: :class:`TypeError`, :class:`Error`
- :returns: int - pool ID, or None if it doesn't exist
+ :returns: pool ID, or None if it doesn't exist
"""
self.require_state("connected")
pool_name_raw = cstr(pool_name, 'pool_name')
else:
raise make_ex(ret, "error looking up pool '%s'" % pool_name)
- def pool_reverse_lookup(self, pool_id: int):
+ def pool_reverse_lookup(self, pool_id: int) -> Optional[str]:
"""
Returns a pool's name based on its ID.
:param pool_id: ID of the pool to look up
:raises: :class:`TypeError`, :class:`Error`
- :returns: string - pool name, or None if it doesn't exist
+ :returns: pool name, or None if it doesn't exist
"""
self.require_state("connected")
cdef:
List inconsistent placement groups in the given pool
:param pool_id: ID of the pool in which PGs are listed
- :returns: list - inconsistent placement groups
+ :returns: inconsistent placement groups
"""
self.require_state("connected")
cdef:
"""
Gets a list of pool names.
- :returns: list - of pool names.
+ :returns: list of pool names.
"""
self.require_state("connected")
cdef:
Get the fsid of the cluster as a hexadecimal string.
:raises: :class:`Error`
- :returns: str - cluster fsid
+ :returns: cluster fsid
"""
self.require_state("connected")
cdef:
:param ioctx_name: name of the pool
:raises: :class:`TypeError`, :class:`Error`
- :returns: Ioctx - Rados Ioctx object
+ :returns: Rados Ioctx object
"""
self.require_state("connected")
ioctx_name_raw = cstr(ioctx_name, 'ioctx_name')
:param pool_id: ID of the pool
:raises: :class:`TypeError`, :class:`Error`
- :returns: Ioctx - Rados Ioctx object
+ :returns: Rados Ioctx object
"""
self.require_state("connected")
cdef:
num_snaps = num_snaps * 2
self.cur_snap = 0
- def __iter__(self):
+ def __iter__(self) -> 'SnapIterator':
return self
- def __next__(self):
+ def __next__(self) -> 'Snap':
"""
Get the next Snapshot
:raises: :class:`Error`, StopIteration
- :returns: Snap - next snapshot
+ :returns: next snapshot
"""
if self.cur_snap >= self.max_snap:
raise StopIteration
Find when a snapshot in the current pool occurred
:raises: :class:`Error`
- :returns: datetime - the data and time the snapshot was created
+ :returns: the data and time the snapshot was created
"""
cdef time_t snap_time
The return value is set when the operation is complete or safe,
whichever comes first.
- :returns: int - return value of the operation
+ :returns: return value of the operation
"""
with nogil:
ret = rados_aio_get_return_value(self.rados_comp)
:raises: :class:`TypeError`
:raises: :class:`Error`
- :returns: str - data read from object
+ :returns: data read from object
"""
self.require_ioctx_open()
key_raw = cstr(key, 'key')
"""
Get pool usage statistics
- :returns: dict - contains the following keys:
+ :returns: dict contains the following keys:
- ``num_bytes`` (int) - size of pool in bytes
:raises: :class:`TypeError`
:raises: :class:`Error`
- :returns: bool - True on success
+ :returns: True on success
"""
self.require_ioctx_open()
key_raw = cstr(key, 'key')
raise make_ex(ret, "Failed to remove '%s'" % key)
return True
- def trunc(self, key: str, size: int):
+ def trunc(self, key: str, size: int) -> int:
"""
Resize an object
:raises: :class:`TypeError`
:raises: :class:`Error`
- :returns: int - 0 on success, otherwise raises error
+ :returns: 0 on success, otherwise raises error
"""
self.require_ioctx_open()
:raises: :class:`TypeError`
:raises: :class:`Error`
- :returns: str - value of the xattr
+ :returns: value of the xattr
"""
self.require_ioctx_open()
:raises: :class:`TypeError`
:raises: :class:`Error`
- :returns: bool - True on success, otherwise raise an error
+ :returns: True on success, otherwise raise an error
"""
self.require_ioctx_open()
:raises: :class:`TypeError`
:raises: :class:`Error`
- :returns: bool - True on success, otherwise raise an error
+ :returns: True on success, otherwise raise an error
"""
self.require_ioctx_open()
:raises: :class:`TypeError`
:raises: :class:`Error`
- :returns: bool - True on success, otherwise raise an error
+ :returns: True on success, otherwise raise an error
"""
self.require_ioctx_open()
"""
Get pool name
- :returns: str - pool name
+ :returns: pool name
"""
cdef:
int name_len = 10