diff options
Diffstat (limited to 'lib/python/apex-python-utils.py')
-rwxr-xr-x | lib/python/apex-python-utils.py | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/python/apex-python-utils.py b/lib/python/apex-python-utils.py index 4eee4f75..6c76cb13 100755 --- a/lib/python/apex-python-utils.py +++ b/lib/python/apex-python-utils.py @@ -12,6 +12,7 @@ import sys import apex import logging import os +import yaml from jinja2 import Environment, FileSystemLoader @@ -26,10 +27,24 @@ def parse_net_settings(args): - network_isolation: bool enable or disable network_isolation """ - settings = apex.NetworkSettings(args.file, + settings = apex.NetworkSettings(args.net_settings_file, args.network_isolation) + net_env = apex.NetworkEnvironment(settings, args.net_env_file) + dump_yaml(net_env.get_netenv_settings(), '/tmp/network-environment.yaml') settings.dump_bash() + +def dump_yaml(data, file): + """ + Dumps data to a file as yaml + :param data: yaml to be written to file + :param file: filename to write to + :return: + """ + with open(file, "w") as fh: + yaml.dump(data, fh, default_flow_style=False) + + def parse_deploy_settings(args): settings = apex.DeploySettings(args.file) settings.dump_bash() @@ -84,11 +99,17 @@ def parse_args(): net_settings = subparsers.add_parser('parse-net-settings', help='Parse network settings file') - net_settings.add_argument('-f', '--file', default='network-settings.yaml', + net_settings.add_argument('-s', '--net-settings-file', + default='network-settings.yaml', + dest='net_settings_file', help='path to network settings file') net_settings.add_argument('-i', '--network-isolation', type=bool, default=True, dest='network_isolation', help='network isolation') + net_settings.add_argument('-e', '--net-env-file', + default="network-environment.yaml", + dest='net_env_file', + help='path to network environment file') net_settings.set_defaults(func=parse_net_settings) get_int_ip = subparsers.add_parser('find-ip', |