diff options
Diffstat (limited to 'lib/python/apex-python-utils.py')
-rwxr-xr-x | lib/python/apex-python-utils.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/python/apex-python-utils.py b/lib/python/apex-python-utils.py index 802e8571..1d5b4a7c 100755 --- a/lib/python/apex-python-utils.py +++ b/lib/python/apex-python-utils.py @@ -13,6 +13,8 @@ import sys import apex import logging import os +from jinja2 import Environment, FileSystemLoader + def parse_net_settings(settings_args): settings = apex.NetworkSettings(settings_args.path, @@ -27,6 +29,14 @@ def find_ip(int_args): print(interface.ip) +def build_nic_template(nic_args): + env = Environment(loader=FileSystemLoader(nic_args.template_directory)) + template = env.get_template(nic_args.template_filename) + print(template.render(enabled_networks=nic_args.enabled_networks, + external_net_type=nic_args.ext_net_type, + external_net_af=nic_args.address_family)) + + parser = argparse.ArgumentParser() parser.add_argument('--DEBUG', action='store_true', default=False, help="Turn on debug messages") @@ -49,6 +59,20 @@ get_int_ip.add_argument('-af', '--address_family', default=4, type=int, help='IP Address family') get_int_ip.set_defaults(func=find_ip) +nic_template = subparsers.add_parser('nic_template', help='Build NIC templates') +nic_template.add_argument('-d', '--template_directory', required=True, + help='Template file directory') +nic_template.add_argument('-f', '--template_filename', required=True, + help='Template file to process') +nic_template.add_argument('-n', '--enabled_networks', required=True, + help='enabled network list') +nic_template.add_argument('-e', '--ext_net_type', default='interface', + choices=['interface', 'br-ex'], + help='External network type') +nic_template.add_argument('-af', '--address_family', type=int, default=4, + help='IP address family') +nic_template.set_defaults(func=build_nic_template) + args = parser.parse_args(sys.argv[1:]) if args.DEBUG: logging.basicConfig(level=logging.DEBUG) |