Made the git commands use the distro class/conf

This commit is contained in:
Joshua Harlow 2012-03-19 13:07:27 -07:00
parent f1cfd31fe8
commit 7622e95d7e
4 changed files with 31 additions and 11 deletions

View File

@ -24,6 +24,16 @@ commands:
- service
- httpd
- stop
git:
checkout:
- git
- checkout
clone:
- git
- clone
pull:
- git
- pull
libvirt:
restart:
- service

View File

@ -23,6 +23,16 @@ commands:
- service
- apache2
- stop
git:
checkout:
- git
- checkout
clone:
- git
- clone
pull:
- git
- pull
iscsi:
restart:
- service

View File

@ -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()

View File

@ -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