diff options
author | Konrad Bańka <k.banka@samsung.com> | 2020-01-07 15:33:04 +0100 |
---|---|---|
committer | Konrad Bańka <k.banka@samsung.com> | 2020-01-07 15:33:04 +0100 |
commit | 4f411bacefec35c9a51e078175668aa97a398477 (patch) | |
tree | 84a3110745d0ab5d5f5455a1d32b9af3917cbcf9 /src | |
parent | 2a35410560f1c22ed12cd137cbf843e36f74740e (diff) |
Instantiate infra_workload based on vf-module-*-ids
Deprecate k8s-rb-definition-* parameters from sdnc_directives
in favor of vf-module-*-id that are used by newer artifact broker.
Issue-ID: MULTICLOUD-836
Signed-off-by: Konrad Bańka <k.banka@samsung.com>
Change-Id: I26ae16bd53ced56ae11523584f900a102f6e0bb9
Diffstat (limited to 'src')
-rw-r--r-- | src/k8splugin/api/brokerhandler.go | 14 | ||||
-rw-r--r-- | src/k8splugin/api/brokerhandler_test.go | 49 |
2 files changed, 21 insertions, 42 deletions
diff --git a/src/k8splugin/api/brokerhandler.go b/src/k8splugin/api/brokerhandler.go index b377baf1..7671db44 100644 --- a/src/k8splugin/api/brokerhandler.go +++ b/src/k8splugin/api/brokerhandler.go @@ -134,15 +134,13 @@ func (b brokerInstanceHandler) createHandler(w http.ResponseWriter, r *http.Requ return } - rbName := req.getAttributeValue(req.SDNCDirectives, "k8s-rb-definition-name") - if rbName == "" { - http.Error(w, "k8s-rb-definition-name is missing from sdnc-directives", http.StatusBadRequest) + if req.VFModuleModelInvariantID == "" { + http.Error(w, "vf-module-model-invariant-id is empty", http.StatusBadRequest) return } - rbVersion := req.getAttributeValue(req.SDNCDirectives, "k8s-rb-definition-version") - if rbVersion == "" { - http.Error(w, "k8s-rb-definition-version is missing from sdnc-directives", http.StatusBadRequest) + if req.VFModuleModelVersionID == "" { + http.Error(w, "vf-module-model-version-id is empty", http.StatusBadRequest) return } @@ -160,8 +158,8 @@ func (b brokerInstanceHandler) createHandler(w http.ResponseWriter, r *http.Requ // Setup the resource parameters for making the request var instReq app.InstanceRequest - instReq.RBName = rbName - instReq.RBVersion = rbVersion + instReq.RBName = req.VFModuleModelInvariantID + instReq.RBVersion = req.VFModuleModelVersionID instReq.ProfileName = profileName instReq.CloudRegion = cloudRegion instReq.Labels = map[string]string{ diff --git a/src/k8splugin/api/brokerhandler_test.go b/src/k8splugin/api/brokerhandler_test.go index 00ca3b7b..83ff588b 100644 --- a/src/k8splugin/api/brokerhandler_test.go +++ b/src/k8splugin/api/brokerhandler_test.go @@ -48,18 +48,19 @@ func TestBrokerCreateHandler(t *testing.T) { expectedCode: http.StatusUnprocessableEntity, }, { - label: "Missing parameter failure", + label: "Missing vf-module-*-id parameter", input: bytes.NewBuffer([]byte(`{ "vf-module-model-customization-id": "84sdfkio938", - "user_directives": { + "vf-module-model-invariant-id": "123456qwerty", + "sdnc_directives": { "attributes": [ { - "attribute_name": "k8s-rb-definition-name", - "attribute_value": "test-rbdef" + "attribute_name": "vf_module_name", + "attribute_value": "test-vf-module-name" }, { - "attribute_name": "k8s-rb-definition-version", - "attribute_value": "v1" + "attribute_name": "k8s-rb-profile-name", + "attribute_value": "profile1" } ] } @@ -67,9 +68,11 @@ func TestBrokerCreateHandler(t *testing.T) { expectedCode: http.StatusBadRequest, }, { - label: "Deprecated parameters passed (user_directives)", + label: "Missing parameter from sdnc_directives", input: bytes.NewBuffer([]byte(`{ - "vf-module-model-customization-id": "97sdfkio168", + "vf-module-model-customization-id": "84sdfkio938", + "vf-module-model-invariant-id": "123456qwerty", + "vf-module-model-version-id": "123qweasdzxc", "sdnc_directives": { "attributes": [ { @@ -77,22 +80,6 @@ func TestBrokerCreateHandler(t *testing.T) { "attribute_value": "test-vf-module-name" } ] - }, - "user_directives": { - "attributes": [ - { - "attribute_name": "rb-definition-name", - "attribute_value": "test-rbdef" - }, - { - "attribute_name": "rb-definition-version", - "attribute_value": "v1" - }, - { - "attribute_name": "rb-profile-name", - "attribute_value": "profile1" - } - ] } }`)), expectedCode: http.StatusBadRequest, @@ -101,6 +88,8 @@ func TestBrokerCreateHandler(t *testing.T) { label: "Succesfully create an Instance", input: bytes.NewBuffer([]byte(`{ "vf-module-model-customization-id": "84sdfkio938", + "vf-module-model-invariant-id": "123456qwerty", + "vf-module-model-version-id": "123qweasdzxc", "sdnc_directives": { "attributes": [ { @@ -108,14 +97,6 @@ func TestBrokerCreateHandler(t *testing.T) { "attribute_value": "test-vf-module-name" }, { - "attribute_name": "k8s-rb-definition-name", - "attribute_value": "test-rbdef" - }, - { - "attribute_name": "k8s-rb-definition-version", - "attribute_value": "v1" - }, - { "attribute_name": "k8s-rb-profile-name", "attribute_value": "profile1" } @@ -149,8 +130,8 @@ func TestBrokerCreateHandler(t *testing.T) { { ID: "HaKpys8e", Request: app.InstanceRequest{ - RBName: "test-rbdef", - RBVersion: "v1", + RBName: "123456qwerty", + RBVersion: "123qweasdzxc", ProfileName: "profile1", CloudRegion: "region1", }, |