From 1a6af28f66d2686ad53368095c9143279bf54ec3 Mon Sep 17 00:00:00 2001 From: lombardof Date: Thu, 10 May 2018 11:49:32 +0200 Subject: [PATCH] vim account creation with additional config param; fix Bug 489 Change-Id: Ia58e3821acb78f265a25636e216221df34f3f030 Signed-off-by: lombardof --- instancehandler/views.py | 37 +-- vimhandler/template/config/aws.html | 113 ++++----- vimhandler/template/config/aws_show.html | 83 +++--- vimhandler/template/config/openstack.html | 46 ++-- .../template/config/openstack_show.html | 215 ++++++++-------- vimhandler/template/config/openvim.html | 16 +- vimhandler/template/config/openvim_show.html | 29 +-- vimhandler/template/config/vmware.html | 228 +++++++++-------- vimhandler/template/config/vmware_show.html | 166 ++++++------ vimhandler/template/vim_create.html | 238 ++++++++++-------- vimhandler/template/vim_show.html | 33 ++- vimhandler/views.py | 4 + 12 files changed, 604 insertions(+), 604 deletions(-) diff --git a/instancehandler/views.py b/instancehandler/views.py index 86d00d5..534579a 100644 --- a/instancehandler/views.py +++ b/instancehandler/views.py @@ -40,28 +40,29 @@ def create(request, project_id=None): "nsdId": request.POST.get('nsdId', ''), "vimAccountId": request.POST.get('vimAccountId', ''), } - if 'ssh_key' in request.POST: + if 'ssh_key' in request.POST and request.POST.get('ssh_key') != '': ns_data["ssh-authorized-key"] = [request.POST.get('ssh_key')] if 'config' in request.POST: ns_config = yaml.load(request.POST.get('config')) - if "vim-network-name" in ns_config: - ns_config["vld"] = ns_config.pop("vim-network-name") - if "vld" in ns_config: - for vld in ns_config["vld"]: - if vld.get("vim-network-name"): - if isinstance(vld["vim-network-name"], dict): - vim_network_name_dict = {} - for vim_account, vim_net in vld["vim-network-name"].items(): - vim_network_name_dict[ns_data["vimAccountId"]] = vim_net - vld["vim-network-name"] = vim_network_name_dict - ns_data["vld"] = ns_config["vld"] - if "vnf" in ns_config: - for vnf in ns_config["vnf"]: - if vnf.get("vim_account"): - vnf["vimAccountId"] = ns_data["vimAccountId"] - - ns_data["vnf"] = ns_config["vnf"] + if isinstance(ns_config, dict): + if "vim-network-name" in ns_config: + ns_config["vld"] = ns_config.pop("vim-network-name") + if "vld" in ns_config: + for vld in ns_config["vld"]: + if vld.get("vim-network-name"): + if isinstance(vld["vim-network-name"], dict): + vim_network_name_dict = {} + for vim_account, vim_net in vld["vim-network-name"].items(): + vim_network_name_dict[ns_data["vimAccountId"]] = vim_net + vld["vim-network-name"] = vim_network_name_dict + ns_data["vld"] = ns_config["vld"] + if "vnf" in ns_config: + for vnf in ns_config["vnf"]: + if vnf.get("vim_account"): + vnf["vimAccountId"] = ns_data["vimAccountId"] + + ns_data["vnf"] = ns_config["vnf"] print ns_data client = Client() result = client.ns_create(ns_data) diff --git a/vimhandler/template/config/aws.html b/vimhandler/template/config/aws.html index 911e927..5bf7f0a 100644 --- a/vimhandler/template/config/aws.html +++ b/vimhandler/template/config/aws.html @@ -1,76 +1,71 @@ -