Skip to content

Commit

Permalink
feat: use ovn macam to allocate mac for static ip pod
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed Apr 25, 2019
1 parent 3e7a422 commit 5429f51
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/ovs/ovn-nbctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (c Client) CreatePort(ls, port, ip, mac string) (*nic, error) {
ip = address[1]
} else {
if mac == "" {
mac = util.GenerateMac()
mac = "dynamic"
}

// remove mask, and retrieve mask from subnet cidr later
Expand All @@ -63,6 +63,15 @@ func (c Client) CreatePort(ls, port, ip, mac string) (*nic, error) {
klog.Errorf("create port %s failed %v", port, err)
return nil, err
}

if mac == "dynamic" {
address, err := c.getLogicalSwitchPortDynamicAddress(port)
if err != nil {
klog.Errorf("get port %s dynamic-addresses failed %v", port, err)
return nil, err
}
mac = address[0]
}
}
cidr, err := c.ovnNbCommand("get", "logical_switch", ls, "other_config:subnet")
if err != nil {
Expand Down

0 comments on commit 5429f51

Please sign in to comment.