1313 NODE_CONFIG_PATH ,
1414 NODE_CLI_STATUS_FILENAME ,
1515 SCHAIN_NODE_DATA_PATH ,
16- SCHAINS_MNT_DIR_SYNC
16+ SCHAINS_MNT_DIR_SYNC ,
1717)
1818from node_cli .configs .env import get_env_config
1919
20- from node_cli .utils .helper import (
21- get_request ,
22- error_exit ,
23- safe_load_yml
24- )
20+ from node_cli .utils .helper import get_request , error_exit , safe_load_yml
2521from node_cli .utils .exit_codes import CLIExitCodes
2622from node_cli .utils .print_formatters import (
2723 print_dkg_statuses ,
2824 print_firewall_rules ,
2925 print_schain_info ,
30- print_schains
26+ print_schains ,
3127)
3228from node_cli .utils .docker_utils import ensure_volume , is_volume_exists
3329from node_cli .utils .helper import read_json , run_cmd , save_json
4137
4238def get_schain_firewall_rules (schain : str ) -> None :
4339 status , payload = get_request (
44- blueprint = BLUEPRINT_NAME ,
45- method = 'firewall-rules' ,
46- params = {'schain_name' : schain }
40+ blueprint = BLUEPRINT_NAME , method = 'firewall-rules' , params = {'schain_name' : schain }
4741 )
4842 if status == 'ok' :
4943 print_firewall_rules (payload ['endpoints' ])
@@ -52,10 +46,7 @@ def get_schain_firewall_rules(schain: str) -> None:
5246
5347
5448def show_schains () -> None :
55- status , payload = get_request (
56- blueprint = BLUEPRINT_NAME ,
57- method = 'list'
58- )
49+ status , payload = get_request (blueprint = BLUEPRINT_NAME , method = 'list' )
5950 if status == 'ok' :
6051 schains = payload
6152 if not schains :
@@ -69,11 +60,7 @@ def show_schains() -> None:
6960
7061def show_dkg_info (all_ : bool = False ) -> None :
7162 params = {'all' : all_ }
72- status , payload = get_request (
73- blueprint = BLUEPRINT_NAME ,
74- method = 'dkg-statuses' ,
75- params = params
76- )
63+ status , payload = get_request (blueprint = BLUEPRINT_NAME , method = 'dkg-statuses' , params = params )
7764 if status == 'ok' :
7865 print_dkg_statuses (payload )
7966 else :
@@ -82,9 +69,7 @@ def show_dkg_info(all_: bool = False) -> None:
8269
8370def show_config (name : str ) -> None :
8471 status , payload = get_request (
85- blueprint = BLUEPRINT_NAME ,
86- method = 'config' ,
87- params = {'schain_name' : name }
72+ blueprint = BLUEPRINT_NAME , method = 'config' , params = {'schain_name' : name }
8873 )
8974 if status == 'ok' :
9075 pprint .pprint (payload )
@@ -97,9 +82,7 @@ def get_node_cli_schain_status_filepath(schain_name: str) -> str:
9782
9883
9984def update_node_cli_schain_status (
100- schain_name : str ,
101- repair_ts : Optional [int ] = None ,
102- snapshot_from : Optional [str ] = None
85+ schain_name : str , repair_ts : Optional [int ] = None , snapshot_from : Optional [str ] = None
10386) -> None :
10487 path = get_node_cli_schain_status_filepath (schain_name )
10588 if os .path .isdir (path ):
@@ -110,7 +93,7 @@ def update_node_cli_schain_status(
11093 status = {
11194 'schain_name' : schain_name ,
11295 'repair_ts' : repair_ts ,
113- 'snapshot_from' : snapshot_from
96+ 'snapshot_from' : snapshot_from ,
11497 }
11598 os .makedirs (os .path .dirname (path ), exist_ok = True )
11699 save_json (path , status )
@@ -121,20 +104,15 @@ def get_node_cli_schain_status(schain_name: str) -> dict:
121104 return read_json (path )
122105
123106
124- def toggle_schain_repair_mode (
125- schain : str ,
126- snapshot_from : Optional [str ] = None
127- ) -> None :
107+ def toggle_schain_repair_mode (schain : str , snapshot_from : Optional [str ] = None ) -> None :
128108 ts = int (time .time ())
129109 update_node_cli_schain_status (schain_name = schain , repair_ts = ts , snapshot_from = snapshot_from )
130110 print ('Schain has been set for repair' )
131111
132112
133113def describe (schain : str , raw = False ) -> None :
134114 status , payload = get_request (
135- blueprint = BLUEPRINT_NAME ,
136- method = 'get' ,
137- params = {'schain_name' : schain }
115+ blueprint = BLUEPRINT_NAME , method = 'get' , params = {'schain_name' : schain }
138116 )
139117 if status == 'ok' :
140118 print_schain_info (payload , raw = raw )
@@ -193,23 +171,18 @@ def rm_btrfs_subvolume(subvolume: str) -> None:
193171
194172def fillin_snapshot_folder (src_path : str , block_number : int ) -> None :
195173 snapshots_dirname = 'snapshots'
196- snapshot_folder_path = os .path .join (
197- src_path , snapshots_dirname , str (block_number ))
174+ snapshot_folder_path = os .path .join (src_path , snapshots_dirname , str (block_number ))
198175 os .makedirs (snapshot_folder_path , exist_ok = True )
199176 for subvolume in os .listdir (src_path ):
200177 if subvolume != snapshots_dirname :
201178 logger .debug ('Copying %s to %s' , subvolume , snapshot_folder_path )
202179 subvolume_path = os .path .join (src_path , subvolume )
203- subvolume_snapshot_path = os .path .join (
204- snapshot_folder_path , subvolume )
180+ subvolume_snapshot_path = os .path .join (snapshot_folder_path , subvolume )
205181 make_btrfs_snapshot (subvolume_path , subvolume_snapshot_path )
206182
207183
208184def restore_schain_from_snapshot (
209- schain : str ,
210- snapshot_path : str ,
211- env_type : Optional [str ] = None ,
212- schain_type : str = 'medium'
185+ schain : str , snapshot_path : str , env_type : Optional [str ] = None , schain_type : str = 'medium'
213186) -> None :
214187 if env_type is None :
215188 env_config = get_env_config ()
0 commit comments