mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-06-09 16:07:36 +08:00
fix detect host info
This commit is contained in:
@@ -484,18 +484,19 @@ func (h *SHostInfo) detectNestSupport() {
|
||||
}
|
||||
|
||||
func (h *SHostInfo) detectiveOsDist() {
|
||||
files, err := procutils.NewCommand("sh", "-c", "ls /etc/*elease").Output()
|
||||
files, err := procutils.NewRemoteCommandAsFarAsPossible("sh", "-c", "ls /etc/*elease").Output()
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
return
|
||||
}
|
||||
re := regexp.MustCompile(`(.+) release ([\d.]+)[^(]*(?:\((.+)\))?`)
|
||||
for _, file := range strings.Split(string(files), "\n") {
|
||||
content, err := fileutils2.FileGetContents(file)
|
||||
content, err := procutils.NewRemoteCommandAsFarAsPossible("cat", file).Output()
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
continue
|
||||
}
|
||||
m := re.FindStringSubmatch(content)
|
||||
m := re.FindStringSubmatch(string(content))
|
||||
if len(m) == 4 {
|
||||
h.sysinfo.OsDistribution = m[1]
|
||||
h.sysinfo.OsVersion = m[2]
|
||||
|
||||
@@ -96,9 +96,7 @@ func detectiveKVMModuleSupport() string {
|
||||
func ModprobeKvmModule(name string, remove, nest bool) bool {
|
||||
var params = []string{"modprobe"}
|
||||
if remove {
|
||||
if err := procutils.NewRemoteCommandAsFarAsPossible("rmmod", name).Run(); err != nil {
|
||||
log.Errorf("rmmod failed %s: %s", name, err)
|
||||
}
|
||||
params = append(params, "-r")
|
||||
}
|
||||
params = append(params, name)
|
||||
if nest {
|
||||
@@ -127,10 +125,12 @@ func detectNestSupport() string {
|
||||
nestStatus := HOST_NEST_UNSUPPORT
|
||||
|
||||
if moduleName != KVM_MODULE_UNSUPPORT && isNestSupport(moduleName) {
|
||||
log.Infof("Host is support kvm nest ...")
|
||||
nestStatus = HOST_NEST_SUPPORT
|
||||
}
|
||||
|
||||
if nestStatus == HOST_NEST_SUPPORT && loadKvmModuleWithNest(moduleName) {
|
||||
log.Infof("Host kvm nest is enabled ...")
|
||||
nestStatus = HOST_NEST_ENABLE
|
||||
}
|
||||
return nestStatus
|
||||
|
||||
Reference in New Issue
Block a user