Skip to content

Commit

Permalink
Merge pull request #16 from alauda/feat/use-macam
Browse files Browse the repository at this point in the history
feat: use ovn macam to allocate mac for static ip pod
  • Loading branch information
oilbeater committed Apr 25, 2019
2 parents 3e7a422 + 5429f51 commit 8715566
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 8715566

Please sign in to comment.