refactor the monitor
[doctor.git] / tests / monitor / __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 from oslo_config import cfg
10 from oslo_utils import importutils
11
12 OPTS = [
13     cfg.StrOpt('type',
14                default='sample',
15                choices=['sample'],
16                help='the type of doctor monitor component',
17                required=True),
18 ]
19
20
21 _monitor_name_class_mapping = {
22     'sample': 'monitor.sample.SampleMonitor'
23 }
24
25 def get_monitor(conf, inspector_url, log):
26     monitor_class = _monitor_name_class_mapping.get(conf.monitor.type)
27     return importutils.import_object(monitor_class, conf,
28                                      inspector_url, log)