forked from Juniper/contrail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
route_target.go
40 lines (33 loc) · 956 Bytes
/
route_target.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package logic
import (
"context"
"github.com/Juniper/contrail/pkg/compilation/intent"
"github.com/Juniper/contrail/pkg/db"
"github.com/Juniper/contrail/pkg/models"
"github.com/Juniper/contrail/pkg/services"
)
// TODO: get_autonomous_system method
const (
defaultAutonomousSystem = 64512
routeTargetIntPoolID = "route_target_number"
)
func createDefaultRouteTarget(
ctx context.Context,
evaluateContext *intent.EvaluateContext,
) (*models.RouteTarget, error) {
target, err := evaluateContext.IntPoolAllocator.AllocateInt(ctx, routeTargetIntPoolID, db.EmptyIntOwner)
if err != nil {
return nil, err
}
rtKey := models.RouteTargetString(defaultAutonomousSystem, target)
rtResponse, err := evaluateContext.WriteService.CreateRouteTarget(
ctx,
&services.CreateRouteTargetRequest{
RouteTarget: &models.RouteTarget{
FQName: []string{rtKey},
DisplayName: rtKey,
},
},
)
return rtResponse.GetRouteTarget(), err
}