From 4c84696280434e761fabe2fca7d80fe18fb6a78a Mon Sep 17 00:00:00 2001 From: Janki Date: Thu, 22 Sep 2016 12:10:41 +0530 Subject: [PATCH] VNFFG Manager fixes Fixes vnf_mapping field in Tacker-Horizon. Change-Id: I8e6e33ef2dfba7bed9501704bbd8931e6b564552 Implements: blueprint tacker-vnffg Closes-Bug: #1626527 --- .../dashboards/nfv/vnffgmanager/forms.py | 29 ++++++++++++------- .../templates/vnffgmanager/_deploy_vnffg.html | 10 +++---- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/tacker_horizon/openstack_dashboard/dashboards/nfv/vnffgmanager/forms.py b/tacker_horizon/openstack_dashboard/dashboards/nfv/vnffgmanager/forms.py index 146ffc0..01cb0a3 100644 --- a/tacker_horizon/openstack_dashboard/dashboards/nfv/vnffgmanager/forms.py +++ b/tacker_horizon/openstack_dashboard/dashboards/nfv/vnffgmanager/forms.py @@ -26,11 +26,12 @@ LOG = logging.getLogger(__name__) class DeployVNFFG(forms.SelfHandlingForm): vnffg_name = forms.CharField(max_length=255, label=_("VNFFG Name")) vnffgd_id = forms.ChoiceField(label=_("VNFFG Catalog Name")) - vnf_mapping = forms.MultipleChoiceField(label=_("VNF Mapping"), - required=False) - symmetrical = forms.BooleanField(label=_("Should a reverse path be " - "created for the NFP"), - required=False) + vnf_mapping = forms.CharField(label=_("VNF Mapping"), + required=False) + symmetrical = forms.BooleanField(label=_("Symmetrical path"), + required=False, help_text="Decides" + " whether to automatically create a" + " reverse patch for the NFP") def __init__(self, request, *args, **kwargs): super(DeployVNFFG, self).__init__(request, *args, **kwargs) @@ -51,10 +52,9 @@ class DeployVNFFG(forms.SelfHandlingForm): data = super(DeployVNFFG, self).clean() return data - def get_vnf(self, request, vnf): - vnfs = api.tacker.vnf_list(self.request) - if vnf in vnfs: - return vnf + def list_vnfs(self, request): + vnfs = [vnfs['name'] for vnfs in api.tacker.vnf_list(request)] + return vnfs def handle(self, request, data): try: @@ -66,7 +66,16 @@ class DeployVNFFG(forms.SelfHandlingForm): _vnf_mappings = vnf_mapping.split(",") for mapping in _vnf_mappings: vnfd_name, vnf = mapping.split(":", 1) - _vnf_mapping[vnfd_name] = self.get_vnf(request, vnf) + # Check if specified VNF exists + vnfs = self.list_vnfs(request) + try: + if vnf in vnfs: + _vnf_mapping[vnfd_name] = vnf + else: + raise Exception + except Exception: + exceptions.handle(request, _('Specified VNF %s not' + ' found') % vnf) symmetrical = data['symmetrical'] vnffg_arg = {'vnffg': {'vnffgd_id': vnffgd_id, diff --git a/tacker_horizon/openstack_dashboard/dashboards/nfv/vnffgmanager/templates/vnffgmanager/_deploy_vnffg.html b/tacker_horizon/openstack_dashboard/dashboards/nfv/vnffgmanager/templates/vnffgmanager/_deploy_vnffg.html index 890f1a1..b6016f5 100644 --- a/tacker_horizon/openstack_dashboard/dashboards/nfv/vnffgmanager/templates/vnffgmanager/_deploy_vnffg.html +++ b/tacker_horizon/openstack_dashboard/dashboards/nfv/vnffgmanager/templates/vnffgmanager/_deploy_vnffg.html @@ -6,10 +6,8 @@ {% block modal-body-right %}

{% trans "Description:" %}

{% blocktrans %} Deploys a VNFFG.
- If the VNFFGD template is parameterized, - upload a yaml file with values for those parameters.
- If the VNFFGD template is not parameterized, any - yaml file uploaded will be ignored.
- If a configuration yaml file is uploaded, it will be - applied to the VNFFG post its successful creation.{% endblocktrans %}

+ VNF Mapping is a list of logical VNFD name to VNF instance name + mapping. Example
+ VNFD1:VNF1, VNFD2: VNF2
+ {% endblocktrans %}

{% endblock %}