02735b118ec5b90c6397fc166207dc93c2433049
[doctor.git] / doctor_tests / installer / __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('INSTALLER_TYPE', 'local'),
17                choices=['local', 'apex'],
18                help='the type of installer',
19                required=True),
20     cfg.StrOpt('ip',
21                default=os.environ.get('INSTALLER_IP', '127.0.0.1'),
22                help='the ip of installer'),
23     cfg.StrOpt('username',
24                default='root',
25                help='the user name for login installer server',
26                required=True),
27 ]
28
29
30 _installer_name_class_mapping = {
31     'local': 'doctor_tests.installer.local.LocalInstaller',
32     'apex': 'doctor_tests.installer.apex.ApexInstaller'
33 }
34
35
36 def get_installer(conf, log):
37     installer_class = _installer_name_class_mapping[conf.installer.type]
38     return importutils.import_object(installer_class, conf, log)