pyocf: API for getting cleaning policy from cache

Signed-off-by: Jan Musial <jan.musial@intel.com>
This commit is contained in:
Jan Musial 2022-06-21 15:33:04 +02:00
parent 2f289bd873
commit fb83a182ee

View File

@ -17,6 +17,7 @@ from ctypes import (
byref, byref,
cast, cast,
create_string_buffer, create_string_buffer,
POINTER,
) )
from enum import IntEnum, auto from enum import IntEnum, auto
from datetime import timedelta from datetime import timedelta
@ -346,6 +347,22 @@ class Cache:
if c.results["error"]: if c.results["error"]:
raise OcfError("Error changing cleaning policy", c.results["error"]) raise OcfError("Error changing cleaning policy", c.results["error"])
def get_cleaning_policy(self):
cleaning_policy = c_int()
self.read_lock()
status = self.owner.lib.ocf_mngt_cache_cleaning_get_policy(
self.cache_handle, byref(cleaning_policy)
)
self.read_unlock()
if status != OcfErrorCode.OCF_OK:
raise OcfError("Failed to get cleaning policy", ret)
return CleaningPolicy(cleaning_policy.value)
def set_cleaning_policy_param(self, cleaning_policy: CleaningPolicy, param_id, param_value): def set_cleaning_policy_param(self, cleaning_policy: CleaningPolicy, param_id, param_value):
self.write_lock() self.write_lock()
@ -998,6 +1015,8 @@ lib.ocf_cache_get_front_volume.argtypes = [c_void_p]
lib.ocf_cache_get_front_volume.restype = c_void_p lib.ocf_cache_get_front_volume.restype = c_void_p
lib.ocf_cache_get_volume.argtypes = [c_void_p] lib.ocf_cache_get_volume.argtypes = [c_void_p]
lib.ocf_cache_get_volume.restype = c_void_p lib.ocf_cache_get_volume.restype = c_void_p
lib.ocf_mngt_cache_cleaning_get_policy.argypes = [c_void_p, POINTER(c_int)]
lib.ocf_mngt_cache_cleaning_get_policy.restype = OcfErrorCode
lib.ocf_mngt_cache_cleaning_set_policy.argtypes = [ lib.ocf_mngt_cache_cleaning_set_policy.argtypes = [
c_void_p, c_void_p,
c_uint32, c_uint32,