#!/usr/bin/env python
import jinja2
import argparse
def request_template_parameters():
parser = argparse.ArgumentParser(
description='Gather parameters for generating custom data file'
)
parser.add_argument(
'--hostname' ,
action="store" ,
type=str ,
help='The hostname of the firewall'
)
parser.add_argument(
'--install_security_gw' ,
action="store" ,
type=str ,
help='Defining a secure gateway or management function - values are true or false'
)
parser.add_argument(
'--install_ppak' ,
action="store" ,
type=str ,
help='values are true or false'
)
parser.add_argument(
'--install_security_managment' ,
action="store" ,
type=str ,
help='values are true or false'
)
parser.add_argument(
'--ipstat_v6' ,
action="store" ,
type=str ,
help='values are true or false for ipv6'
)
parser.add_argument(
'--sic_key' ,
action="store" ,
type=str ,
help='The one time Secure Internal Communication key'
)
args = parser.parse_args()
hostname = args.hostname
install_security_gw = args.install_security_gw
install_ppak = args.install_ppak
install_security_managment = args.install_security_managment
ipstat_v6 = args.ipstat_v6
sic_key = args.sic_key
return hostname, install_security_gw, install_ppak, install_security_managment, ipstat_v6, sic_key
def load_template(template_filename😞
templateLoader = jinja2.FileSystemLoader(searchpath="./")
templateEnv = jinja2.Environment(loader=templateLoader)
template_object = template_filename
template = templateEnv.get_template(template_object)
return template
def write_to_file(filename, contents😞
file = open(filename,"w")
file.write(contents)
file.close()
def main():
script_input = request_template_parameters()
hostname_input = script_input[0]
install_security_gw_input = script_input[1]
install_ppak_input = script_input[2]
install_security_managment_input = script_input[3]
ipstat_v6_input = script_input[4]
sic_key_input = script_input[5]
template = load_template("cloudguard_init.j2")
# Place arguments here to build up a configuration file to pass to --cloud
outputText = template.render(
hostname = hostname_input ,
install_security_gw = install_security_gw_input ,
install_ppak = install_ppak_input ,
install_security_managment = install_security_managment_input ,
ipstat_v6 = ipstat_v6_input ,
sic_key = sic_key_input
)
print('cloudguard-init.txt file generated in present working directory')
write_to_file("cloudguard-init.txt",outputText)
if __name__ == '__main__':
main()