
*) Change task config format . Split "context" & "runner" stuff *) Refactor Verification . Move validation to context.base, runner.base and scenario.base . Validate whole config fully before starting any of tasks . Optimize scenario args validation (create only one time clients) . Optimize order of validation: 1) Validate names of benchmarks 2) Validate all static parameters, e.g. configuration of runner and context 3) If everything is ok in all benchmarks, then start validation of scenario args. . Store validation result (exception) in task["verification_log"] . Remove verification logic from BenchmarkEngine.__exit__ . Remove scenario args verification results from task["results"] *) Fix & Swtich to new format doc/samples/tasks . Switch to new fromat . Add missing task configratuion . Better formatting . json & yaml samples *) Refactored unit tests . tests.rally.benchmark.test_engine . tests.rally.benchmark.context.base . tests.orcestrator.test_api.start_task cover validation step as well and new change format *) Refactor orchestrator api start task . Remove benchmark engine context . Call verify explicity . Do not raise any excpetion in case of validation error . Catch in start task any unexcepted Exceptions a set deployment in incosistance state *) Refactor CLI . Properly handle new behaviour of verification . Replace table on task start to just message . Add HINTs to task detailed command *) Add unit test for checking doc samples *) Improve benchmark engine LOGing blueprint benchmark-new-task-config Change-Id: I23d3f6b3439fdb44946a7c2491d5a9b3559dc671
97 lines
3.2 KiB
Python
97 lines
3.2 KiB
Python
# Copyright 2014: Mirantis Inc.
|
|
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
import functools
|
|
import sys
|
|
|
|
from rally.benchmark.context import base
|
|
from rally.benchmark import utils
|
|
from rally.openstack.common.gettextutils import _
|
|
from rally.openstack.common import log as logging
|
|
from rally import osclients
|
|
from rally import utils as rutils
|
|
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
|
|
class ResourceCleaner(base.Context):
|
|
"""Context class for resource cleanup (both admin and non-admin)."""
|
|
|
|
__ctx_name__ = "cleaner"
|
|
|
|
CONFIG_SCHEMA = {
|
|
"type": "object",
|
|
"$schema": "http://json-schema.org/draft-03/schema",
|
|
"properties": {},
|
|
"additionalProperties": False
|
|
}
|
|
|
|
def __init__(self, context):
|
|
super(ResourceCleaner, self).__init__(context)
|
|
self.admin = None
|
|
self.users = None
|
|
if "admin" in context and context["admin"]:
|
|
self.admin = context["admin"]["endpoint"]
|
|
if "users" in context and context["users"]:
|
|
self.users = [u["endpoint"] for u in context["users"]]
|
|
|
|
@rutils.log_task_wrapper(LOG.info, _("Cleanup users resources."))
|
|
def _cleanup_users_resources(self):
|
|
if not self.users:
|
|
return
|
|
|
|
for user in self.users:
|
|
clients = osclients.Clients(user)
|
|
methods = [
|
|
functools.partial(utils.delete_nova_resources, clients.nova()),
|
|
functools.partial(utils.delete_glance_resources,
|
|
clients.glance(), clients.keystone()),
|
|
functools.partial(utils.delete_cinder_resources,
|
|
clients.cinder())
|
|
]
|
|
|
|
for method in methods:
|
|
try:
|
|
method()
|
|
except Exception as e:
|
|
LOG.debug(_("Not all resources were cleaned."),
|
|
exc_info=sys.exc_info())
|
|
LOG.warning(_('Unable to fully cleanup the cloud: %s') %
|
|
(e.message))
|
|
|
|
@rutils.log_task_wrapper(LOG.info, _("Cleanup admin resources."))
|
|
def _cleanup_admin_resources(self):
|
|
if not self.admin:
|
|
return
|
|
|
|
try:
|
|
admin = osclients.Clients(self.admin)
|
|
utils.delete_keystone_resources(admin.keystone())
|
|
except Exception as e:
|
|
LOG.debug(_("Not all resources were cleaned."),
|
|
exc_info=sys.exc_info())
|
|
LOG.warning(_('Unable to fully cleanup keystone service: %s') %
|
|
(e.message))
|
|
|
|
def setup(self):
|
|
pass
|
|
|
|
def cleanup(self):
|
|
if self.users:
|
|
self._cleanup_users_resources()
|
|
if self.admin:
|
|
self._cleanup_admin_resources()
|