Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
This commit is contained in:
Василий Толстов 2015-03-30 10:33:17 +03:00
parent dda4e55470
commit da65c72ea4
2 changed files with 12 additions and 8 deletions

View File

@ -73,9 +73,9 @@ func validateCloudConfig(config []byte, rules []rule) (report Report, err error)
// any parsing issues into the provided report. Unrecoverable errors are // any parsing issues into the provided report. Unrecoverable errors are
// returned as an error. // returned as an error.
func parseCloudConfig(cfg []byte, report *Report) (node, error) { func parseCloudConfig(cfg []byte, report *Report) (node, error) {
yaml.UnmarshalMappingKeyTransform = func(nameIn string) (nameOut string) { // yaml.UnmarshalMappingKeyTransform = func(nameIn string) (nameOut string) {
return nameIn // return nameIn
} // }
// unmarshal the config into an implicitly-typed form. The yaml library // unmarshal the config into an implicitly-typed form. The yaml library
// will implicitly convert types into their normalized form // will implicitly convert types into their normalized form
// (e.g. 0744 -> 484, off -> false). // (e.g. 0744 -> 484, off -> false).
@ -104,9 +104,9 @@ func parseCloudConfig(cfg []byte, report *Report) (node, error) {
w = normalizeNodeNames(w, report) w = normalizeNodeNames(w, report)
// unmarshal the config into the explicitly-typed form. // unmarshal the config into the explicitly-typed form.
yaml.UnmarshalMappingKeyTransform = func(nameIn string) (nameOut string) { // yaml.UnmarshalMappingKeyTransform = func(nameIn string) (nameOut string) {
return strings.Replace(nameIn, "-", "_", -1) // return strings.Replace(nameIn, "-", "_", -1)
} // }
var strong config.CloudConfig var strong config.CloudConfig
if err := yaml.Unmarshal([]byte(cfg), &strong); err != nil { if err := yaml.Unmarshal([]byte(cfg), &strong); err != nil {
return node{}, err return node{}, err

View File

@ -21,9 +21,9 @@ import (
"os/exec" "os/exec"
"strings" "strings"
"github.com/vishvananda/netlink"
"github.com/vtolstov/cloudinit/config" "github.com/vtolstov/cloudinit/config"
"github.com/vtolstov/cloudinit/network" "github.com/vtolstov/cloudinit/network"
"github.com/vishvananda/netlink"
) )
func RestartNetwork(interfaces []network.InterfaceGenerator) (err error) { func RestartNetwork(interfaces []network.InterfaceGenerator) (err error) {
@ -57,7 +57,11 @@ func downNetworkInterfaces(interfaces []network.InterfaceGenerator) error {
for _, iface := range interfaces { for _, iface := range interfaces {
if systemInterface, ok := sysInterfaceMap[iface.Name()]; ok { if systemInterface, ok := sysInterfaceMap[iface.Name()]; ok {
log.Printf("Taking down interface %q\n", systemInterface.Name) log.Printf("Taking down interface %q\n", systemInterface.Name)
if err := netlink.NetworkLinkDown(systemInterface); err != nil { link, err := netlink.LinkByName(systemInterface.Name)
if err != nil {
fmt.Printf("Error while downing interface %q (%s). Continuing...\n", systemInterface.Name, err)
}
if err = netlink.LinkSetDown(link); err != nil {
fmt.Printf("Error while downing interface %q (%s). Continuing...\n", systemInterface.Name, err) fmt.Printf("Error while downing interface %q (%s). Continuing...\n", systemInterface.Name, err)
} }
} }