Dan Smith | 8ad1c47 | 2013-02-26 13:03:16 -0500 | [diff] [blame] | 1 | # Copyright 2013 IBM Corp. |
| 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 | |
Rohan Kanade | 9ce97df | 2013-12-10 18:59:35 +0530 | [diff] [blame] | 16 | import time |
| 17 | |
junboli | bc2ae86 | 2017-07-29 15:46:48 +0800 | [diff] [blame] | 18 | import six |
| 19 | |
Sean Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 20 | from tempest.api.compute import base |
Matt Riedemann | a8c641a | 2016-07-12 17:07:33 -0400 | [diff] [blame] | 21 | from tempest.common import compute |
Andrea Frittoli | cd36841 | 2017-08-14 21:37:56 +0100 | [diff] [blame] | 22 | from tempest.common import utils |
Ryan Tidwell | 1964a26 | 2016-05-04 15:13:23 -0700 | [diff] [blame] | 23 | from tempest.common.utils import net_utils |
Matt Riedemann | a8c641a | 2016-07-12 17:07:33 -0400 | [diff] [blame] | 24 | from tempest.common import waiters |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 25 | from tempest import config |
Matt Riedemann | 3570c1e | 2016-07-29 12:15:38 -0400 | [diff] [blame] | 26 | from tempest.lib import decorators |
Andrea Frittoli (andreaf) | db9672e | 2016-02-23 14:07:24 -0500 | [diff] [blame] | 27 | from tempest.lib import exceptions as lib_exc |
Dan Smith | 8ad1c47 | 2013-02-26 13:03:16 -0500 | [diff] [blame] | 28 | |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 29 | CONF = config.CONF |
| 30 | |
Dan Smith | 8ad1c47 | 2013-02-26 13:03:16 -0500 | [diff] [blame] | 31 | |
zhufl | 615e63b | 2018-08-01 17:23:38 +0800 | [diff] [blame] | 32 | class AttachInterfacesTestBase(base.BaseV2ComputeTest): |
Dan Smith | 8ad1c47 | 2013-02-26 13:03:16 -0500 | [diff] [blame] | 33 | |
| 34 | @classmethod |
Emily Hugenbruch | e7991d9 | 2014-12-12 16:53:36 +0000 | [diff] [blame] | 35 | def skip_checks(cls): |
zhufl | 615e63b | 2018-08-01 17:23:38 +0800 | [diff] [blame] | 36 | super(AttachInterfacesTestBase, cls).skip_checks() |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 37 | if not CONF.service_available.neutron: |
Mark McClain | f2982e8 | 2013-07-06 17:48:03 -0400 | [diff] [blame] | 38 | raise cls.skipException("Neutron is required") |
Adam Gandelman | 7186f7a | 2014-07-23 09:28:56 -0400 | [diff] [blame] | 39 | if not CONF.compute_feature_enabled.interface_attach: |
| 40 | raise cls.skipException("Interface attachment is not available.") |
Emily Hugenbruch | e7991d9 | 2014-12-12 16:53:36 +0000 | [diff] [blame] | 41 | |
| 42 | @classmethod |
| 43 | def setup_credentials(cls): |
Salvatore Orlando | 5a33724 | 2014-01-15 22:49:22 +0000 | [diff] [blame] | 44 | # This test class requires network and subnet |
| 45 | cls.set_network_resources(network=True, subnet=True) |
zhufl | 615e63b | 2018-08-01 17:23:38 +0800 | [diff] [blame] | 46 | super(AttachInterfacesTestBase, cls).setup_credentials() |
Emily Hugenbruch | e7991d9 | 2014-12-12 16:53:36 +0000 | [diff] [blame] | 47 | |
| 48 | @classmethod |
| 49 | def setup_clients(cls): |
zhufl | 615e63b | 2018-08-01 17:23:38 +0800 | [diff] [blame] | 50 | super(AttachInterfacesTestBase, cls).setup_clients() |
Jordan Pittier | 8160d31 | 2017-04-18 11:52:23 +0200 | [diff] [blame] | 51 | cls.subnets_client = cls.os_primary.subnets_client |
| 52 | cls.ports_client = cls.os_primary.ports_client |
Dan Smith | 8ad1c47 | 2013-02-26 13:03:16 -0500 | [diff] [blame] | 53 | |
zhufl | 615e63b | 2018-08-01 17:23:38 +0800 | [diff] [blame] | 54 | def _create_server_get_interfaces(self): |
| 55 | server = self.create_test_server(wait_until='ACTIVE') |
| 56 | ifs = (self.interfaces_client.list_interfaces(server['id']) |
| 57 | ['interfaceAttachments']) |
| 58 | body = waiters.wait_for_interface_status( |
| 59 | self.interfaces_client, server['id'], ifs[0]['port_id'], 'ACTIVE') |
| 60 | ifs[0]['port_state'] = body['port_state'] |
| 61 | return server, ifs |
| 62 | |
| 63 | |
| 64 | class AttachInterfacesTestJSON(AttachInterfacesTestBase): |
| 65 | |
Matt Riedemann | a8c641a | 2016-07-12 17:07:33 -0400 | [diff] [blame] | 66 | def wait_for_port_detach(self, port_id): |
| 67 | """Waits for the port's device_id to be unset. |
| 68 | |
| 69 | :param port_id: The id of the port being detached. |
| 70 | :returns: The final port dict from the show_port response. |
| 71 | """ |
| 72 | port = self.ports_client.show_port(port_id)['port'] |
| 73 | device_id = port['device_id'] |
| 74 | start = int(time.time()) |
| 75 | |
| 76 | # NOTE(mriedem): Nova updates the port's device_id to '' rather than |
| 77 | # None, but it's not contractual so handle Falsey either way. |
| 78 | while device_id: |
| 79 | time.sleep(self.build_interval) |
| 80 | port = self.ports_client.show_port(port_id)['port'] |
| 81 | device_id = port['device_id'] |
| 82 | |
| 83 | timed_out = int(time.time()) - start >= self.build_timeout |
| 84 | |
| 85 | if device_id and timed_out: |
| 86 | message = ('Port %s failed to detach (device_id %s) within ' |
| 87 | 'the required time (%s s).' % |
| 88 | (port_id, device_id, self.build_timeout)) |
guo yunxian | ebb15f2 | 2016-11-01 21:03:35 +0800 | [diff] [blame] | 89 | raise lib_exc.TimeoutException(message) |
Matt Riedemann | a8c641a | 2016-07-12 17:07:33 -0400 | [diff] [blame] | 90 | |
| 91 | return port |
| 92 | |
lianghao | 1635334 | 2017-11-28 21:08:12 +0800 | [diff] [blame] | 93 | def _check_interface(self, iface, server_id=None, port_id=None, |
| 94 | network_id=None, fixed_ip=None, mac_addr=None): |
| 95 | if server_id: |
| 96 | iface = waiters.wait_for_interface_status( |
| 97 | self.interfaces_client, server_id, iface['port_id'], 'ACTIVE') |
Dan Smith | 8ad1c47 | 2013-02-26 13:03:16 -0500 | [diff] [blame] | 98 | if port_id: |
| 99 | self.assertEqual(iface['port_id'], port_id) |
| 100 | if network_id: |
| 101 | self.assertEqual(iface['net_id'], network_id) |
| 102 | if fixed_ip: |
| 103 | self.assertEqual(iface['fixed_ips'][0]['ip_address'], fixed_ip) |
venkata anil | 4537530 | 2014-12-30 10:41:43 +0000 | [diff] [blame] | 104 | if mac_addr: |
| 105 | self.assertEqual(iface['mac_addr'], mac_addr) |
Dan Smith | 8ad1c47 | 2013-02-26 13:03:16 -0500 | [diff] [blame] | 106 | |
Dan Smith | 8ad1c47 | 2013-02-26 13:03:16 -0500 | [diff] [blame] | 107 | def _test_create_interface(self, server): |
lkuchlan | 87b5a2d | 2016-09-27 15:46:16 +0300 | [diff] [blame] | 108 | iface = (self.interfaces_client.create_interface(server['id']) |
ghanshyam | a2364f1 | 2015-08-24 15:45:37 +0900 | [diff] [blame] | 109 | ['interfaceAttachment']) |
zhufl | 7b63833 | 2016-11-14 10:23:30 +0800 | [diff] [blame] | 110 | iface = waiters.wait_for_interface_status( |
| 111 | self.interfaces_client, server['id'], iface['port_id'], 'ACTIVE') |
Dan Smith | 8ad1c47 | 2013-02-26 13:03:16 -0500 | [diff] [blame] | 112 | return iface |
| 113 | |
| 114 | def _test_create_interface_by_network_id(self, server, ifs): |
| 115 | network_id = ifs[0]['net_id'] |
lkuchlan | 87b5a2d | 2016-09-27 15:46:16 +0300 | [diff] [blame] | 116 | iface = self.interfaces_client.create_interface( |
ghanshyam | a2364f1 | 2015-08-24 15:45:37 +0900 | [diff] [blame] | 117 | server['id'], net_id=network_id)['interfaceAttachment'] |
lianghao | 1635334 | 2017-11-28 21:08:12 +0800 | [diff] [blame] | 118 | self._check_interface(iface, server_id=server['id'], |
| 119 | network_id=network_id) |
Dan Smith | 8ad1c47 | 2013-02-26 13:03:16 -0500 | [diff] [blame] | 120 | return iface |
| 121 | |
Maho Koshiya | 3fc1246 | 2015-12-14 19:03:12 +0900 | [diff] [blame] | 122 | def _test_create_interface_by_port_id(self, server, ifs): |
| 123 | network_id = ifs[0]['net_id'] |
| 124 | port = self.ports_client.create_port(network_id=network_id) |
| 125 | port_id = port['port']['id'] |
| 126 | self.addCleanup(self.ports_client.delete_port, port_id) |
lkuchlan | 87b5a2d | 2016-09-27 15:46:16 +0300 | [diff] [blame] | 127 | iface = self.interfaces_client.create_interface( |
Maho Koshiya | 3fc1246 | 2015-12-14 19:03:12 +0900 | [diff] [blame] | 128 | server['id'], port_id=port_id)['interfaceAttachment'] |
lianghao | 1635334 | 2017-11-28 21:08:12 +0800 | [diff] [blame] | 129 | self._check_interface(iface, server_id=server['id'], port_id=port_id, |
| 130 | network_id=network_id) |
Maho Koshiya | 3fc1246 | 2015-12-14 19:03:12 +0900 | [diff] [blame] | 131 | return iface |
| 132 | |
Maho Koshiya | 7b62958 | 2016-02-22 10:59:01 +0900 | [diff] [blame] | 133 | def _test_create_interface_by_fixed_ips(self, server, ifs): |
| 134 | network_id = ifs[0]['net_id'] |
Ryan Tidwell | 1964a26 | 2016-05-04 15:13:23 -0700 | [diff] [blame] | 135 | subnet_id = ifs[0]['fixed_ips'][0]['subnet_id'] |
| 136 | ip_list = net_utils.get_unused_ip_addresses(self.ports_client, |
| 137 | self.subnets_client, |
| 138 | network_id, |
| 139 | subnet_id, |
| 140 | 1) |
Maho Koshiya | 7b62958 | 2016-02-22 10:59:01 +0900 | [diff] [blame] | 141 | |
Ryan Tidwell | 1964a26 | 2016-05-04 15:13:23 -0700 | [diff] [blame] | 142 | fixed_ips = [{'ip_address': ip_list[0]}] |
lkuchlan | 87b5a2d | 2016-09-27 15:46:16 +0300 | [diff] [blame] | 143 | iface = self.interfaces_client.create_interface( |
Maho Koshiya | 7b62958 | 2016-02-22 10:59:01 +0900 | [diff] [blame] | 144 | server['id'], net_id=network_id, |
| 145 | fixed_ips=fixed_ips)['interfaceAttachment'] |
| 146 | self.addCleanup(self.ports_client.delete_port, iface['port_id']) |
lianghao | 1635334 | 2017-11-28 21:08:12 +0800 | [diff] [blame] | 147 | self._check_interface(iface, server_id=server['id'], |
| 148 | fixed_ip=ip_list[0]) |
Maho Koshiya | 7b62958 | 2016-02-22 10:59:01 +0900 | [diff] [blame] | 149 | return iface |
| 150 | |
Dan Smith | 8ad1c47 | 2013-02-26 13:03:16 -0500 | [diff] [blame] | 151 | def _test_show_interface(self, server, ifs): |
| 152 | iface = ifs[0] |
lkuchlan | 87b5a2d | 2016-09-27 15:46:16 +0300 | [diff] [blame] | 153 | _iface = self.interfaces_client.show_interface( |
ghanshyam | a2364f1 | 2015-08-24 15:45:37 +0900 | [diff] [blame] | 154 | server['id'], iface['port_id'])['interfaceAttachment'] |
venkata anil | 4537530 | 2014-12-30 10:41:43 +0000 | [diff] [blame] | 155 | self._check_interface(iface, port_id=_iface['port_id'], |
| 156 | network_id=_iface['net_id'], |
| 157 | fixed_ip=_iface['fixed_ips'][0]['ip_address'], |
| 158 | mac_addr=_iface['mac_addr']) |
Dan Smith | 8ad1c47 | 2013-02-26 13:03:16 -0500 | [diff] [blame] | 159 | |
| 160 | def _test_delete_interface(self, server, ifs): |
| 161 | # NOTE(danms): delete not the first or last, but one in the middle |
| 162 | iface = ifs[1] |
lkuchlan | 87b5a2d | 2016-09-27 15:46:16 +0300 | [diff] [blame] | 163 | self.interfaces_client.delete_interface(server['id'], iface['port_id']) |
| 164 | _ifs = (self.interfaces_client.list_interfaces(server['id']) |
ghanshyam | a2364f1 | 2015-08-24 15:45:37 +0900 | [diff] [blame] | 165 | ['interfaceAttachments']) |
Oleg Bondarev | ee50bb1 | 2014-01-16 00:01:34 +0400 | [diff] [blame] | 166 | start = int(time.time()) |
Dan Smith | 8ad1c47 | 2013-02-26 13:03:16 -0500 | [diff] [blame] | 167 | |
Oleg Bondarev | ee50bb1 | 2014-01-16 00:01:34 +0400 | [diff] [blame] | 168 | while len(ifs) == len(_ifs): |
| 169 | time.sleep(self.build_interval) |
lkuchlan | 87b5a2d | 2016-09-27 15:46:16 +0300 | [diff] [blame] | 170 | _ifs = (self.interfaces_client.list_interfaces(server['id']) |
ghanshyam | a2364f1 | 2015-08-24 15:45:37 +0900 | [diff] [blame] | 171 | ['interfaceAttachments']) |
Oleg Bondarev | ee50bb1 | 2014-01-16 00:01:34 +0400 | [diff] [blame] | 172 | timed_out = int(time.time()) - start >= self.build_timeout |
| 173 | if len(ifs) == len(_ifs) and timed_out: |
| 174 | message = ('Failed to delete interface within ' |
| 175 | 'the required time: %s sec.' % self.build_timeout) |
guo yunxian | ebb15f2 | 2016-11-01 21:03:35 +0800 | [diff] [blame] | 176 | raise lib_exc.TimeoutException(message) |
Oleg Bondarev | ee50bb1 | 2014-01-16 00:01:34 +0400 | [diff] [blame] | 177 | |
| 178 | self.assertNotIn(iface['port_id'], [i['port_id'] for i in _ifs]) |
Dan Smith | 8ad1c47 | 2013-02-26 13:03:16 -0500 | [diff] [blame] | 179 | return _ifs |
| 180 | |
| 181 | def _compare_iface_list(self, list1, list2): |
| 182 | # NOTE(danms): port_state will likely have changed, so just |
| 183 | # confirm the port_ids are the same at least |
| 184 | list1 = [x['port_id'] for x in list1] |
| 185 | list2 = [x['port_id'] for x in list2] |
| 186 | |
| 187 | self.assertEqual(sorted(list1), sorted(list2)) |
| 188 | |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 189 | @decorators.idempotent_id('73fe8f02-590d-4bf1-b184-e9ca81065051') |
Andrea Frittoli | cd36841 | 2017-08-14 21:37:56 +0100 | [diff] [blame] | 190 | @utils.services('network') |
zhufl | 607cfbf | 2017-12-28 14:55:08 +0800 | [diff] [blame] | 191 | def test_create_list_show_delete_interfaces_by_network_port(self): |
Dan Smith | 8ad1c47 | 2013-02-26 13:03:16 -0500 | [diff] [blame] | 192 | server, ifs = self._create_server_get_interfaces() |
| 193 | interface_count = len(ifs) |
zhufl | 080dcfb | 2016-10-21 17:45:38 +0800 | [diff] [blame] | 194 | self.assertGreater(interface_count, 0) |
Dan Smith | 8ad1c47 | 2013-02-26 13:03:16 -0500 | [diff] [blame] | 195 | |
Rohan Kanade | 9ce97df | 2013-12-10 18:59:35 +0530 | [diff] [blame] | 196 | try: |
| 197 | iface = self._test_create_interface(server) |
| 198 | except lib_exc.BadRequest as e: |
| 199 | msg = ('Multiple possible networks found, use a Network ID to be ' |
| 200 | 'more specific.') |
junboli | bc2ae86 | 2017-07-29 15:46:48 +0800 | [diff] [blame] | 201 | if not CONF.compute.fixed_network_name and six.text_type(e) == msg: |
Rohan Kanade | 9ce97df | 2013-12-10 18:59:35 +0530 | [diff] [blame] | 202 | raise |
| 203 | else: |
| 204 | ifs.append(iface) |
Dan Smith | 8ad1c47 | 2013-02-26 13:03:16 -0500 | [diff] [blame] | 205 | |
| 206 | iface = self._test_create_interface_by_network_id(server, ifs) |
| 207 | ifs.append(iface) |
| 208 | |
Maho Koshiya | 3fc1246 | 2015-12-14 19:03:12 +0900 | [diff] [blame] | 209 | iface = self._test_create_interface_by_port_id(server, ifs) |
| 210 | ifs.append(iface) |
| 211 | |
zhufl | 607cfbf | 2017-12-28 14:55:08 +0800 | [diff] [blame] | 212 | _ifs = (self.interfaces_client.list_interfaces(server['id']) |
| 213 | ['interfaceAttachments']) |
| 214 | self._compare_iface_list(ifs, _ifs) |
| 215 | |
| 216 | self._test_show_interface(server, ifs) |
| 217 | |
| 218 | _ifs = self._test_delete_interface(server, ifs) |
| 219 | self.assertEqual(len(ifs) - 1, len(_ifs)) |
| 220 | |
| 221 | @decorators.idempotent_id('d290c06c-f5b3-11e7-8ec8-002293781009') |
| 222 | @utils.services('network') |
| 223 | def test_create_list_show_delete_interfaces_by_fixed_ip(self): |
| 224 | # NOTE(zhufl) By default only project that is admin or network owner |
| 225 | # or project with role advsvc is authorised to create interfaces with |
| 226 | # fixed-ip, so if we don't create network for each project, do not |
| 227 | # test _test_create_interface_by_fixed_ips. |
| 228 | if not (CONF.auth.use_dynamic_credentials and |
| 229 | CONF.auth.create_isolated_networks and |
| 230 | not CONF.network.shared_physical_network): |
| 231 | raise self.skipException("Only owner network supports " |
| 232 | "creating interface by fixed ip.") |
| 233 | |
| 234 | server, ifs = self._create_server_get_interfaces() |
| 235 | interface_count = len(ifs) |
| 236 | self.assertGreater(interface_count, 0) |
| 237 | |
| 238 | try: |
| 239 | iface = self._test_create_interface(server) |
| 240 | except lib_exc.BadRequest as e: |
| 241 | msg = ('Multiple possible networks found, use a Network ID to be ' |
| 242 | 'more specific.') |
| 243 | if not CONF.compute.fixed_network_name and six.text_type(e) == msg: |
| 244 | raise |
| 245 | else: |
| 246 | ifs.append(iface) |
| 247 | |
Maho Koshiya | 7b62958 | 2016-02-22 10:59:01 +0900 | [diff] [blame] | 248 | iface = self._test_create_interface_by_fixed_ips(server, ifs) |
| 249 | ifs.append(iface) |
| 250 | |
lkuchlan | 87b5a2d | 2016-09-27 15:46:16 +0300 | [diff] [blame] | 251 | _ifs = (self.interfaces_client.list_interfaces(server['id']) |
ghanshyam | a2364f1 | 2015-08-24 15:45:37 +0900 | [diff] [blame] | 252 | ['interfaceAttachments']) |
Dan Smith | 8ad1c47 | 2013-02-26 13:03:16 -0500 | [diff] [blame] | 253 | self._compare_iface_list(ifs, _ifs) |
| 254 | |
| 255 | self._test_show_interface(server, ifs) |
| 256 | |
| 257 | _ifs = self._test_delete_interface(server, ifs) |
| 258 | self.assertEqual(len(ifs) - 1, len(_ifs)) |
| 259 | |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 260 | @decorators.idempotent_id('2f3a0127-95c7-4977-92d2-bc5aec602fb4') |
Matt Riedemann | a8c641a | 2016-07-12 17:07:33 -0400 | [diff] [blame] | 261 | def test_reassign_port_between_servers(self): |
| 262 | """Tests the following: |
| 263 | |
| 264 | 1. Create a port in Neutron. |
| 265 | 2. Create two servers in Nova. |
| 266 | 3. Attach the port to the first server. |
| 267 | 4. Detach the port from the first server. |
| 268 | 5. Attach the port to the second server. |
| 269 | 6. Detach the port from the second server. |
| 270 | """ |
| 271 | network = self.get_tenant_network() |
| 272 | network_id = network['id'] |
| 273 | port = self.ports_client.create_port(network_id=network_id) |
| 274 | port_id = port['port']['id'] |
| 275 | self.addCleanup(self.ports_client.delete_port, port_id) |
| 276 | |
| 277 | # create two servers |
| 278 | _, servers = compute.create_test_server( |
zhufl | 0419088 | 2017-05-23 10:21:48 +0800 | [diff] [blame] | 279 | self.os_primary, tenant_network=network, |
| 280 | wait_until='ACTIVE', min_count=2) |
Matt Riedemann | a8c641a | 2016-07-12 17:07:33 -0400 | [diff] [blame] | 281 | # add our cleanups for the servers since we bypassed the base class |
| 282 | for server in servers: |
zhufl | 1355d98 | 2017-01-05 12:06:20 +0800 | [diff] [blame] | 283 | self.addCleanup(self.delete_server, server['id']) |
Matt Riedemann | a8c641a | 2016-07-12 17:07:33 -0400 | [diff] [blame] | 284 | |
| 285 | for server in servers: |
| 286 | # attach the port to the server |
lkuchlan | 87b5a2d | 2016-09-27 15:46:16 +0300 | [diff] [blame] | 287 | iface = self.interfaces_client.create_interface( |
Matt Riedemann | a8c641a | 2016-07-12 17:07:33 -0400 | [diff] [blame] | 288 | server['id'], port_id=port_id)['interfaceAttachment'] |
lianghao | 1635334 | 2017-11-28 21:08:12 +0800 | [diff] [blame] | 289 | self._check_interface(iface, server_id=server['id'], |
| 290 | port_id=port_id) |
Matt Riedemann | a8c641a | 2016-07-12 17:07:33 -0400 | [diff] [blame] | 291 | |
| 292 | # detach the port from the server; this is a cast in the compute |
| 293 | # API so we have to poll the port until the device_id is unset. |
lkuchlan | 87b5a2d | 2016-09-27 15:46:16 +0300 | [diff] [blame] | 294 | self.interfaces_client.delete_interface(server['id'], port_id) |
Matt Riedemann | a8c641a | 2016-07-12 17:07:33 -0400 | [diff] [blame] | 295 | self.wait_for_port_detach(port_id) |
zhufl | 615e63b | 2018-08-01 17:23:38 +0800 | [diff] [blame] | 296 | |
| 297 | |
| 298 | class AttachInterfacesUnderV243Test(AttachInterfacesTestBase): |
| 299 | max_microversion = '2.43' |
| 300 | |
| 301 | @decorators.attr(type='smoke') |
| 302 | @decorators.idempotent_id('c7e0e60b-ee45-43d0-abeb-8596fd42a2f9') |
| 303 | @utils.services('network') |
| 304 | def test_add_remove_fixed_ip(self): |
| 305 | # Add and Remove the fixed IP to server. |
| 306 | server, ifs = self._create_server_get_interfaces() |
| 307 | interface_count = len(ifs) |
| 308 | self.assertGreater(interface_count, 0) |
| 309 | network_id = ifs[0]['net_id'] |
| 310 | self.servers_client.add_fixed_ip(server['id'], networkId=network_id) |
| 311 | # Remove the fixed IP from server. |
| 312 | server_detail = self.os_primary.servers_client.show_server( |
| 313 | server['id'])['server'] |
| 314 | # Get the Fixed IP from server. |
| 315 | fixed_ip = None |
| 316 | for ip_set in server_detail['addresses']: |
| 317 | for ip in server_detail['addresses'][ip_set]: |
| 318 | if ip['OS-EXT-IPS:type'] == 'fixed': |
| 319 | fixed_ip = ip['addr'] |
| 320 | break |
| 321 | if fixed_ip is not None: |
| 322 | break |
| 323 | self.servers_client.remove_fixed_ip(server['id'], address=fixed_ip) |