@@ -573,7 +573,7 @@ def _do_start(self, name):
573573 LocalClient .execute_command_background ("nohup obd telemetry post %s --data='%s' > /dev/null &" % (name , json .dumps (data )))
574574
575575 def get_start_task_info (self , name ):
576- return self .get_task_info_log (name , "start" )
576+ return self .get_task_info_log_by_type (name , "start" )
577577
578578 @serial ("stop" )
579579 def stop (self , name , background_tasks ):
@@ -585,7 +585,7 @@ def stop(self, name, background_tasks):
585585 background_tasks .add_task (self ._do_stop , name )
586586
587587 def get_stop_task_info (self , name ):
588- return self .get_task_info_log (name , "stop" )
588+ return self .get_task_info_log_by_type (name , "stop" )
589589
590590 @auto_register ("stop" )
591591 def _do_stop (self , name ):
@@ -603,43 +603,68 @@ def _do_stop(self, name):
603603 data [component ] = _ .get_variable ('run_result' )
604604 LocalClient .execute_command_background ("nohup obd telemetry post %s --data='%s' > /dev/null &" % (name , json .dumps (data )))
605605
606- def get_task_info_log (self , name , task_type ):
606+ def get_task_info_log_by_type (self , name , task_type ):
607607 task_info = task .get_task_manager ().get_task_info (name , task_type = task_type )
608608 if task_info is None :
609609 raise Exception ("task {0} not found" .format (name ))
610610 deploy = self .get_deploy (name )
611611 components = deploy .deploy_config .components
612- total_count = (len (const .START_PLUGINS ) + len (const .INIT_PLUGINS )) * len (components )
612+ total_count = 0
613+ if task_type == const .TASK_TYPE_INSTALL :
614+ total_count = (len (const .START_PLUGINS ) + len (const .INIT_PLUGINS )) * len (components )
615+ elif task_type == const .TASK_TYPE_START :
616+ total_count = len (const .START_PLUGINS ) * len (components )
617+ elif task_type == const .TASK_TYPE_STOP :
618+ total_count = len (const .STOP_PLUGINS ) * len (components )
613619 finished_count = 0
614620 current = ""
615621 task_result = TaskResult .RUNNING
616622 info_dict = dict ()
617623
618624 for component in components :
619- info_dict [component ] = ComponentInfo (component = component , status = TaskStatus .PENDING ,
620- result = TaskResult .RUNNING )
621- if component in self .obd .namespaces :
622- for plugin in const .INIT_PLUGINS :
625+ info_dict [component ] = ComponentInfo (component = component , status = TaskStatus .PENDING ,
626+ result = TaskResult .RUNNING )
627+
628+ if task_type == const .TASK_TYPE_INSTALL :
629+ for component in components :
630+ if component in self .obd .namespaces :
631+ for plugin in const .INIT_PLUGINS :
632+ if self .obd .namespaces [component ].get_return (plugin ) is not None :
633+ info_dict [component ].status = TaskStatus .RUNNING
634+ finished_count += 1
635+ current = "{0}: {1} finished" .format (component , plugin )
636+ if not self .obd .namespaces [component ].get_return (plugin ):
637+ info_dict [component ].result = TaskResult .FAILED
638+
639+ if task_type == const .TASK_TYPE_INSTALL or task_type == const .TASK_TYPE_START :
640+ for component in components :
641+ for plugin in const .START_PLUGINS :
642+ if component not in self .obd .namespaces :
643+ break
623644 if self .obd .namespaces [component ].get_return (plugin ) is not None :
624645 info_dict [component ].status = TaskStatus .RUNNING
625646 finished_count += 1
626647 current = "{0}: {1} finished" .format (component , plugin )
627648 if not self .obd .namespaces [component ].get_return (plugin ):
628649 info_dict [component ].result = TaskResult .FAILED
629-
630- for component in components :
631- for plugin in const .START_PLUGINS :
632- if component not in self .obd .namespaces :
633- break
634- if self .obd .namespaces [component ].get_return (plugin ) is not None :
635- info_dict [component ].status = TaskStatus .RUNNING
636- finished_count += 1
637- current = "{0}: {1} finished" .format (component , plugin )
638- if not self .obd .namespaces [component ].get_return (plugin ):
639- info_dict [component ].result = TaskResult .FAILED
640- else :
641- if plugin == const .START_PLUGINS [- 1 ]:
642- info_dict [component ].result = TaskResult .SUCCESSFUL
650+ else :
651+ if plugin == const .START_PLUGINS [- 1 ]:
652+ info_dict [component ].result = TaskResult .SUCCESSFUL
653+
654+ if task_type == const .TASK_TYPE_STOP :
655+ for component in components :
656+ for plugin in const .STOP_PLUGINS :
657+ if component not in self .obd .namespaces :
658+ break
659+ if self .obd .namespaces [component ].get_return (plugin ) is not None :
660+ info_dict [component ].status = TaskStatus .RUNNING
661+ finished_count += 1
662+ current = "{0}: {1} finished" .format (component , plugin )
663+ if not self .obd .namespaces [component ].get_return (plugin ):
664+ info_dict [component ].result = TaskResult .FAILED
665+ else :
666+ if plugin == const .STOP_PLUGINS [- 1 ]:
667+ info_dict [component ].result = TaskResult .SUCCESSFUL
643668
644669 if task_info .status == TaskStatus .FINISHED :
645670 task_result = task_info .result
@@ -655,7 +680,7 @@ def get_task_info_log(self, name, task_type):
655680 msg = msg )
656681
657682 def get_install_task_info (self , name ):
658- return self .get_task_info_log (name , "install" )
683+ return self .get_task_info_log_by_type (name , "install" )
659684
660685 def __build_connection_info (self , component , info ):
661686 if info is None :
0 commit comments