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 |
Matthew Treinish | 88f49ef | 2014-01-29 18:36:27 +0000 | [diff] [blame] | 16 | from tempest import config |
Walter A. Boring IV | b725e62 | 2013-07-11 17:21:33 -0700 | [diff] [blame] | 17 | import tempest.stress.stressaction as stressaction |
David Kranz | b9d9750 | 2013-05-01 15:55:04 -0400 | [diff] [blame] | 18 | |
Matthew Treinish | 88f49ef | 2014-01-29 18:36:27 +0000 | [diff] [blame] | 19 | CONF = config.CONF |
| 20 | |
David Kranz | b9d9750 | 2013-05-01 15:55:04 -0400 | [diff] [blame] | 21 | |
Giulio Fidente | c57ac8b | 2013-08-01 11:28:41 +0200 | [diff] [blame] | 22 | class ServerCreateDestroyTest(stressaction.StressAction): |
Walter A. Boring IV | b725e62 | 2013-07-11 17:21:33 -0700 | [diff] [blame] | 23 | |
| 24 | def setUp(self, **kwargs): |
Matthew Treinish | 88f49ef | 2014-01-29 18:36:27 +0000 | [diff] [blame] | 25 | self.image = CONF.compute.image_ref |
| 26 | self.flavor = CONF.compute.flavor_ref |
Walter A. Boring IV | b725e62 | 2013-07-11 17:21:33 -0700 | [diff] [blame] | 27 | |
| 28 | def run(self): |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 29 | name = data_utils.rand_name("instance") |
Walter A. Boring IV | b725e62 | 2013-07-11 17:21:33 -0700 | [diff] [blame] | 30 | self.logger.info("creating %s" % name) |
David Kranz | 668d389 | 2015-02-16 09:20:08 -0500 | [diff] [blame] | 31 | server = self.manager.servers_client.create_server( |
Walter A. Boring IV | b725e62 | 2013-07-11 17:21:33 -0700 | [diff] [blame] | 32 | name, self.image, self.flavor) |
David Kranz | b9d9750 | 2013-05-01 15:55:04 -0400 | [diff] [blame] | 33 | server_id = server['id'] |
Walter A. Boring IV | b725e62 | 2013-07-11 17:21:33 -0700 | [diff] [blame] | 34 | self.manager.servers_client.wait_for_server_status(server_id, |
| 35 | 'ACTIVE') |
| 36 | self.logger.info("created %s" % server_id) |
| 37 | self.logger.info("deleting %s" % name) |
ghanshyam | 51e84f4 | 2014-10-02 17:28:18 +0900 | [diff] [blame] | 38 | self.manager.servers_client.delete_server(server_id) |
Walter A. Boring IV | b725e62 | 2013-07-11 17:21:33 -0700 | [diff] [blame] | 39 | self.manager.servers_client.wait_for_server_termination(server_id) |
| 40 | self.logger.info("deleted %s" % server_id) |