aboutsummaryrefslogtreecommitdiffstats
path: root/src/rsync/pkg/context/context.go
diff options
context:
space:
mode:
authorManjunath Ranganathaiah <manjunath.ranganathaiah@intel.com>2020-06-26 22:22:13 +0000
committerRitu Sood <ritu.sood@intel.com>2020-06-27 20:11:33 -0700
commit8f338f5fb69c509439eb7f9ac7cfe7bd47849f8b (patch)
tree5839a7e861033ec259da8bcf31e496997b6143fe /src/rsync/pkg/context/context.go
parent8e446beb55c68314896f16cb3105816cacc05f84 (diff)
Remove config and yaml file creation
Signed-off-by: Manjunath Ranganathaiah <manjunath.ranganathaiah@intel.com> Issue-ID: MULTICLOUD-1005 Change-Id: Iaa8b70f38cf1fc1f89cf2d95fbe37c242fc44f65
Diffstat (limited to 'src/rsync/pkg/context/context.go')
-rw-r--r--src/rsync/pkg/context/context.go52
1 files changed, 7 insertions, 45 deletions
diff --git a/src/rsync/pkg/context/context.go b/src/rsync/pkg/context/context.go
index 67e589c9..e5da1296 100644
--- a/src/rsync/pkg/context/context.go
+++ b/src/rsync/pkg/context/context.go
@@ -20,7 +20,6 @@ import (
"encoding/json"
"fmt"
"log"
- "os"
"sync"
"strings"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/appcontext"
@@ -50,8 +49,6 @@ type instMap struct {
clusters []clusterInfo
}
-const basePath string = "/tmp/rsync/"
-
func getInstMap(order string, dependency string, level string) ([]instMap, error) {
if order == "" {
@@ -97,10 +94,10 @@ func deleteResource(clustername string, resname string, respath string) error {
var gp res.Resource
err = gp.Delete(respath, resname, "default", c)
if err != nil {
- log.Println("Delete resource failed: " + err.Error())
+ log.Println("Delete resource failed: " + err.Error() + resname)
return err
}
- log.Println("Resource succesfully deleted")
+ log.Println("Resource succesfully deleted", resname)
return nil
}
@@ -118,16 +115,16 @@ func createResource(clustername string, resname string, respath string) error {
var gp res.Resource
_, err = gp.Create(respath,"default", c)
if err != nil {
- log.Println("Create failed: " + err.Error())
+ log.Println("Create failed: " + err.Error() + resname)
return err
}
- log.Println("Resource succesfully created")
+ log.Println("Resource succesfully created", resname)
return nil
}
func terminateResource(ac appcontext.AppContext, resmap instMap, appname string, clustername string) error {
- var resPath string = basePath + appname + "/" + clustername + "/resources/"
+
rh, err := ac.GetResourceHandle(appname, clustername, resmap.name)
if err != nil {
return err
@@ -139,31 +136,14 @@ func terminateResource(ac appcontext.AppContext, resmap instMap, appname string,
}
if resval != "" {
- if _, err := os.Stat(resPath); os.IsNotExist(err) {
- err = os.MkdirAll(resPath, 0755)
- if err != nil {
- return err
- }
- }
- resPath := resPath + resmap.name + ".yaml"
- f, err := os.Create(resPath)
- defer f.Close()
- if err != nil {
- return err
- }
- _, err = f.WriteString(resval.(string))
- if err != nil {
- return err
- }
result := strings.Split(resmap.name, "+")
if result[0] == "" {
return pkgerrors.Errorf("Resource name is nil")
}
- err = deleteResource(clustername, result[0], resPath)
+ err = deleteResource(clustername, result[0], resval.(string))
if err != nil {
return err
}
- //defer os.Remove(resPath)
} else {
return pkgerrors.Errorf("Resource value is nil")
}
@@ -173,7 +153,6 @@ func terminateResource(ac appcontext.AppContext, resmap instMap, appname string,
}
func instantiateResource(ac appcontext.AppContext, resmap instMap, appname string, clustername string) error {
- var resPath string = basePath + appname + "/" + clustername + "/resources/"
rh, err := ac.GetResourceHandle(appname, clustername, resmap.name)
if err != nil {
return err
@@ -185,31 +164,14 @@ func instantiateResource(ac appcontext.AppContext, resmap instMap, appname strin
}
if resval != "" {
- if _, err := os.Stat(resPath); os.IsNotExist(err) {
- err = os.MkdirAll(resPath, 0755)
- if err != nil {
- return err
- }
- }
- resPath := resPath + resmap.name + ".yaml"
- f, err := os.Create(resPath)
- defer f.Close()
- if err != nil {
- return err
- }
- _, err = f.WriteString(resval.(string))
- if err != nil {
- return err
- }
result := strings.Split(resmap.name, "+")
if result[0] == "" {
return pkgerrors.Errorf("Resource name is nil")
}
- err = createResource(clustername, result[0], resPath)
+ err = createResource(clustername, result[0], resval.(string))
if err != nil {
return err
}
- //defer os.Remove(resPath)
} else {
return pkgerrors.Errorf("Resource value is nil")
}