<s> import logging <EOL> from util import full_stack <EOL> from util import exec_remote_command <EOL> from util import build_context_script <EOL> from dbaas_cloudstack . models import HostAttr as CS_HostAttr <EOL> from workflow . steps . util . base import BaseStep <EOL> from workflow . exceptions . error_codes import DBAAS_0023 <EOL> from workflow . steps . util import test_bash_script_error <EOL> from workflow . steps . mongodb . util import build_enable_authentication_single_instance_script <EOL> from workflow . steps . mongodb . util import build_mongorestore_database_script <EOL> from workflow . steps . mongodb . util import build_change_mongodb_conf_file_script <EOL> from workflow . steps . mongodb . util import build_restart_database_script <EOL> from workflow . steps . mongodb . util import build_start_database_script <EOL> from workflow . steps . mongodb . util import build_stop_database_script <EOL> from workflow . steps . mongodb . util import build_clean_data_data_script <EOL> from workflow . steps . util import td_agent_script <EOL> LOG = logging . getLogger ( __name__ ) <EOL> class ChangeMongoDBStorageEngine ( BaseStep ) : <EOL> def __unicode__ ( self ) : <EOL> return "<STR_LIT>" <EOL> def do ( self , workflow_dict ) : <EOL> try : <EOL> instances = workflow_dict [ '<STR_LIT>' ] <EOL> script = test_bash_script_error ( ) <EOL> script += build_change_mongodb_conf_file_script ( ) <EOL> script += build_stop_database_script ( clean_data = False ) <EOL> script += build_clean_data_data_script ( ) <EOL> script += build_start_database_script ( ) <EOL> script += build_mongorestore_database_script ( ) <EOL> script += build_enable_authentication_single_instance_script ( ) <EOL> script += build_restart_database_script ( ) <EOL> script += td_agent_script ( option = '<STR_LIT>' ) <EOL> context_dict = { <EOL> } <EOL> script = build_context_script ( context_dict , script ) <EOL> output = { } <EOL> host = instances [ <NUM_LIT:0> ] . hostname <EOL> cs_host_attr = CS_HostAttr . objects . get ( host = host ) <EOL> return_code = exec_remote_command ( server = host . address , <EOL> username = cs_host_attr . vm_user , <EOL> password = cs_host_attr . vm_password , <EOL> command = script , <EOL> output = output ) <EOL> LOG . info ( output ) <EOL> if return_code != <NUM_LIT:0> : <EOL> raise Exception ( str ( output ) ) <EOL> return True <EOL> except Exception : <EOL> traceback = full_stack ( ) <EOL> workflow_dict [ '<STR_LIT>' ] [ '<STR_LIT>' ] . append ( DBAAS_0023 ) <EOL> workflow_dict [ '<STR_LIT>' ] [ '<STR_LIT>' ] . append ( traceback ) <EOL> return False <EOL> def undo ( self , workflow_dict ) : <EOL> return True </s>
