oslo.config==3.22.0 # Apache-2.0
python-openstackclient==2.3.0
python-ceilometerclient==2.6.2
-python-heatclient==1.7.0
python-keystoneclient==3.5.0
python-neutronclient==6.0.0
python-novaclient==6.0.0
python-congressclient==1.5.0
+python-glanceclient==2.5.0
virtualenv==15.1.0
-coverage>=4.0 # Apache-2.0
-oslotest>=1.10.0 # Apache-2.0
-python-subunit>=0.0.18 # Apache-2.0/BSD
-testtools>=1.4.0 # MIT
-oslotest>=1.10.0 # Apache-2.0
-testrepository>=0.0.18 # Apache-2.0/BSD
-testresources>=0.2.4 # Apache-2.0/BSD
-testscenarios>=0.4 # Apache-2.0/BSD
-oslosphinx>=4.7.0 # Apache-2.0
\ No newline at end of file
##############################################################################\r
from oslo_config import cfg\r
\r
+import image\r
+import os_clients\r
+\r
\r
def list_opts():\r
- return []\r
+ return [\r
+ ('os_clients', os_clients.OPTS),\r
+ ('image', image.IMAGE_OPTS),\r
+ ]\r
\r
\r
def prepare_conf(conf=None):\r
from keystoneauth1.identity import v2
from keystoneauth1.identity import v3
+from keystoneauth1 import session
def get_identity_auth():
username=username,
password=password,
tenant_name=project_name)
+
+
+def get_session(auth=None):
+ """Get a user credentials auth session."""
+ if auth is None:
+ auth = get_identity_auth()
+ return session.Session(auth=auth)
--- /dev/null
+##############################################################################
+# 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 urllib2
+
+from oslo_config import cfg
+
+from identity_auth import get_session
+from os_clients import glance_client
+import logger as doctor_log
+
+IMAGE_OPTS = [
+ cfg.StrOpt('name',
+ default=os.environ.get('IMAGE_NAME', 'cirros'),
+ help='the name of test image',
+ required=True),
+ cfg.StrOpt('format',
+ default='qcow2',
+ help='the format of test image',
+ required=True),
+ cfg.StrOpt('file_name',
+ default='cirros.img',
+ help='the name of image file',
+ required=True),
+ cfg.StrOpt('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),
+]
+
+LOG = doctor_log.Logger('doctor').getLogger()
+
+
+class Image(object):
+
+ def __init__(self, conf):
+ self.conf = conf
+ self.glance = \
+ glance_client(conf.os_clients.glance_version,
+ get_session())
+ self.use_existing_image = False
+ self.image = None
+
+ def create(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.file_name):
+ resp = urllib2.urlopen(self.conf.image.url)
+ with open(self.conf.image.file_name, "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.file_name, 'rb'))
+ else:
+ self.use_existing_image = True
+ self.image = images[self.conf.image.name]
+
+ LOG.info('image create end......')
+
+ def delete(self):
+ LOG.info('image delete start.......')
+
+ if not self.use_existing_image and self.image:
+ self.glance.images.delete(self.image['id'])
+
+ LOG.info('image delete end.......')
import sys
import config
+from image import Image
import logger as doctor_log
-LOG = doctor_log.Logger(__name__).getLogger()
+LOG = doctor_log.Logger('doctor').getLogger()
class DoctorTest(object):
def __init__(self, conf):
self.conf = conf
+ self.image = Image(self.conf)
def run(self):
"""run doctor test"""
# prepare the cloud env
# preparing VM image...
+ self.image.create()
# creating test user...
# verify the test results
except Exception as e:
- LOG.error('doctor test failed: %s ', e)
+ LOG.error('doctor test failed, Exception=%s' % e)
+ sys.exit(1)
+ finally:
+ self.image.delete()
def main():
--- /dev/null
+##############################################################################\r
+# Copyright (c) 2017 ZTE Corporation and others.\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are made available under the terms of the Apache License, Version 2.0\r
+# which accompanies this distribution, and is available at\r
+# http://www.apache.org/licenses/LICENSE-2.0\r
+##############################################################################\r
+from oslo_config import cfg\r
+\r
+import glanceclient.client as glanceclient\r
+\r
+\r
+OPTS = [\r
+ cfg.StrOpt('glance_version', default='2', help='glance version'),\r
+]\r
+\r
+\r
+def glance_client(version, session):\r
+ return glanceclient.Client(version=version,\r
+ session=session)\r
install_command = pip install -U {opts} {packages}
setenv = VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/test-requirements.txt
+passenv =
+ OS_AUTH_URL
+ OS_USERNAME
+ OS_PASSWORD
+ OS_USER_DOMAIN_NAME
+ OS_PROJECT_NAME
+ OS_TENANT_NAME
+ OS_PROJECT_DOMAIN_NAME
+ IMAGE_NAME
+ VM_COUNT
+ PROFILER_TYPE
+ PYTHON_ENABLE
+ CI_DEBUG
[testenv:verify]
changedir = {toxinidir}/tests