summaryrefslogtreecommitdiffstats
path: root/src/dcm/pkg/module/logicalcloud.go
diff options
context:
space:
mode:
authorIgor D.C <igor.duarte.cardoso@intel.com>2020-09-25 22:31:11 +0000
committerIgor D.C <igor.duarte.cardoso@intel.com>2020-09-25 23:24:29 +0000
commit8c0cc1278cc4d84863b076b2014b9bc9d8805218 (patch)
tree6f2274560030252710464db5b6ae93da8a0dce2e /src/dcm/pkg/module/logicalcloud.go
parent425795c7d4e6ce81932918aca2a1462384d4507f (diff)
Implement Terminate operation in DCM
Also makes minor changes to non-terminate code as a side-effect of supporting the new Terminate operation (such as including tagContext in the LogicalCloudClient implementation of LogicalCloudManager interface). These changes are/will also be leveraged by other operations. Issue-ID: MULTICLOUD-1143 Change-Id: Idbd2ec9f6cf0e5584a0f51cf4c16144db56d9fa0 Signed-off-by: Igor D.C <igor.duarte.cardoso@intel.com>
Diffstat (limited to 'src/dcm/pkg/module/logicalcloud.go')
-rw-r--r--src/dcm/pkg/module/logicalcloud.go36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/dcm/pkg/module/logicalcloud.go b/src/dcm/pkg/module/logicalcloud.go
index 7d3c806b..9b8ff703 100644
--- a/src/dcm/pkg/module/logicalcloud.go
+++ b/src/dcm/pkg/module/logicalcloud.go
@@ -17,6 +17,7 @@
package module
import (
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/appcontext"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/module"
@@ -72,6 +73,7 @@ type LogicalCloudManager interface {
GetAll(project string) ([]LogicalCloud, error)
Delete(project, name string) error
Update(project, name string, c LogicalCloud) (LogicalCloud, error)
+ GetLogicalCloudContext(name string) (appcontext.AppContext, string, error)
}
// Interface facilitates unit testing by mocking functions
@@ -87,9 +89,10 @@ type Utility interface {
// LogicalCloudClient implements the LogicalCloudManager
// It will also be used to maintain some localized state
type LogicalCloudClient struct {
- storeName string
- tagMeta string
- util Utility
+ storeName string
+ tagMeta string
+ tagContext string
+ util Utility
}
// Added for unit testing; implements Utility interface
@@ -227,6 +230,33 @@ func (v *LogicalCloudClient) Update(project, logicalCloudName string, c LogicalC
return c, nil
}
+// GetClusterContext returns the AppContext for corresponding provider and name
+func (v *LogicalCloudClient) GetLogicalCloudContext(name string) (appcontext.AppContext, string, error) {
+ //Construct key and tag to select the entry
+ key := LogicalCloudKey{
+ LogicalCloudName: name,
+ Project: "test-project", // FIXME(igordc): temporary, need to do some rework in the LC structs
+ }
+
+ value, err := db.DBconn.Find(v.storeName, key, v.tagContext)
+ if err != nil {
+ return appcontext.AppContext{}, "", pkgerrors.Wrap(err, "Get Logical Cloud Context")
+ }
+
+ //value is a byte array
+ if value != nil {
+ ctxVal := string(value[0])
+ var lcc appcontext.AppContext
+ _, err = lcc.LoadAppContext(ctxVal)
+ if err != nil {
+ return appcontext.AppContext{}, "", pkgerrors.Wrap(err, "Reinitializing Logical Cloud AppContext")
+ }
+ return lcc, ctxVal, nil
+ }
+
+ return appcontext.AppContext{}, "", pkgerrors.New("Error getting Logical Cloud AppContext")
+}
+
func (d DBService) DBInsert(storeName string, key db.Key, query interface{}, meta string, c interface{}) error {
err := db.DBconn.Insert(storeName, key, nil, meta, c)