1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #822 from wenchma/18626-add_IpamInfo_func

Add IpamInfo() function to retrun ipamV4Info and ipamV6Info
This commit is contained in:
Madhu Venugopal 2015-12-20 19:55:29 -08:00
commit b464d40ce6

View file

@ -59,6 +59,7 @@ type Network interface {
// NetworkInfo returns some configuration and operational information about the network
type NetworkInfo interface {
IpamConfig() (string, []*IpamConf, []*IpamConf)
IpamInfo() ([]*IpamInfo, []*IpamInfo)
DriverOptions() map[string]string
Scope() string
}
@ -1164,3 +1165,25 @@ func (n *network) IpamConfig() (string, []*IpamConf, []*IpamConf) {
return n.ipamType, v4L, v6L
}
func (n *network) IpamInfo() ([]*IpamInfo, []*IpamInfo) {
n.Lock()
defer n.Unlock()
v4Info := make([]*IpamInfo, len(n.ipamV4Info))
v6Info := make([]*IpamInfo, len(n.ipamV6Info))
for i, info := range n.ipamV4Info {
ic := &IpamInfo{}
info.CopyTo(ic)
v4Info[i] = ic
}
for i, info := range n.ipamV6Info {
ic := &IpamInfo{}
info.CopyTo(ic)
v6Info[i] = ic
}
return v4Info, v6Info
}