-
Notifications
You must be signed in to change notification settings - Fork 48
/
MockDriver.go
74 lines (58 loc) · 2.2 KB
/
MockDriver.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
// Mock Driver 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.09.
package mock
import (
"C"
cblog "github.com/cloud-barista/cb-log"
"github.com/sirupsen/logrus"
mkcon "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/mock/connect"
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"
icon "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/connect"
)
type MockDriver struct{}
var cblogger *logrus.Logger
func init() {
// cblog is a global variable.
cblogger = cblog.GetLogger("CB-SPIDER")
}
func (MockDriver) GetDriverVersion() string {
return "MOCK DRIVER Version 1.0"
}
func (MockDriver) GetDriverCapability() idrv.DriverCapabilityInfo {
var drvCapabilityInfo idrv.DriverCapabilityInfo
drvCapabilityInfo.ImageHandler = true
drvCapabilityInfo.VPCHandler = true
drvCapabilityInfo.SecurityHandler = true
drvCapabilityInfo.KeyPairHandler = true
drvCapabilityInfo.VNicHandler = false
drvCapabilityInfo.PublicIPHandler = false
drvCapabilityInfo.VMHandler = true
drvCapabilityInfo.VMSpecHandler = true
return drvCapabilityInfo
}
func (driver *MockDriver) ConnectCloud(connectionInfo idrv.ConnectionInfo) (icon.CloudConnection, error) {
// <standard flow>
// 1. get info of credential and region for Test A Cloud from connectionInfo.
// 2. create a client object(or service object) of XXX Cloud with credential info.
// 3. create CloudConnection Instance of "connect/XXX_CloudConnection".
// 4. return CloudConnection Interface of XXX_CloudConnection.
// ex)
// MockName = "mock01"
iConn := mkcon.MockConnection{
Region: connectionInfo.RegionInfo,
MockName: connectionInfo.CredentialInfo.MockName,
}
// Please, do not delete this line.
mkrs.PrepareVMImage(iConn.MockName)
mkrs.PrepareVMSpec(iConn.MockName)
return &iConn, nil
}
var CloudDriver MockDriver