Merge pull request #5006 from yousong/automated-cherry-pick-of-#5005-upstream-release-3.1

Automated cherry pick of #5005: hostman: fix detection of ovn controller version
This commit is contained in:
yunion-ci-robot
2020-02-05 02:17:48 +08:00
committed by GitHub
2 changed files with 14 additions and 3 deletions
+5 -2
View File
@@ -141,8 +141,11 @@ func (h *SHostInfo) Init() error {
if err := h.parseConfig(); err != nil {
return err
}
if err := h.setupOvnChassis(); err != nil {
return err
if HasOvnSupport() {
if err := h.setupOvnChassis(); err != nil {
return err
}
return nil
}
log.Infof("Start detectHostInfo")
if err := h.detectHostInfo(); err != nil {
+9 -1
View File
@@ -107,13 +107,21 @@ func (oh *OvnHelper) mustPrepService() {
}
func MustGetOvnVersion() string {
output, err := procutils.NewCommand("ovn-controller", "--version").Output()
output, err := procutils.NewRemoteCommandAsFarAsPossible("ovn-controller", "--version").Output()
if err != nil {
return ""
}
return ovnExtractVersion(string(output))
}
func HasOvnSupport() bool {
ver := MustGetOvnVersion()
if ver != "" {
return true
}
return false
}
func ovnExtractVersion(in string) string {
r := make([]rune, 0, 8)
var (