e488f352779df033f58a2c2bf0b3f3acc3ac0e4f
[samplevnf.git] / VNFs / DPPD-PROX / helper-scripts / rapid / createrapid.py
1 #!/usr/bin/python
2
3 ##
4 ## Copyright (c) 2010-2020 Intel Corporation
5 ##
6 ## Licensed under the Apache License, Version 2.0 (the "License");
7 ## you may not use this file except in compliance with the License.
8 ## You may obtain a copy of the License at
9 ##
10 ##     http://www.apache.org/licenses/LICENSE-2.0
11 ##
12 ## Unless required by applicable law or agreed to in writing, software
13 ## distributed under the License is distributed on an "AS IS" BASIS,
14 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ## See the License for the specific language governing permissions and
16 ## limitations under the License.
17 ##
18 from rapid_log import RapidLog
19 from stackdeployment import StackDeployment
20 try:
21     import configparser
22 except ImportError:
23     # Python 2.x fallback
24     import ConfigParser as configparser
25
26 class RapidStackManager(object):
27     @staticmethod
28     def parse_config(rapid_stack_params):
29         config = configparser.RawConfigParser()
30         config.read('config_file')
31         section = 'OpenStack'
32         options = config.options(section)
33         for option in options:
34             rapid_stack_params[option] = config.get(section, option)
35         return (rapid_stack_params)
36
37     @staticmethod
38     def deploy_stack(rapid_stack_params):
39         cloud_name = rapid_stack_params['cloud_name']
40         stack_name = rapid_stack_params['stack_name']
41         heat_template = rapid_stack_params['heat_template']
42         heat_param = rapid_stack_params['heat_param']
43         keypair_name = rapid_stack_params['keypair_name']
44         user = rapid_stack_params['user']
45         deployment = StackDeployment(cloud_name)
46         deployment.deploy(stack_name, keypair_name, heat_template, heat_param)
47         deployment.generate_env_file(user)
48
49 def main():
50     rapid_stack_params = {}
51     RapidStackManager.parse_config(rapid_stack_params)
52     log_file = 'CREATE{}.log'.format(rapid_stack_params['stack_name'])
53     RapidLog.log_init(log_file, 'DEBUG', 'INFO', '2020.09.23')
54     #cloud_name = 'openstackL6'
55     #stack_name = 'rapid'
56     #heat_template = 'openstack-rapid.yaml'
57     #heat_param = 'params_rapid.yaml'
58     #keypair_name = 'prox_key'
59     #user = 'centos'
60     RapidStackManager.deploy_stack(rapid_stack_params)
61
62 if __name__ == "__main__":
63     main()