@@ -614,7 +614,12 @@ def _run(args):
614
614
mode .set_defaults (handler = _run )
615
615
616
616
617
- def dispatch_run (func , args , walle_provider ):
617
+ def dispatch_run (func , args , walle_provider , need_confirmation = False ):
618
+ if need_confirmation and not __confirm (args ):
619
+ print ("Aborting slice installation/formatting" )
620
+ # TODO(shmel1k@): add confirmation message.
621
+ return
622
+
618
623
logger .debug ("run func '%s' with cmd args is '%s'" , func .__name__ , args )
619
624
620
625
cluster_details = safe_load_cluster_details (args .cluster , walle_provider )
@@ -654,9 +659,33 @@ def dispatch_run(func, args, walle_provider):
654
659
# shutil.rmtree(temp_dir)
655
660
656
661
662
+ def __confirm (args ) -> bool :
663
+ if hasattr (args , "confirm" ) and args .confirm :
664
+ return True
665
+
666
+ confirm = input (
667
+ "You are trying to setup or format slice. Note, that during setup or format all previous data will be erased.\n "
668
+ + "Press [y] to continue or [n] to abort installation/formatting: "
669
+ )
670
+ for i in range (0 , 3 ):
671
+ lw = confirm .strip ().lower ()
672
+ if lw == "n" :
673
+ return False
674
+ if lw == "y" :
675
+ return True
676
+ confirm = input ("Enter [y] or [n]" )
677
+ lw = confirm .strip ().lower ()
678
+ if lw == "n" :
679
+ return False
680
+ if lw == "y" :
681
+ return True
682
+
683
+ return False
684
+
685
+
657
686
def add_install_mode (modes , walle_provider ):
658
687
def _run (args ):
659
- dispatch_run (handlers .Slice .slice_install , args , walle_provider )
688
+ dispatch_run (handlers .Slice .slice_install , args , walle_provider , True )
660
689
661
690
mode = modes .add_parser (
662
691
"install" ,
@@ -701,7 +730,6 @@ def _run(args):
701
730
702
731
def add_update_raw_configs (modes , walle_provider ):
703
732
def _run (args ):
704
-
705
733
dispatch_run (lambda self : handlers .Slice .slice_update_raw_configs (self , args .raw_cfg ), args , walle_provider )
706
734
707
735
mode = modes .add_parser (
@@ -750,7 +778,7 @@ def _run(args):
750
778
751
779
def add_clear_mode (modes , walle_provider ):
752
780
def _run (args ):
753
- dispatch_run (handlers .Slice .slice_clear , args , walle_provider )
781
+ dispatch_run (handlers .Slice .slice_clear , args , walle_provider , True )
754
782
755
783
mode = modes .add_parser (
756
784
"clear" ,
@@ -771,7 +799,7 @@ def _run(args):
771
799
772
800
def add_format_mode (modes , walle_provider ):
773
801
def _run (args ):
774
- dispatch_run (handlers .Slice .slice_format , args , walle_provider )
802
+ dispatch_run (handlers .Slice .slice_format , args , walle_provider , True )
775
803
776
804
mode = modes .add_parser (
777
805
"format" ,
0 commit comments