diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index b80976ee..ae1a461e 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -368,7 +368,7 @@ }, { "ImportPath": "github.com/rancher/netconf", - "Rev": "157105e12d6963f6a1c5765540261f6878f0de89" + "Rev": "b9aeb623c8ef9551d79efec57ee059658c1ac89c" }, { "ImportPath": "github.com/ryanuber/go-glob", diff --git a/Godeps/_workspace/src/github.com/rancher/netconf/netconf.go b/Godeps/_workspace/src/github.com/rancher/netconf/netconf.go index f8f4efea..4170551e 100644 --- a/Godeps/_workspace/src/github.com/rancher/netconf/netconf.go +++ b/Godeps/_workspace/src/github.com/rancher/netconf/netconf.go @@ -42,6 +42,8 @@ func ApplyNetworkConfigs(netCfg *NetworkConfig) error { return err } + dhcpLinks := []string{} + //apply network config for _, link := range links { linkName := link.Attrs().Name @@ -80,13 +82,25 @@ func ApplyNetworkConfigs(netCfg *NetworkConfig) error { } if match.Match != "" { - err = applyNetConf(link, match) - if err != nil { + if match.DHCP { + dhcpLinks = append(dhcpLinks, link.Attrs().Name) + } else if err = applyNetConf(link, match); err != nil { log.Errorf("Failed to apply settings to %s : %v", linkName, err) } } } + if len(dhcpLinks) > 0 { + log.Infof("Running DHCP on %v", dhcpLinks) + dhcpcdArgs := append([]string{"-MA4", "-e", "force_hostname=true"}, dhcpLinks...) + cmd := exec.Command("dhcpcd", dhcpcdArgs...) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + if err := cmd.Run(); err != nil { + log.Error(err) + } + } + if err != nil { return err } @@ -95,15 +109,7 @@ func ApplyNetworkConfigs(netCfg *NetworkConfig) error { } func applyNetConf(link netlink.Link, netConf InterfaceConfig) error { - if netConf.DHCP { - log.Infof("Running DHCP on %s", link.Attrs().Name) - cmd := exec.Command("dhcpcd", "-A4", "-e", "force_hostname=true", link.Attrs().Name) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - if err := cmd.Run(); err != nil { - log.Error(err) - } - } else if netConf.IPV4LL { + if netConf.IPV4LL { if err := AssignLinkLocalIP(link); err != nil { log.Errorf("IPV4LL set failed: %v", err) return err