def pai_service(): if len(sys.argv) < 2: pai_service_info() return option = sys.argv[1] del sys.argv[1] if option not in ["start", "delete", "stop", "refresh"]: pai_service_info() return parser = argparse.ArgumentParser() parser.add_argument('-p', '--config-path', dest="config_path", required=True, help="The path of your configuration directory.") parser.add_argument('-n', '--service-name', dest="service_name", default='all', help="Build and push the target image to the registry") args = parser.parse_args(sys.argv[1:]) config_path = args.config_path service_name = args.service_name cluster_object_model = cluster_object_model_generate_service(config_path) cluster_object_model_k8s = cluster_object_model_generate_k8s(config_path) service_list = None if service_name != "all": service_list = [service_name] # Tricky , re-install kubectl first. # TODO: install kubectl-install here. if kubectl_env_checking(cluster_object_model_k8s) == False: return if option == "start": service_management_starter = service_management_start.serivce_management_start( cluster_object_model, service_list) service_management_starter.run() if option == "delete": service_management_deleter = service_management_delete.service_management_delete( cluster_object_model, service_list) service_management_deleter.run() if option == "stop": service_management_stopper = service_management_stop.service_management_stop( cluster_object_model, service_list) service_management_stopper.run() if option == "refresh": service_management_refresher = service_management_refresh.service_management_refresh( cluster_object_model, service_list) service_management_refresher.run()
def service_delete(self, args): cluster_object_model, service_list = self.process_args(args) logger.warning( "--------------------------------------------------------") logger.warning( "--------------------------------------------------------") logger.warning( "---------- Dangerous Operation!!! ---------------") logger.warning( "------ The target service will be stopped -------") logger.warning( "------ And the persistent data on the disk -------") logger.warning( "------- will be deleted --------") logger.warning( "--------------------------------------------------------") logger.warning( "--------------------------------------------------------") logger.warning( "-------- It's an irreversible operation -------") logger.warning( "-------- After this operation, -------") logger.warning( "------ the deleted service data is unrecoverable -------") logger.warning( "--------------------------------------------------------") logger.warning( "--------------------------------------------------------") logger.warning( "---- Please ensure you wanna do this operator, ------") logger.warning( "------- after knowing all risk above. -------") logger.warning( "--------------------------------------------------------") logger.warning( "--------------------------------------------------------") count_input = 0 while True: user_input = raw_input( "Do you want to continue this operation? (Y/N) ") if user_input == "N": return elif user_input == "Y": break else: print(" Please type Y or N.") count_input = count_input + 1 if count_input == 3: logger.warning( "3 Times......... Sorry, we will force stopping your operation." ) return service_management_deleter = service_management_delete.service_management_delete( cluster_object_model, service_list) service_management_deleter.run()