blob: f993441f0c2468a4c183489e7b2ced67875620c9 [file] [log] [blame]
Jay Pipesf4dad392012-06-05 16:03:58 -04001# 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
18import nose
19import unittest2 as unittest
20
Matthew Treinish481466b2012-12-20 17:16:01 -050021from tempest import clients
Matthew Treinisha83a16e2012-12-07 13:44:02 -050022from tempest.common.utils.data_utils import rand_name
Jay Pipesf4dad392012-06-05 16:03:58 -040023from tempest import exceptions
Jay Pipesf4dad392012-06-05 16:03:58 -040024
25
26class BaseNetworkTest(unittest.TestCase):
27
Jay Pipesf4dad392012-06-05 16:03:58 -040028 @classmethod
29 def setUpClass(cls):
Matthew Treinish481466b2012-12-20 17:16:01 -050030 os = clients.Manager()
Jay Pipesf38eaac2012-06-21 13:37:35 -040031 client = os.network_client
32 config = os.config
33 networks = []
34 enabled = True
35
36 # Validate that there is even an endpoint configured
37 # for networks, and mark the attr for skipping if not
38 try:
39 client.list_networks()
40 except exceptions.EndpointNotFound:
41 enabled = False
42 skip_msg = "No OpenStack Network API endpoint"
43 raise nose.SkipTest(skip_msg)
Jay Pipesf4dad392012-06-05 16:03:58 -040044
45 @classmethod
46 def tearDownClass(cls):
47 for network in cls.networks:
48 cls.client.delete_network(network['id'])
49
50 def create_network(self, network_name=None):
51 """Wrapper utility that returns a test network"""
52 network_name = network_name or rand_name('test-network')
53
54 resp, body = self.client.create_network(network_name)
55 network = body['network']
56 self.networks.append(network)
57 return network