def action(action_name, force=False): """ Run a single action. """ with lcd(env.DIR): vagrant = Vagrant(env.DIR) with vagrant.session(timeout=30): puts(green('Vagrant session running.')) for action in actions: if action.name == action_name: action.vagrant = vagrant with cd('~'): if not force: puts(magenta('Testing task %s...' % (action.name, ))) if action.test(): force = 'run' else: force = 'fail' if force == 'run': puts(cyan('Running task %s:run' % (action.name, ))) action.run() elif force == 'fail': puts(yellow('Running task %s:fail' % (action.name, ))) action.fail()
def provision(): if path.exists(env.DIR): if confirm('%s exists, delete?' % env.DIR, default=False): if confirm('Destroy VM too?', default=False): with lcd(env.DIR): local('vagrant destroy', capture=False) local('rm -Rf %s' % env.DIR) if not path.exists(env.DIR): os.makedirs(env.DIR) shutil.copy('Vagrantfile', env.DIR) with lcd(env.DIR): vagrant = Vagrant(env.DIR) with vagrant.session(timeout=30): puts(green('Vagrant session running.')) for action in actions: action.vagrant = vagrant puts(magenta('Testing task %s...' % (action.name, ))) with cd('~'): if action.test(): puts(cyan('Running task %s:run' % (action.name, ))) action.run() else: puts(yellow('Running task %s:fail' % (action.name, ))) action.fail()
def test(action_name): """ Test a single action. """ with lcd(env.DIR): vagrant = Vagrant(env.DIR) with vagrant.session(timeout=30): puts(green('Vagrant session running.')) for action in actions: if action.name == action_name: action.vagrant = vagrant puts(magenta('Testing task %s...' % (action.name, ))) with cd('~'): if action.test(): puts(green('Test passed')) else: puts(red('Test failed'))