<s> from fabric . api import * <EOL> from fabric . state import env , output <EOL> from fabric . tasks import execute <EOL> from testmill import fabric as ravello <EOL> output . output = False <EOL> @ task <EOL> def provision ( name ) : <EOL> app = ravello . get_application ( name ) <EOL> if app : <EOL> print ( '<STR_LIT>' <EOL> . format ( name ) ) <EOL> ravello . start_application ( name , wait = True ) <EOL> else : <EOL> vms = [ ] <EOL> vms . append ( { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:image>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT> } ) <EOL> vms . append ( { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:image>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : [ '<STR_LIT:http>' , '<STR_LIT>' ] } ) <EOL> print ( '<STR_LIT>' . format ( name ) ) <EOL> app = ravello . create_application ( name , vms = vms ) <EOL> env . hosts = ravello . lookup ( name ) <EOL> env . application_name = name <EOL> print ( '<STR_LIT>' <EOL> . format ( name , app [ '<STR_LIT>' ] , app [ '<STR_LIT>' ] , len ( app [ '<STR_LIT>' ] ) ) ) <EOL> @ task <EOL> @ parallel <EOL> def update ( ) : <EOL> sudo ( '<STR_LIT>' , quiet = True ) <EOL> sudo ( '<STR_LIT>' , quiet = True ) <EOL> @ task <EOL> @ parallel <EOL> def setup ( ) : <EOL> put ( '<STR_LIT>' ) <EOL> appname , vmname = ravello . reverse_lookup ( env . host ) <EOL> with cd ( '<STR_LIT>' ) : <EOL> sudo ( '<STR_LIT>' . format ( vmname ) ) <EOL> @ task <EOL> @ ravello . only_on ( '<STR_LIT>' ) <EOL> def push ( ) : <EOL> put ( '<STR_LIT>' ) <EOL> sudo ( '<STR_LIT>' , quiet = True ) <EOL> sudo ( '<STR_LIT>' ) <EOL> env . web_host = env . host <EOL> @ task ( default = True ) <EOL> def deploy ( name = '<STR_LIT>' ) : <EOL> execute ( provision , name ) <EOL> execute ( update ) <EOL> execute ( setup ) <EOL> execute ( push ) <EOL> print ( '<STR_LIT>' <EOL> . format ( env . application_name , env . web_host ) ) </s>
