forked from hpe-storage/common-host-libs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nlt.go
37 lines (32 loc) · 1.01 KB
/
nlt.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
package util
// Copyright 2019 Hewlett Packard Enterprise Development LP.
const (
installDirPattern = "^install_dir\\s*=\\s*(?P<install_dir>.*)"
nltConf = "/etc/nlt.conf"
hpeInstallDir = "/opt/hpe-storage/"
nltDefaultInstallDir = "/opt/NimbleStorage"
)
// GetNltHome returns base install directory of NLT or HPE cloud toolkits
func GetNltHome() (installDir string) {
conf := nltConf
installDir = nltDefaultInstallDir
isPresent, _, err := FileExists(nltConf)
if err != nil || !isPresent {
// If NLT is not installed, assume common hpe install directory for plugin
return hpeInstallDir
}
lines, err := FileGetStringsWithPattern(conf, installDirPattern)
if err != nil {
// Assume default NLT installation directory if install_dir param not present
return installDir
}
if len(lines) > 0 {
installDir = lines[0]
}
isPresent, _, err = FileExists(installDir)
if err != nil || !isPresent {
// NLT seems to be not installed, return empty string
installDir = ""
}
return installDir
}