#NEWLINE# def do( self , workflow_dict ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# databaseinfra = workflow_dict [ 'databaseinfra' ] #NEWLINE# driver = databaseinfra . get_driver ( ) #NEWLINE# sentinel = driver . get_sentinel_client ( ) #NEWLINE# master = sentinel . discover_master ( databaseinfra . name ) #NEWLINE# master_host = master [ 0 ] #NEWLINE# master_port = master [ 1 ] #NEWLINE# for ( index , source_host ) in enumerate ( workflow_dict [ 'source_hosts' ] ) : #NEWLINE# #INDENT# target_host = source_host . future_host #NEWLINE# target_cs_host_attr = CS_HostAttr . objects . get ( host = target_host ) #NEWLINE# script = test_bash_script_error ( ) #NEWLINE# script += build_start_stop_scripts ( ) #NEWLINE# if ( index < 2 ) : #NEWLINE# #INDENT# script += build_start_database_script ( ) #NEWLINE# #UNINDENT# script += build_start_sentinel_script ( ) #NEWLINE# script += build_start_http_script ( ) #NEWLINE# script = build_context_script ( { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , script ) #NEWLINE# output = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# LOG . info ( script ) #NEWLINE# return_code = exec_remote_command ( server = target_host . address , username = target_cs_host_attr . vm_user , password = target_cs_host_attr . vm_password , command = script , output = output ) #NEWLINE# LOG . info ( output ) #NEWLINE# if ( return_code != 0 ) : #NEWLINE# #INDENT# raise Exception ( str ( output ) ) #NEWLINE# #UNINDENT# #UNINDENT# for target_instance in workflow_dict [ 'target_instances' ] : #NEWLINE# #INDENT# if ( target_instance . instance_type == target_instance . REDIS ) : #NEWLINE# #INDENT# LOG . info ( 'Changing master of host: {}' . format ( target_instance . address ) ) #NEWLINE# client = driver . get_client ( target_instance ) #NEWLINE# client . slaveof ( master_host , master_port ) #NEWLINE# LOG . info ( 'New master: {}:{}' . format ( master_host , master_port ) ) #NEWLINE# #UNINDENT# #UNINDENT# return True #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# traceback = full_stack ( ) #NEWLINE# workflow_dict [ 'exceptions' ] [ 'error_codes' ] . append ( DBAAS_0020 ) #NEWLINE# workflow_dict [ 'exceptions' ] [ 'traceback' ] . append ( traceback ) #NEWLINE# return False