Extract Volume::open() class method
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
parent
d60e48ee26
commit
dcf3129ff8
@ -29,6 +29,7 @@ from .shared import OcfErrorCode, Uuid
|
||||
from ..ocf import OcfLib
|
||||
from ..utils import print_buffer, Size as S
|
||||
from .data import Data
|
||||
from .queue import Queue
|
||||
|
||||
|
||||
class VolumeCaps(Structure):
|
||||
@ -136,13 +137,7 @@ class Volume:
|
||||
print("{}".format(Volume._uuid_))
|
||||
return -1
|
||||
|
||||
if volume.opened:
|
||||
return -OcfErrorCode.OCF_ERR_NOT_OPEN_EXC
|
||||
|
||||
Volume._instances_[ref] = volume
|
||||
volume.handle = ref
|
||||
|
||||
return volume.do_open()
|
||||
return Volume.open(ref, volume)
|
||||
|
||||
@VolumeOps.CLOSE
|
||||
def _close(ref):
|
||||
@ -172,6 +167,16 @@ class Volume:
|
||||
|
||||
return Volume._ops_[cls]
|
||||
|
||||
@staticmethod
|
||||
def open(ref, volume):
|
||||
if volume.opened:
|
||||
return -OcfErrorCode.OCF_ERR_NOT_OPEN_EXC
|
||||
|
||||
Volume._instances_[ref] = volume
|
||||
volume.handle = ref
|
||||
|
||||
return volume.do_open()
|
||||
|
||||
@classmethod
|
||||
def get_io_ops(cls):
|
||||
return IoOps(_set_data=cls._io_set_data, _get_data=cls._io_get_data)
|
||||
|
Loading…
Reference in New Issue
Block a user