-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add feature & REST API for list of support CloudOS
- Loading branch information
1 parent
6147a60
commit 252f553
Showing
6 changed files
with
132 additions
and
15 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package cloudos | ||
|
||
import ( | ||
"github.com/sirupsen/logrus" | ||
"github.com/cloud-barista/cb-store/config" | ||
|
||
"gopkg.in/yaml.v3" | ||
"io/ioutil" | ||
"os" | ||
_ "fmt" | ||
"strings" | ||
"sort" | ||
) | ||
|
||
|
||
var cblog *logrus.Logger | ||
|
||
func init() { | ||
cblog = config.Cblogger | ||
} | ||
|
||
|
||
|
||
type CloudOSList struct { | ||
Name []string `yaml:"cloudos"` | ||
} | ||
|
||
func readYaml() CloudOSList { | ||
// Set Environment Value of Project Root Path | ||
rootPath := os.Getenv("CBSPIDER_ROOT") | ||
data, err := ioutil.ReadFile(rootPath + "/cloud-info-manager/cloudos.yaml") | ||
if err != nil { | ||
cblog.Error(err) | ||
panic(err) | ||
} | ||
|
||
var coList CloudOSList | ||
err = yaml.Unmarshal(data, &coList) | ||
if err != nil { | ||
cblog.Error(err) | ||
panic(err) | ||
} | ||
|
||
return coList | ||
} | ||
|
||
func ListCloudOS() []string { | ||
|
||
// read YAML file | ||
cloudosList := readYaml() | ||
|
||
// to Upper | ||
for n, cloudos := range cloudosList.Name{ | ||
cloudosList.Name[n] = strings.ToUpper(cloudos) | ||
} | ||
|
||
sort.Strings(cloudosList.Name) | ||
cblog.Info(cloudosList) | ||
|
||
/* for _, cloudos := range cloudosList.Name{ | ||
fmt.Printf("\n%s", cloudos) | ||
} | ||
*/ | ||
|
||
return cloudosList.Name | ||
} | ||
|
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,19 @@ | ||
# Cloud Driver Manager 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 | ||
# | ||
# by CB-Spider Team, 2020.03. | ||
|
||
|
||
### List of support CloudOS. | ||
|
||
cloudos: | ||
- aws | ||
- GCP | ||
- AZURE | ||
- OPENSTACK | ||
- CLOUDIT | ||
- ALIBABA | ||
- CLOUDTWIN |
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,25 @@ | ||
// Test for Cloud Driver Handler 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 | ||
// | ||
// by CB-Spider Team, 2019.10. | ||
|
||
package main | ||
|
||
import ( | ||
cim "github.com/cloud-barista/cb-spider/cloud-info-manager" | ||
|
||
"fmt" | ||
) | ||
|
||
func getCloudOSList() { | ||
cloudOSList := cim.ListCloudOS() | ||
fmt.Printf(" === %#v\n", cloudOSList) | ||
} | ||
|
||
func main() { | ||
getCloudOSList() | ||
} | ||
|