Bug - Testing in Apex with OpenStack master fails
[doctor.git] / doctor_tests / inspector / __init__.py
1 #############################################################################
2 # Copyright (c) 2017 ZTE Corporation and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 import os
10
11 from oslo_config import cfg
12 from oslo_utils import importutils
13
14 from doctor_tests.common.constants import Inspector
15
16
17 OPTS = [
18     cfg.StrOpt('type',
19                default=os.environ.get('INSPECTOR_TYPE', Inspector.SAMPLE),
20                choices=['sample', 'congress', 'vitrage'],
21                help='the component of doctor inspector',
22                required=True),
23     cfg.StrOpt('ip',
24                default='127.0.0.1',
25                help='the host ip of inspector',
26                required=False),
27     cfg.StrOpt('port',
28                default='12345',
29                help='the port of default for inspector',
30                required=False),
31     cfg.BoolOpt('update_neutron_port_dp_status',
32                 default=False,
33                 help='Update data plane status of affected neutron ports',
34                 required=False),
35 ]
36
37
38 _inspector_name_class_mapping = {
39     Inspector.SAMPLE: 'doctor_tests.inspector.sample.SampleInspector',
40     Inspector.CONGRESS: 'doctor_tests.inspector.congress.CongressInspector',
41     Inspector.VITRAGE: 'doctor_tests.inspector.vitrage.VitrageInspector',
42 }
43
44
45 def get_inspector(conf, log, transport_url=None):
46     inspector_class = _inspector_name_class_mapping[conf.inspector.type]
47     if conf.inspector.type == 'sample':
48         return importutils.import_object(inspector_class, conf, log,
49                                          transport_url)
50     else:
51         return importutils.import_object(inspector_class, conf, log)