aboutsummaryrefslogtreecommitdiffstats
path: root/src/dcm/pkg/module/logicalcloud.go
diff options
context:
space:
mode:
authorEric Multanen <eric.w.multanen@intel.com>2020-10-16 23:25:49 +0000
committerGerrit Code Review <gerrit@onap.org>2020-10-16 23:25:49 +0000
commitf192f46107c86d3e15e9fb889e2e4382e26e94e3 (patch)
treebe944d97cf01aa3f04fec151026e1e1fbe96e636 /src/dcm/pkg/module/logicalcloud.go
parent2573d840571cb511e27ba5ef663a4b99bc717a45 (diff)
parent5e013d0d327dee9f5cd53fee6ec8d2d2593e0258 (diff)
Merge "Restore commented unit test TestDeleteLogicalCloud"
Diffstat (limited to 'src/dcm/pkg/module/logicalcloud.go')
-rw-r--r--src/dcm/pkg/module/logicalcloud.go18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/dcm/pkg/module/logicalcloud.go b/src/dcm/pkg/module/logicalcloud.go
index 580e9022..3fe981b8 100644
--- a/src/dcm/pkg/module/logicalcloud.go
+++ b/src/dcm/pkg/module/logicalcloud.go
@@ -75,7 +75,6 @@ type LogicalCloudManager interface {
GetAll(project string) ([]LogicalCloud, error)
Delete(project, name string) error
Update(project, name string, c LogicalCloud) (LogicalCloud, error)
- GetLogicalCloudContext(project string, name string) (appcontext.AppContext, string, error)
}
// Interface facilitates unit testing by mocking functions
@@ -86,6 +85,8 @@ type Utility interface {
DBRemove(storeName string, key db.Key) error
CheckProject(project string) error
CheckLogicalCloud(project, logicalCloud string) error
+ GetLogicalCloudContext(storeName string, key db.Key, meta string, project string, name string) (appcontext.AppContext, string, error)
+ GetAppContextStatus(ac appcontext.AppContext) (*appcontext.AppContextStatus, error)
}
// LogicalCloudClient implements the LogicalCloudManager
@@ -208,7 +209,7 @@ func (v *LogicalCloudClient) Delete(project, logicalCloudName string) error {
return pkgerrors.New("Logical Cloud does not exist")
}
- context, _, err := v.GetLogicalCloudContext(project, logicalCloudName)
+ context, _, err := v.util.GetLogicalCloudContext(v.storeName, key, v.tagMeta, project, logicalCloudName)
// If there's no context for Logical Cloud, just go ahead and delete it now
if err != nil {
err = v.util.DBRemove(v.storeName, key)
@@ -220,7 +221,7 @@ func (v *LogicalCloudClient) Delete(project, logicalCloudName string) error {
// Make sure rsync status for this logical cloud is Terminated,
// otherwise we can't remove appcontext yet
- acStatus, _ := getAppContextStatus(context)
+ acStatus, _ := v.util.GetAppContextStatus(context)
switch acStatus.Status {
case appcontext.AppContextStatusEnum.Terminated:
// remove the appcontext
@@ -267,14 +268,9 @@ func (v *LogicalCloudClient) Update(project, logicalCloudName string, c LogicalC
}
// GetLogicalCloudContext returns the AppContext for corresponding provider and name
-func (v *LogicalCloudClient) GetLogicalCloudContext(project string, name string) (appcontext.AppContext, string, error) {
- //Construct key and tag to select the entry
- key := LogicalCloudKey{
- LogicalCloudName: name,
- Project: project,
- }
+func (d DBService) GetLogicalCloudContext(storeName string, key db.Key, meta string, project string, name string) (appcontext.AppContext, string, error) {
- value, err := v.util.DBFind(v.storeName, key, v.tagContext)
+ value, err := d.DBFind(storeName, key, meta)
if err != nil {
return appcontext.AppContext{}, "", pkgerrors.Wrap(err, "Get Logical Cloud Context")
}
@@ -353,7 +349,7 @@ func (d DBService) CheckLogicalCloud(project, logicalCloud string) error {
return nil
}
-func getAppContextStatus(ac appcontext.AppContext) (*appcontext.AppContextStatus, error) {
+func (d DBService) GetAppContextStatus(ac appcontext.AppContext) (*appcontext.AppContextStatus, error) {
h, err := ac.GetCompositeAppHandle()
if err != nil {