def pyflakes(): """ Does a syntax and code-style check on the python code of this project using pyflakes. """ with show('everything'): local("pyflakes . | grep -v smaclib/api | grep -v example/gen-py", capture=False)
def action_rm_34_1_symlinks(master): with show('running'): run('rm -f %(master_dir)s/release-firefox-mozilla-release-34.1.py' % master) run('rm -f %(master_dir)s/l10n-changesets_mozilla-release-34.1' % master) print OK, "Removed 34.1 symlinks in %(hostname)s:%(basedir)s" % master
def run(self): with settings(show('warnings', 'running', 'stdout', 'stderr'), warn_only=True): fab_lcd(dir_p) result = fab_local('ls -l', capture=True) print 'Current Environment :: %s' % (env) print result
def start(master): with show('running'): put(BUILDBOT_WRANGLER, '%s/buildbot-wrangler.py' % master['basedir']) run('rm -f *.pyc', workdir=master['basedir']) run('python buildbot-wrangler.py start %s' % master['master_dir'], workdir=master['basedir']) print OK, "started %(hostname)s:%(basedir)s" % master
def update_buildbot(master): with show('running'): buildbot_dir = os.path.dirname(master['buildbot_setup']) with cd(buildbot_dir): run('hg pull') run('hg update -r %s' % master['buildbot_branch']) run('unset PYTHONHOME PYTHONPATH; %s setup.py install' % master['buildbot_python'])
def action_add_esr52_symlinks(master): with show('running'): run('ln -s %(bbconfigs_dir)s/mozilla/release-thunderbird-comm-esr52.py ' '%(master_dir)s/' % master) run('ln -s %(bbconfigs_dir)s/mozilla/l10n-changesets_thunderbird-esr52 ' '%(master_dir)s/' % master) print OK, "Added esr52 symlinks in %(hostname)s:%(basedir)s" % master
def start(master): with show('running'): put(BUILDBOT_WRANGLER, '%s/buildbot-wrangler.py' % master['basedir']) run('rm -f *.pyc', workdir=master['basedir']) run('python buildbot-wrangler.py start %s' % master['master_dir'], workdir=master['basedir']) print OK, "started %(hostname)s:%(basedir)s" % master
def install_blueprint(ag='apt-get'): devs_repo = '/etc/apt/sources.list.d/devstructure.list' with settings( show('running', 'stdout', 'stderr'), warn_only=True, always_use_pty='false'): x = open('/etc/lsb-release').readlines() for line in x: if not line.find('DISTRIB_CODENAME') == -1: vers = line.split('=')[1].strip('\n') open(devs_repo,'wt')\ .write("deb http://packages.devstructure.com {0} main".format(vers)) inst_bluep = fab_local("wget -O {0} {1}".format( '/etc/apt/trusted.gpg.d/devstructure.gpg', 'http://packages.devstructure.com/keyring.gpg' )) ## Have to update here to install Blueprint, otherwise would ## save time not updating the cache. apt_upd = fab_local('apt-get update',capture=True) if apt_upd.succeeded: fab_local("{0} {1}".format(ag,'install --no-install-recommends --assume-yes blueprint'))
def _put_as_user(self, source, destination): for attempt in range(self.transfer_retries): retry = False try: with settings(show('everything'), warn_only=False): pout = put(source, destination, use_sudo=True) self._chown(destination) if pout.failed: raise Exception("Failed transfer: %s" % (pout)) else: basename = os.path.basename(destination) print(yellow("Sent file %s" % (basename))) except BaseException as e: retry = True print(red("Failed to upload %s on attempt %d" % (source, attempt + 1))) print(red(e)) except: # Should never get here, delete this block when more confident retry = True print(red("Failed to upload %s on attempt %d with unknown exception" % (source, attempt + 1))) finally: if not retry: return e = Exception("Failed to transfer file %s, exiting..." % source) print(red(e)) raise e
def _bootstrap(abs_bootstrap_dir_path): dir_name = os.path.basename(abs_bootstrap_dir_path) with show('debug'): run('mkdir -p /tmp/locust/') put(abs_bootstrap_dir_path, '/tmp/locust/') sudo("chmod +x /tmp/locust/{0}/bootstrap.sh".format(dir_name)) sudo("/tmp/locust/{0}/bootstrap.sh".format(dir_name))
def run_build(repo_name): with cd('/vagrant/' + repo_name), show('output'), hide('running', 'warnings'): # this is needed in order to add github to known_hosts run('ssh-keyscan -H github.com >> ~/.ssh/known_hosts') result = run('$BUILD_HOME/run.bash', pty=True) return result.return_code
def install_db_patches(): with prefix(env.activate): with prefix(env.proj_pythonpath): with show('stdout'): print green("Installing db_patches") src = os.path.join(env.proj_dir, 'src', 'install_db_patches.py') run('python %s update' % src)
def send_blueprint_script(src_path,target_path): with settings(show('warnings', 'running', 'stdout', 'stderr'), warn_only=False, shell='/bin/bash -lc', user='******', ): ## try/except wrapped check to validate existance of local file try: with open(src_path, 'rt') as f: f.readline() except IOError as e: print "I/O error [{0}] {1}: {2}".format(e.errno, e.strerror, e.filename) sys_exit(1) test_exist = fab_run('ls -l %s' % (target_path)) if test_exist.succeeded: replace_yesno = fab_prompt( 'File <{0}> already Exists. OK to Replace? [yes/no]'.format(target_path), default='no') if debug == True: print 'You said [{0}], exiting.'.format(replace_yesno) if 'yes' in replace_yesno.lower(): replace_yesno = True else: replace_yesno = False #ch = lambda x: 'yes' if x == True else 'no' sys_exit(0) test = fab_put(src_path,target_path,use_sudo=False, mirror_local_mode=False, mode=None) else: test = fab_run('[ -f %s ]' % (lsbdata))
def action_rm_34_1_symlinks(master): with show('running'): run('rm -f %(master_dir)s/release-firefox-mozilla-release-34.1.py' % master) run('rm -f %(master_dir)s/l10n-changesets_mozilla-release-34.1' % master) print OK, "Removed 34.1 symlinks in %(hostname)s:%(basedir)s" % master
def start(master): with show('running'): with cd(master['basedir']): put('buildbot-wrangler.py', '%s/buildbot-wrangler.py' % master['basedir']) run('rm -f *.pyc') run('python buildbot-wrangler.py start %s' % master['master_dir'])
def action_stop(master): with show('running'): with cd(master['basedir']): put(BUILDBOT_WRANGLER, '%s/buildbot-wrangler.py' % master['basedir']) run('python buildbot-wrangler.py stop %s' % master['master_dir']) print OK, "stopped %(hostname)s:%(basedir)s" % master
def _bootstrap(abs_bootstrap_dir_path): dir_name = os.path.basename(abs_bootstrap_dir_path) with show('debug'): run('mkdir -p /tmp/locust/') put(abs_bootstrap_dir_path, '/tmp/locust/') sudo("chmod +x /tmp/locust/{0}/bootstrap.sh".format(dir_name)) sudo("/tmp/locust/{0}/bootstrap.sh".format(dir_name))
def execute( script, name=None, verbose=True, shell=True, pty=True, combine_stderr=True, dir=None ): """Run arbitrary scripts on a remote host.""" script = dedent(script).strip() if verbose: prefix = "[%s]" % env.host_string if env.colors: prefix = env.color_settings['host_prefix'](prefix) print("%s run: %s" % (prefix, name or script)) name = name or DEFAULT_SCRIPT_NAME with hide('running', 'stdout', 'stderr'): run('cat > ' + name + ' << FABEND\n' + script + '\nFABEND\n', dir=dir) run('chmod +x ' + name, dir=dir) try: if verbose > 1: with show('stdout', 'stderr'): output = run('./' + name, shell, pty, combine_stderr, dir) else: output = run('./' + name, shell, pty, combine_stderr, dir) finally: run('rm ' + name, dir=dir) return output
def action_update_queue(host): with show('running'): queue_dir = "/builds/buildbot/queue" tools_dir = "%s/tools" % queue_dir with cd(tools_dir): run('hg pull -u') print OK, "updated queue in %s" % host
def wrapper(*args, **kwargs): # iterates and executes the wrapped function/testcase # for each one of the vagrant images. # ex: centos, ubuntu-vivid, ubuntu-trusty for image in images: vagrant_up(image=image) user, ip, port, pkey = vagrant_ssh_config() hs = build_host_string(user, ip, port) # set some fabric settings to either be very verbose # or very quiet. if verbose: fabric_flags = show('debug') else: fabric_flags = hide('everything') with settings(fabric_flags, host_string=hs, key_filename=pkey, disable_known_hosts=True): try: print("In method: %s for vagrant image %s" % ( func.func_name, image)) func(*args, **kwargs) vagrant_destroy() except: vagrant_destroy() raise
def execute( script, name=None, verbose=True, shell=True, pty=True, combine_stderr=True, dir=None ): """Run arbitrary scripts on a remote host.""" script = dedent(script).strip() if verbose: prefix = "[%s]" % env.host_string if env.colors: prefix = env.color_settings['host_prefix'](prefix) print("%s run: %s" % (prefix, name or script)) name = name or DEFAULT_SCRIPT_NAME with hide('running', 'stdout', 'stderr'): run('cat > ' + name + ' << FABEND\n' + script + '\nFABEND\n', dir=dir) run('chmod +x ' + name, dir=dir) try: if verbose > 1: with show('stdout', 'stderr'): output = run('./' + name, shell, pty, combine_stderr, dir) else: output = run('./' + name, shell, pty, combine_stderr, dir) finally: run('rm ' + name, dir=dir) return output
def action_add_esr52_symlinks(master): with show('running'): run('ln -s %(bbconfigs_dir)s/mozilla/release-thunderbird-comm-esr52.py ' '%(master_dir)s/' % master) run('ln -s %(bbconfigs_dir)s/mozilla/l10n-changesets_thunderbird-esr52 ' '%(master_dir)s/' % master) print OK, "Added esr52 symlinks in %(hostname)s:%(basedir)s" % master
def graceful_restart(master): with show('running'): with cd(master['basedir']): put('buildbot-wrangler.py', '%s/buildbot-wrangler.py' % master['basedir']) run('rm -f *.pyc') run('python buildbot-wrangler.py graceful_restart %s %s' % (master['master_dir'], master['http_port']))
def action_update_master_config(master): """Update buildbot master_conf.json""" with show('running'): run('python buildbot-configs/update-master-json.py %s master/master_config.json' % PRODUCTION_MASTERS_URL, workdir=master['basedir']) print OK, \ "finished, the master_config.json file has been updated on %s" % master['hostname']
def update_buildbot(master): with show('running'): buildbot_dir = os.path.dirname(master['buildbot_setup']) with cd(buildbot_dir): run('hg pull') run('hg update -r %s' % master['buildbot_branch']) run('unset PYTHONHOME PYTHONPATH; %s setup.py install' % master['buildbot_python'])
def action_update_buildbot(master): with show('running'): buildbot_dir = os.path.dirname(master['buildbot_setup']) run('hg pull', workdir=buildbot_dir) run('hg update -r %s' % master['buildbot_branch'], workdir=buildbot_dir) run('unset PYTHONHOME PYTHONPATH; %s setup.py install' % master['buildbot_python'], workdir=buildbot_dir) print OK, "updated buildbot in %(hostname)s:%(basedir)s" % master
def install_packages(pkgs_list): """Given a list of packages will install them""" utils.apt_get_update() pkgs_string = "" for pkg in pkgs_list: pkgs_string += " {}".format(pkg) with show('stdout', 'stderr'): sudo('apt-get install {}'.format(pkgs_string))
def reconfig(master): print "starting reconfig of %(hostname)s:%(basedir)s" % master with show('running'): with cd(master['basedir']): put('buildbot-wrangler.py', '%s/buildbot-wrangler.py' % master['basedir']) run('rm -f *.pyc') run('python buildbot-wrangler.py reconfig %s' % master['master_dir']) print "finished reconfig of %(hostname)s:%(basedir)s" % master
def action_update_buildbot(master): with show('running'): buildbot_dir = os.path.dirname(master['buildbot_setup']) run('hg pull', workdir=buildbot_dir) run('hg update -r %s' % master['buildbot_branch'], workdir=buildbot_dir) run('unset PYTHONHOME PYTHONPATH; %s setup.py install' % master['buildbot_python'], workdir=buildbot_dir) print OK, "updated buildbot in %(hostname)s:%(basedir)s" % master
def action_graceful_stop(master): with show('running'): put(BUILDBOT_WRANGLER, '%s/buildbot-wrangler.py' % master['basedir']) run('rm -f *.pyc', workdir=master['basedir']) run('python buildbot-wrangler.py graceful_stop %s %s' % (master['master_dir'], master['http_port']), workdir=master['basedir']) print OK, "gracefully stopped %(hostname)s:%(basedir)s" % master
def action_graceful_stop(master): with show('running'): put(BUILDBOT_WRANGLER, '%s/buildbot-wrangler.py' % master['basedir']) run('rm -f *.pyc', workdir=master['basedir']) run('python buildbot-wrangler.py graceful_stop %s %s' % (master['master_dir'], master['http_port']), workdir=master['basedir']) print OK, "gracefully stopped %(hostname)s:%(basedir)s" % master
def action_update(master): print "sleeping 30 seconds to make sure that hg.m.o syncs NFS... ", time.sleep(30) print OK with show('running'): retry(run, args=('source bin/activate && make update',), kwargs={'workdir': master['basedir']}, sleeptime=10, retry_exceptions=(SystemExit,)) print OK, "updated %(hostname)s:%(basedir)s" % master
def action_update(master): print "sleeping 30 seconds to make sure that hg.m.o syncs NFS... ", time.sleep(30) print OK with show('running'): retry(run, args=('source bin/activate && make update',), kwargs={'workdir': master['basedir']}, sleeptime=10, retry_exceptions=(SystemExit,)) print OK, "updated %(hostname)s:%(basedir)s" % master
def action_graceful_restart(master): with show('running'): put(BUILDBOT_WRANGLER, '%s/buildbot-wrangler.py' % master['basedir']) run('rm -f *.pyc', workdir=master['basedir']) run('python buildbot-wrangler.py graceful_restart %s %s' % (master['master_dir'], master['http_port']), workdir=master['basedir']) print OK, \ "finished gracefully restarting of %(hostname)s:%(basedir)s" % master
def update(foopy, revision='default'): with show('running'): with cd('/builds/tools'): run('hg pull && hg update -r %s' % revision) run('find /builds/tools -name \\*.pyc -exec rm {} \\;') with hide('stdout', 'stderr', 'running'): tools_rev = run('hg ident -i') print OK, "updated %s tools to %12s" % (foopy, tools_rev)
def action_reconfig(master): """Performs a reconfig (only - no update or checkconfig)""" print "starting reconfig of %(hostname)s:%(basedir)s" % master with show('running'): put(BUILDBOT_WRANGLER, '%s/buildbot-wrangler.py' % master['basedir']) run('rm -f *.pyc', workdir=master['basedir']) run('python buildbot-wrangler.py reconfig %s' % master['master_dir'], workdir=master['basedir']) print OK, "finished reconfig of %(hostname)s:%(basedir)s" % master
def copy_repo_files_install_env(self, project_slug, project_path, repo_url): """ workaround not having permissions in target dir to clone directly""" tmp_dir = '/tmp/fctools/%s' % project_slug sudo('rm -rf %s' % tmp_dir) with settings(show('commands'), warn_only=True): # so that you can enter credentials run('git clone %s %s -b dev' % (repo_url, tmp_dir)) # dev branch is default sudo('rm -rf %s/.git' % tmp_dir) sudo('cp -R %s/* %s' % (tmp_dir, project_path)) sudo('rm -rf %s' % tmp_dir)
def action_graceful_restart(master): with show('running'): put(BUILDBOT_WRANGLER, '%s/buildbot-wrangler.py' % master['basedir']) run('rm -f *.pyc', workdir=master['basedir']) run('python buildbot-wrangler.py graceful_restart %s %s' % (master['master_dir'], master['http_port']), workdir=master['basedir']) print OK, \ "finished gracefully restarting of %(hostname)s:%(basedir)s" % master
def action_restart(master): with show('running'): with cd(master['basedir']): put(BUILDBOT_WRANGLER, '%s/buildbot-wrangler.py' % master['basedir']) run('rm -f *.pyc') run('python buildbot-wrangler.py restart %s' % master['master_dir']) print OK, "finished restarting of %(hostname)s:%(basedir)s" % master
def update(foopy): with show('running'): with cd('/builds/tools'): run('hg pull && hg update') run('find /builds/tools -name \\*.pyc -exec rm {} \\;') with hide('stdout', 'stderr', 'running'): tools_rev = run('hg ident -i') print OK, "updated %s tools to %12s" % (foopy, tools_rev)
def test_password_prompt_displays_host_string(self): """ Password prompt lines should include the user/host in question """ env.password = None env.no_agent = env.no_keys = True with show('everything'), password_response(PASSWORDS[env.user], silent=False): run("ls /simple") regex = r'^\[%s\] Login password for \'%s\': ' % (env.host_string, env.user) assert_contains(regex, sys.stderr.getvalue())
def reconfig(master): print "starting reconfig of %(hostname)s:%(basedir)s" % master with show('running'): with cd(master['basedir']): put('buildbot-wrangler.py', '%s/buildbot-wrangler.py' % master['basedir']) run('rm -f *.pyc') run('python buildbot-wrangler.py reconfig %s' % master['master_dir']) print "finished reconfig of %(hostname)s:%(basedir)s" % master
def action_reconfig(master): """Performs a reconfig (only - no update or checkconfig)""" print "starting reconfig of %(hostname)s:%(basedir)s" % master with show('running'): put(BUILDBOT_WRANGLER, '%s/buildbot-wrangler.py' % master['basedir']) run('rm -f *.pyc', workdir=master['basedir']) run('python buildbot-wrangler.py reconfig %s' % master['master_dir'], workdir=master['basedir']) print OK, "finished reconfig of %(hostname)s:%(basedir)s" % master
def validate_os(lsbdata): with settings(show('warnings', 'running', 'stdout', 'stderr'), warn_only=True, shell='/bin/bash -lc'): if debug == True: test = fab_local('[ -f %s ]' % (lsbdata), capture=True) else: test = fab_run('[ -f %s ]' % (lsbdata)) if test.succeeded: if debug == True: lsb_conts = fab_local("cat %s " % (lsbdata), capture=True) else: lsb_conts = fab_run("cat %s " % (lsbdata)) ## Convert string to a StringIO object, to ease converting ## to a dictionary ## Seems like extra work, but this is meant ## to ease future improvements to this code lsbIO = cStringIO.StringIO(lsb_conts) ## Build dictionary with dict. comprehension ## Stripping '\r' is only required when execuing remotely lsbdata_d = { k: v for k, v in [ a.strip('\n').strip('\r').split('=') for a in lsbIO.readlines() ] } if debug: print '<Debug Enabled> Flag Raised after building lsbdata_d Dict' if lsbdata_d['DISTRIB_ID'].lower() == 'ubuntu': if debug == True: result = fab_local( 'echo This is where we would execute our deploy.') if result.succeeded: #print 'Succeeded!' return True else: return False else: result = fab_run( 'echo This is where we would execute our deploy.', shell=True) if result.succeeded: #print 'Succeeded!' return True else: return False else: return False else: return False
def update(master): with show('running'): with cd(master['bbcustom_dir']): run('hg pull') run('hg update -r %s' % master['bbcustom_branch']) with cd(master['bbconfigs_dir']): run('hg pull') run('hg update -r %s' % master['bbconfigs_branch']) with cd(master['tools_dir']): run('hg pull') run('hg update -r %s' % master['tools_branch'])
def prod(): '''set target to production. will be more useful when i have a test app, haha ''' with show('everything', 'debug'): env.hosts = ['kevinburke.webfactional.com'] env.user = '******' if os.name == "nt": env.key_filename = ["C:\Users\Orlan Davies\My Dropbox\Work\goodmorningcmc\priv.ppk"] env.remote_5c_dir = '~/webapps/goodmorning5c'
def update(master): with show('running'): with cd(master['bbcustom_dir']): run('hg pull') run('hg update -r %s' % master['bbcustom_branch']) with cd(master['bbconfigs_dir']): run('hg pull') run('hg update -r %s' % master['bbconfigs_branch']) with cd(master['tools_dir']): run('hg pull') run('hg update -r %s' % master['tools_branch'])
def actual_task(dir_p='/',env='lab'): print '%s' % ('Testing, testing...') print dir_p with settings(show('warnings', 'running', 'stdout', 'stderr'), warn_only=True): for a in dir_p: print a with fab_lcd(a): result = fab_local('ls -l', capture=True) print 'Current Environment :: %s' % (env) #print result result = ''
def action_retry_dead_queue(host): for q in 'commands', 'pulse': cmd = "find /dev/shm/queue/%s/dead -type f" % q for f in run(cmd).split("\n"): f = f.strip() if not f: continue with show('running'): if f.endswith(".log"): run("rm %s" % f) else: run("mv %s /dev/shm/queue/%s/new" % (f, q))
def action_retry_dead_queue(host): for q in 'commands', 'pulse': cmd = "find /dev/shm/queue/%s/dead -type f" % q for f in run(cmd).split("\n"): f = f.strip() if not f: continue with show('running'): if f.endswith(".log"): run("rm %s" % f) else: run("mv %s /dev/shm/queue/%s/new" % (f, q))
def deploy_aa(path_to_rpm): """ Deploys rpm package to hpc cluster. Usage: fab -H <FROM_HOST> deploy_aa:<PATH_TO_RPM> """ with settings(hide('stdout'), warn_only=True): with settings(host_string=env.host): get(path_to_rpm, '/tmp') with settings(host_string=env.dist_server): copy_to_host(path_to_rpm) create_repo() env.package_version = version(path_to_rpm) with settings(host_string=env.master_server): run_yum() with show('stdout'): verify_version()
def update_database(self): try: self.backup_db_at_start() with settings(show('stdout')): if env.use_syncdb: self.syncdb() self.migrate() # todo: must the 'backup at end' moved to after the except? self.backup_db_at_end() except Exception as e: self.restore_db_at_start() self.rollback(e)
def test_trailing_newline_line_drop(self): """ Trailing newlines shouldn't cause last line to be dropped. """ # Multiline output with trailing newline cmd = "ls /" output_string = RESPONSES[cmd] # TODO: fix below lines, duplicates inner workings of tested code prefix = "[%s] out: " % env.host_string expected = prefix + ('\n' + prefix).join(output_string.split('\n')) # Create, tie off thread with settings(show('everything'), hide('running')): result = run(cmd) # Test equivalence of expected, received output eq_(expected, sys.stdout.getvalue()) # Also test that the captured value matches, too. eq_(output_string, result)
def RunCommand(cfg, host, cmd): key = Path(cfg.configpath).joinpath(cfg.keypath) key = Path(key).joinpath(cfg.keyname) if cfg.log_level == "DEBUG": with settings(show('everything'), user='******', host_string=host, key_filename=key.as_posix(), warn_only=True): results = fabric_run(cmd) else: with settings(hide('everything'), user='******', host_string=host, key_filename=key.as_posix(), warn_only=True): results = fabric_run(cmd) return results
def action_reconfig(master): """Performs a reconfig (only - no update or checkconfig)""" print "starting reconfig of %(hostname)s:%(basedir)s" % master with hide('stdout', 'stderr', 'running'): lockfile_check = run('if [ -e %s ]; then echo "lockfile found"; fi' % RECONFIG_LOCKFILE, workdir=master['basedir']) if lockfile_check != "": print FAIL, "lockfile (%s) found in %s:%s" % ( RECONFIG_LOCKFILE, master['hostname'], master['basedir']) raise Exception("Couldn't get lockfile to reconfig") with show('running'): action_create_reconfig_lockfile(master, notify=False) put(BUILDBOT_WRANGLER, '%s/buildbot-wrangler.py' % master['basedir']) run('rm -f *.pyc', workdir=master['basedir']) run('python buildbot-wrangler.py reconfig %s' % master['master_dir'], workdir=master['basedir']) action_remove_reconfig_lockfile(master, notify=False) print OK, "finished reconfig of %(hostname)s:%(basedir)s" % master
def send_blueprint_script(src_path, target_path): with settings( show('warnings', 'running', 'stdout', 'stderr'), warn_only=False, shell='/bin/bash -lc', user='******', ): ## try/except wrapped check to validate existance of local file try: with open(src_path, 'rt') as f: f.readline() except IOError as e: print "I/O error [{0}] {1}: {2}".format(e.errno, e.strerror, e.filename) sys_exit(1) test_exist = fab_run('ls -l %s' % (target_path)) if test_exist.succeeded: replace_yesno = fab_prompt( 'File <{0}> already Exists. OK to Replace? [yes/no]'.format( target_path), default='no') if debug == True: print 'You said [{0}], exiting.'.format(replace_yesno) if 'yes' in replace_yesno.lower(): replace_yesno = True else: replace_yesno = False #ch = lambda x: 'yes' if x == True else 'no' sys_exit(0) test = fab_put(src_path, target_path, use_sudo=False, mirror_local_mode=False, mode=None) else: test = fab_run('[ -f %s ]' % (lsbdata))
def wrapper(*args, **kwargs): # iterates and executes the wrapped function/testcase # for each one of the docker images. # ex: centos, ubuntu-vivid, ubuntu-trusty for image in images: c1 = docker_run(image=image, privileged=privileged) hs = build_host_string(c1, env.docker_host) # set some fabric settings to either be very verbose # or very quiet. if verbose: fabric_flags = show('debug') else: fabric_flags = hide('everything') with settings(fabric_flags, host_string=hs): try: print("In method: %s for docker image %s" % (func.func_name, image)) func(*args, **kwargs) docker_rm(c1) except: docker_rm(c1) raise
def action_restart_pulse_publisher(master): with show('running'): run('/etc/init.d/pulse_publisher restart') print OK, 'Pulse publisher restarted on %s:%s' % (master['hostname'], master['basedir'])