From fcb33ebcc77ac7bb6ba0e0989c54bd6f8cefe766 Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Sat, 1 Dec 2018 01:12:19 +0100 Subject: [PATCH] osm.py: added config_file option to nsi_create Change-Id: Ief0707cec43fc5da3ff54117690fb121991924f0 Signed-off-by: garciadeblas --- osmclient/scripts/osm.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/osmclient/scripts/osm.py b/osmclient/scripts/osm.py index 94a503e..c2fe67f 100755 --- a/osmclient/scripts/osm.py +++ b/osmclient/scripts/osm.py @@ -1056,10 +1056,15 @@ def nst_create2(ctx, filename, overwrite): nst_create(ctx, filename, overwrite) -def nsi_create(ctx, nst_name, nsi_name, vim_account, ssh_keys, config): +def nsi_create(ctx, nst_name, nsi_name, vim_account, ssh_keys, config, config_file): '''creates a new Network Slice Instance (NSI)''' try: check_client_version(ctx.obj, ctx.command.name) + if config_file: + if config: + raise ClientException('"--config" option is incompatible with "--config_file" option') + with open(config_file, 'r') as cf: + config=cf.read() ctx.obj.nsi.create(nst_name, nsi_name, config=config, ssh_keys=ssh_keys, account=vim_account) except ClientException as inst: @@ -1082,10 +1087,13 @@ def nsi_create(ctx, nst_name, nsi_name, vim_account, ssh_keys, config): '],\n' 'netslice-vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]' ) +@click.option('--config_file', + default=None, + help='nsi specific yaml configuration file') @click.pass_context -def nsi_create1(ctx, nst_name, nsi_name, vim_account, ssh_keys, config): +def nsi_create1(ctx, nst_name, nsi_name, vim_account, ssh_keys, config, config_file): '''creates a new Network Slice Instance (NSI)''' - nsi_create(ctx, nst_name, nsi_name, vim_account, ssh_keys, config) + nsi_create(ctx, nst_name, nsi_name, vim_account, ssh_keys, config, config_file) @cli.command(name='netslice-instance-create', short_help='creates a new Network Slice Instance') @@ -1103,10 +1111,13 @@ def nsi_create1(ctx, nst_name, nsi_name, vim_account, ssh_keys, config): '],\n' 'netslice-vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]' ) +@click.option('--config_file', + default=None, + help='nsi specific yaml configuration file') @click.pass_context -def nsi_create2(ctx, nst_name, nsi_name, vim_account, ssh_keys, config): +def nsi_create2(ctx, nst_name, nsi_name, vim_account, ssh_keys, config, config_file): '''creates a new Network Slice Instance (NSI)''' - nsi_create(ctx, nst_name, nsi_name, vim_account, ssh_keys, config) + nsi_create(ctx, nst_name, nsi_name, vim_account, ssh_keys, config, config_file) #################### -- 2.17.1