ee44018c39a0f0485053e106dab6c35447354b83
[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', 'daisy', 'fuel'],
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     cfg.StrOpt('key_file',
28                default=os.environ.get('SSH_KEY', None),
29                help='the key for user to login installer server',
30                required=False),
31 ]
32
33
34 _installer_name_class_mapping = {
35     'local': 'doctor_tests.installer.local.LocalInstaller',
36     'apex': 'doctor_tests.installer.apex.ApexInstaller',
37     'daisy': 'doctor_tests.installer.daisy.DaisyInstaller',
38     'fuel': 'doctor_tests.installer.mcp.McpInstaller'
39 }
40
41
42 def get_installer(conf, log):
43     installer_class = _installer_name_class_mapping[conf.installer.type]
44     return importutils.import_object(installer_class, conf, log)