Skip to content

Commit

Permalink
add plugin=off mode
Browse files Browse the repository at this point in the history
  • Loading branch information
powerkimhub committed May 19, 2020
1 parent 83b0aeb commit 3938ea0
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
57 changes: 55 additions & 2 deletions cloud-control-manager/CloudDriverHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ package clouddriverhandler

import (
idrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces"

awsdrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/aws"
azuredrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/azure"
gcpdrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/gcp"
alibabadrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/alibaba"
openstackdrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/openstack"
clouditdrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/cloudit"
dockerdrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/docker"
// cloudtwindrv "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/drivers/cloudtwin"

icbs "github.com/cloud-barista/cb-store/interfaces"

"github.com/cloud-barista/cb-store/config"
Expand Down Expand Up @@ -60,7 +70,12 @@ func GetCloudDriver(cloudConnectName string) (idrv.CloudDriver, error) {
return nil, err
}

return getCloudDriver(*cldDrvInfo)
pluginSW := os.Getenv("PLUGIN_SW")
if strings.ToUpper(pluginSW) == "ON" {
return getStaticCloudDriver(*cldDrvInfo)
} else {
return getCloudDriver(*cldDrvInfo)
}
}

// 1. get credential info
Expand All @@ -77,7 +92,13 @@ func GetCloudConnection(cloudConnectName string) (icon.CloudConnection, error) {
return nil, err
}

cldDriver, err := getCloudDriver(*cldDrvInfo)
pluginSW := os.Getenv("PLUGIN_SW")
var cldDriver idrv.CloudDriver
if strings.ToUpper(pluginSW) == "ON" {
cldDriver, err = getStaticCloudDriver(*cldDrvInfo)
} else {
cldDriver, err = getCloudDriver(*cldDrvInfo)
}
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -232,3 +253,35 @@ func getCloudDriver(cldDrvInfo dim.CloudDriverInfo) (idrv.CloudDriver, error) {

return cloudDriver, nil
}

func getStaticCloudDriver(cldDrvInfo dim.CloudDriverInfo) (idrv.CloudDriver, error) {
cblog.Info("CloudDriverHandler: called getStaticCloudDriver() - " + cldDrvInfo.DriverName )

var cloudDriver idrv.CloudDriver

// select driver
switch cldDrvInfo.ProviderName {
case "AWS":
cloudDriver = new(awsdrv.AwsDriver)
case "AZURE":
cloudDriver = new(azuredrv.AzureDriver)
case "GCP":
cloudDriver = new(gcpdrv.GCPDriver)
case "ALIBABA":
cloudDriver = new(alibabadrv.AlibabaDriver)
case "OPENSTACK":
cloudDriver = new(openstackdrv.OpenStackDriver)
case "CLOUDIT":
cloudDriver = new(clouditdrv.ClouditDriver)
case "DOCKER":
cloudDriver = new(dockerdrv.DockerDriver)
//case "CLOUDTWIN":
// cloudDriver = new(cloudtwindrv.CloudTwinDriver)

default:
errmsg := cldDrvInfo.ProviderName + " is not supported static Cloud Driver!!"
return cloudDriver, fmt.Errorf(errmsg)
}

return cloudDriver, nil
}
1 change: 1 addition & 0 deletions setup.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export CBSPIDER_ROOT=$GOPATH/src/github.com/cloud-barista/cb-spider
export CBSTORE_ROOT=$GOPATH/src/github.com/cloud-barista/cb-spider
export CBLOG_ROOT=$GOPATH/src/github.com/cloud-barista/cb-spider
export PLUGIN_SW=OFF

0 comments on commit 3938ea0

Please sign in to comment.