Handle try_add core adding mode

Signed-off-by: Jan Musial <jan.musial@intel.com>
This commit is contained in:
Jan Musial 2021-08-24 14:45:45 +02:00
parent 6a1d5f2ad6
commit 30fe2eb783
2 changed files with 12 additions and 3 deletions

View File

@ -570,7 +570,7 @@ class Cache:
def write_unlock(self):
self.owner.lib.ocf_mngt_cache_unlock(self.cache_handle)
def add_core(self, core: Core):
def add_core(self, core: Core, try_add=False):
self.write_lock()
c = OcfCompletion(
@ -582,8 +582,11 @@ class Cache:
]
)
cfg = core.get_cfg()
cfg._try_add = try_add
self.owner.lib.ocf_mngt_cache_add_core(
self.cache_handle, byref(core.get_cfg()), c, None
self.cache_handle, byref(cfg), c, None
)
c.wait()

View File

@ -19,6 +19,9 @@ from ctypes import (
cast,
byref,
create_string_buffer,
sizeof,
memmove,
pointer,
)
from datetime import timedelta
@ -90,7 +93,10 @@ class Core:
return c
def get_cfg(self):
return self.cfg
config_copy = CoreConfig()
memmove(pointer(config_copy), pointer(self.cfg), sizeof(config_copy))
return config_copy
def get_handle(self):
return self.handle