added mtu
This commit is contained in:
parent
a14b1ca025
commit
04bbde74ad
2 changed files with 8 additions and 8 deletions
10
network.go
10
network.go
|
|
@ -36,10 +36,15 @@ type NetworkDevice struct {
|
|||
Type string
|
||||
MACAddress string
|
||||
Bridge string
|
||||
MTU string
|
||||
}
|
||||
|
||||
func (n *NetworkDevice) String() string {
|
||||
return fmt.Sprintf("%s=%s,bridge=%s", n.Type, n.MACAddress, n.Bridge)
|
||||
var mtu string
|
||||
if n.MTU != "" {
|
||||
mtu = "," + n.MTU
|
||||
}
|
||||
return fmt.Sprintf("%s=%s,bridge=%s%s", n.Type, n.MACAddress, n.Bridge, mtu)
|
||||
}
|
||||
func parseNetworkDevice(s string) (n *NetworkDevice) {
|
||||
cfg := strings.Split(s, ",")
|
||||
|
|
@ -57,7 +62,8 @@ func parseNetworkDevice(s string) (n *NetworkDevice) {
|
|||
for _, o := range cfg {
|
||||
if strings.HasPrefix(o, "bridge=") {
|
||||
n.Bridge = o[7:]
|
||||
break
|
||||
} else if strings.HasPrefix(o, "mtu=") {
|
||||
n.MTU = o[4:]
|
||||
}
|
||||
}
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue