Merge "Add a method to download and create a CentOS 7 image"

This commit is contained in:
Zuul 2018-04-18 18:40:32 +00:00 committed by Gerrit Code Review
commit 7f35fc0f5e
1 changed files with 25 additions and 1 deletions

View File

@ -29,6 +29,9 @@ from manila_tempest_tests.tests.api import base
from manila_tempest_tests.tests.scenario import manager_share as manager
from manila_tempest_tests import utils
from tempfile import mkstemp
from urllib2 import urlopen
CONF = config.CONF
LOG = logging.getLogger(__name__)
@ -72,7 +75,10 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
raise self.skipException(message)
if not hasattr(self, 'flavor_ref'):
self.flavor_ref = CONF.share.client_vm_flavor_ref
if CONF.share.image_with_share_tools:
if CONF.share.image_with_share_tools == 'centos':
self.image_ref = self._create_centos_based_glance_image()
elif CONF.share.image_with_share_tools:
images = self.compute_images_client.list_images()["images"]
for img in images:
if img["name"] == CONF.share.image_with_share_tools:
@ -296,6 +302,24 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
return locations
def _create_centos_based_glance_image(self):
imagepath = mkstemp(suffix='.qcow2')[1]
imagefile = open(imagepath, 'wb+')
image_response = urlopen('http://cloud.centos.org/centos/7/images/' +
'CentOS-7-x86_64-GenericCloud.qcow2')
LOG.info('Downloading CentOS7 image')
while True:
imagecopy = image_response.read(100 * 1024 * 1024)
if imagecopy == '':
break
imagefile.write(imagecopy)
imagefile.close()
LOG.info('Creating Glance image using the downloaded image file')
return self._image_create('centos', 'bare', imagepath, 'qcow2')
@tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
def test_mount_share_one_vm(self):
instance = self.boot_instance(wait_until="BUILD")