fix regex expression to find IPV4 address
[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         if 'dataplane_subnet_mask' not in rapid_stack_params.keys():
36             rapid_stack_params['dataplane_subnet_mask'] = 24
37         return (rapid_stack_params)
38
39     @staticmethod
40     def deploy_stack(rapid_stack_params):
41         cloud_name = rapid_stack_params['cloud_name']
42         stack_name = rapid_stack_params['stack_name']
43         heat_template = rapid_stack_params['heat_template']
44         heat_param = rapid_stack_params['heat_param']
45         user = rapid_stack_params['user']
46         dataplane_subnet_mask = rapid_stack_params['dataplane_subnet_mask']
47         deployment = StackDeployment(cloud_name)
48         deployment.deploy(stack_name, heat_template, heat_param)
49         deployment.generate_env_file(user, dataplane_subnet_mask)
50
51 def main():
52     rapid_stack_params = {}
53     RapidStackManager.parse_config(rapid_stack_params)
54     log_file = 'CREATE{}.log'.format(rapid_stack_params['stack_name'])
55     RapidLog.log_init(log_file, 'DEBUG', 'INFO', '2021.03.15')
56     #cloud_name = 'openstackL6'
57     #stack_name = 'rapid'
58     #heat_template = 'openstack-rapid.yaml'
59     #heat_param = 'params_rapid.yaml'
60     #user = 'centos'
61     RapidStackManager.deploy_stack(rapid_stack_params)
62
63 if __name__ == "__main__":
64     main()