Support ips capability in static and mac capability in tuning

This change introduces new capability flag to change MAC address
and to specify IP addresses by tuning and static.
This commit is contained in:
Tomofumi Hayashi
2019-06-20 17:11:47 +09:00
parent 2b6808807f
commit 660685a8af
6 changed files with 169 additions and 7 deletions

View File

@ -34,6 +34,10 @@ type Net struct {
Name string `json:"name"`
CNIVersion string `json:"cniVersion"`
IPAM *IPAMConfig `json:"ipam"`
RuntimeConfig struct {
IPs []string `json:"ips,omitempty"`
} `json:"runtimeConfig,omitempty"`
}
type IPAMConfig struct {
@ -134,6 +138,14 @@ func LoadIPAMConfig(bytes []byte, envArgs string) (*IPAMConfig, string, error) {
return nil, "", err
}
if len(n.RuntimeConfig.IPs) != 0 {
// args IP overwrites IP, so clear IPAM Config
n.IPAM.Addresses = make([]Address, 0, len(n.RuntimeConfig.IPs))
for _, addr := range n.RuntimeConfig.IPs {
n.IPAM.Addresses = append(n.IPAM.Addresses, Address{AddressStr: addr})
}
}
if n.IPAM == nil {
return nil, "", fmt.Errorf("IPAM config missing 'ipam' key")
}