File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -742,6 +742,15 @@ def nfs_iso_sr(host, nfs_iso_device_config):
742
742
# teardown
743
743
sr .forget ()
744
744
745
+ @pytest .fixture (scope = 'module' )
746
+ def exit_on_fistpoint (host ):
747
+ from lib .fistpoint import FistPoint
748
+ logging .info (">> Enabling exit on fistpoint" )
749
+ FistPoint .enable_exit_on_fistpoint (host )
750
+ yield
751
+ logging .info ("<< Disabling exit on fistpoint" )
752
+ FistPoint .disable_exit_on_fistpoint (host )
753
+
745
754
@pytest .fixture (scope = 'module' )
746
755
def cifs_iso_sr (host , cifs_iso_device_config ):
747
756
""" A Samba/CIFS SR. """
Original file line number Diff line number Diff line change
1
+ import logging
2
+ from typing import Final
3
+
4
+ from lib .host import Host
5
+
6
+ FISTPOINT_DIR : Final = "/tmp"
7
+ LVHDRT_EXIT_FIST : Final = "fist_LVHDRT_exit"
8
+
9
+ class FistPoint :
10
+ fistpointName : str
11
+
12
+ def __init__ (self , host : Host , name : str ):
13
+ self .fistpointName = self ._get_name (name )
14
+ self .host = host
15
+
16
+ @staticmethod
17
+ def enable_exit_on_fistpoint (host : Host ):
18
+ host .create_file (FistPoint ._get_path (LVHDRT_EXIT_FIST ), "" )
19
+
20
+ @staticmethod
21
+ def disable_exit_on_fistpoint (host : Host ):
22
+ host .ssh (["rm" , FistPoint ._get_path (LVHDRT_EXIT_FIST )])
23
+
24
+ @staticmethod
25
+ def _get_name (name : str ) -> str :
26
+ if name .startswith ("fist_" ):
27
+ return name
28
+ else :
29
+ return f"fist_{ name } "
30
+
31
+ @staticmethod
32
+ def _get_path (name ) -> str :
33
+ return f"{ FISTPOINT_DIR } /{ name } "
34
+
35
+ def enable (self ):
36
+ logging .info (f"Enable fistpoint { self .fistpointName } " )
37
+ self .host .create_file (self ._get_path (self .fistpointName ), "" )
38
+
39
+ def disable (self ):
40
+ logging .info (f"Disabling fistpoint { self .fistpointName } " )
41
+ self .host .ssh (["rm" , self ._get_path (self .fistpointName )])
42
+
43
+ def __enter__ (self ):
44
+ self .enable ()
45
+ return self
46
+
47
+ def __exit__ (self , * _ ):
48
+ self .disable ()
You can’t perform that action at this time.
0 commit comments