<s> import logging <EOL> from util import gen_infra_names <EOL> from util import full_stack <EOL> from util . providers import get_engine_credentials <EOL> from physical . models import DatabaseInfra <EOL> from . . base import BaseStep <EOL> from ... . exceptions . error_codes import DBAAS_0002 <EOL> LOG = logging . getLogger ( __name__ ) <EOL> class BuildDatabaseInfra ( BaseStep ) : <EOL> def __unicode__ ( self ) : <EOL> return "<STR_LIT>" <EOL> def do ( self , workflow_dict ) : <EOL> try : <EOL> workflow_dict [ '<STR_LIT>' ] = gen_infra_names ( <EOL> name = workflow_dict [ '<STR_LIT:name>' ] , qt = workflow_dict [ '<STR_LIT>' ] ) <EOL> databaseinfra = DatabaseInfra ( ) <EOL> databaseinfra . name = workflow_dict [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> credentials = get_engine_credentials ( engine = str ( workflow_dict [ '<STR_LIT>' ] . engine_type ) , <EOL> environment = workflow_dict [ '<STR_LIT>' ] ) <EOL> databaseinfra . user = credentials . user <EOL> databaseinfra . password = credentials . password <EOL> databaseinfra . engine = workflow_dict [ <EOL> '<STR_LIT>' ] . engine <EOL> databaseinfra . plan = workflow_dict [ '<STR_LIT>' ] <EOL> databaseinfra . environment = workflow_dict [ '<STR_LIT>' ] <EOL> databaseinfra . capacity = <NUM_LIT:1> <EOL> databaseinfra . per_database_size_mbytes = workflow_dict [ <EOL> '<STR_LIT>' ] . max_db_size <EOL> databaseinfra . save ( ) <EOL> LOG . info ( "<STR_LIT>" ) <EOL> workflow_dict [ '<STR_LIT>' ] = databaseinfra <EOL> return True <EOL> except Exception : <EOL> traceback = full_stack ( ) <EOL> workflow_dict [ '<STR_LIT>' ] [ '<STR_LIT>' ] . append ( DBAAS_0002 ) <EOL> workflow_dict [ '<STR_LIT>' ] [ '<STR_LIT>' ] . append ( traceback ) <EOL> return False <EOL> def undo ( self , workflow_dict ) : <EOL> try : <EOL> if '<STR_LIT>' in workflow_dict : <EOL> LOG . info ( "<STR_LIT>" ) <EOL> workflow_dict [ '<STR_LIT>' ] . delete ( ) <EOL> return True <EOL> except Exception : <EOL> traceback = full_stack ( ) <EOL> workflow_dict [ '<STR_LIT>' ] [ '<STR_LIT>' ] . append ( DBAAS_0002 ) <EOL> workflow_dict [ '<STR_LIT>' ] [ '<STR_LIT>' ] . append ( traceback ) <EOL> return False </s>
