diff --git a/fabfile/tasks/helpers.py b/fabfile/tasks/helpers.py index e80e0a8e3..c3657a904 100644 --- a/fabfile/tasks/helpers.py +++ b/fabfile/tasks/helpers.py @@ -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': '', @@ -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 diff --git a/fabfile/tasks/tester.py b/fabfile/tasks/tester.py index 3e0ad23c0..de7005069 100644 --- a/fabfile/tasks/tester.py +++ b/fabfile/tasks/tester.py @@ -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 * @@ -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: diff --git a/fabfile/utils/fabos.py b/fabfile/utils/fabos.py index a463f41af..238438f18 100644 --- a/fabfile/utils/fabos.py +++ b/fabfile/utils/fabos.py @@ -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'