refactor congress inspector
[doctor.git] / 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 OPTS = [
15     cfg.StrOpt('type',
16                default=os.environ.get('INSPECTOR_TYPE', 'sample'),
17                choices=['sample', 'congress', 'vitrage'],
18                help='the component of doctor inspector',
19                required=True),
20     cfg.StrOpt('ip',
21                default='127.0.0.1',
22                help='the ip of default inspector',
23                required=False),
24     cfg.StrOpt('port',
25                default='12345',
26                help='the port of default for inspector',
27                required=False),
28 ]
29
30
31 _inspector_name_class_mapping = {
32     'sample': 'inspector.sample.SampleInspector',
33     'congress': 'inspector.congress.CongressInspector',
34 }
35
36 def get_inspector(conf, log):
37     inspector_class = _inspector_name_class_mapping[conf.inspector.type]
38     return importutils.import_object(inspector_class, conf, log)