Skip to content

Commit

Permalink
Fabric changes to support liberty openstack release with contrail
Browse files Browse the repository at this point in the history
Partial-Bug: #1547784

Change-Id: If37d5433e799f1d03ebc3f23cc8a7e8b4ca2a2a6
  • Loading branch information
moghea committed Feb 25, 2016
1 parent 7c4378a commit 29b5bda
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 11 deletions.
45 changes: 35 additions & 10 deletions fabfile/tasks/helpers.py
Expand Up @@ -479,9 +479,18 @@ def add_images(image=None):
sudo("wget http://%s/%s" % (mount, local))
sudo("gunzip " + remote_gz)

cmd = "source /etc/contrail/openstackrc; {PRECMD}"\
" glance image-create --name {IMGNAME}"\
" --is-public True --container-format {IMGFORMAT}"\
os_type = detect_ostype()
openstack_sku = get_openstack_sku()

if os_type in ['ubuntu'] and openstack_sku in ['liberty']:
cmd = "source /etc/contrail/openstackrc; {PRECMD}"\
" glance image-create --name {IMGNAME}"\
" --visibility public --container-format {IMGFORMAT}"\
" --disk-format {DISKFORMAT} {IMGFILE_OPT}"
else:
cmd = "source /etc/contrail/openstackrc; {PRECMD}"\
" glance image-create --name {IMGNAME}"\
" --is-public True --container-format {IMGFORMAT}"\
" --disk-format {DISKFORMAT} {IMGFILE_OPT}"
if ".vmdk" in loc:
glance_kwargs = {'PRECMD': '',
Expand Down Expand Up @@ -571,15 +580,31 @@ def add_basic_images(image=None):
remote_gz = remote+".gz"
run("wget http://%s/%s" % (mount, local))
run("gunzip " + remote_gz)
if ".vmdk" in loc:
if 'converts' in loc:
glance_id = run("(source /etc/contrail/openstackrc; glance image-create --name '"+name+"' --is-public True --container-format bare --disk-format vmdk --property vmware_disktype='sparse' --property vmware_adaptertype='ide' < "+remote+" | grep -e 'id\>' | awk '{printf $4}')")

os_type = detect_ostype()
openstack_sku = get_openstack_sku()

if os_type in ['ubuntu'] and openstack_sku in ['liberty']:
if ".vmdk" in loc:
if 'converts' in loc:
glance_id = run("(source /etc/contrail/openstackrc; glance image-create --name '"+name+"' --visibility public --container-format bare --disk-format vmdk --property vmware_disktype='sparse' --property vmware_adaptertype='ide' < "+remote+" | grep -e 'id\>' | awk '{printf $4}')")
else:
glance_id = run("(source /etc/contrail/openstackrc; glance add name='"+name+"' --visibility public container_format=ovf disk_format=vmdk < "+remote+" | grep -e 'id\>' | awk '{printf $4}')")
if glance_id.succeeded:
preload_image_to_esx('http://%s/%s' % (mount,local), glance_id, sizes, openstack_version)
else:
glance_id = run("(source /etc/contrail/openstackrc; glance add name='"+name+"' is_public=true container_format=ovf disk_format=vmdk < "+remote+" | grep -e 'id\>' | awk '{printf $4}')")
if glance_id.succeeded:
preload_image_to_esx('http://%s/%s' % (mount,local), glance_id, sizes, openstack_version)
run("(source /etc/contrail/openstackrc; glance image-create --name '"+name+"' --visibility public --container-format ovf --disk-format qcow2 --property hypervisor_type=qemu < "+remote+")")
else:
run("(source /etc/contrail/openstackrc; glance image-create --name '"+name+"' --is-public True --container-format ovf --disk-format qcow2 --property hypervisor_type=qemu < "+remote+")")
if ".vmdk" in loc:
if 'converts' in loc:
glance_id = run("(source /etc/contrail/openstackrc; glance image-create --name '"+name+"' --is-public True --container-format bare --disk-format vmdk --property vmware_disktype='sparse' --property vmware_adaptertype='ide' < "+remote+" | grep -e 'id\>' | awk '{printf $4}')")
else:
glance_id = run("(source /etc/contrail/openstackrc; glance add name='"+name+"' is_public=true container_format=ovf disk_format=vmdk < "+remote+" | grep -e 'id\>' | awk '{printf $4}')")
if glance_id.succeeded:
preload_image_to_esx('http://%s/%s' % (mount,local), glance_id, sizes, openstack_version)
else:
run("(source /etc/contrail/openstackrc; glance image-create --name '"+name+"' --is-public True --container-format ovf --disk-format qcow2 --property hypervisor_type=qemu < "+remote+")")

run("rm "+remote)

#end add_basic_images
Expand Down
9 changes: 8 additions & 1 deletion fabfile/tasks/tester.py
Expand Up @@ -4,6 +4,7 @@
import string
import socket
import tempfile
from string import whitespace
from random import randrange
from datetime import datetime as dt
from fabfile.config import *
Expand Down Expand Up @@ -350,7 +351,13 @@ def setup_test_env():
testrepository junitxml pytun requests==2.3.0 pyvmomi==5.5.0 eventlet'
elif 'ubuntu' == detect_ostype():
pkg = 'fixtures==1.0.0 testtools==1.7.1 testresources==0.2.7 \
testrepository junitxml pytun requests==2.3.0 pyvmomi==5.5.0 eventlet'
testrepository junitxml pytun pyvmomi==5.5.0 eventlet'
output = sudo('pip show requests | grep Version')
if output.succeeded:
version = output.split(':')[1].translate(None, whitespace)
if version <= 2.3:
if (LooseVersion(version) < LooseVersion('2.3.0')):
pkg += ' requests==2.3.0'
if os.environ.has_key('GUESTVM_IMAGE'):
pkg = pkg + ' pexpect'
if ui_browser:
Expand Down
2 changes: 2 additions & 0 deletions fabfile/utils/fabos.py
Expand Up @@ -51,6 +51,8 @@ def get_openstack_sku(use_install_repo=False):
openstack_sku = 'juno'
elif pkg_ver.find('2015.1') != -1:
openstack_sku = 'kilo'
elif pkg_ver.find('12.0') != -1:
openstack_sku = 'liberty'
else:
print "OpenStack distribution unknown.. assuming icehouse.."
openstack_sku = 'icehouse'
Expand Down

0 comments on commit 29b5bda

Please sign in to comment.