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)
+ account=vim_account)
except ClientException as inst:
- print((inst.message))
+ print(inst.message)
exit(1)
'netslice_subnet: [\n'
'id: TEXT, vim_account: TEXT,\n'
'vnf: [member-vnf-index: TEXT, vim_account: TEXT]\n'
- 'vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]'
+ 'vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]\n'
+ 'additionalParamsForNsi: {param: value, ...}\n'
+ 'additionalParamsForsubnet: [{id: SUBNET_ID, additionalParamsForNs: {}, additionalParamsForVnf: {}}]\n'
'],\n'
'netslice-vld: [name: TEXT, vim-network-name: TEXT or DICT with vim_account, vim_net entries]'
)
vnf["vimAccountId"] = get_vim_account_id(vnf.pop("vim_account"))
ns["vnf"] = ns_config["vnf"]
- #print yaml.safe_dump(ns)
+ if "additionalParamsForNs" in ns_config:
+ ns["additionalParamsForNs"] = ns_config.pop("additionalParamsForNs")
+ if not isinstance(ns["additionalParamsForNs"], dict):
+ raise ValueError("Error at --config 'additionalParamsForNs' must be a dictionary")
+ if "additionalParamsForVnf" in ns_config:
+ ns["additionalParamsForVnf"] = ns_config.pop("additionalParamsForVnf")
+ if not isinstance(ns["additionalParamsForVnf"], list):
+ raise ValueError("Error at --config 'additionalParamsForVnf' must be a list")
+ for additional_param_vnf in ns["additionalParamsForVnf"]:
+ if not isinstance(additional_param_vnf, dict):
+ raise ValueError("Error at --config 'additionalParamsForVnf' items must be dictionaries")
+ if not additional_param_vnf.get("member-vnf-index"):
+ raise ValueError("Error at --config 'additionalParamsForVnf' items must contain "
+ "'member-vnf-index'")
+ if not additional_param_vnf.get("additionalParams"):
+ raise ValueError("Error at --config 'additionalParamsForVnf' items must contain "
+ "'additionalParams'")
+
+ # print yaml.safe_dump(ns)
try:
self._apiResource = '/ns_instances_content'
self._apiBase = '{}{}{}'.format(self._apiName,
vnf["vimAccountId"] = get_vim_account_id(vnf.pop("vim_account"))
nsi["netslice-subnet"] = nsi_config["netslice-subnet"]
- #print yaml.safe_dump(nsi)
+ if "additionalParamsForNsi" in nsi_config:
+ nsi["additionalParamsForNsi"] = nsi_config.pop("additionalParamsForNsi")
+ if not isinstance(nsi["additionalParamsForNsi"], dict):
+ raise ValueError("Error at --config 'additionalParamsForNsi' must be a dictionary")
+ if "additionalParamsForSubnet" in nsi_config:
+ nsi["additionalParamsForSubnet"] = nsi_config.pop("additionalParamsForSubnet")
+ if not isinstance(nsi["additionalParamsForSubnet"], list):
+ raise ValueError("Error at --config 'additionalParamsForSubnet' must be a list")
+ for additional_param_subnet in nsi["additionalParamsForSubnet"]:
+ if not isinstance(additional_param_subnet, dict):
+ raise ValueError("Error at --config 'additionalParamsForSubnet' items must be dictionaries")
+ if not additional_param_subnet.get("id"):
+ raise ValueError("Error at --config 'additionalParamsForSubnet' items must contain subnet 'id'")
+ if not additional_param_subnet.get("additionalParamsForNs") and\
+ not additional_param_subnet.get("additionalParamsForVnf"):
+ raise ValueError("Error at --config 'additionalParamsForSubnet' items must contain "
+ "'additionalParamsForNs' and/or 'additionalParamsForVnf'")
+
+ # print yaml.safe_dump(nsi)
try:
self._apiResource = '/netslice_instances_content'
self._apiBase = '{}{}{}'.format(self._apiName,