From 90437986bcd1a49d1e73ada8ed65a9b63721bea2 Mon Sep 17 00:00:00 2001 From: Yuval Brik Date: Thu, 10 Aug 2017 09:39:05 +0300 Subject: [PATCH] Plan: send only parameters for protected resources Change-Id: I0d47d065b3567c0118dcfccfed5d794013f22f0c --- karbor_dashboard/protectionplans/forms.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/karbor_dashboard/protectionplans/forms.py b/karbor_dashboard/protectionplans/forms.py index a99c0fd..c7db1e4 100644 --- a/karbor_dashboard/protectionplans/forms.py +++ b/karbor_dashboard/protectionplans/forms.py @@ -59,11 +59,17 @@ class CreateProtectionPlanForm(horizon_forms.SelfHandlingForm): def handle(self, request, data): try: - new_plan = karborclient.plan_create(request, - data["name"], - data["provider_id"], - json.loads(data["resources"]), - json.loads(data["parameters"])) + resources = json.loads(data["resources"]) + types = {resource["type"] for resource in resources} + parameters = json.loads(data["parameters"]) + parameters = {k: v for k, v in parameters.items() if k in types} + new_plan = karborclient.plan_create( + request, + data["name"], + data["provider_id"], + resources, + parameters, + ) messages.success(request, _("Protection Plan created successfully."))