Jay Pipes | f4dad39 | 2012-06-05 16:03:58 -0400 | [diff] [blame] | 1 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
| 2 | |
| 3 | # Copyright 2012 OpenStack, LLC |
| 4 | # All Rights Reserved. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 | # not use this file except in compliance with the License. You may obtain |
| 8 | # a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 15 | # License for the specific language governing permissions and limitations |
| 16 | # under the License. |
| 17 | |
Jay Pipes | f4dad39 | 2012-06-05 16:03:58 -0400 | [diff] [blame] | 18 | |
Matthew Treinish | 481466b | 2012-12-20 17:16:01 -0500 | [diff] [blame] | 19 | from tempest import clients |
Matthew Treinish | a83a16e | 2012-12-07 13:44:02 -0500 | [diff] [blame] | 20 | from tempest.common.utils.data_utils import rand_name |
Attila Fazekas | dc21642 | 2013-01-29 15:12:14 +0100 | [diff] [blame] | 21 | import tempest.test |
Jay Pipes | f4dad39 | 2012-06-05 16:03:58 -0400 | [diff] [blame] | 22 | |
| 23 | |
Attila Fazekas | dc21642 | 2013-01-29 15:12:14 +0100 | [diff] [blame] | 24 | class BaseNetworkTest(tempest.test.BaseTestCase): |
Jay Pipes | f4dad39 | 2012-06-05 16:03:58 -0400 | [diff] [blame] | 25 | |
Jay Pipes | f4dad39 | 2012-06-05 16:03:58 -0400 | [diff] [blame] | 26 | @classmethod |
| 27 | def setUpClass(cls): |
Matthew Treinish | 481466b | 2012-12-20 17:16:01 -0500 | [diff] [blame] | 28 | os = clients.Manager() |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 29 | |
Dan Smith | d6c1f88 | 2013-02-26 15:50:11 -0500 | [diff] [blame] | 30 | if not os.config.network.quantum_available: |
| 31 | raise cls.skipException("Quantum support is required") |
Jay Pipes | f4dad39 | 2012-06-05 16:03:58 -0400 | [diff] [blame] | 32 | |
| 33 | @classmethod |
| 34 | def tearDownClass(cls): |
| 35 | for network in cls.networks: |
| 36 | cls.client.delete_network(network['id']) |
| 37 | |
| 38 | def create_network(self, network_name=None): |
Sean Dague | f237ccb | 2013-01-04 15:19:14 -0500 | [diff] [blame] | 39 | """Wrapper utility that returns a test network.""" |
Jay Pipes | f4dad39 | 2012-06-05 16:03:58 -0400 | [diff] [blame] | 40 | network_name = network_name or rand_name('test-network') |
| 41 | |
| 42 | resp, body = self.client.create_network(network_name) |
| 43 | network = body['network'] |
| 44 | self.networks.append(network) |
| 45 | return network |