-
Notifications
You must be signed in to change notification settings - Fork 47
/
DockerCloudConnection.go
120 lines (96 loc) · 3.88 KB
/
DockerCloudConnection.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// 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 Docker Driver.
//
// by CB-Spider Team, 2020.05.
package connect
import (
"context"
cblog "github.com/cloud-barista/cb-log"
dkrs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/docker/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/docker/docker/client"
"github.com/sirupsen/logrus"
"errors"
)
var cblogger *logrus.Logger
func init() {
// cblog is a global variable.
cblogger = cblog.GetLogger("CB-SPIDER")
}
type DockerCloudConnection struct {
ConnectionInfo idrv.ConnectionInfo
Context context.Context
Client *client.Client
}
// CreateRegionZoneHandler implements connect.CloudConnection.
func (*DockerCloudConnection) CreateRegionZoneHandler() (irs.RegionZoneHandler, error) {
return nil, errors.New("Driver: not implemented")
}
func (cloudConn *DockerCloudConnection) CreateImageHandler() (irs.ImageHandler, error) {
cblogger.Info("Docker Cloud Driver: called CreateImageHandler()!")
imageHandler := dkrs.DockerImageHandler{cloudConn.ConnectionInfo.RegionInfo, cloudConn.Context, cloudConn.Client}
return &imageHandler, nil
}
func (cloudConn *DockerCloudConnection) CreateVMHandler() (irs.VMHandler, error) {
cblogger.Info("Docker Cloud Driver: called CreateVMHandler()!")
vmHandler := dkrs.DockerVMHandler{
Region: cloudConn.ConnectionInfo.RegionInfo,
Context: cloudConn.Context,
Client: cloudConn.Client,
}
return &vmHandler, nil
}
func (cloudConn *DockerCloudConnection) CreateVPCHandler() (irs.VPCHandler, error) {
cblogger.Error("Docker Cloud Driver: called CreateVPCHandler(), but not supported!")
return nil, nil
}
func (cloudConn DockerCloudConnection) CreateSecurityHandler() (irs.SecurityHandler, error) {
cblogger.Error("Docker Cloud Driver: called CreateSecurityHandler(), but not supported!")
return nil, nil
}
func (cloudConn *DockerCloudConnection) CreateKeyPairHandler() (irs.KeyPairHandler, error) {
cblogger.Error("Docker Cloud Driver: called CreateKeyPairHandler(), but not supported!")
return nil, nil
}
func (cloudConn *DockerCloudConnection) CreateVMSpecHandler() (irs.VMSpecHandler, error) {
cblogger.Error("Docker Cloud Driver: called CreateVMSpecHandler(), but not supported!")
return nil, nil
}
func (cloudConn *DockerCloudConnection) IsConnected() (bool, error) {
cblogger.Info("Docker Cloud Driver: called IsConnected()!")
if cloudConn == nil {
return false, nil
}
if cloudConn.Client == nil {
return false, nil
}
return true, nil
}
func (cloudConn *DockerCloudConnection) Close() error {
cblogger.Info("Docker Cloud Driver: called Close()!")
return cloudConn.Client.Close()
}
func (cloudConn *DockerCloudConnection) CreateNLBHandler() (irs.NLBHandler, error) {
return nil, errors.New("Docker Cloud Driver NLB: not implemented")
}
func (cloudConn *DockerCloudConnection) CreateDiskHandler() (irs.DiskHandler, error) {
return nil, errors.New("Docker Driver: not implemented")
}
func (cloudConn *DockerCloudConnection) CreateClusterHandler() (irs.ClusterHandler, error) {
return nil, errors.New("Docker Driver: not implemented")
}
func (cloudConn *DockerCloudConnection) CreateMyImageHandler() (irs.MyImageHandler, error) {
return nil, errors.New("Docker Driver: not implemented")
}
func (cloudConn *DockerCloudConnection) CreateAnyCallHandler() (irs.AnyCallHandler, error) {
return nil, errors.New("Docker Driver: not implemented")
}
func (*DockerCloudConnection) CreatePriceInfoHandler() (irs.PriceInfoHandler, error) {
return nil, errors.New("Docker Driver: not implemented")
}