vpcagent: ovn: add ClaimRoutes

This commit is contained in:
Yousong Zhou
2021-03-24 20:16:19 +08:00
parent 5fd1c309c8
commit bf5ef89a95
2 changed files with 28 additions and 0 deletions
+26
View File
@@ -638,6 +638,32 @@ func (keeper *OVNNorthboundKeeper) ClaimGuestnetwork(ctx context.Context, guestn
return keeper.cli.Must(ctx, "ClaimGuestnetwork", args)
}
func (keeper *OVNNorthboundKeeper) ClaimRoutes(ctx context.Context, vpc *agentmodels.Vpc, routes resolvedRoutes) error {
var irows []types.IRow
for _, route := range routes {
irows = append(irows, &ovn_nb.LogicalRouterStaticRoute{
Policy: ptr("dst-ip"),
IpPrefix: route.Cidr,
Nexthop: route.NextHop,
})
}
ocVersion := fmt.Sprintf("%s.%d", vpc.UpdatedAt, vpc.UpdateVersion)
allFound, args := cmp(&keeper.DB, ocVersion, irows...)
if allFound {
return nil
}
lrName := vpcLrName(vpc.Id)
for i, irow := range irows {
ref := fmt.Sprintf("r%d", i)
args = append(args, ovnCreateArgs(irow, ref)...)
args = append(args, "--", "add", "Logical_Router", lrName, "static_routes", "@"+ref)
}
if len(args) > 0 {
return keeper.cli.Must(ctx, "ClaimGuestnetwork", args)
}
return nil
}
func (keeper *OVNNorthboundKeeper) ClaimVpcGuestDnsRecords(ctx context.Context, vpc *agentmodels.Vpc) error {
var (
grs = map[string][]string{}
+2
View File
@@ -164,6 +164,8 @@ func (w *Worker) run(ctx context.Context, mss *agentmodels.ModelSets) (err error
ovndb.ClaimGuestnetwork(ctx, guestnetwork)
}
}
routes := resolveRoutes(vpc, mss)
ovndb.ClaimRoutes(ctx, vpc, routes)
}
for _, vpc := range mss.Vpcs {
if vpc.Id == apis.DEFAULT_VPC_ID {