From 84ba5044b1b1f3dc4a0499874f8e44f540ee38f5 Mon Sep 17 00:00:00 2001 From: Hui Xiang Date: Mon, 8 Dec 2014 09:32:09 +0800 Subject: [PATCH] Fix typo err. --- hooks/charmhelpers/fetch/giturl.py | 48 ++++++++++++++++++++++++++++++ hooks/quantum_utils.py | 4 +-- 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 hooks/charmhelpers/fetch/giturl.py diff --git a/hooks/charmhelpers/fetch/giturl.py b/hooks/charmhelpers/fetch/giturl.py new file mode 100644 index 00000000..61684cb6 --- /dev/null +++ b/hooks/charmhelpers/fetch/giturl.py @@ -0,0 +1,48 @@ +import os +from charmhelpers.fetch import ( + BaseFetchHandler, + UnhandledSource +) +from charmhelpers.core.host import mkdir + +import six +if six.PY3: + raise ImportError('GitPython does not support Python 3') + +try: + from git import Repo +except ImportError: + from charmhelpers.fetch import apt_install + apt_install("python-git") + from git import Repo + + +class GitUrlFetchHandler(BaseFetchHandler): + """Handler for git branches via generic and github URLs""" + def can_handle(self, source): + url_parts = self.parse_url(source) + # TODO (mattyw) no support for ssh git@ yet + if url_parts.scheme not in ('http', 'https', 'git'): + return False + else: + return True + + def clone(self, source, dest, branch): + if not self.can_handle(source): + raise UnhandledSource("Cannot handle {}".format(source)) + + repo = Repo.clone_from(source, dest) + repo.git.checkout(branch) + + def install(self, source, branch="master"): + url_parts = self.parse_url(source) + branch_name = url_parts.path.strip("/").split("/")[-1] + dest_dir = os.path.join(os.environ.get('CHARM_DIR'), "fetched", + branch_name) + if not os.path.exists(dest_dir): + mkdir(dest_dir, perms=0o755) + try: + self.clone(source, dest_dir, branch) + except OSError as e: + raise UnhandledSource(e.strerror) + return dest_dir diff --git a/hooks/quantum_utils.py b/hooks/quantum_utils.py index 87d3965e..d48da4e7 100644 --- a/hooks/quantum_utils.py +++ b/hooks/quantum_utils.py @@ -637,7 +637,7 @@ def init_ocf_MonitorNeutron_f(update=False): def init_external_agent_f(update=False): - agent = 'ns_cleanup.sh' + agent = 'ns_ovs_cleanup.sh' exec_dir = '/usr/lib/ocf/resource.d/openstack' copy_file(LEGACY_HA_TEMPLATE_FILES, exec_dir, agent, stat.S_IEXEC, update=update) @@ -665,7 +665,7 @@ def install_legacy_ha_files(update=False): def get_external_agent_f(): - agent = 'ns_cleanup.sh' + agent = 'ns_ovs_cleanup.sh' exec_dir = '/usr/lib/ocf/resource.d/openstack' return os.path.join(exec_dir, agent)