Skip to content

Commit

Permalink
Merge pull request #200 from Mashimiao/add-network-host-specific-check
Browse files Browse the repository at this point in the history
validate: add network host-specific check
  • Loading branch information
vbatts authored Mar 9, 2017
2 parents 47ca924 + 768043e commit b8b1ce1
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 @@ -474,6 +475,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 && v.HostSpecific {
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 currently", prio.Name))
}
}
}

return
}
Expand Down

0 comments on commit b8b1ce1

Please sign in to comment.