-
Notifications
You must be signed in to change notification settings - Fork 118
/
config.go
75 lines (67 loc) · 1.98 KB
/
config.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
package config
import (
"fmt"
"io/ioutil"
"os"
"gopkg.in/yaml.v2"
"github.com/libopenstorage/openstorage/api"
"github.com/libopenstorage/openstorage/volume"
)
const (
Version = "v1"
GraphDriverAPIBase = "/var/lib/osd/graphdriver/"
UrlKey = "url"
MgmtPortKey = "mgmtPort"
PluginPortKey = "pluginPort"
VersionKey = "version"
DataDir = ".data"
FlexVolumePort uint16 = 2345
)
func init() {
os.MkdirAll(volume.MountBase, 0755)
os.MkdirAll(GraphDriverAPIBase, 0755)
}
// swagger:model
type ClusterConfig struct {
ClusterId string
ClusterUuid string
NodeId string
SchedulerNodeName string
MgtIface string
DataIface string
DefaultDriver string
MgmtIp string
DataIp string
ManagementURL string
FluentDHost string
SystemSharedSecret string
AllowSecurityRemoval bool
HWType api.HardwareType
// QuorumTimeoutInSeconds configures time after which an
// out of quorum node will restart
QuorumTimeoutInSeconds int
// SnapLockTryDurationInMinutes is the time for which
// the cluster manager will try acquiring a lock for cluster snapshot
SnapLockTryDurationInMinutes int
}
// swagger:model
type Config struct {
Osd struct {
ClusterConfig ClusterConfig `yaml:"cluster"`
// map[string]string is volume.VolumeParams equivalent
Drivers map[string]map[string]string
// map[string]string is volume.VolumeParams equivalent
GraphDrivers map[string]map[string]string
}
}
func Parse(filePath string) (*Config, error) {
config := &Config{}
data, err := ioutil.ReadFile(filePath)
if err != nil {
return nil, fmt.Errorf("Unable to read the OSD configuration file (%s): %s", filePath, err.Error())
}
if err := yaml.Unmarshal(data, config); err != nil {
return nil, fmt.Errorf("Unable to parse OSD configuration: %s", err.Error())
}
return config, nil
}