efdf5e1f79ecc76c55863357179ca5fb44f7bebb
[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         push_gateway = rapid_stack_params['push_gateway']
46         deployment = StackDeployment(cloud_name)
47         deployment.deploy(stack_name, keypair_name, heat_template, heat_param)
48         deployment.generate_env_file(user, push_gateway)
49
50 def main():
51     rapid_stack_params = {}
52     RapidStackManager.parse_config(rapid_stack_params)
53     log_file = 'CREATE{}.log'.format(rapid_stack_params['stack_name'])
54     RapidLog.log_init(log_file, 'DEBUG', 'INFO', '2020.05.05')
55     #cloud_name = 'openstackL6'
56     #stack_name = 'rapid'
57     #heat_template = 'openstack-rapid.yaml'
58     #heat_param = 'params_rapid.yaml'
59     #keypair_name = 'prox_key'
60     #user = 'centos'
61     #push_gateway = None
62     RapidStackManager.deploy_stack(rapid_stack_params)
63
64 if __name__ == "__main__":
65     main()