#NEWLINE# def deploy( self , mode ) : #NEWLINE# #INDENT# if ( not mode ) : #NEWLINE# #INDENT# mode = 'single-node' #NEWLINE# #UNINDENT# success = True #NEWLINE# deploy_path = os . path . join ( self . path , 'deploy' ) #NEWLINE# if os . path . isdir ( deploy_path ) : #NEWLINE# #INDENT# shutil . rmtree ( deploy_path ) #NEWLINE# #UNINDENT# os . mkdir ( deploy_path ) #NEWLINE# services = self . services #NEWLINE# app_params = self . get_app_params ( ) #NEWLINE# templates_path = os . path . join ( MainSettings . ROOT , 'templates' ) #NEWLINE# template_names = [ 'namespace.json' , 'pod.json' , 'service-pod.json' , 'notebook.json' , 'controller.json' , 'service.json' ] #NEWLINE# templates = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for name in deployed_service : #NEWLINE# #INDENT# with open ( os . path . join ( templates_path , name ) , 'r' ) as tf : #NEWLINE# #INDENT# templates [ name ] = tf . read ( ) #NEWLINE# #UNINDENT# #UNINDENT# with open ( os . path . join ( deploy_path , 'notebook.json' ) , 'w+' ) as nb_file : #NEWLINE# #INDENT# nb_string = fill_template_string ( templates [ 'notebook.json' ] , app_params ) #NEWLINE# nb_file . write ( nb_string ) #NEWLINE# #UNINDENT# with open ( os . path . join ( deploy_path , 'namespace.json' ) , 'w+' ) as ns_file : #NEWLINE# #INDENT# ns_string = fill_template_string ( templates [ 'namespace.json' ] , app_params ) #NEWLINE# ns_file . write ( ns_string ) #NEWLINE# #UNINDENT# for service in services : #NEWLINE# #INDENT# deployed_service = service . deploy ( mode , deploy_path , self , templates ) #NEWLINE# if ( not deployed_service ) : #NEWLINE# #INDENT# success = False #NEWLINE# #UNINDENT# #UNINDENT# redirect_url = ClusterManager . get_instance ( ) . deploy_app ( self . app_id , deploy_path ) #NEWLINE# if ( not redirect_url ) : #NEWLINE# #INDENT# success = False #NEWLINE# #UNINDENT# if success : #NEWLINE# #INDENT# app_id = app_params [ 'app.id' ] #NEWLINE# msg = 'Successfully deployed app {0} in {1} mode with ID {2}' . format ( self . name , mode , app_id ) #NEWLINE# info_log ( self . TAG , msg ) #NEWLINE# return redirect_url #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# error_log ( self . TAG , 'Failed to deploy app {0} in {1} mode.' . format ( self . name , mode ) ) #NEWLINE# return None