Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 1 | # Copyright 2013 NEC Corporation. |
| 2 | # All Rights Reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | # not use this file except in compliance with the License. You may obtain |
| 6 | # a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | # License for the specific language governing permissions and limitations |
| 14 | # under the License. |
| 15 | |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 16 | from tempest_lib import exceptions as lib_exc |
| 17 | |
Sean Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 18 | from tempest.api.compute import base |
Matthew Treinish | a03ed79 | 2013-09-23 21:38:15 +0000 | [diff] [blame] | 19 | from tempest.common import tempest_fixtures as fixtures |
Fei Long Wang | d39431f | 2015-05-14 11:30:48 +1200 | [diff] [blame] | 20 | from tempest.common.utils import data_utils |
Masayuki Igawa | 394d8d9 | 2014-03-04 17:21:56 +0900 | [diff] [blame] | 21 | from tempest import test |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 22 | |
| 23 | |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 24 | class AggregatesAdminTestJSON(base.BaseV2ComputeAdminTest): |
Ken'ichi Ohmichi | 88363cb | 2015-11-19 08:00:54 +0000 | [diff] [blame] | 25 | """Tests Aggregates API that require admin privileges""" |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 26 | |
Mitsuhiko Yamazaki | ae8fc53 | 2013-04-22 11:17:35 +0900 | [diff] [blame] | 27 | _host_key = 'OS-EXT-SRV-ATTR:host' |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 28 | |
| 29 | @classmethod |
Rohan Kanade | 60b7309 | 2015-02-04 17:58:19 +0530 | [diff] [blame] | 30 | def setup_clients(cls): |
| 31 | super(AggregatesAdminTestJSON, cls).setup_clients() |
| 32 | cls.client = cls.os_adm.aggregates_client |
| 33 | |
| 34 | @classmethod |
Andrea Frittoli | 50bb80d | 2014-09-15 12:34:27 +0100 | [diff] [blame] | 35 | def resource_setup(cls): |
| 36 | super(AggregatesAdminTestJSON, cls).resource_setup() |
Ken'ichi Ohmichi | 4937f56 | 2015-03-23 00:15:01 +0000 | [diff] [blame] | 37 | cls.aggregate_name_prefix = 'test_aggregate' |
| 38 | cls.az_name_prefix = 'test_az' |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 39 | |
ghanshyam | e1bd29e | 2015-08-18 16:47:24 +0900 | [diff] [blame] | 40 | hosts_all = cls.os_adm.hosts_client.list_hosts()['hosts'] |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 41 | hosts = map(lambda x: x['host_name'], |
| 42 | filter(lambda y: y['service'] == 'compute', hosts_all)) |
| 43 | cls.host = hosts[0] |
| 44 | |
anju Tiwari | 0599f52 | 2014-04-17 17:10:40 +0530 | [diff] [blame] | 45 | def _try_delete_aggregate(self, aggregate_id): |
| 46 | # delete aggregate, if it exists |
| 47 | try: |
| 48 | self.client.delete_aggregate(aggregate_id) |
| 49 | # if aggregate not found, it depict it was deleted in the test |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 50 | except lib_exc.NotFound: |
anju Tiwari | 0599f52 | 2014-04-17 17:10:40 +0530 | [diff] [blame] | 51 | pass |
| 52 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 53 | @test.idempotent_id('0d148aa3-d54c-4317-aa8d-42040a475e20') |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 54 | def test_aggregate_create_delete(self): |
| 55 | # Create and delete an aggregate. |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 56 | aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) |
ghanshyam | 2eb282d | 2015-08-04 15:05:19 +0900 | [diff] [blame] | 57 | aggregate = (self.client.create_aggregate(name=aggregate_name) |
| 58 | ['aggregate']) |
anju Tiwari | 0599f52 | 2014-04-17 17:10:40 +0530 | [diff] [blame] | 59 | self.addCleanup(self._try_delete_aggregate, aggregate['id']) |
Chang Bo Guo | fc77e93 | 2013-09-16 17:38:26 -0700 | [diff] [blame] | 60 | self.assertEqual(aggregate_name, aggregate['name']) |
llg8212 | e4cd392 | 2014-02-15 12:14:21 +0800 | [diff] [blame] | 61 | self.assertIsNone(aggregate['availability_zone']) |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 62 | |
David Kranz | 0a73517 | 2015-01-16 10:51:18 -0500 | [diff] [blame] | 63 | self.client.delete_aggregate(aggregate['id']) |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 64 | self.client.wait_for_resource_deletion(aggregate['id']) |
| 65 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 66 | @test.idempotent_id('5873a6f8-671a-43ff-8838-7ce430bb6d0b') |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 67 | def test_aggregate_create_delete_with_az(self): |
| 68 | # Create and delete an aggregate. |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 69 | aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) |
| 70 | az_name = data_utils.rand_name(self.az_name_prefix) |
David Kranz | 0a73517 | 2015-01-16 10:51:18 -0500 | [diff] [blame] | 71 | aggregate = self.client.create_aggregate( |
ghanshyam | 2eb282d | 2015-08-04 15:05:19 +0900 | [diff] [blame] | 72 | name=aggregate_name, availability_zone=az_name)['aggregate'] |
anju Tiwari | 0599f52 | 2014-04-17 17:10:40 +0530 | [diff] [blame] | 73 | self.addCleanup(self._try_delete_aggregate, aggregate['id']) |
Chang Bo Guo | fc77e93 | 2013-09-16 17:38:26 -0700 | [diff] [blame] | 74 | self.assertEqual(aggregate_name, aggregate['name']) |
| 75 | self.assertEqual(az_name, aggregate['availability_zone']) |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 76 | |
David Kranz | 0a73517 | 2015-01-16 10:51:18 -0500 | [diff] [blame] | 77 | self.client.delete_aggregate(aggregate['id']) |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 78 | self.client.wait_for_resource_deletion(aggregate['id']) |
| 79 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 80 | @test.idempotent_id('68089c38-04b1-4758-bdf0-cf0daec4defd') |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 81 | def test_aggregate_create_verify_entry_in_list(self): |
| 82 | # Create an aggregate and ensure it is listed. |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 83 | aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) |
ghanshyam | 2eb282d | 2015-08-04 15:05:19 +0900 | [diff] [blame] | 84 | aggregate = (self.client.create_aggregate(name=aggregate_name) |
| 85 | ['aggregate']) |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 86 | self.addCleanup(self.client.delete_aggregate, aggregate['id']) |
| 87 | |
ghanshyam | 2eb282d | 2015-08-04 15:05:19 +0900 | [diff] [blame] | 88 | aggregates = self.client.list_aggregates()['aggregates'] |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 89 | self.assertIn((aggregate['id'], aggregate['availability_zone']), |
| 90 | map(lambda x: (x['id'], x['availability_zone']), |
| 91 | aggregates)) |
| 92 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 93 | @test.idempotent_id('36ec92ca-7a73-43bc-b920-7531809e8540') |
ivan-zhu | 35e1f8e | 2013-10-18 15:51:16 +0800 | [diff] [blame] | 94 | def test_aggregate_create_update_metadata_get_details(self): |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 95 | # Create an aggregate and ensure its details are returned. |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 96 | aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) |
ghanshyam | 2eb282d | 2015-08-04 15:05:19 +0900 | [diff] [blame] | 97 | aggregate = (self.client.create_aggregate(name=aggregate_name) |
| 98 | ['aggregate']) |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 99 | self.addCleanup(self.client.delete_aggregate, aggregate['id']) |
| 100 | |
ghanshyam | 2eb282d | 2015-08-04 15:05:19 +0900 | [diff] [blame] | 101 | body = self.client.show_aggregate(aggregate['id'])['aggregate'] |
Chang Bo Guo | fc77e93 | 2013-09-16 17:38:26 -0700 | [diff] [blame] | 102 | self.assertEqual(aggregate['name'], body['name']) |
| 103 | self.assertEqual(aggregate['availability_zone'], |
| 104 | body['availability_zone']) |
ivan-zhu | 35e1f8e | 2013-10-18 15:51:16 +0800 | [diff] [blame] | 105 | self.assertEqual({}, body["metadata"]) |
| 106 | |
| 107 | # set the metadata of the aggregate |
| 108 | meta = {"key": "value"} |
Ken'ichi Ohmichi | ec452b8 | 2015-07-15 04:59:51 +0000 | [diff] [blame] | 109 | body = self.client.set_metadata(aggregate['id'], metadata=meta) |
ghanshyam | 2eb282d | 2015-08-04 15:05:19 +0900 | [diff] [blame] | 110 | self.assertEqual(meta, body['aggregate']["metadata"]) |
ivan-zhu | 35e1f8e | 2013-10-18 15:51:16 +0800 | [diff] [blame] | 111 | |
| 112 | # verify the metadata has been set |
ghanshyam | 2eb282d | 2015-08-04 15:05:19 +0900 | [diff] [blame] | 113 | body = self.client.show_aggregate(aggregate['id'])['aggregate'] |
ivan-zhu | 35e1f8e | 2013-10-18 15:51:16 +0800 | [diff] [blame] | 114 | self.assertEqual(meta, body["metadata"]) |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 115 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 116 | @test.idempotent_id('4d2b2004-40fa-40a1-aab2-66f4dab81beb') |
Zhu Zhu | 7b5f629 | 2013-09-22 15:47:54 +0800 | [diff] [blame] | 117 | def test_aggregate_create_update_with_az(self): |
| 118 | # Update an aggregate and ensure properties are updated correctly |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 119 | aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) |
| 120 | az_name = data_utils.rand_name(self.az_name_prefix) |
David Kranz | 0a73517 | 2015-01-16 10:51:18 -0500 | [diff] [blame] | 121 | aggregate = self.client.create_aggregate( |
ghanshyam | 2eb282d | 2015-08-04 15:05:19 +0900 | [diff] [blame] | 122 | name=aggregate_name, availability_zone=az_name)['aggregate'] |
Zhu Zhu | 7b5f629 | 2013-09-22 15:47:54 +0800 | [diff] [blame] | 123 | self.addCleanup(self.client.delete_aggregate, aggregate['id']) |
| 124 | |
Zhu Zhu | 7b5f629 | 2013-09-22 15:47:54 +0800 | [diff] [blame] | 125 | self.assertEqual(aggregate_name, aggregate['name']) |
| 126 | self.assertEqual(az_name, aggregate['availability_zone']) |
| 127 | self.assertIsNotNone(aggregate['id']) |
| 128 | |
| 129 | aggregate_id = aggregate['id'] |
| 130 | new_aggregate_name = aggregate_name + '_new' |
| 131 | new_az_name = az_name + '_new' |
| 132 | |
Ken'ichi Ohmichi | ec452b8 | 2015-07-15 04:59:51 +0000 | [diff] [blame] | 133 | resp_aggregate = self.client.update_aggregate( |
| 134 | aggregate_id, |
| 135 | name=new_aggregate_name, |
ghanshyam | 2eb282d | 2015-08-04 15:05:19 +0900 | [diff] [blame] | 136 | availability_zone=new_az_name)['aggregate'] |
Zhu Zhu | 7b5f629 | 2013-09-22 15:47:54 +0800 | [diff] [blame] | 137 | self.assertEqual(new_aggregate_name, resp_aggregate['name']) |
| 138 | self.assertEqual(new_az_name, resp_aggregate['availability_zone']) |
| 139 | |
ghanshyam | 2eb282d | 2015-08-04 15:05:19 +0900 | [diff] [blame] | 140 | aggregates = self.client.list_aggregates()['aggregates'] |
Zhu Zhu | 7b5f629 | 2013-09-22 15:47:54 +0800 | [diff] [blame] | 141 | self.assertIn((aggregate_id, new_aggregate_name, new_az_name), |
| 142 | map(lambda x: |
Matthew Treinish | 1d14c54 | 2014-06-17 20:25:40 -0400 | [diff] [blame] | 143 | (x['id'], x['name'], x['availability_zone']), |
Zhu Zhu | 7b5f629 | 2013-09-22 15:47:54 +0800 | [diff] [blame] | 144 | aggregates)) |
| 145 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 146 | @test.idempotent_id('c8e85064-e79b-4906-9931-c11c24294d02') |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 147 | def test_aggregate_add_remove_host(self): |
| 148 | # Add an host to the given aggregate and remove. |
Matthew Treinish | a03ed79 | 2013-09-23 21:38:15 +0000 | [diff] [blame] | 149 | self.useFixture(fixtures.LockFixture('availability_zone')) |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 150 | aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) |
ghanshyam | 2eb282d | 2015-08-04 15:05:19 +0900 | [diff] [blame] | 151 | aggregate = (self.client.create_aggregate(name=aggregate_name) |
| 152 | ['aggregate']) |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 153 | self.addCleanup(self.client.delete_aggregate, aggregate['id']) |
| 154 | |
ghanshyam | 2eb282d | 2015-08-04 15:05:19 +0900 | [diff] [blame] | 155 | body = (self.client.add_host(aggregate['id'], host=self.host) |
| 156 | ['aggregate']) |
Chang Bo Guo | fc77e93 | 2013-09-16 17:38:26 -0700 | [diff] [blame] | 157 | self.assertEqual(aggregate_name, body['name']) |
| 158 | self.assertEqual(aggregate['availability_zone'], |
| 159 | body['availability_zone']) |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 160 | self.assertIn(self.host, body['hosts']) |
| 161 | |
ghanshyam | 2eb282d | 2015-08-04 15:05:19 +0900 | [diff] [blame] | 162 | body = (self.client.remove_host(aggregate['id'], host=self.host) |
| 163 | ['aggregate']) |
Chang Bo Guo | fc77e93 | 2013-09-16 17:38:26 -0700 | [diff] [blame] | 164 | self.assertEqual(aggregate_name, body['name']) |
| 165 | self.assertEqual(aggregate['availability_zone'], |
| 166 | body['availability_zone']) |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 167 | self.assertNotIn(self.host, body['hosts']) |
| 168 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 169 | @test.idempotent_id('7f6a1cc5-2446-4cdb-9baa-b6ae0a919b72') |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 170 | def test_aggregate_add_host_list(self): |
| 171 | # Add an host to the given aggregate and list. |
Matthew Treinish | a03ed79 | 2013-09-23 21:38:15 +0000 | [diff] [blame] | 172 | self.useFixture(fixtures.LockFixture('availability_zone')) |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 173 | aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) |
ghanshyam | 2eb282d | 2015-08-04 15:05:19 +0900 | [diff] [blame] | 174 | aggregate = (self.client.create_aggregate(name=aggregate_name) |
| 175 | ['aggregate']) |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 176 | self.addCleanup(self.client.delete_aggregate, aggregate['id']) |
Ken'ichi Ohmichi | ec452b8 | 2015-07-15 04:59:51 +0000 | [diff] [blame] | 177 | self.client.add_host(aggregate['id'], host=self.host) |
| 178 | self.addCleanup(self.client.remove_host, aggregate['id'], |
| 179 | host=self.host) |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 180 | |
ghanshyam | 2eb282d | 2015-08-04 15:05:19 +0900 | [diff] [blame] | 181 | aggregates = self.client.list_aggregates()['aggregates'] |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 182 | aggs = filter(lambda x: x['id'] == aggregate['id'], aggregates) |
Chang Bo Guo | fc77e93 | 2013-09-16 17:38:26 -0700 | [diff] [blame] | 183 | self.assertEqual(1, len(aggs)) |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 184 | agg = aggs[0] |
Chang Bo Guo | fc77e93 | 2013-09-16 17:38:26 -0700 | [diff] [blame] | 185 | self.assertEqual(aggregate_name, agg['name']) |
llg8212 | e4cd392 | 2014-02-15 12:14:21 +0800 | [diff] [blame] | 186 | self.assertIsNone(agg['availability_zone']) |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 187 | self.assertIn(self.host, agg['hosts']) |
| 188 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 189 | @test.idempotent_id('eeef473c-7c52-494d-9f09-2ed7fc8fc036') |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 190 | def test_aggregate_add_host_get_details(self): |
| 191 | # Add an host to the given aggregate and get details. |
Matthew Treinish | a03ed79 | 2013-09-23 21:38:15 +0000 | [diff] [blame] | 192 | self.useFixture(fixtures.LockFixture('availability_zone')) |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 193 | aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) |
ghanshyam | 2eb282d | 2015-08-04 15:05:19 +0900 | [diff] [blame] | 194 | aggregate = (self.client.create_aggregate(name=aggregate_name) |
| 195 | ['aggregate']) |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 196 | self.addCleanup(self.client.delete_aggregate, aggregate['id']) |
Ken'ichi Ohmichi | ec452b8 | 2015-07-15 04:59:51 +0000 | [diff] [blame] | 197 | self.client.add_host(aggregate['id'], host=self.host) |
| 198 | self.addCleanup(self.client.remove_host, aggregate['id'], |
| 199 | host=self.host) |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 200 | |
ghanshyam | 2eb282d | 2015-08-04 15:05:19 +0900 | [diff] [blame] | 201 | body = self.client.show_aggregate(aggregate['id'])['aggregate'] |
Chang Bo Guo | fc77e93 | 2013-09-16 17:38:26 -0700 | [diff] [blame] | 202 | self.assertEqual(aggregate_name, body['name']) |
llg8212 | e4cd392 | 2014-02-15 12:14:21 +0800 | [diff] [blame] | 203 | self.assertIsNone(body['availability_zone']) |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 204 | self.assertIn(self.host, body['hosts']) |
| 205 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 206 | @test.idempotent_id('96be03c7-570d-409c-90f8-e4db3c646996') |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 207 | def test_aggregate_add_host_create_server_with_az(self): |
| 208 | # Add an host to the given aggregate and create a server. |
Matthew Treinish | a03ed79 | 2013-09-23 21:38:15 +0000 | [diff] [blame] | 209 | self.useFixture(fixtures.LockFixture('availability_zone')) |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 210 | aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) |
| 211 | az_name = data_utils.rand_name(self.az_name_prefix) |
David Kranz | 0a73517 | 2015-01-16 10:51:18 -0500 | [diff] [blame] | 212 | aggregate = self.client.create_aggregate( |
ghanshyam | 2eb282d | 2015-08-04 15:05:19 +0900 | [diff] [blame] | 213 | name=aggregate_name, availability_zone=az_name)['aggregate'] |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 214 | self.addCleanup(self.client.delete_aggregate, aggregate['id']) |
Ken'ichi Ohmichi | ec452b8 | 2015-07-15 04:59:51 +0000 | [diff] [blame] | 215 | self.client.add_host(aggregate['id'], host=self.host) |
| 216 | self.addCleanup(self.client.remove_host, aggregate['id'], |
| 217 | host=self.host) |
Ken'ichi Ohmichi | 4937f56 | 2015-03-23 00:15:01 +0000 | [diff] [blame] | 218 | server_name = data_utils.rand_name('test_server') |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 219 | admin_servers_client = self.os_adm.servers_client |
David Kranz | 0fb1429 | 2015-02-11 15:55:20 -0500 | [diff] [blame] | 220 | server = self.create_test_server(name=server_name, |
| 221 | availability_zone=az_name, |
| 222 | wait_until='ACTIVE') |
ghanshyam | 0f82525 | 2015-08-25 16:02:50 +0900 | [diff] [blame] | 223 | body = admin_servers_client.show_server(server['id'])['server'] |
Mitsuhiko Yamazaki | ae8fc53 | 2013-04-22 11:17:35 +0900 | [diff] [blame] | 224 | self.assertEqual(self.host, body[self._host_key]) |