@@ -740,9 +740,12 @@ def __init__(self):
740740
741741class ClusterMirrorCommand (ObdCommand ):
742742
743- def init (self , cmd , args ):
743+ def init (self , cmd , args , need_deploy_name = True ):
744744 super (ClusterMirrorCommand , self ).init (cmd , args )
745- self .parser .set_usage ('%s <deploy name> [options]' % self .prev_cmd )
745+ usage = '%s <deploy name> [options]'
746+ if not need_deploy_name :
747+ usage = '%s [options]'
748+ self .parser .set_usage (usage % self .prev_cmd )
746749 return self
747750
748751 def get_obd_namespaces_data (self , obd ):
@@ -837,6 +840,10 @@ def __init__(self):
837840 self .parser .allow_undefine = True
838841 self .parser .undefine_warn = False
839842
843+ def init (self , cmd , args , need_deploy_name = False ):
844+ super (DemoCommand , self ).init (cmd , args , need_deploy_name )
845+ return self
846+
840847 def _do_command (self , obd ):
841848 setattr (self .opts , 'force' , True )
842849 setattr (self .opts , 'clean' , True )
@@ -849,6 +856,33 @@ def _do_command(self, obd):
849856 return res
850857
851858
859+ class PrefCommand (ClusterMirrorCommand ):
860+
861+ def __init__ (self ):
862+ super (PrefCommand , self ).__init__ ('pref' , 'Quickly start' )
863+ self .parser .add_option ('-c' , '--components' , type = 'string' , help = "List the components. Multiple components are separated with commas. [oceanbase-ce,obproxy-ce,obagent,prometheus,grafana,ob-configserver]\n Example: \n start oceanbase-ce: obd demo -c oceanbase-ce\n "
864+ + "start -c oceanbase-ce V3.2.3: obd pref -c oceanbase-ce --oceanbase-ce.version=3.2.3\n "
865+ + "start oceanbase-ce and obproxy-ce: obd pref -c oceanbase-ce,obproxy-ce" , default = 'oceanbase-ce,obproxy-ce,obagent,prometheus,grafana' )
866+ self .parser .allow_undefine = True
867+ self .parser .undefine_warn = False
868+
869+ def init (self , cmd , args , need_deploy_name = False ):
870+ super (PrefCommand , self ).init (cmd , args , need_deploy_name )
871+ return self
872+
873+ def _do_command (self , obd ):
874+ setattr (self .opts , 'force' , True )
875+ setattr (self .opts , 'clean' , True )
876+ setattr (self .opts , 'force' , True )
877+ setattr (self .opts , 'force_delete' , True )
878+ setattr (self .opts , 'max' , True )
879+ obd .set_options (self .opts )
880+
881+ res = obd .demo (name = 'pref' )
882+ self .background_telemetry_task (obd , 'pref' )
883+ return res
884+
885+
852886class WebCommand (ObdCommand ):
853887
854888 def __init__ (self ):
@@ -916,20 +950,25 @@ def __init__(self):
916950 self .parser .add_option ('-C' , '--clean' , action = 'store_true' , help = "Clean the home path if the directory belong to you." , default = False )
917951 self .parser .add_option ('-U' , '--unuselibrepo' , '--ulp' , action = 'store_true' , help = "Disable OBD from installing the libs mirror automatically." )
918952 self .parser .add_option ('-A' , '--auto-create-tenant' , '--act' , action = 'store_true' , help = "Automatically create a tenant named `test` by using all the available resource of the cluster." )
953+ self .parser .add_option ('-i' , '--interactive' , action = 'store_true' , help = "Interactive deployment cluster, including deployment and startup." )
919954 # self.parser.add_option('-F', '--fuzzymatch', action='store_true', help="enable fuzzy match when search package")
920955
921956 def _do_command (self , obd ):
922- if self .cmds :
923- if getattr (self .opts , 'force' , False ) or getattr (self .opts , 'clean' , False ):
924- setattr (self .opts , 'skip_cluster_status_check' , True )
925- obd .set_options (self .opts )
926- res = obd .deploy_cluster (self .cmds [0 ])
927- self .background_telemetry_task (obd )
928- if res and COMMAND_ENV .get (const .INTERACTIVE_INSTALL , '0' ) == '0' :
929- obd .stdio .print (FormatText .success ('Please execute ` obd cluster start %s ` to start' % self .cmds [0 ]))
930- return res
957+ if getattr (self .opts , 'interactive' ):
958+ name = self .cmds [0 ] if self .cmds else ''
959+ return obd .interactive_deploy (name )
931960 else :
932- return self ._show_help ()
961+ if self .cmds :
962+ if getattr (self .opts , 'force' , False ) or getattr (self .opts , 'clean' , False ):
963+ setattr (self .opts , 'skip_cluster_status_check' , True )
964+ obd .set_options (self .opts )
965+ res = obd .deploy_cluster (self .cmds [0 ])
966+ self .background_telemetry_task (obd )
967+ if res and COMMAND_ENV .get (const .INTERACTIVE_INSTALL , '0' ) == '0' :
968+ obd .stdio .print (FormatText .success ('Please execute ` obd cluster start %s ` to start' % self .cmds [0 ]))
969+ return res
970+ else :
971+ return self ._show_help ()
933972
934973
935974class ClusterScaleoutCommand (ClusterMirrorCommand ):
@@ -2803,6 +2842,7 @@ def __init__(self):
28032842 super (MainCommand , self ).__init__ ('obd' , '' )
28042843 self .register_command (DevModeMajorCommand ())
28052844 self .register_command (DemoCommand ())
2845+ self .register_command (PrefCommand ())
28062846 self .register_command (WebCommand ())
28072847 self .register_command (MirrorMajorCommand ())
28082848 self .register_command (ClusterMajorCommand ())
0 commit comments