def _create_network(name, subnet): tempfile = file.temp() try: definition = _NETWORK_TEMPLATE % dict(name=name, subnet=subnet) file.write(tempfile, definition) core.run("virsh net-define %s" % tempfile) core.run("virsh net-autostart %s" % name) finally: file.remove(tempfile)
def _upload(self): # TODO Warn if there are local changes tmp_tar = git.create_archive(self.revision) try: core.put(tmp_tar, "deploy.tar.gz") core.run("tar -xzf deploy.tar.gz") file.remove("deploy.tar.gz") with ctx.unpatched_state(): file.write("VERSION", git.revparse(self.revision)) finally: core.local("rm -rf %s" % tmp_tar)
def _upload(owner, upload_dir, revision): tmp_tar = git.create_archive(revision) try: with ctx.cd(upload_dir): with ctx.sudo(): put(tmp_tar, 'deploy.tar.gz') file.attributes('deploy.tar.gz', owner=owner) with ctx.sudo(owner): run('tar -xzf deploy.tar.gz') file.remove('deploy.tar.gz') file.write('VERSION', git.revparse(revision)) finally: local('rm -rf %s' % tmp_tar)
def test_remove_recusrive(run): run.expects_call().with_args("rm -f path") file.remove("path", recursive=False) run.expects_call().with_args("rm -f -r path") file.remove("path", recursive=True)
def site_disable(site): with ctx.sudo(): with ctx.cd('/etc/nginx/sites-enabled'): file.remove(site) reload()
def test_remove_defaults(run): run.expects_call().with_args("rm -f path") file.remove("path")
def test_remove_force(run): run.expects_call().with_args("rm path") file.remove("path", force=False) run.expects_call().with_args("rm -f path") file.remove("path", force=True)