pyocf: Use abstract Volume in generic code paths

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski 2021-10-19 14:43:02 +02:00
parent 9e13364896
commit 838870fa10
4 changed files with 9 additions and 11 deletions

View File

@ -13,7 +13,7 @@ from threading import Thread, Condition, Event
from copy import deepcopy
from pyocf.utils import Size
from pyocf.types.volume import RamVolume
from pyocf.types.volume import Volume
from pyocf.types.io import Io, IoDir
from pyocf.types.data import Data
@ -67,7 +67,7 @@ class JobSpec:
qd: int = 1
size: Size = Size(0)
io_size: Size = Size(0)
target: RamVolume = None
target: Volume = None
time_based: bool = False
time: timedelta = None
continue_on_error: bool = False
@ -211,7 +211,7 @@ class Rio:
self.global_jobspec.qd = qd
return self
def target(self, target: RamVolume):
def target(self, target: Volume):
self.global_jobspec.target = target
return self

View File

@ -29,7 +29,7 @@ from .queue import Queue
from .shared import Uuid, OcfCompletion, OcfError, SeqCutOffPolicy
from .stats.core import CoreInfo
from .stats.shared import UsageStats, RequestsStats, BlocksStats, ErrorsStats
from .volume import RamVolume
from .volume import Volume
from ..ocf import OcfLib
from ..utils import Size, struct_to_dict
@ -58,7 +58,7 @@ class Core:
def __init__(
self,
device: RamVolume,
device: Volume,
name: str = "core",
seq_cutoff_threshold: int = DEFAULT_SEQ_CUTOFF_THRESHOLD,
seq_cutoff_promotion_count: int = DEFAULT_SEQ_CUTOFF_PROMOTION_COUNT,

View File

@ -12,8 +12,6 @@ from .cleaner import CleanerOps, Cleaner
from .shared import OcfError
from ..ocf import OcfLib
from .queue import Queue
from .volume import RamVolume
class OcfCtxOps(Structure):
_fields_ = [
@ -84,7 +82,7 @@ class OcfCtx:
byref(self.volume_types[self.volume_types_count].get_props()),
)
if result != 0:
raise OcfError("RamVolume type registration failed", result)
raise OcfError("Volume type registration failed", result)
self.volume_types_count += 1

View File

@ -24,7 +24,7 @@ from pyocf.types.core import Core
from pyocf.types.data import Data
from pyocf.types.io import IoDir
from pyocf.types.shared import OcfError, OcfCompletion, CacheLineSize, SeqCutOffPolicy
from pyocf.types.volume import RamVolume
from pyocf.types.volume import Volume, RamVolume
from pyocf.utils import Size
logger = logging.getLogger(__name__)
@ -342,14 +342,14 @@ def test_start_cache_huge_device(pyocf_ctx_log_buffer, cls):
pass_criteria:
- Starting cache on device too big to handle should fail
"""
class HugeDevice(RamVolume):
class HugeDevice(Volume):
def get_length(self):
return Size.from_B((cls * c_uint32(-1).value))
def submit_io(self, io):
io.contents._end(io, 0)
cache_device = HugeDevice(Size.from_MiB(50))
cache_device = HugeDevice()
with pytest.raises(OcfError, match="OCF_ERR_INVAL_CACHE_DEV"):
cache = Cache.start_on_device(cache_device, cache_line_size=cls, metadata_volatile=True)