forked from cloud-barista/cb-spider
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[+NHN Cloud conn. Driver] Add NHN Driver Codes
- Loading branch information
1 parent
9516279
commit 6751b38
Showing
56 changed files
with
12,234 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
221 changes: 221 additions & 0 deletions
221
cloud-control-manager/cloud-driver/drivers/nhncloud-plugin/NHNCloudDriver-lib.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
// 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 ETRI, Innogrid, 2021.12. | ||
// by ETRI Team, 2022.08. | ||
|
||
package main | ||
|
||
import ( | ||
// "github.com/davecgh/go-spew/spew" | ||
nhnsdk "github.com/cloud-barista/nhncloud-sdk-go" | ||
ostack "github.com/cloud-barista/nhncloud-sdk-go/openstack" | ||
|
||
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" | ||
|
||
// nhncon "github.com/cloud-barista/nhncloud/nhncloud/connect" | ||
nhncon "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/nhncloud/connect" | ||
|
||
// nhnrs "github.com/cloud-barista/nhncloud/nhncloud/resources" | ||
nhnrs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/nhncloud/resources" | ||
) | ||
|
||
type NhnCloudDriver struct{} | ||
|
||
func (NhnCloudDriver) GetDriverVersion() string { | ||
return "NHNCLOUD DRIVER Version 1.0" | ||
} | ||
|
||
func (NhnCloudDriver) 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 | ||
drvCapabilityInfo.NLBHandler = true | ||
drvCapabilityInfo.ClusterHandler = true | ||
drvCapabilityInfo.MyImageHandler = true | ||
drvCapabilityInfo.DiskHandler = true | ||
|
||
drvCapabilityInfo.SINGLE_VPC = true | ||
|
||
return drvCapabilityInfo | ||
} | ||
|
||
func (driver *NhnCloudDriver) ConnectCloud(connectionInfo idrv.ConnectionInfo) (icon.CloudConnection, error) { | ||
// 1. get info of credential and region for Test A Cloud from connectionInfo. | ||
// 2. create a client object(or service object) of Test A Cloud with credential info. | ||
// 3. create CloudConnection Instance of "connect/TDA_CloudConnection". | ||
// 4. return CloudConnection Interface of TDA_CloudConnection. | ||
|
||
// Initialize Logger | ||
nhnrs.InitLog() | ||
|
||
VMClient, err := getVMClient(connectionInfo) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
ImageClient, err := getImageClient(connectionInfo) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
NetworkClient, err := getNetworkClient(connectionInfo) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
VolumeClient, err := getVolumeClient(connectionInfo) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
ClusterClient, err := getClusterClient(connectionInfo) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
iConn := nhncon.NhnCloudConnection{ | ||
CredentialInfo: connectionInfo.CredentialInfo, // Note) Need in RegionZoneHandler | ||
RegionInfo: connectionInfo.RegionInfo, | ||
VMClient: VMClient, | ||
ImageClient: ImageClient, | ||
NetworkClient: NetworkClient, | ||
VolumeClient: VolumeClient, | ||
ClusterClient: ClusterClient, | ||
} | ||
return &iConn, nil | ||
} | ||
|
||
func getVMClient(connInfo idrv.ConnectionInfo) (*nhnsdk.ServiceClient, error) { | ||
authOpts := nhnsdk.AuthOptions{ | ||
IdentityEndpoint: connInfo.CredentialInfo.IdentityEndpoint, | ||
Username: connInfo.CredentialInfo.Username, | ||
Password: connInfo.CredentialInfo.Password, | ||
DomainName: connInfo.CredentialInfo.DomainName, | ||
TenantID: connInfo.CredentialInfo.TenantId, // Caution : TenantID spelling for SDK | ||
} | ||
|
||
providerClient, err := ostack.AuthenticatedClient(authOpts) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
client, err := ostack.NewComputeV2(providerClient, nhnsdk.EndpointOpts{ | ||
Region: connInfo.RegionInfo.Region, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return client, err | ||
} | ||
|
||
func getImageClient(connInfo idrv.ConnectionInfo) (*nhnsdk.ServiceClient, error) { | ||
authOpts := nhnsdk.AuthOptions{ | ||
IdentityEndpoint: connInfo.CredentialInfo.IdentityEndpoint, | ||
Username: connInfo.CredentialInfo.Username, | ||
Password: connInfo.CredentialInfo.Password, | ||
DomainName: connInfo.CredentialInfo.DomainName, | ||
TenantID: connInfo.CredentialInfo.TenantId, // Caution : TenantID spelling for SDK | ||
} | ||
|
||
providerClient, err := ostack.AuthenticatedClient(authOpts) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
client, err := ostack.NewImageServiceV2(providerClient, nhnsdk.EndpointOpts{ | ||
Region: connInfo.RegionInfo.Region, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return client, err | ||
} | ||
|
||
func getNetworkClient(connInfo idrv.ConnectionInfo) (*nhnsdk.ServiceClient, error) { | ||
authOpts := nhnsdk.AuthOptions{ | ||
IdentityEndpoint: connInfo.CredentialInfo.IdentityEndpoint, | ||
Username: connInfo.CredentialInfo.Username, | ||
Password: connInfo.CredentialInfo.Password, | ||
DomainName: connInfo.CredentialInfo.DomainName, | ||
TenantID: connInfo.CredentialInfo.TenantId, // Caution : TenantID spelling for SDK | ||
} | ||
|
||
providerClient, err := ostack.AuthenticatedClient(authOpts) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
client, err := ostack.NewNetworkV2(providerClient, nhnsdk.EndpointOpts{ | ||
Name: "neutron", | ||
Region: connInfo.RegionInfo.Region, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return client, err | ||
} | ||
|
||
func getVolumeClient(connInfo idrv.ConnectionInfo) (*nhnsdk.ServiceClient, error) { | ||
authOpts := nhnsdk.AuthOptions{ | ||
IdentityEndpoint: connInfo.CredentialInfo.IdentityEndpoint, | ||
Username: connInfo.CredentialInfo.Username, | ||
Password: connInfo.CredentialInfo.Password, | ||
DomainName: connInfo.CredentialInfo.DomainName, | ||
TenantID: connInfo.CredentialInfo.TenantId, // Caution : TenantID spelling for SDK | ||
} | ||
|
||
providerClient, err := ostack.AuthenticatedClient(authOpts) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
client, err := ostack.NewBlockStorageV2(providerClient, nhnsdk.EndpointOpts{ | ||
Region: connInfo.RegionInfo.Region, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return client, err | ||
} | ||
|
||
func getClusterClient(connInfo idrv.ConnectionInfo) (*nhnsdk.ServiceClient, error) { | ||
authOpts := nhnsdk.AuthOptions{ | ||
IdentityEndpoint: connInfo.CredentialInfo.IdentityEndpoint, | ||
Username: connInfo.CredentialInfo.Username, | ||
Password: connInfo.CredentialInfo.Password, | ||
DomainName: connInfo.CredentialInfo.DomainName, | ||
TenantID: connInfo.CredentialInfo.TenantId, // Caution : TenantID spelling for SDK | ||
} | ||
|
||
providerClient, err := ostack.AuthenticatedClient(authOpts) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
client, err := ostack.NewContainerInfraV1(providerClient, nhnsdk.EndpointOpts{ | ||
Region: connInfo.RegionInfo.Region, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return client, err | ||
} | ||
|
||
var CloudDriver NhnCloudDriver |
16 changes: 16 additions & 0 deletions
16
cloud-control-manager/cloud-driver/drivers/nhncloud-plugin/build_driver_lib.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
source $CBSPIDER_ROOT/setup.env | ||
|
||
DRIVERLIB_PATH=$CBSPIDER_ROOT/cloud-driver-libs | ||
DRIVERFILENAME=nhncloud-driver-v1.0 | ||
|
||
go mod download # cb-spider's go.mod and go.sum will be applied. | ||
|
||
function build() { | ||
rm -rf $DRIVERLIB_PATH/${DRIVERFILENAME}.so | ||
env GO111MODULE=on go build -buildmode=plugin -o ${DRIVERFILENAME}.so NHNCloudDriver-lib.go || return 1 | ||
chmod +x ${DRIVERFILENAME}.so || return 1 | ||
mv ./${DRIVERFILENAME}.so $DRIVERLIB_PATH || return 1 | ||
} | ||
|
||
build |
Oops, something went wrong.