David Kranz | b9d9750 | 2013-05-01 15:55:04 -0400 | [diff] [blame] | 1 | # Copyright 2013 Quanta Research Cambridge, Inc. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
Fei Long Wang | d39431f | 2015-05-14 11:30:48 +1200 | [diff] [blame] | 15 | from tempest.common.utils import data_utils |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 16 | from tempest.common import waiters |
Matthew Treinish | 88f49ef | 2014-01-29 18:36:27 +0000 | [diff] [blame] | 17 | from tempest import config |
Walter A. Boring IV | b725e62 | 2013-07-11 17:21:33 -0700 | [diff] [blame] | 18 | import tempest.stress.stressaction as stressaction |
David Kranz | b9d9750 | 2013-05-01 15:55:04 -0400 | [diff] [blame] | 19 | |
Matthew Treinish | 88f49ef | 2014-01-29 18:36:27 +0000 | [diff] [blame] | 20 | CONF = config.CONF |
| 21 | |
David Kranz | b9d9750 | 2013-05-01 15:55:04 -0400 | [diff] [blame] | 22 | |
Giulio Fidente | c57ac8b | 2013-08-01 11:28:41 +0200 | [diff] [blame] | 23 | class ServerCreateDestroyTest(stressaction.StressAction): |
Walter A. Boring IV | b725e62 | 2013-07-11 17:21:33 -0700 | [diff] [blame] | 24 | |
| 25 | def setUp(self, **kwargs): |
Matthew Treinish | 88f49ef | 2014-01-29 18:36:27 +0000 | [diff] [blame] | 26 | self.image = CONF.compute.image_ref |
| 27 | self.flavor = CONF.compute.flavor_ref |
Walter A. Boring IV | b725e62 | 2013-07-11 17:21:33 -0700 | [diff] [blame] | 28 | |
| 29 | def run(self): |
zhufl | 63ce488 | 2016-09-06 16:04:35 +0800 | [diff] [blame] | 30 | name = data_utils.rand_name(self.__class__.__name__ + "-instance") |
Walter A. Boring IV | b725e62 | 2013-07-11 17:21:33 -0700 | [diff] [blame] | 31 | self.logger.info("creating %s" % name) |
David Kranz | 668d389 | 2015-02-16 09:20:08 -0500 | [diff] [blame] | 32 | server = self.manager.servers_client.create_server( |
Ken'ichi Ohmichi | f2d436e | 2015-09-03 01:13:16 +0000 | [diff] [blame] | 33 | name=name, imageRef=self.image, flavorRef=self.flavor)['server'] |
David Kranz | b9d9750 | 2013-05-01 15:55:04 -0400 | [diff] [blame] | 34 | server_id = server['id'] |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 35 | waiters.wait_for_server_status(self.manager.servers_client, server_id, |
| 36 | 'ACTIVE') |
Walter A. Boring IV | b725e62 | 2013-07-11 17:21:33 -0700 | [diff] [blame] | 37 | self.logger.info("created %s" % server_id) |
| 38 | self.logger.info("deleting %s" % name) |
ghanshyam | 51e84f4 | 2014-10-02 17:28:18 +0900 | [diff] [blame] | 39 | self.manager.servers_client.delete_server(server_id) |
Ken'ichi Ohmichi | e91a0c6 | 2015-08-13 02:09:16 +0000 | [diff] [blame] | 40 | waiters.wait_for_server_termination(self.manager.servers_client, |
| 41 | server_id) |
Walter A. Boring IV | b725e62 | 2013-07-11 17:21:33 -0700 | [diff] [blame] | 42 | self.logger.info("deleted %s" % server_id) |