pyocf: remove Queue objects from Cache::start() params
... since a started cache is required to construct a queue object. Instead add params to control whether to construct and register management and default I/O queue in start(). Additionally introducing Cache method to register additional I/O queues. Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
parent
1f9c3dd24f
commit
650511df4e
@ -205,10 +205,7 @@ class Cache:
|
|||||||
self.cores = []
|
self.cores = []
|
||||||
|
|
||||||
def start_cache(
|
def start_cache(
|
||||||
self,
|
self, init_mngmt_queue=True, init_default_io_queue=True, locked: bool = False,
|
||||||
default_io_queue: Queue = None,
|
|
||||||
mngt_queue: Queue = None,
|
|
||||||
locked: bool = False,
|
|
||||||
):
|
):
|
||||||
cfg = CacheConfig(
|
cfg = CacheConfig(
|
||||||
_name=self.name.encode("ascii"),
|
_name=self.name.encode("ascii"),
|
||||||
@ -231,20 +228,24 @@ class Cache:
|
|||||||
if status:
|
if status:
|
||||||
raise OcfError("Creating cache instance failed", status)
|
raise OcfError("Creating cache instance failed", status)
|
||||||
|
|
||||||
self.mngt_queue = mngt_queue or Queue(self, "mgmt-{}".format(self.get_name()))
|
if init_mngmt_queue:
|
||||||
|
self.mngt_queue = Queue(self, "mgmt-{}".format(self.get_name()))
|
||||||
if default_io_queue:
|
|
||||||
self.io_queues += [default_io_queue]
|
|
||||||
else:
|
|
||||||
self.io_queues += [Queue(self, "default-io-{}".format(self.get_name()))]
|
|
||||||
|
|
||||||
status = self.owner.lib.ocf_mngt_cache_set_mngt_queue(self, self.mngt_queue)
|
status = self.owner.lib.ocf_mngt_cache_set_mngt_queue(self, self.mngt_queue)
|
||||||
if status:
|
if status:
|
||||||
raise OcfError("Error setting management queue", status)
|
raise OcfError("Error setting management queue", status)
|
||||||
|
|
||||||
|
if init_default_io_queue:
|
||||||
|
self.io_queues = [Queue(self, "default-io-{}".format(self.get_name()))]
|
||||||
|
else:
|
||||||
|
self.io_queues = []
|
||||||
|
|
||||||
self.started = True
|
self.started = True
|
||||||
self.owner.caches.append(self)
|
self.owner.caches.append(self)
|
||||||
|
|
||||||
|
def add_io_queue(self, *args, **kwargs):
|
||||||
|
q = Queue(self, args, **kwargs)
|
||||||
|
self.io_queues += [q]
|
||||||
|
|
||||||
def standby_detach(self):
|
def standby_detach(self):
|
||||||
self.write_lock()
|
self.write_lock()
|
||||||
c = OcfCompletion([("cache", c_void_p), ("priv", c_void_p), ("error", c_int)])
|
c = OcfCompletion([("cache", c_void_p), ("priv", c_void_p), ("error", c_int)])
|
||||||
|
Loading…
Reference in New Issue
Block a user