This repository has been archived by the owner on Aug 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
import-drivers.go
72 lines (56 loc) · 1.62 KB
/
import-drivers.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
// Cloud Control Manager's Rest Runtime 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.05.
package main
import (
"github.com/sirupsen/logrus"
"github.com/cloud-barista/cb-store/config"
dim "github.com/cloud-barista/poc-cicd-spider/cloud-info-manager/driver-info-manager"
"strings"
"os"
"path/filepath"
)
var cblog *logrus.Logger
func init() {
cblog = config.Cblogger
}
func main() {
InsertDriverInfos()
}
// (1) get driver-lib file list
// (2) loop:
// load DriverInfo List from all driver-lib file list
// (3) insert
func InsertDriverInfos() {
var files []string
cbspiderRoot := os.Getenv("CBSPIDER_ROOT")
if cbspiderRoot == "" {
Cblogger.Error("$CBSPIDER_ROOT is not set!!")
os.Exit(1)
}
drvLibPath := cbspiderRoot + "/cloud-driver-libs/"
err := filepath.Walk(drvLibPath, func(path string, info os.FileInfo, err error) error {
files = append(files, info.Name())
return nil
})
if err != nil {
panic(err)
}
for _, file := range files {
if strings.Contains(file, ".so") {
// docker-driver-v1.0.so
driverName := strings.ReplaceAll(file, ".so", "")
strs := strings.Split(file, "-")
cloudos := strings.ToUpper(strs[0])
cloudDriverInfo := dim.CloudDriverInfo{driverName, cloudos, file}
_, err := dim.RegisterCloudDriverInfo(cloudDriverInfo)
if err != nil {
cblog.Error(err)
}
}
}
}