@@ -77,7 +77,10 @@ def log_failed_call(target_host, next_target, device_path, vdi_uuid, remote_meth
7777 target_host , device_path , vdi_uuid , remote_method , next_target , e
7878 ), priority = util .LOG_DEBUG )
7979
80- def linstorhostcall (local_method , remote_method ):
80+ def linstorhostcall (local_method , remote_method = None ):
81+ if not remote_method :
82+ remote_method = local_method
83+
8184 def decorated (response_parser ):
8285 def wrapper (* args , ** kwargs ):
8386 self = args [0 ]
@@ -216,7 +219,7 @@ def check(self, vdi_uuid, ignore_missing_footer=False, fast=False):
216219 }
217220 return self ._check (vdi_uuid , ** kwargs )
218221
219- @linstorhostcall (CowUtil . check , 'check' )
222+ @linstorhostcall ('check' )
220223 def _check (self , vdi_uuid , response ):
221224 return CowUtil .CheckResult (response )
222225
@@ -227,7 +230,7 @@ def get_info(self, vdi_uuid, include_parent=True):
227230 }
228231 return self ._get_info (vdi_uuid , self ._extract_uuid , ** kwargs )
229232
230- @linstorhostcall (CowUtil . getInfo , 'getInfo' )
233+ @linstorhostcall ('getInfo' )
231234 def _get_info (self , vdi_uuid , response ):
232235 obj = json .loads (response )
233236
@@ -242,42 +245,42 @@ def _get_info(self, vdi_uuid, response):
242245
243246 return image_info
244247
245- @linstorhostcall (CowUtil . hasParent , 'hasParent' )
248+ @linstorhostcall ('hasParent' )
246249 def has_parent (self , vdi_uuid , response ):
247250 return util .strtobool (response )
248251
249252 def get_parent (self , vdi_uuid ):
250253 return self ._get_parent (vdi_uuid , self ._extract_uuid )
251254
252- @linstorhostcall (CowUtil . getParent , 'getParent' )
255+ @linstorhostcall ('getParent' )
253256 def _get_parent (self , vdi_uuid , response ):
254257 return response
255258
256- @linstorhostcall (CowUtil . getSizeVirt , 'getSizeVirt' )
259+ @linstorhostcall ('getSizeVirt' )
257260 def get_size_virt (self , vdi_uuid , response ):
258261 return int (response )
259262
260- @linstorhostcall (CowUtil . getMaxResizeSize , 'getMaxResizeSize' )
263+ @linstorhostcall ('getMaxResizeSize' )
261264 def get_max_resize_size (self , vdi_uuid , response ):
262265 return int (response )
263266
264- @linstorhostcall (CowUtil . getSizePhys , 'getSizePhys' )
267+ @linstorhostcall ('getSizePhys' )
265268 def get_size_phys (self , vdi_uuid , response ):
266269 return int (response )
267270
268- @linstorhostcall (CowUtil . getAllocatedSize , 'getAllocatedSize' )
271+ @linstorhostcall ('getAllocatedSize' )
269272 def get_allocated_size (self , vdi_uuid , response ):
270273 return int (response )
271274
272- @linstorhostcall (CowUtil . getDepth , 'getDepth' )
275+ @linstorhostcall ('getDepth' )
273276 def get_depth (self , vdi_uuid , response ):
274277 return int (response )
275278
276- @linstorhostcall (CowUtil . getKeyHash , 'getKeyHash' )
279+ @linstorhostcall ('getKeyHash' )
277280 def get_key_hash (self , vdi_uuid , response ):
278281 return response or None
279282
280- @linstorhostcall (CowUtil . getBlockBitmap , 'getBlockBitmap' )
283+ @linstorhostcall ('getBlockBitmap' )
281284 def get_block_bitmap (self , vdi_uuid , response ):
282285 return base64 .b64decode (response )
283286
@@ -297,31 +300,31 @@ def _get_drbd_size(self, cowutil_inst, path):
297300
298301 @linstormodifier ()
299302 def create (self , path , size , static , msize = 0 ):
300- return self ._call_local_method_or_fail (CowUtil .create , path , size , static , msize )
303+ return self ._call_local_method_or_fail (self . _cowutil .create , path , size , static , msize )
301304
302305 @linstormodifier ()
303306 def set_size_phys (self , path , size , debug = True ):
304- return self ._call_local_method_or_fail (CowUtil .setSizePhys , path , size , debug )
307+ return self ._call_local_method_or_fail (self . _cowutil .setSizePhys , path , size , debug )
305308
306309 @linstormodifier ()
307310 def set_parent (self , path , parentPath , parentRaw = False ):
308- return self ._call_local_method_or_fail (CowUtil .setParent , path , parentPath , parentRaw )
311+ return self ._call_local_method_or_fail (self . _cowutil .setParent , path , parentPath , parentRaw )
309312
310313 @linstormodifier ()
311314 def set_hidden (self , path , hidden = True ):
312- return self ._call_local_method_or_fail (CowUtil .setHidden , path , hidden )
315+ return self ._call_local_method_or_fail (self . _cowutil .setHidden , path , hidden )
313316
314317 @linstormodifier ()
315318 def set_key (self , path , key_hash ):
316- return self ._call_local_method_or_fail (CowUtil .setKey , path , key_hash )
319+ return self ._call_local_method_or_fail (self . _cowutil .setKey , path , key_hash )
317320
318321 @linstormodifier ()
319322 def kill_data (self , path ):
320- return self ._call_local_method_or_fail (CowUtil .killData , path )
323+ return self ._call_local_method_or_fail (self . _cowutil .killData , path )
321324
322325 @linstormodifier ()
323326 def snapshot (self , path , parent , parentRaw , msize = 0 , checkEmpty = True ):
324- return self ._call_local_method_or_fail (CowUtil .snapshot , path , parent , parentRaw , msize , checkEmpty )
327+ return self ._call_local_method_or_fail (self . _cowutil .snapshot , path , parent , parentRaw , msize , checkEmpty )
325328
326329 def inflate (self , journaler , vdi_uuid , vdi_path , new_size , old_size ):
327330 # Only inflate if the LINSTOR volume capacity is not enough.
@@ -377,30 +380,30 @@ def set_size_virt(self, path, size, jFile):
377380 'size' : size ,
378381 'jFile' : jFile
379382 }
380- return self ._call_method (CowUtil .setSizeVirt , 'setSizeVirt' , path , use_parent = False , ** kwargs )
383+ return self ._call_method (self . _cowutil .setSizeVirt , 'setSizeVirt' , path , use_parent = False , ** kwargs )
381384
382385 @linstormodifier ()
383386 def set_size_virt_fast (self , path , size ):
384387 kwargs = {
385388 'size' : size
386389 }
387- return self ._call_method (CowUtil .setSizeVirtFast , 'setSizeVirtFast' , path , use_parent = False , ** kwargs )
390+ return self ._call_method (self . _cowutil .setSizeVirtFast , 'setSizeVirtFast' , path , use_parent = False , ** kwargs )
388391
389392 @linstormodifier ()
390393 def force_parent (self , path , parentPath , parentRaw = False ):
391394 kwargs = {
392395 'parentPath' : str (parentPath ),
393396 'parentRaw' : parentRaw
394397 }
395- return self ._call_method (CowUtil .setParent , 'setParent' , path , use_parent = False , ** kwargs )
398+ return self ._call_method (self . _cowutil .setParent , 'setParent' , path , use_parent = False , ** kwargs )
396399
397400 @linstormodifier ()
398401 def force_coalesce (self , path ):
399- return int (self ._call_method (CowUtil .coalesce , 'coalesce' , path , use_parent = True ))
402+ return int (self ._call_method (self . _cowutil .coalesce , 'coalesce' , path , use_parent = True ))
400403
401404 @linstormodifier ()
402405 def force_repair (self , path ):
403- return self ._call_method (CowUtil .repair , 'repair' , path , use_parent = False )
406+ return self ._call_method (self . _cowutil .repair , 'repair' , path , use_parent = False )
404407
405408 @linstormodifier ()
406409 def force_deflate (self , path , newSize , oldSize , zeroize ):
@@ -478,12 +481,12 @@ def _raise_openers_exception(self, device_path, e):
478481
479482 def _call_local_method (self , local_method , device_path , * args , ** kwargs ):
480483 if isinstance (local_method , str ):
481- local_method = getattr (self , local_method )
484+ local_method = getattr (self . _cowutil , local_method )
482485
483486 try :
484487 def local_call ():
485488 try :
486- return local_method (self . _cowutil , device_path , * args , ** kwargs )
489+ return local_method (device_path , * args , ** kwargs )
487490 except util .CommandException as e :
488491 if e .code == errno .EROFS or e .code == errno .EMEDIUMTYPE :
489492 raise ErofsLinstorCallException (e ) # Break retry calls.
@@ -510,7 +513,7 @@ def _call_method(self, local_method, remote_method, device_path, use_parent, *ar
510513 # we must check where this last one is open instead of the child.
511514
512515 if isinstance (local_method , str ):
513- local_method = getattr (self , local_method )
516+ local_method = getattr (self . _cowutil , local_method )
514517
515518 # A. Try to write locally...
516519 try :
@@ -569,7 +572,7 @@ def remote_call():
569572
570573 if no_host_found :
571574 try :
572- return local_method (self . _cowutil , device_path , * args , ** kwargs )
575+ return local_method (device_path , * args , ** kwargs )
573576 except Exception as e :
574577 self ._raise_openers_exception (device_path , e )
575578
0 commit comments