Skip to content

Commit

Permalink
Merge pull request #24 from srl-wim/impr-netlink-logging
Browse files Browse the repository at this point in the history
improve-netlink-logging
  • Loading branch information
henderiw authored Sep 4, 2020
2 parents 02d3dff + 5127346 commit 9d938d2
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions clab/netlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,28 +120,26 @@ func (c *cLab) DeleteVirtualWiring(id int, link *Link) (err error) {
var cmd *exec.Cmd

log.Debug("Delete netns: ", link.a.Node.LongName)
//err = linkFile(src, dst)
cmd = exec.Command("sudo", "ip", "netns", "del", link.a.Node.LongName)
err = runCmd(cmd)
if err != nil {
log.Debug("%s failed with: %v", cmd.String(), err)
log.Debugf("%s failed with: %v", cmd.String(), err)
}

log.Debug("Delete netns: ", link.b.Node.LongName)
//err = linkFile(src, dst)
cmd = exec.Command("sudo", "ip", "netns", "del", link.b.Node.LongName)
err = runCmd(cmd)
if err != nil {
log.Debug("%s failed with: %v", cmd.String(), err)
log.Debugf("%s failed with: %v", cmd.String(), err)
}
return nil
}

func runCmd(cmd *exec.Cmd) error {
b, err := cmd.CombinedOutput()
if err != nil {
log.Warnf("'%s' failed with: %v", cmd.String(), err)
log.Warnf("'%s' failed output: %v", cmd.String(), string(b))
log.Debugf("'%s' failed with: %v", cmd.String(), err)
log.Debugf("'%s' failed output: %v", cmd.String(), string(b))
return err
}
log.Debugf("'%s' output: %v", cmd.String(), string(b))
Expand Down

0 comments on commit 9d938d2

Please sign in to comment.