<s> import logging <EOL> from util import full_stack <EOL> from time import sleep <EOL> from workflow . steps . util . base import BaseStep <EOL> from workflow . exceptions . error_codes import DBAAS_0021 <EOL> from workflow . steps . util . restore_snapshot import use_database_initialization_script <EOL> LOG = logging . getLogger ( __name__ ) <EOL> class StartDatabase ( BaseStep ) : <EOL> def __unicode__ ( self ) : <EOL> return "<STR_LIT>" <EOL> def do ( self , workflow_dict ) : <EOL> try : <EOL> databaseinfra = workflow_dict [ '<STR_LIT>' ] <EOL> host = workflow_dict [ '<STR_LIT:host>' ] <EOL> hosts = [ host , ] <EOL> if workflow_dict [ '<STR_LIT>' ] >= <NUM_LIT:1> : <EOL> hosts . extend ( workflow_dict [ '<STR_LIT>' ] ) <EOL> for host in hosts : <EOL> return_code , output = use_database_initialization_script ( databaseinfra = databaseinfra , <EOL> host = host , <EOL> option = '<STR_LIT:start>' ) <EOL> if return_code != <NUM_LIT:0> : <EOL> raise Exception ( str ( output ) ) <EOL> LOG . info ( '<STR_LIT>' ) <EOL> sleep ( <NUM_LIT> ) <EOL> return True <EOL> except Exception : <EOL> traceback = full_stack ( ) <EOL> workflow_dict [ '<STR_LIT>' ] [ '<STR_LIT>' ] . append ( DBAAS_0021 ) <EOL> workflow_dict [ '<STR_LIT>' ] [ '<STR_LIT>' ] . append ( traceback ) <EOL> return False <EOL> def undo ( self , workflow_dict ) : <EOL> LOG . info ( "<STR_LIT>" ) <EOL> try : <EOL> databaseinfra = workflow_dict [ '<STR_LIT>' ] <EOL> host = workflow_dict [ '<STR_LIT:host>' ] <EOL> hosts = [ host , ] <EOL> if workflow_dict [ '<STR_LIT>' ] >= <NUM_LIT:1> : <EOL> hosts . extend ( workflow_dict [ '<STR_LIT>' ] ) <EOL> for host in hosts : <EOL> return_code , output = use_database_initialization_script ( databaseinfra = databaseinfra , <EOL> host = host , <EOL> option = '<STR_LIT>' ) <EOL> if return_code != <NUM_LIT:0> : <EOL> LOG . info ( str ( output ) ) <EOL> return True <EOL> except Exception : <EOL> traceback = full_stack ( ) <EOL> workflow_dict [ '<STR_LIT>' ] [ '<STR_LIT>' ] . append ( DBAAS_0021 ) <EOL> workflow_dict [ '<STR_LIT>' ] [ '<STR_LIT>' ] . append ( traceback ) <EOL> return False </s>
