tempest-stress/tempest_stress/actions/server_create_destroy.py
Ghanshyam Mann 0d1b2d9f2a Switch to use stable data_utils
Tempest provides stable library interfaces under tempest.lib.
This patch switches to use it for data_utils.

Tempest will remove the deprecated version of data_utils
in https://review.opendev.org/c/openstack/tempest/+/499869

Change-Id: I82621da3b9fe33063827f4f662b8fe9b07d6acee
2020-12-29 15:19:12 -06:00

44 lines
1.7 KiB
Python

# Copyright 2013 Quanta Research Cambridge, Inc.
#
# 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.
from tempest.common import waiters
from tempest import config
from tempest.lib.common.utils import data_utils
import tempest_stress.stressaction as stressaction
CONF = config.CONF
class ServerCreateDestroyTest(stressaction.StressAction):
def setUp(self, **kwargs):
self.image = CONF.compute.image_ref
self.flavor = CONF.compute.flavor_ref
def run(self):
name = data_utils.rand_name(self.__class__.__name__ + "-instance")
self.logger.info("creating %s" % name)
server = self.manager.servers_client.create_server(
name=name, imageRef=self.image, flavorRef=self.flavor)['server']
server_id = server['id']
waiters.wait_for_server_status(self.manager.servers_client, server_id,
'ACTIVE')
self.logger.info("created %s" % server_id)
self.logger.info("deleting %s" % name)
self.manager.servers_client.delete_server(server_id)
waiters.wait_for_server_termination(self.manager.servers_client,
server_id)
self.logger.info("deleted %s" % server_id)