summaryrefslogtreecommitdiffstats
path: root/tests/image.py
diff options
context:
space:
mode:
authorRyota MIBU <r-mibu@cq.jp.nec.com>2017-09-11 13:45:47 +0000
committerdongwenjuan <dong.wenjuan@zte.com.cn>2017-09-13 09:14:16 +0800
commit44d1e135eced7afe13b8772a610ae5cdae310b68 (patch)
treed75782b7b9fe95f245654dd98662e3fa6d47dbb2 /tests/image.py
parent5ffd957a87858e026011e4bbde9b493c62c11b8e (diff)
fix package path and move files under doctor_tests
Change-Id: Ibde6a36c43064e5fbea1a0b7a9b49349c343e42f Signed-off-by: Ryota MIBU <r-mibu@cq.jp.nec.com>
Diffstat (limited to 'tests/image.py')
-rw-r--r--tests/image.py74
1 files changed, 0 insertions, 74 deletions
diff --git a/tests/image.py b/tests/image.py
deleted file mode 100644
index 453322b8..00000000
--- a/tests/image.py
+++ /dev/null
@@ -1,74 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 ZTE Corporation and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import os
-import urllib.request
-
-from oslo_config import cfg
-
-from identity_auth import get_session
-from os_clients import glance_client
-
-OPTS = [
- cfg.StrOpt('image_name',
- default=os.environ.get('IMAGE_NAME', 'cirros'),
- help='the name of test image',
- required=True),
- cfg.StrOpt('image_format',
- default='qcow2',
- help='the format of test image',
- required=True),
- cfg.StrOpt('image_filename',
- default='cirros.img',
- help='the name of image file',
- required=True),
- cfg.StrOpt('image_download_url',
- default='https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img',
- help='the url where to get the image',
- required=True),
-]
-
-
-class Image(object):
-
- def __init__(self, conf, log):
- self.conf = conf
- self.log = log
- self.glance = \
- glance_client(conf.glance_version, get_session())
- self.use_existing_image = False
- self.image = None
-
- def create(self):
- self.log.info('image create start......')
-
- images = {image.name: image for image in self.glance.images.list()}
- if self.conf.image_name not in images:
- if not os.path.exists(self.conf.image_filename):
- resp = urllib.request.urlopen(self.conf.image_download_url)
- with open(self.conf.image_filename, "wb") as file:
- file.write(resp.read())
- self.image = self.glance.images.create(name=self.conf.image_name,
- disk_format=self.conf.image_format,
- container_format="bare",
- visibility="public")
- self.glance.images.upload(self.image['id'],
- open(self.conf.image_filename, 'rb'))
- else:
- self.use_existing_image = True
- self.image = images[self.conf.image_name]
-
- self.log.info('image create end......')
-
- def delete(self):
- self.log.info('image delete start.......')
-
- if not self.use_existing_image and self.image:
- self.glance.images.delete(self.image['id'])
-
- self.log.info('image delete end.......')