def runAnsiblePlaybook(playbook, inventory=None, argsfile=None, checkout=None, version=None): pass basecmd = "ansible-playbook" # inventory string requires -i "content" # inventory isfile requires -i <file> # argsfile requires -e "@<file>" # checkout requires source hacking/env-setup # verison requires checkout <version> rc, so, se = run_command(basecmd)
def trymerge(self, url, branch): this_branch = "test__" + branch cmd = "git branch -d %s" % this_branch rc, so, se = run_command(cmd, cwd=self.repo_path) cmd = "git checkout -b %s" % this_branch rc, so, se = run_command(cmd, cwd=self.repo_path) if rc != 0: import epdb; epdb.st() return rc cmd = "git pull %s %s" % (url, branch) rc, so, se = run_command(cmd, cwd=self.repo_path) if rc != 0: import epdb; epdb.st() return rc cmd = "git checkout %s" % self.branch rc, so, se = run_command(cmd, cwd=self.repo_path) cmd = "git merge %s" % this_branch this_rc, so, se = run_command(cmd, cwd=self.repo_path) if rc != 0: import epdb; epdb.st() return rc cmd = "git branch -d %s" % this_branch rc, so, se = run_command(cmd, cwd=self.repo_path) return True
def trypatch(self, patch): this_branch = "test__" patch_file = os.path.join(self.tmp_path, "patch1") f = open(patch_file, "wb") f.write(patch) f.close() cmd = "git apply %s" % patch_file this_rc, this_so, this_se = run_command(cmd, cwd=self.repo_path) if this_rc == 0: return True else: #import epdb; epdb.st() return False
def get_ssh_config(self): cmd = "vagrant ssh-config" rc, so, se = run_command(cmd, cwd=self.workdir) print rc, so, se self.ssh_config = so ssh_dict = {} lines = so.split("\n") for line in lines: if line != "": try: w = shlex.split(line, 1) k = w[0].strip().lower() v = w[1].strip() ssh_dict[k] = v except: # import epdb; epdb.st() pass self.ssh_dict = ssh_dict
def makecheckout(self): if not os.path.isdir(self.repo_path): cmd = "git clone %s %s" % (self.repo_url, self.repo_path) run_command(cmd, cwd=self.tmp_path) else: cmd = "git reset --hard" run_command(cmd, cwd=self.repo_path) cmd = "git checkout %s" % self.branch run_command(cmd, cwd=self.repo_path) cmd = "git reset --hard" run_command(cmd, cwd=self.repo_path) cmd = "git pull --rebase" run_command(cmd, cwd=self.repo_path) cmd = "git clean -f" run_command(cmd, cwd=self.repo_path)
def start(self): cmd = "vagrant up" rc, so, se = run_command(cmd, cwd=self.workdir) print rc, so, se self.get_ssh_config()
def destroy(self): cmd = "vagrant destroy" rc, so, se = run_command(cmd, cwd=self.workdir) print rc, so, se