From fdc40c8c8fc28f39f36c6aa3e738fcd29e62039f Mon Sep 17 00:00:00 2001 From: pengtao Date: Tue, 5 Nov 2019 14:04:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0keys=20=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/deploy_keys.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/deploy/deploy_keys.py b/deploy/deploy_keys.py index fd543ea..3ca7b1b 100644 --- a/deploy/deploy_keys.py +++ b/deploy/deploy_keys.py @@ -30,20 +30,18 @@ class DeployKeys: def run(self): svn_path, ipadr = self.get_config() if svn_path: - shutil.rmtree(svn_path) + key_path = f"{svn_path}/keys" + args = dict() + tar_file = self.build_svn_tar(key_path) + if tar_file: + hostfile = self.build_hostfile() + args['hostfile'] = hostfile + args['tar_file'] = tar_file + self.ansible_deploy(args) + else: + log.error(f"tar file no found with {self.project}") else: - pass - os.system(f"mkdir -p {svn_path}") - key_path = f"{svn_path}/keys" - args = dict() - tar_file = self.build_svn_tar(key_path) - if tar_file: - hostfile = self.build_hostfile() - args['hostfile'] = hostfile - args['tar_file'] = tar_file - self.ansible_deploy(args) - else: - log.error(f"tar file no found with {self.project}") + raise Exception(f"{self.project} config not found in manager table!") def get_config(self): @@ -76,6 +74,9 @@ class DeployKeys: try: log.info("svn export config start") s = svn.remote.RemoteClient(svn_path) + if self.svn_paths: + shutil.rmtree(self.svn_paths) + s.export(self.svn_paths, force=True) log.info("svn export config success") except Exception: