Instantiate infra_workload based on vf-module-*-ids 69/99669/5
authorKonrad Bańka <k.banka@samsung.com>
Tue, 7 Jan 2020 14:33:04 +0000 (15:33 +0100)
committerKonrad Bańka <k.banka@samsung.com>
Tue, 7 Jan 2020 14:33:04 +0000 (15:33 +0100)
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

src/k8splugin/api/brokerhandler.go
src/k8splugin/api/brokerhandler_test.go

index b377baf..7671db4 100644 (file)
@@ -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{
index 00ca3b7..83ff588 100644 (file)
@@ -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,20 +88,14 @@ 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": [
                                                {
                                                        "attribute_name": "vf_module_name",
                                                        "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",
                                                },