aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/cli.py
diff options
context:
space:
mode:
authormarios <marios@redhat.com>2014-08-01 17:21:35 +0300
committerDan Prince <dprince@redhat.com>2014-08-11 15:50:52 -0400
commit97f5eee7d135f462e82aa2c1ac9716971ad16ddc (patch)
tree72bfeb7cb8991afe5581750548c67359d3e694f6 /os_net_config/cli.py
parent2a2a50221559d81958ae309d193ab0e18602d268 (diff)
Adds mock ability to the ENI and Ifcfg providers
Specifying mock=True for 'apply' will return a string representing the changes required, or commands to be used in order to implement the requested/specified configuration. This is also exposed to the cli, with -m (--mock), e.g. os-net-config --mock -c ./etc/example_os_net_config_1.json -p eni
Diffstat (limited to 'os_net_config/cli.py')
-rw-r--r--os_net_config/cli.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/os_net_config/cli.py b/os_net_config/cli.py
index 2ebe8f3..89ba3d0 100644
--- a/os_net_config/cli.py
+++ b/os_net_config/cli.py
@@ -57,6 +57,13 @@ def parse_opts(argv):
parser.add_argument('--version', action='version',
version=os_net_config.__version__)
+ parser.add_argument(
+ '-m', '--mock',
+ dest="mock",
+ action='store_true',
+ help="Return the configuration commands, without applying them.",
+ required=False)
+
opts = parser.parse_args(argv[1:])
return opts
@@ -89,7 +96,7 @@ def main(argv=sys.argv):
elif opts.provider == 'eni':
provider = impl_eni.ENINetConfig()
elif opts.provider == 'iproute':
- provider = impl_iproute.IprouteNetConfig()
+ provider = impl_iproute.IPRouteNetConfig()
else:
logger.error('Invalid provider specified.')
return 1
@@ -115,8 +122,12 @@ def main(argv=sys.argv):
for iface_json in iface_array:
obj = objects.object_from_json(iface_json)
provider.addObject(obj)
- provider.apply()
- return 0
+ if opts.mock:
+ res = provider.apply(mock=True)
+ print res
+ else:
+ provider.apply()
+ return 0
if __name__ == '__main__':