-
Notifications
You must be signed in to change notification settings - Fork 47
/
AwsCloudConnection.go
114 lines (88 loc) · 3.42 KB
/
AwsCloudConnection.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
// Proof of Concepts 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 a Cloud Driver Example for PoC Test.
//
// by powerkim@etri.re.kr, 2019.06.
package connect
import (
cblog "github.com/cloud-barista/cb-log"
idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces"
//irs2 "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/new-resources"
irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources"
"github.com/sirupsen/logrus"
ars "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/aws/resources"
//ec2drv "github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/ec2"
)
//type AwsCloudConnection struct{}
type AwsCloudConnection struct {
CredentialInfo idrv.CredentialInfo
Region idrv.RegionInfo
KeyPairClient *ec2.EC2
VMClient *ec2.EC2
VNetworkClient *ec2.EC2
//VNicClient *ec2.EC2
ImageClient *ec2.EC2
//PublicIPClient *ec2.EC2
SecurityClient *ec2.EC2
VmSpecClient *ec2.EC2
}
var cblogger *logrus.Logger
func init() {
// cblog is a global variable.
cblogger = cblog.GetLogger("CB-SPIDER")
}
func (cloudConn *AwsCloudConnection) CreateKeyPairHandler() (irs.KeyPairHandler, error) {
cblogger.Info("Start CreateKeyPairHandler()")
keyPairHandler := ars.AwsKeyPairHandler{cloudConn.CredentialInfo, cloudConn.Region, cloudConn.KeyPairClient}
//keyPairHandler := ars.AwsKeyPairHandler{cloudConn.Region, cloudConn.KeyPairClient}
return &keyPairHandler, nil
}
func (cloudConn *AwsCloudConnection) CreateVMHandler() (irs.VMHandler, error) {
cblogger.Info("Start CreateVMHandler()")
vmHandler := ars.AwsVMHandler{cloudConn.Region, cloudConn.VMClient}
return &vmHandler, nil
}
func (cloudConn *AwsCloudConnection) IsConnected() (bool, error) {
return true, nil
}
func (cloudConn *AwsCloudConnection) Close() error {
return nil
}
func (cloudConn *AwsCloudConnection) CreateVPCHandler() (irs.VPCHandler, error) {
cblogger.Info("Start")
handler := ars.AwsVPCHandler{cloudConn.Region, cloudConn.VNetworkClient}
return &handler, nil
}
//func (cloudConn *AwsCloudConnection) CreateImageHandler() (irs2.ImageHandler, error) {
func (cloudConn *AwsCloudConnection) CreateImageHandler() (irs.ImageHandler, error) {
cblogger.Info("Start")
handler := ars.AwsImageHandler{cloudConn.Region, cloudConn.ImageClient}
return &handler, nil
}
func (cloudConn *AwsCloudConnection) CreateSecurityHandler() (irs.SecurityHandler, error) {
cblogger.Info("Start")
handler := ars.AwsSecurityHandler{cloudConn.Region, cloudConn.SecurityClient}
return &handler, nil
}
/*
func (cloudConn *AwsCloudConnection) CreateVNicHandler() (irs.VNicHandler, error) {
cblogger.Info("Start")
handler := ars.AwsVNicHandler{cloudConn.Region, cloudConn.VNicClient}
return &handler, nil
}
func (cloudConn *AwsCloudConnection) CreatePublicIPHandler() (irs.PublicIPHandler, error) {
cblogger.Info("Start")
handler := ars.AwsPublicIPHandler{cloudConn.Region, cloudConn.PublicIPClient}
return &handler, nil
}
*/
func (cloudConn *AwsCloudConnection) CreateVMSpecHandler() (irs.VMSpecHandler, error) {
cblogger.Info("Start")
handler := ars.AwsVmSpecHandler{cloudConn.Region, cloudConn.VmSpecClient}
return &handler, nil
}