Skip to content

Commit

Permalink
validate: add network host-specific check
Browse files Browse the repository at this point in the history
Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
  • Loading branch information
Ma Shimiao committed Nov 28, 2016
1 parent 893d9e3 commit 5d8122a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"net"
"os"
"path/filepath"
"reflect"
Expand Down Expand Up @@ -411,6 +412,26 @@ func (v *Validator) CheckLinuxResources() (msgs []string) {
msgs = append(msgs, fmt.Sprintf("Minimum memory limit should be larger than memory reservation"))
}
}
if r.Network != nil && hostCheck {
var exist bool
interfaces, err := net.Interfaces()
if err != nil {
msgs = append(msgs, err.Error())
return
}
for _, prio := range r.Network.Priorities {
exist = false
for _, ni := range interfaces {
if prio.Name == ni.Name {
exist = true
break
}
}
if !exist {
msgs = append(msgs, fmt.Sprintf("Interface %s does not exist on host", prio.Name))
}
}
}

return
}
Expand Down

0 comments on commit 5d8122a

Please sign in to comment.