-
Notifications
You must be signed in to change notification settings - Fork 47
/
Ibm_CloudConnection.go
165 lines (151 loc) · 5.65 KB
/
Ibm_CloudConnection.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package connect
import (
"context"
"errors"
"github.com/IBM/platform-services-go-sdk/globaltaggingv1"
vpcv0230 "github.com/IBM/vpc-go-sdk/0.23.0/vpcv1"
"github.com/IBM/vpc-go-sdk/vpcv1"
cblog "github.com/cloud-barista/cb-log"
ibmrs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/ibmcloud-vpc/resources"
"github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/ibmcloud-vpc/utils/kubernetesserviceapiv1"
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 IbmCloudConnection struct {
CredentialInfo idrv.CredentialInfo
Region idrv.RegionInfo
VpcService *vpcv1.VpcV1
ClusterService *kubernetesserviceapiv1.KubernetesServiceApiV1
TaggingService *globaltaggingv1.GlobalTaggingV1
VpcService0230 *vpcv0230.VpcV1
Ctx context.Context
}
func (cloudConn *IbmCloudConnection) CreateImageHandler() (irs.ImageHandler, error) {
cblogger.Info("Ibm Cloud Driver: called CreateImageHandler()!")
imageHandler := ibmrs.IbmImageHandler{
CredentialInfo: cloudConn.CredentialInfo,
Region: cloudConn.Region,
VpcService: cloudConn.VpcService,
Ctx: cloudConn.Ctx,
}
return &imageHandler, nil
}
func (cloudConn *IbmCloudConnection) CreateVMHandler() (irs.VMHandler, error) {
cblogger.Info("Ibm Cloud Driver: called CreateVMHandler()!")
vmHandler := ibmrs.IbmVMHandler{
CredentialInfo: cloudConn.CredentialInfo,
Region: cloudConn.Region,
VpcService: cloudConn.VpcService,
VpcService0230: cloudConn.VpcService0230,
Ctx: cloudConn.Ctx,
}
return &vmHandler, nil
}
func (cloudConn *IbmCloudConnection) CreateVPCHandler() (irs.VPCHandler, error) {
cblogger.Info("Ibm Cloud Driver: called CreateVPCHandler()!")
vpcHandler := ibmrs.IbmVPCHandler{
CredentialInfo: cloudConn.CredentialInfo,
Region: cloudConn.Region,
VpcService: cloudConn.VpcService,
Ctx: cloudConn.Ctx,
}
return &vpcHandler, nil
}
func (cloudConn *IbmCloudConnection) CreateSecurityHandler() (irs.SecurityHandler, error) {
cblogger.Info("Ibm Cloud Driver: called CreateSecurityHandler()!")
securityHandler := ibmrs.IbmSecurityHandler{
CredentialInfo: cloudConn.CredentialInfo,
Region: cloudConn.Region,
VpcService: cloudConn.VpcService,
Ctx: cloudConn.Ctx,
}
return &securityHandler, nil
}
func (cloudConn *IbmCloudConnection) CreateKeyPairHandler() (irs.KeyPairHandler, error) {
cblogger.Info("Ibm Cloud Driver: called CreateVPCHandler()!")
keyPairHandler := ibmrs.IbmKeyPairHandler{
CredentialInfo: cloudConn.CredentialInfo,
Region: cloudConn.Region,
VpcService: cloudConn.VpcService,
Ctx: cloudConn.Ctx,
}
return &keyPairHandler, nil
}
func (cloudConn *IbmCloudConnection) CreateVMSpecHandler() (irs.VMSpecHandler, error) {
cblogger.Info("Ibm Cloud Driver: called CreateVMSpecHandler()!")
vmSpecHandler := ibmrs.IbmVmSpecHandler{
CredentialInfo: cloudConn.CredentialInfo,
Region: cloudConn.Region,
VpcService: cloudConn.VpcService,
Ctx: cloudConn.Ctx,
}
return &vmSpecHandler, nil
}
func (cloudConn *IbmCloudConnection) CreateNLBHandler() (irs.NLBHandler, error) {
cblogger.Info("Ibm Cloud Driver: called CreateNLBHandler()!")
nlbHandler := ibmrs.IbmNLBHandler{
CredentialInfo: cloudConn.CredentialInfo,
Region: cloudConn.Region,
VpcService: cloudConn.VpcService,
Ctx: cloudConn.Ctx,
}
return &nlbHandler, nil
}
func (cloudConn *IbmCloudConnection) IsConnected() (bool, error) {
cblogger.Info("Ibm Cloud Driver: called IsConnected()!")
return true, nil
}
func (cloudConn *IbmCloudConnection) Close() error {
cblogger.Info("Ibm Cloud Driver: called Close()!")
return nil
}
func (cloudConn *IbmCloudConnection) CreateDiskHandler() (irs.DiskHandler, error) {
cblogger.Info("Ibm Cloud Driver: called CreateDiskHandler()!")
diskHandler := ibmrs.IbmDiskHandler{
CredentialInfo: cloudConn.CredentialInfo,
Region: cloudConn.Region,
VpcService: cloudConn.VpcService,
Ctx: cloudConn.Ctx,
}
return &diskHandler, nil
}
func (cloudConn *IbmCloudConnection) CreateClusterHandler() (irs.ClusterHandler, error) {
cblogger.Info("Ibm Cloud Driver: called CreateClusterHandler()!")
clusterHandler := ibmrs.IbmClusterHandler{
CredentialInfo: cloudConn.CredentialInfo,
Region: cloudConn.Region,
VpcService: cloudConn.VpcService,
ClusterService: cloudConn.ClusterService,
TaggingService: cloudConn.TaggingService,
Ctx: cloudConn.Ctx,
}
return &clusterHandler, nil
}
func (cloudConn *IbmCloudConnection) CreateMyImageHandler() (irs.MyImageHandler, error) {
cblogger.Info("Ibm Cloud Driver: called CreateMyImageHandler()!")
myIamgeHandler := ibmrs.IbmMyImageHandler{
CredentialInfo: cloudConn.CredentialInfo,
Region: cloudConn.Region,
VpcService: cloudConn.VpcService,
Ctx: cloudConn.Ctx,
}
return &myIamgeHandler, nil
}
func (cloudConn *IbmCloudConnection) CreateAnyCallHandler() (irs.AnyCallHandler, error) {
return nil, errors.New("Ibm Driver: not implemented")
}
func (cloudConn *IbmCloudConnection) CreateRegionZoneHandler() (irs.RegionZoneHandler, error) {
cblogger.Info("Ibm Cloud Driver: called CreateRegionZoneHandler()!")
regionZoneHandler := ibmrs.IbmRegionZoneHandler{
Region: cloudConn.Region,
VpcService: cloudConn.VpcService,
Ctx: cloudConn.Ctx,
}
return ®ionZoneHandler, nil
}