Skip to content

Commit

Permalink
better handling of kcli download with a custom url
Browse files Browse the repository at this point in the history
  • Loading branch information
karmab committed Oct 9, 2018
1 parent e475b00 commit 31c176d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -15,3 +15,4 @@ prout.yml
.DS_Store
.cache/
kvirt/static/reports/*
venv
2 changes: 2 additions & 0 deletions kvirt/config.py
Expand Up @@ -1158,6 +1158,8 @@ def handle_host(self, pool=None, templates=[], switch=None, download=False,
search = re.search(r".*/(.*)\?.*", url)
if search is not None:
shortname = search.group(1)
else:
shortname = os.path.basename(url)
if cmd is None and template != '' and template in TEMPLATESCOMMANDS:
cmd = TEMPLATESCOMMANDS[template]
common.pprint("Grabbing template %s..." % shortname, color='green')
Expand Down
32 changes: 20 additions & 12 deletions kvirt/kvm/__init__.py
Expand Up @@ -2128,29 +2128,37 @@ def add_image(self, image, pool, cmd=None, name=None, size=1):
if shortimage.endswith('bz2'):
if self.host == 'localhost' or self.host == '127.0.0.1':
if find_executable('bunzip2') is not None:
cmd = "bunzip2 %s/%s" % (poolpath, shortimage)
os.system(cmd)
uncompresscmd = "bunzip2 %s/%s" % (poolpath, shortimage)
os.system(uncompresscmd)
else:
common.pprint("bunzip2 not found. Can't uncompress image", color="blue")
elif self.protocol == 'ssh':
cmd = 'ssh -p %s %s@%s "bunzip2 %s/%s"' % (self.port, self.user, self.host, poolpath, shortimage)
os.system(cmd)
uncompresscmd = 'ssh -p %s %s@%s "bunzip2 %s/%s"' % (self.port, self.user, self.host, poolpath,
shortimage)
os.system(uncompresscmd)
shortimage = shortimage.replace('.bz2', '')
if shortimage.endswith('gz'):
if self.host == 'localhost' or self.host == '127.0.0.1':
if find_executable('gunzip') is not None:
cmd = "gunzip %s/%s" % (poolpath, shortimage)
os.system(cmd)
uncompresscmd = "gunzip %s/%s" % (poolpath, shortimage)
os.system(uncompresscmd)
else:
common.pprint("gunzip not found. Can't uncompress image", color="blue")
elif self.protocol == 'ssh':
cmd = 'ssh -p %s %s@%s "bunzip2 %s/%s"' % (self.port, self.user, self.host, poolpath, shortimage)
os.system(cmd)
uncompresscmd = 'ssh -p %s %s@%s "gunzip %s/%s"' % (self.port, self.user, self.host, poolpath,
shortimage)
os.system(uncompresscmd)
shortimage = shortimage.replace('.gz', '')
if shortimage.endswith('xz'):
if self.host == 'localhost' or self.host == '127.0.0.1':
if find_executable('unxz') is not None:
cmd = "unxz %s/%s" % (poolpath, shortimage)
os.system(cmd)
uncompresscmd = "unxz %s/%s" % (poolpath, shortimage)
os.system(uncompresscmd)
else:
common.pprint("unxz not found. Can't uncompress image", color="blue")
elif self.protocol == 'ssh':
cmd = 'ssh -p %s %s@%s "unxz %s/%s"' % (self.port, self.user, self.host, poolpath, shortimage)
os.system(cmd)
uncompresscmd = 'ssh -p %s %s@%s "unxz %s/%s"' % (self.port, self.user, self.host, poolpath, shortimage)
os.system(uncompresscmd)
shortimage = shortimage.replace('.xz', '')
if cmd is not None:
if self.host == 'localhost' or self.host == '127.0.0.1':
Expand Down
2 changes: 2 additions & 0 deletions plans/openshift/okd.sh
Expand Up @@ -25,4 +25,6 @@ GOBIN=~/.terraform.d/plugins go get -u github.com/dmacvicar/terraform-provider-l
PUBKEY=`cat ~/.ssh/authorized_keys`
echo export OPENSHIFT_INSTALL_SSH_PUB_KEY=\"${PUBKEY}\" >> ~/env.sh
source ~/env.sh
# bin/openshift-install ignition-configs --dir ${WORKSPACE}
# bin/openshift-install manifests --dir ${WORKSPACE}
# bin/openshift-install cluster --log-level=debug

0 comments on commit 31c176d

Please sign in to comment.