Made the git commands use the distro class/conf
This commit is contained in:
parent
f1cfd31fe8
commit
7622e95d7e
@ -24,6 +24,16 @@ commands:
|
||||
- service
|
||||
- httpd
|
||||
- stop
|
||||
git:
|
||||
checkout:
|
||||
- git
|
||||
- checkout
|
||||
clone:
|
||||
- git
|
||||
- clone
|
||||
pull:
|
||||
- git
|
||||
- pull
|
||||
libvirt:
|
||||
restart:
|
||||
- service
|
||||
|
@ -23,6 +23,16 @@ commands:
|
||||
- service
|
||||
- apache2
|
||||
- stop
|
||||
git:
|
||||
checkout:
|
||||
- git
|
||||
- checkout
|
||||
clone:
|
||||
- git
|
||||
- clone
|
||||
pull:
|
||||
- git
|
||||
- pull
|
||||
iscsi:
|
||||
restart:
|
||||
- service
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user