-
Notifications
You must be signed in to change notification settings - Fork 47
/
MockCloudConnection.go
81 lines (67 loc) · 2.48 KB
/
MockCloudConnection.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Cloud Driver Interface of CB-Spider.
// The CB-Spider is a sub-Framework of the Cloud-Barista Multi-Cloud Project.
// The CB-Spider Mission is to connect all the clouds with a single interface.
//
// * Cloud-Barista: https://github.com/cloud-barista
//
// This is Mock Driver.
//
// by CB-Spider Team, 2020.05.
package connect
import (
cblog "github.com/cloud-barista/cb-log"
mkrs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/mock/resources"
idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces"
irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources"
"github.com/sirupsen/logrus"
)
var cblogger *logrus.Logger
func init() {
// cblog is a global variable.
cblogger = cblog.GetLogger("CB-SPIDER")
}
type MockConnection struct {
Region idrv.RegionInfo
MockName string
}
func (cloudConn *MockConnection) CreateImageHandler() (irs.ImageHandler, error) {
cblogger.Info("Mock Driver: called CreateImageHandler()!")
handler := mkrs.MockImageHandler{cloudConn.MockName}
return &handler, nil
}
func (cloudConn *MockConnection) CreateVMHandler() (irs.VMHandler, error) {
cblogger.Info("Mock Driver: called CreateVMHandler()!")
handler := mkrs.MockVMHandler{cloudConn.Region, cloudConn.MockName}
return &handler, nil
}
func (cloudConn *MockConnection) CreateVPCHandler() (irs.VPCHandler, error) {
cblogger.Info("Mock Driver: called CreateVPCHandler()!")
handler := mkrs.MockVPCHandler{cloudConn.MockName}
return &handler, nil
}
func (cloudConn MockConnection) CreateSecurityHandler() (irs.SecurityHandler, error) {
cblogger.Info("Mock Driver: called CreateSecurityHandler()!")
handler := mkrs.MockSecurityHandler{cloudConn.MockName}
return &handler, nil
}
func (cloudConn *MockConnection) CreateKeyPairHandler() (irs.KeyPairHandler, error) {
cblogger.Info("Mock Driver: called CreateKeyPairHandler()!")
handler := mkrs.MockKeyPairHandler{cloudConn.MockName}
return &handler, nil
}
func (cloudConn *MockConnection) CreateVMSpecHandler() (irs.VMSpecHandler, error) {
cblogger.Info("Mock Driver: called CreateVMSpecHandler()!")
handler := mkrs.MockVMSpecHandler{cloudConn.MockName}
return &handler, nil
}
func (cloudConn *MockConnection) IsConnected() (bool, error) {
cblogger.Info("Mock Driver: called IsConnected()!")
if cloudConn == nil {
return false, nil
}
return true, nil
}
func (cloudConn *MockConnection) Close() error {
cblogger.Info("Mock Driver: called Close()!")
return nil
}