[pyocf] properly resolve volume type
OCF volume type is different for each context in which given type (Volume subclass) is registered. So OCF volume type should not be a Volume subclass member. Adding map in Context class to store OCF volume type for each registered volume type. Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
parent
6a9436740b
commit
9739a442b6
@ -256,7 +256,7 @@ class Cache:
|
|||||||
raise OcfError("Failed to detach failover cache device", c.results["error"])
|
raise OcfError("Failed to detach failover cache device", c.results["error"])
|
||||||
|
|
||||||
def standby_activate(self, device, open_cores=True):
|
def standby_activate(self, device, open_cores=True):
|
||||||
device_cfg = Cache.generate_device_config(device)
|
device_cfg = self.generate_device_config(device)
|
||||||
|
|
||||||
activate_cfg = CacheStandbyActivateConfig(_device=device_cfg, _open_cores=open_cores,)
|
activate_cfg = CacheStandbyActivateConfig(_device=device_cfg, _open_cores=open_cores,)
|
||||||
|
|
||||||
@ -456,8 +456,7 @@ class Cache:
|
|||||||
if status:
|
if status:
|
||||||
raise OcfError("Error adding partition to cache", status)
|
raise OcfError("Error adding partition to cache", status)
|
||||||
|
|
||||||
@staticmethod
|
def generate_device_config(self, device, perform_test=True):
|
||||||
def generate_device_config(device, perform_test=True):
|
|
||||||
uuid = Uuid(
|
uuid = Uuid(
|
||||||
_data=cast(create_string_buffer(device.uuid.encode("ascii")), c_char_p),
|
_data=cast(create_string_buffer(device.uuid.encode("ascii")), c_char_p),
|
||||||
_size=len(device.uuid) + 1,
|
_size=len(device.uuid) + 1,
|
||||||
@ -467,7 +466,7 @@ class Cache:
|
|||||||
lib = OcfLib.getInstance()
|
lib = OcfLib.getInstance()
|
||||||
result = lib.ocf_volume_create(
|
result = lib.ocf_volume_create(
|
||||||
byref(volume),
|
byref(volume),
|
||||||
device.type,
|
self.owner.ocf_volume_type[type(device)],
|
||||||
byref(uuid)
|
byref(uuid)
|
||||||
)
|
)
|
||||||
if result != 0:
|
if result != 0:
|
||||||
@ -487,7 +486,7 @@ class Cache:
|
|||||||
self.device = device
|
self.device = device
|
||||||
self.device_name = device.uuid
|
self.device_name = device.uuid
|
||||||
|
|
||||||
device_config = Cache.generate_device_config(device, perform_test=perform_test)
|
device_config = self.generate_device_config(device, perform_test=perform_test)
|
||||||
|
|
||||||
attach_cfg = CacheAttachConfig(
|
attach_cfg = CacheAttachConfig(
|
||||||
_device=device_config,
|
_device=device_config,
|
||||||
@ -515,7 +514,7 @@ class Cache:
|
|||||||
self.device = device
|
self.device = device
|
||||||
self.device_name = device.uuid
|
self.device_name = device.uuid
|
||||||
|
|
||||||
device_config = Cache.generate_device_config(device, perform_test=False)
|
device_config = self.generate_device_config(device, perform_test=False)
|
||||||
|
|
||||||
attach_cfg = CacheAttachConfig(
|
attach_cfg = CacheAttachConfig(
|
||||||
_device=device_config,
|
_device=device_config,
|
||||||
@ -543,7 +542,7 @@ class Cache:
|
|||||||
self.device = device
|
self.device = device
|
||||||
self.device_name = device.uuid
|
self.device_name = device.uuid
|
||||||
|
|
||||||
device_config = Cache.generate_device_config(device, perform_test=perform_test)
|
device_config = self.generate_device_config(device, perform_test=perform_test)
|
||||||
|
|
||||||
attach_cfg = CacheAttachConfig(
|
attach_cfg = CacheAttachConfig(
|
||||||
_device=device_config,
|
_device=device_config,
|
||||||
@ -580,7 +579,7 @@ class Cache:
|
|||||||
self.device = device
|
self.device = device
|
||||||
self.device_name = device.uuid
|
self.device_name = device.uuid
|
||||||
|
|
||||||
device_config = Cache.generate_device_config(device)
|
device_config = self.generate_device_config(device)
|
||||||
|
|
||||||
attach_cfg = CacheAttachConfig(
|
attach_cfg = CacheAttachConfig(
|
||||||
_device=device_config,
|
_device=device_config,
|
||||||
|
@ -37,6 +37,7 @@ class OcfCtx:
|
|||||||
self.lib = lib
|
self.lib = lib
|
||||||
self.volume_types_count = 1
|
self.volume_types_count = 1
|
||||||
self.volume_types = {}
|
self.volume_types = {}
|
||||||
|
self.ocf_volume_type = {}
|
||||||
self.caches = []
|
self.caches = []
|
||||||
|
|
||||||
self.cfg = OcfCtxCfg(
|
self.cfg = OcfCtxCfg(
|
||||||
@ -77,7 +78,7 @@ class OcfCtx:
|
|||||||
if result != 0:
|
if result != 0:
|
||||||
raise OcfError("Volume type registration failed", result)
|
raise OcfError("Volume type registration failed", result)
|
||||||
|
|
||||||
volume_type.type = self.lib.ocf_ctx_get_volume_type(
|
self.ocf_volume_type[volume_type] = self.lib.ocf_ctx_get_volume_type(
|
||||||
self.ctx_handle,
|
self.ctx_handle,
|
||||||
volume_type.type_id
|
volume_type.type_id
|
||||||
)
|
)
|
||||||
@ -91,6 +92,7 @@ class OcfCtx:
|
|||||||
self.lib.ocf_ctx_unregister_volume_type(self.ctx_handle, vol_type.type_id)
|
self.lib.ocf_ctx_unregister_volume_type(self.ctx_handle, vol_type.type_id)
|
||||||
|
|
||||||
del self.volume_types[vol_type.type_id]
|
del self.volume_types[vol_type.type_id]
|
||||||
|
del self.ocf_volume_type[vol_type]
|
||||||
|
|
||||||
def cleanup_volume_types(self):
|
def cleanup_volume_types(self):
|
||||||
for k, vol_type in list(self.volume_types.items()):
|
for k, vol_type in list(self.volume_types.items()):
|
||||||
|
Loading…
Reference in New Issue
Block a user