@@ -156,9 +156,12 @@ def to_check_return_code(self) -> CheckReturnCode:
156156 return ret
157157
158158
159- def migrate ():
159+ def migrate (args : typing .Sequence [str ]):
160+ parser = argparse .ArgumentParser (args [0 ])
161+ parser .add_argument ('--local' , action = 'store_true' )
162+ parsed_args = parser .parse_args (args [1 :])
160163 try :
161- match _check_impl (local = False , json = '' , summary = False ):
164+ match _check_impl (local = parsed_args . local , json = '' , summary = False ):
162165 case CheckReturnCode .ALREADY_MIGRATED :
163166 logger .info ("This cluster works on SLES 16. No migration is needed." )
164167 return 0
@@ -167,7 +170,7 @@ def migrate():
167170 return 0
168171 case CheckReturnCode .PASS_NEED_AUTO_FIX :
169172 logger .info ('Starting migration...' )
170- migrate_corosync_conf ()
173+ migrate_corosync_conf (local = parsed_args . local )
171174 logger .info ('Finished migration.' )
172175 return 0
173176 case _:
@@ -372,7 +375,7 @@ def _check_unsupported_corosync_transport(handler: CheckResultHandler, dom):
372375 )
373376
374377
375- def migrate_corosync_conf ():
378+ def migrate_corosync_conf (local : bool ):
376379 conf_path = corosync .conf ()
377380 with open (conf_path , 'r' , encoding = 'utf-8' ) as f :
378381 config = corosync_config_format .DomParser (f ).dom ()
@@ -387,16 +390,17 @@ def migrate_corosync_conf():
387390 'Finish migrating corosync configuration. The original configuration is renamed to %s.bak' ,
388391 os .path .basename (conf_path ),
389392 )
390- for host , result in prun .pcopy_to_remote (
391- conf_path ,
392- utils .list_cluster_nodes_except_me (), conf_path ,
393- atomic_write = True ,
394- ).items ():
395- match result :
396- case None :
397- pass
398- case prun .PRunError () as e :
399- logger .error ("Failed to copy crmsh.conf to host %s: %s" , host , e )
393+ if not local :
394+ for host , result in prun .pcopy_to_remote (
395+ conf_path ,
396+ utils .list_cluster_nodes_except_me (), conf_path ,
397+ atomic_write = True ,
398+ ).items ():
399+ match result :
400+ case None :
401+ pass
402+ case prun .PRunError () as e :
403+ logger .error ("Failed to copy crmsh.conf to host %s: %s" , host , e )
400404
401405
402406def migrate_corosync_conf_impl (config ):
0 commit comments