Debian Codegraph @

neutron_tempest_plugin/fwaas/scenario/fwaas_v2_manager.py

raw
1 # Copyright 2012 OpenStack Foundation
2 # Copyright 2013 IBM Corp.
3 # All Rights Reserved.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License"); you may
6 # not use this file except in compliance with the License. You may obtain
7 # a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 # License for the specific language governing permissions and limitations
15 # under the License.
16
17 from oslo_log import log
18
19 from tempest import config
20 from tempest.lib.common.utils import data_utils
21 from tempest.lib.common.utils import test_utils
22 from tempest.scenario import manager
23
24 CONF = config.CONF
25
26 LOG = log.getLogger(__name__)
27
28
29 class ScenarioTest(manager.NetworkScenarioTest):
30 """Base class for scenario tests. Uses tempest own clients. """
31
32 credentials = ['primary']
33
34
35 class NetworkScenarioTest(ScenarioTest):
36 """Base class for network scenario tests.
37
38 This class provide helpers for network scenario tests, using the neutron
39 API. Helpers from ancestor which use the nova network API are overridden
40 with the neutron API.
41
42 This Class also enforces using Neutron instead of novanetwork.
43 Subclassed tests will be skipped if Neutron is not enabled
44
45 """
46
47 credentials = ['primary', 'admin']
48
49 @classmethod
50 def skip_checks(cls):
51 super(NetworkScenarioTest, cls).skip_checks()
52 if not CONF.service_available.neutron:
53 raise cls.skipException('Neutron not available')
54
55 def _create_router(self, client=None, tenant_id=None,
56 namestart='router-smoke'):
57 if not client:
58 client = self.routers_client
59 if not tenant_id:
60 tenant_id = client.project_id
61 name = data_utils.rand_name(namestart)
62 result = client.create_router(name=name,
63 admin_state_up=True,
64 tenant_id=tenant_id)
65 router = result['router']
66 self.assertEqual(router['name'], name)
67 self.addCleanup(test_utils.call_and_ignore_notfound_exc,
68 client.delete_router,
69 router['id'])
70 return router