aboutsummaryrefslogtreecommitdiffstats
path: root/src/k8splugin/internal/app
diff options
context:
space:
mode:
authorKiran Kamineni <kiran.k.kamineni@intel.com>2019-03-15 15:18:12 -0700
committerKiran Kamineni <kiran.k.kamineni@intel.com>2019-03-26 19:19:53 -0700
commitb2b175eae0f4e8b5b0cb9ccbeeca1e98065feeb5 (patch)
treee5a984dd156016b3b615acfd0b903f61e07655ea /src/k8splugin/internal/app
parent1ab1af62578c1c2bf7b3b2e56827fe408cabdbb3 (diff)
Update definition and profile to latest spec
Bringing all the definition and profile code upto the latest spec. Integrated the end to end instance code changes that were made. P9: Added updated plugin.sh with updated uri paths based on spec Issue-ID: MULTICLOUD-291 Change-Id: Id6e3c6bc2cd02cfb7005e203ccf03e0793b97e95 Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
Diffstat (limited to 'src/k8splugin/internal/app')
-rw-r--r--src/k8splugin/internal/app/vnfhelper.go18
-rw-r--r--src/k8splugin/internal/app/vnfhelper_test.go31
2 files changed, 26 insertions, 23 deletions
diff --git a/src/k8splugin/internal/app/vnfhelper.go b/src/k8splugin/internal/app/vnfhelper.go
index 5984bbd0..0a867090 100644
--- a/src/k8splugin/internal/app/vnfhelper.go
+++ b/src/k8splugin/internal/app/vnfhelper.go
@@ -70,23 +70,17 @@ func ensuresNamespace(namespace string, kubeclient kubernetes.Interface) error {
}
// CreateVNF reads the CSAR files from the files system and creates them one by one
-var CreateVNF = func(csarID string, cloudRegionID string, rbProfileID string, kubeclient *kubernetes.Clientset) (string, map[string][]string, error) {
+var CreateVNF = func(csarID string, cloudRegionID string, profile rb.Profile, kubeclient *kubernetes.Clientset) (string, map[string][]string, error) {
overrideValues := []string{}
- rbProfileClient := rb.NewProfileClient()
- rbProfile, err := rbProfileClient.Get(rbProfileID)
- if err != nil {
- return "", nil, pkgerrors.Wrap(err, "Error getting profile info")
- }
-
//Make sure that the namespace exists before trying to create any resources
- if err := ensuresNamespace(rbProfile.Namespace, kubeclient); err != nil {
- return "", nil, pkgerrors.Wrap(err, "Error while ensuring namespace: "+rbProfile.Namespace)
+ if err := ensuresNamespace(profile.Namespace, kubeclient); err != nil {
+ return "", nil, pkgerrors.Wrap(err, "Error while ensuring namespace: "+profile.Namespace)
}
externalVNFID := generateExternalVNFID()
- internalVNFID := cloudRegionID + "-" + rbProfile.Namespace + "-" + externalVNFID
+ internalVNFID := cloudRegionID + "-" + profile.Namespace + "-" + externalVNFID
- metaMap, err := rb.NewProfileClient().Resolve(rbProfileID, overrideValues)
+ metaMap, err := rb.NewProfileClient().Resolve(profile.RBName, profile.RBVersion, profile.Name, overrideValues)
if err != nil {
return "", nil, pkgerrors.Wrap(err, "Error resolving helm charts")
}
@@ -109,7 +103,7 @@ var CreateVNF = func(csarID string, cloudRegionID string, rbProfileID string, ku
//Populate the namespace from profile instead of instance body
genericKubeData := &utils.ResourceData{
YamlFilePath: filepath,
- Namespace: rbProfile.Namespace,
+ Namespace: profile.Namespace,
VnfId: internalVNFID,
}
diff --git a/src/k8splugin/internal/app/vnfhelper_test.go b/src/k8splugin/internal/app/vnfhelper_test.go
index 0bd21f72..06866150 100644
--- a/src/k8splugin/internal/app/vnfhelper_test.go
+++ b/src/k8splugin/internal/app/vnfhelper_test.go
@@ -28,6 +28,7 @@ import (
utils "k8splugin/internal"
"k8splugin/internal/db"
+ "k8splugin/internal/rb"
)
func LoadMockPlugins(krdLoadedPlugins *map[string]*plugin.Plugin) error {
@@ -84,12 +85,14 @@ func TestCreateVNF(t *testing.T) {
t.Run("Successfully create VNF", func(t *testing.T) {
db.DBconn = &db.MockDB{
Items: map[string]map[string][]byte{
- "123e4567-e89b-12d3-a456-426655440000": {
+ rb.ProfileKey{RBName: "test-rbdef", RBVersion: "v1",
+ Name: "profile1"}.String(): {
"metadata": []byte(
- "{\"name\":\"testresourcebundle\"," +
- "\"namespace\":\"default\"," +
- "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
- "\"rbdid\":\"abcde123-e89b-8888-a456-986655447236\"," +
+ "{\"profile-name\":\"profile1\"," +
+ "\"release-name\":\"testprofilereleasename\"," +
+ "\"namespace\":\"testnamespace\"," +
+ "\"rb-name\":\"test-rbdef\"," +
+ "\"rb-version\":\"v1\"," +
"\"kubernetesversion\":\"1.12.3\"}"),
// base64 encoding of vagrant/tests/vnfs/testrb/helm/profile
"content": []byte("H4sICLmjT1wAA3Byb2ZpbGUudGFyAO1Y32/bNhD2s/6Kg/KyYZZsy" +
@@ -116,13 +119,12 @@ func TestCreateVNF(t *testing.T) {
"YkDi6mRXNk/V1pUxy0uYsI1S+meU+XsPo2kJLnMOKZGy4J6Xt3XgZuHTayEKv3XZLjy+" +
"yJ66WPQwcHBwcHBwcHBwcHBwcHBwcHhm8Q/mTHqWgAoAAA="),
},
- "abcde123-e89b-8888-a456-986655447236": {
+ rb.DefinitionKey{Name: "test-rbdef", Version: "v1"}.String(): {
"metadata": []byte(
- "{\"name\":\"testresourcebundle\"," +
+ "{\"rb-name\":\"test-rbdef\"," +
+ "\"rb-version\":\"v1\"," +
"\"chart-name\":\"vault-consul-dev\"," +
- "\"description\":\"testresourcebundle\"," +
- "\"uuid\":\"abcde123-e89b-8888-a456-986655447236\"," +
- "\"service-type\":\"firewall\"}"),
+ "\"description\":\"testresourcebundle\"}"),
// base64 encoding of vagrant/tests/vnfs/testrb/helm/vault-consul-dev
"content": []byte("H4sICEetS1wAA3ZhdWx0LWNvbnN1bC1kZXYudGFyAO0c7XLbNjK/+R" +
"QYujdJehatb+V4czPnOmnPk9bO2Gk7nbaTgUhIxpgiGAK0o3P9QPca92S3C5AU9GXZiax" +
@@ -191,7 +193,14 @@ func TestCreateVNF(t *testing.T) {
},
}
externaluuid, data, err := CreateVNF("uuid", "cloudregion1",
- "123e4567-e89b-12d3-a456-426655440000", &kubeclient)
+ rb.Profile{
+ RBName: "test-rbdef",
+ RBVersion: "v1",
+ Name: "profile1",
+ ReleaseName: "testprofilereleasename",
+ Namespace: "testnamespace",
+ KubernetesVersion: "1.12.3",
+ }, &kubeclient)
if err != nil {
t.Fatalf("TestCreateVNF returned an error (%s)", err)
}