Merge "1) Cleanup floating IPs that are assigned through Juju Deployment. 2) Add...
[functest.git] / functest / opnfv_tests / openstack / patrole / patrole.py
1 #!/usr/bin/env python
2
3 # Copyright (c) 2018 Orange and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9
10 # pylint: disable=missing-docstring
11
12 import logging
13
14 from six.moves import configparser
15
16 from functest.opnfv_tests.openstack.tempest import tempest
17
18
19 class Patrole(tempest.TempestCommon):
20
21     __logger = logging.getLogger(__name__)
22
23     def configure(self, **kwargs):
24         super(Patrole, self).configure(**kwargs)
25         rconfig = configparser.RawConfigParser()
26         rconfig.read(self.conf_file)
27         rconfig.add_section('rbac')
28         rconfig.set('rbac', 'enable_rbac', True)
29         rconfig.set('rbac', 'rbac_test_role', kwargs.get('role', 'admin'))
30         with open(self.conf_file, 'wb') as config_file:
31             rconfig.write(config_file)
32         self.backup_tempest_config(self.conf_file, self.res_dir)
33
34     def run(self, **kwargs):
35         for exclude in kwargs.get('exclude', []):
36             kwargs['mode'] = "{}(?!.*{})".format(
37                 kwargs.get('mode', ''), exclude)
38         kwargs['mode'] = '{}(?=patrole_tempest_plugin.tests.api.({}))'.format(
39             kwargs['mode'], '|'.join(kwargs.get('services', [])))
40         return super(Patrole, self).run(**kwargs)