Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
Merge pull request #454 from 01org/sameo/topic/networking
Browse files Browse the repository at this point in the history
networking: Support both nil and empty subnet slices
  • Loading branch information
mcastelino authored Aug 13, 2016
2 parents d3c5489 + b7fa760 commit 3e9618a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions networking/libsnnet/cn.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (cn *ComputeNode) addPhyLinkToConfig(link netlink.Link, ipv4Addrs []netlink

for _, addr := range ipv4Addrs {

if cn.ManagementNet == nil {
if cn.ManagementNet == nil || len(cn.ManagementNet) == 0 {
cn.MgtAddr = append(cn.MgtAddr, addr)
cn.MgtLink = append(cn.MgtLink, link)
} else {
Expand All @@ -203,7 +203,7 @@ func (cn *ComputeNode) addPhyLinkToConfig(link netlink.Link, ipv4Addrs []netlink
}
}

if cn.ComputeNet == nil {
if cn.ComputeNet == nil || len(cn.ComputeNet) == 0 {
cn.ComputeAddr = append(cn.ComputeAddr, addr)
cn.ComputeLink = append(cn.ComputeLink, link)
} else {
Expand Down Expand Up @@ -259,7 +259,9 @@ func (cn *ComputeNode) findPhyNwInterface() error {

//Allow auto configuration only in the case where there is a single physical
//interface with an IP address
if (cn.ManagementNet == nil || cn.ComputeNet == nil) && phyInterfaces > 1 {
if (cn.ManagementNet == nil || cn.ComputeNet == nil) ||
(len(cn.ManagementNet) == 0 || len(cn.ComputeNet) == 0) &&
phyInterfaces > 1 {
return fmt.Errorf("unable to autoconfigure network")
}

Expand Down

0 comments on commit 3e9618a

Please sign in to comment.