diff options
author | Tim Rozet <trozet@redhat.com> | 2016-05-31 17:40:11 -0400 |
---|---|---|
committer | Tim Rozet <trozet@redhat.com> | 2016-06-02 21:04:40 -0400 |
commit | 68fc16c4fc98d26bbb58cda6ce7945c2ac6d79bc (patch) | |
tree | d2eb7f5ccf29f66e58c7cf2b1c3575c52604adb7 /lib/python/apex-python-utils.py | |
parent | 46a44b6c0789b32e84a6166f913b2c9a61e29cc3 (diff) |
Migrates network environment parsing to python
Change-Id: Ibaf20a2960a9f4b5e3f256fbed12a61d7606a967
Signed-off-by: Tim Rozet <trozet@redhat.com>
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', |