From 7622e95d7e193ece04377d7873048af5f144e363 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Mon, 19 Mar 2012 13:07:27 -0700 Subject: [PATCH] Made the git commands use the distro class/conf --- conf/distros/rhel-6.yaml | 10 ++++++++++ conf/distros/ubuntu-oneiric.yaml | 10 ++++++++++ devstack/component.py | 3 +-- devstack/downloader.py | 19 ++++++++++--------- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/conf/distros/rhel-6.yaml b/conf/distros/rhel-6.yaml index 26d8854b..618a159d 100644 --- a/conf/distros/rhel-6.yaml +++ b/conf/distros/rhel-6.yaml @@ -24,6 +24,16 @@ commands: - service - httpd - stop + git: + checkout: + - git + - checkout + clone: + - git + - clone + pull: + - git + - pull libvirt: restart: - service diff --git a/conf/distros/ubuntu-oneiric.yaml b/conf/distros/ubuntu-oneiric.yaml index b4093afa..3ea0dc56 100644 --- a/conf/distros/ubuntu-oneiric.yaml +++ b/conf/distros/ubuntu-oneiric.yaml @@ -23,6 +23,16 @@ commands: - service - apache2 - stop + git: + checkout: + - git + - checkout + clone: + - git + - clone + pull: + - git + - pull iscsi: restart: - service diff --git a/devstack/component.py b/devstack/component.py index 96a4dd36..ca4ad6ba 100644 --- a/devstack/component.py +++ b/devstack/component.py @@ -175,8 +175,7 @@ class PkgInstallComponent(ComponentBase): return len(locations) def _do_download(self, uri, target_dir, branch): - downloader = down.GitDownloader(uri, target_dir, branch) - return downloader.download() + return down.GitDownloader(self.distro, uri, target_dir, branch).download() def _get_param_map(self, config_fn): return dict() diff --git a/devstack/downloader.py b/devstack/downloader.py index a24413bd..09647dea 100644 --- a/devstack/downloader.py +++ b/devstack/downloader.py @@ -24,11 +24,8 @@ from devstack import shell as sh LOG = logging.getLogger("devstack.downloader") -# Git commands/subcommands +# Git master branch GIT_MASTER_BRANCH = "master" -CLONE_CMD = ["git", "clone"] -CHECKOUT_CMD = ['git', 'checkout'] -PULL_CMD = ['git', 'pull'] class Downloader(object): @@ -43,26 +40,30 @@ class Downloader(object): class GitDownloader(Downloader): - def __init__(self, uri, store_where, branch): + def __init__(self, distro, uri, store_where, branch): Downloader.__init__(self, uri, store_where) self.branch = branch + self.distro = distro def download(self): dirsmade = list() if sh.isdir(self.store_where): LOG.info("Updating using git: located at %r" % (self.store_where)) - cmd = CHECKOUT_CMD + [GIT_MASTER_BRANCH] + cmd = self.distro.get_command('git', 'checkout') + cmd += [GIT_MASTER_BRANCH] sh.execute(*cmd, cwd=self.store_where) - cmd = PULL_CMD + cmd = self.distro.get_command('git', 'pull') sh.execute(*cmd, cwd=self.store_where) else: LOG.info("Downloading using git: %r to %r" % (self.uri, self.store_where)) dirsmade.extend(sh.mkdirslist(self.store_where)) - cmd = CLONE_CMD + [self.uri, self.store_where] + cmd = self.distro.get_command('git', 'clone') + cmd += [self.uri, self.store_where] sh.execute(*cmd) if self.branch and self.branch != GIT_MASTER_BRANCH: LOG.info("Adjusting branch using git: %r" % (self.branch)) - cmd = CHECKOUT_CMD + [self.branch] + cmd = self.distro.get_command('git', 'checkout') + cmd += [self.branch] sh.execute(*cmd, cwd=self.store_where) return dirsmade