summaryrefslogtreecommitdiffstats
path: root/src/k8splugin/api
diff options
context:
space:
mode:
authorKiran Kamineni <kiran.k.kamineni@intel.com>2019-01-24 15:40:12 -0800
committerKiran Kamineni <kiran.k.kamineni@intel.com>2019-03-19 19:12:04 -0700
commit17275e9b6899ba611458f8ca9aaa868c70d7d0cf (patch)
tree25169d02625832fb2eb7e5a9ff08c43737dd4ef6 /src/k8splugin/api
parente50daed19bbaec979a91f2677289f1c2e6e0d0d9 (diff)
Bring in all the other helper code
Bring in all the helper functions added for end to end integration. This allows the api level upload of helm charts, profiles and also instantiation of said helm charts. P3: Plugin index is based on lowercase kind name whereas the map contains the correct case for kind. Convert to lower case before loading the plugin. Changes after rebasing on the new folder structure. Rebasing over the new folder structure P8: Add unit tests for Resolve function Fix the integration tests for createvnf I had to add a huge blob of base64 encoded data based on the profile and sample helm chart to test the flow. P12: Update the integration test with the rb_profile_id parameter Issue-ID: MULTICLOUD-291 Change-Id: If04c41cb185074989ab6c96557958140c43e456d Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
Diffstat (limited to 'src/k8splugin/api')
-rw-r--r--src/k8splugin/api/handler.go18
-rw-r--r--src/k8splugin/api/handler_test.go8
-rw-r--r--src/k8splugin/api/model.go3
3 files changed, 18 insertions, 11 deletions
diff --git a/src/k8splugin/api/handler.go b/src/k8splugin/api/handler.go
index a6db3c18..32bfa594 100644
--- a/src/k8splugin/api/handler.go
+++ b/src/k8splugin/api/handler.go
@@ -27,6 +27,7 @@ import (
helper "k8splugin/internal/app"
"k8splugin/internal/db"
+ "k8splugin/internal/rb"
)
//TODO: Separate the http handler code and backend code out
@@ -53,7 +54,11 @@ func validateBody(body interface{}) error {
werr := pkgerrors.Wrap(errors.New("Invalid/Missing CsarID in POST request"), "CreateVnfRequest bad request")
return werr
}
- if strings.Contains(b.CloudRegionID, "|") || strings.Contains(b.Namespace, "|") {
+ if b.RBProfileID == "" {
+ werr := pkgerrors.Wrap(errors.New("Invalid/Missing RB ProfileID in POST request"), "CreateVnfRequest bad request")
+ return werr
+ }
+ if strings.Contains(b.CloudRegionID, "|") {
werr := pkgerrors.Wrap(errors.New("Character \"|\" not allowed in CSAR ID"), "CreateVnfRequest bad request")
return werr
}
@@ -104,18 +109,21 @@ func CreateHandler(w http.ResponseWriter, r *http.Request) {
},
nil
*/
- externalVNFID, resourceNameMap, err := helper.CreateVNF(resource.CsarID, resource.CloudRegionID, resource.Namespace, &kubeclient)
+ externalVNFID, resourceNameMap, err := helper.CreateVNF(resource.CsarID, resource.CloudRegionID,
+ resource.RBProfileID, &kubeclient)
if err != nil {
werr := pkgerrors.Wrap(err, "Read Kubernetes Data information error")
http.Error(w, werr.Error(), http.StatusInternalServerError)
return
}
+ rbProfile, _ := rb.NewProfileClient().Get(resource.RBProfileID)
+ namespace := rbProfile.Namespace
// cloud1-default-uuid
- internalVNFID := resource.CloudRegionID + "-" + resource.Namespace + "-" + externalVNFID
+ internalVNFID := resource.CloudRegionID + "-" + namespace + "-" + externalVNFID
// Persist in AAI database.
- log.Printf("Cloud Region ID: %s, Namespace: %s, VNF ID: %s ", resource.CloudRegionID, resource.Namespace, externalVNFID)
+ log.Printf("Cloud Region ID: %s, Namespace: %s, VNF ID: %s ", resource.CloudRegionID, namespace, externalVNFID)
// TODO: Uncomment when annotations are done
// krd.AddNetworkAnnotationsToPod(kubeData, resource.Networks)
@@ -132,7 +140,7 @@ func CreateHandler(w http.ResponseWriter, r *http.Request) {
resp := CreateVnfResponse{
VNFID: externalVNFID,
CloudRegionID: resource.CloudRegionID,
- Namespace: resource.Namespace,
+ Namespace: namespace,
VNFComponents: resourceNameMap,
}
diff --git a/src/k8splugin/api/handler_test.go b/src/k8splugin/api/handler_test.go
index 2bac3111..c34ceec8 100644
--- a/src/k8splugin/api/handler_test.go
+++ b/src/k8splugin/api/handler_test.go
@@ -98,7 +98,7 @@ func TestCreateHandler(t *testing.T) {
label: "Fail to get the VNF client",
input: bytes.NewBuffer([]byte(`{
"cloud_region_id": "region1",
- "namespace": "test",
+ "rb_profile_id": "123e4567-e89b-12d3-a456-426655440000",
"csar_id": "UUID-1"
}`)),
expectedCode: http.StatusInternalServerError,
@@ -108,7 +108,7 @@ func TestCreateHandler(t *testing.T) {
label: "Fail to create the VNF instance",
input: bytes.NewBuffer([]byte(`{
"cloud_region_id": "region1",
- "namespace": "test",
+ "rb_profile_id": "123e4567-e89b-12d3-a456-426655440000",
"csar_id": "UUID-1"
}`)),
expectedCode: http.StatusInternalServerError,
@@ -120,7 +120,7 @@ func TestCreateHandler(t *testing.T) {
label: "Fail to create a VNF DB record",
input: bytes.NewBuffer([]byte(`{
"cloud_region_id": "region1",
- "namespace": "test",
+ "rb_profile_id": "123e4567-e89b-12d3-a456-426655440000",
"csar_id": "UUID-1"
}`)),
expectedCode: http.StatusInternalServerError,
@@ -135,7 +135,7 @@ func TestCreateHandler(t *testing.T) {
label: "Succesful create a VNF",
input: bytes.NewBuffer([]byte(`{
"cloud_region_id": "region1",
- "namespace": "test",
+ "rb_profile_id": "123e4567-e89b-12d3-a456-426655440000",
"csar_id": "UUID-1"
}`)),
expectedCode: http.StatusCreated,
diff --git a/src/k8splugin/api/model.go b/src/k8splugin/api/model.go
index 0e4863c4..164143c2 100644
--- a/src/k8splugin/api/model.go
+++ b/src/k8splugin/api/model.go
@@ -17,9 +17,9 @@ package api
type CreateVnfRequest struct {
CloudRegionID string `json:"cloud_region_id"`
CsarID string `json:"csar_id"`
+ RBProfileID string `json:"rb_profile_id"`
OOFParams []map[string]interface{} `json:"oof_parameters"`
NetworkParams NetworkParameters `json:"network_parameters"`
- Namespace string `json:"namespace"`
Name string `json:"vnf_instance_name"`
Description string `json:"vnf_instance_description"`
}
@@ -56,7 +56,6 @@ type UpdateVnfRequest struct {
CsarID string `json:"csar_id"`
OOFParams []map[string]interface{} `json:"oof_parameters"`
NetworkParams NetworkParameters `json:"network_parameters"`
- Namespace string `json:"namespace"`
Name string `json:"vnf_instance_name"`
Description string `json:"vnf_instance_description"`
}
8 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617