Mauro S. M. Rodrigues | f516640 | 2013-04-01 10:25:26 -0400 | [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 | |
Sean Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 16 | from tempest.api.compute import base |
Mauro S. M. Rodrigues | f516640 | 2013-04-01 10:25:26 -0400 | [diff] [blame] | 17 | from tempest.test import attr |
Mauro S. M. Rodrigues | f516640 | 2013-04-01 10:25:26 -0400 | [diff] [blame] | 18 | |
| 19 | |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 20 | class FixedIPsTestJson(base.BaseV2ComputeAdminTest): |
Mauro S. M. Rodrigues | f516640 | 2013-04-01 10:25:26 -0400 | [diff] [blame] | 21 | _interface = 'json' |
| 22 | |
Attila Fazekas | 2265bc4 | 2013-09-16 14:22:56 +0200 | [diff] [blame] | 23 | @classmethod |
| 24 | def setUpClass(cls): |
| 25 | super(FixedIPsTestJson, cls).setUpClass() |
| 26 | if cls.config.service_available.neutron: |
| 27 | msg = ("%s skipped as neutron is available" % cls.__name__) |
| 28 | raise cls.skipException(msg) |
| 29 | cls.client = cls.os_adm.fixed_ips_client |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 30 | resp, server = cls.create_test_server(wait_until='ACTIVE') |
Attila Fazekas | 2265bc4 | 2013-09-16 14:22:56 +0200 | [diff] [blame] | 31 | resp, server = cls.servers_client.get_server(server['id']) |
| 32 | for ip_set in server['addresses']: |
| 33 | for ip in server['addresses'][ip_set]: |
| 34 | if ip['OS-EXT-IPS:type'] == 'fixed': |
| 35 | cls.ip = ip['addr'] |
| 36 | break |
| 37 | if cls.ip: |
| 38 | break |
| 39 | |
Giulio Fidente | ba3985a | 2013-05-29 01:46:36 +0200 | [diff] [blame] | 40 | @attr(type='gate') |
Mauro S. M. Rodrigues | f516640 | 2013-04-01 10:25:26 -0400 | [diff] [blame] | 41 | def test_list_fixed_ip_details(self): |
| 42 | resp, fixed_ip = self.client.get_fixed_ip_details(self.ip) |
| 43 | self.assertEqual(fixed_ip['address'], self.ip) |
| 44 | |
Giulio Fidente | ba3985a | 2013-05-29 01:46:36 +0200 | [diff] [blame] | 45 | @attr(type='gate') |
Mauro S. M. Rodrigues | f516640 | 2013-04-01 10:25:26 -0400 | [diff] [blame] | 46 | def test_set_reserve(self): |
| 47 | body = {"reserve": "None"} |
| 48 | resp, body = self.client.reserve_fixed_ip(self.ip, body) |
| 49 | self.assertEqual(resp.status, 202) |
| 50 | |
Giulio Fidente | ba3985a | 2013-05-29 01:46:36 +0200 | [diff] [blame] | 51 | @attr(type='gate') |
Mauro S. M. Rodrigues | f516640 | 2013-04-01 10:25:26 -0400 | [diff] [blame] | 52 | def test_set_unreserve(self): |
| 53 | body = {"unreserve": "None"} |
| 54 | resp, body = self.client.reserve_fixed_ip(self.ip, body) |
| 55 | self.assertEqual(resp.status, 202) |
| 56 | |
Mauro S. M. Rodrigues | f516640 | 2013-04-01 10:25:26 -0400 | [diff] [blame] | 57 | |
| 58 | class FixedIPsTestXml(FixedIPsTestJson): |
| 59 | _interface = 'xml' |