<s> import logging <EOL> from dbaas_cloudstack . models import HostAttr <EOL> from util import exec_remote_command <EOL> from workflow . exceptions . error_codes import DBAAS_0015 <EOL> from util import full_stack <EOL> from util import build_context_script <EOL> LOG = logging . getLogger ( __name__ ) <EOL> def run_vm_script ( workflow_dict , context_dict , script ) : <EOL> try : <EOL> final_context_dict = dict ( context_dict . items ( ) ) <EOL> instance = workflow_dict [ '<STR_LIT>' ] <EOL> host = workflow_dict [ '<STR_LIT:host>' ] <EOL> host_csattr = HostAttr . objects . get ( host = host ) <EOL> final_context_dict [ '<STR_LIT>' ] = instance . address <EOL> final_context_dict [ '<STR_LIT>' ] = instance . port <EOL> final_context_dict [ '<STR_LIT>' ] = workflow_dict [ '<STR_LIT>' ] . password <EOL> command = build_context_script ( final_context_dict , script ) <EOL> output = { } <EOL> return_code = exec_remote_command ( server = host . address , <EOL> username = host_csattr . vm_user , <EOL> password = host_csattr . vm_password , <EOL> command = command , <EOL> output = output ) <EOL> if return_code : <EOL> raise Exception ( "<STR_LIT>" . format ( output ) ) <EOL> return True <EOL> except Exception : <EOL> traceback = full_stack ( ) <EOL> workflow_dict [ '<STR_LIT>' ] [ '<STR_LIT>' ] . append ( DBAAS_0015 ) <EOL> workflow_dict [ '<STR_LIT>' ] [ '<STR_LIT>' ] . append ( traceback ) <EOL> return False </s>
