Skip to content

Commit

Permalink
Support vs-specific config
Browse files Browse the repository at this point in the history
  • Loading branch information
Frostman committed Nov 15, 2023
1 parent 4f1f16b commit e4930c5
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions api/agent/v1alpha2/agent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type AgentSpecConfig struct {
ControlVIP string `json:"controlVIP,omitempty"`
CollapsedCore *AgentSpecConfigCollapsedCore `json:"collapsedCore,omitempty"`
SpineLeaf *AgentSpecConfigSpineLeaf `json:"spineLeaf,omitempty"`
VS bool `json:"vs,omitempty"`
}

type AgentSpecConfigCollapsedCore struct {
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/agent.githedgehog.com_agents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ spec:
type: string
spineLeaf:
type: object
vs:
type: boolean
type: object
connections:
items:
Expand Down
1 change: 1 addition & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ _Appears in:_
| `controlVIP` _string_ | |
| `collapsedCore` _[AgentSpecConfigCollapsedCore](#agentspecconfigcollapsedcore)_ | |
| `spineLeaf` _[AgentSpecConfigSpineLeaf](#agentspecconfigspineleaf)_ | |
| `vs` _boolean_ | |


#### AgentSpecConfigCollapsedCore
Expand Down
11 changes: 8 additions & 3 deletions pkg/agent/dozer/bcm/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func planFabricConnections(agent *agentapi.Agent, spec *dozer.Spec) error {

spec.VRFs[VRF_DEFAULT].BGP.Neighbors[ip.String()] = &dozer.SpecVRFBGPNeighbor{
Enabled: boolPtr(true),
Description: stringPtr(fmt.Sprintf("Fabric %s // %s", remote, conn.Name)),
Description: stringPtr(fmt.Sprintf("Fabric @%s #%s", remote, conn.Name)),
RemoteAS: uint32Ptr(peerSw.ASN),
IPv4Unicast: boolPtr(true),
L2VPNEVPN: boolPtr(true),
Expand Down Expand Up @@ -442,6 +442,11 @@ func planDefaultVRFWithBGP(agent *agentapi.Agent, spec *dozer.Spec) error {
return errors.Wrapf(err, "failed to parse protocol ip %s", agent.Spec.Switch.ProtocolIP)
}

maxPaths := uint32(64)
if agent.Spec.Config.VS {
maxPaths = 16
}

spec.VRFs[VRF_DEFAULT] = &dozer.SpecVRF{
Enabled: boolPtr(true),
Interfaces: map[string]*dozer.SpecVRFInterface{},
Expand All @@ -453,7 +458,7 @@ func planDefaultVRFWithBGP(agent *agentapi.Agent, spec *dozer.Spec) error {
Neighbors: map[string]*dozer.SpecVRFBGPNeighbor{},
IPv4Unicast: dozer.SpecVRFBGPIPv4Unicast{
Enabled: true,
MaxPaths: uint32Ptr(64),
MaxPaths: uint32Ptr(maxPaths),
},
L2VPNEVPN: dozer.SpecVRFBGPL2VPNEVPN{
Enabled: true,
Expand Down Expand Up @@ -583,7 +588,7 @@ func planMCLAGDomain(agent *agentapi.Agent, spec *dozer.Spec) (bool, error) {

spec.VRFs[VRF_DEFAULT].BGP.Neighbors[peerIP] = &dozer.SpecVRFBGPNeighbor{
Enabled: boolPtr(true),
Description: stringPtr(fmt.Sprintf("MCLAG peer %s", mclagPeerSwitch)),
Description: stringPtr(fmt.Sprintf("MCLAG session @%s", mclagPeerSwitch)),
PeerType: stringPtr(dozer.SpecVRFBGPNeighborPeerTypeInternal),
IPv4Unicast: boolPtr(true),
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/agent/dozer/bcm/spec_vrf.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ var specVRFEnforcer = &DefaultValueEnforcer[string, *dozer.SpecVRF]{
}

var specVRFBaseEnforcer = &DefaultValueEnforcer[string, *dozer.SpecVRF]{
Summary: "VRF %s base",
Getter: func(name string, value *dozer.SpecVRF) any { return []any{value.Enabled, value.Description} },
Summary: "VRF %s base",
Getter: func(name string, value *dozer.SpecVRF) any {
return []any{value.Enabled, value.Description, value.AnycastMAC}
},
NoReplace: true,
UpdateWeight: ActionWeightVRFBaseUpdate,
DeleteWeight: ActionWeightVRFBaseDelete,
Marshal: func(name string, value *dozer.SpecVRF) (ygot.ValidatedGoStruct, error) {
Expand Down
1 change: 1 addition & 0 deletions pkg/ctrl/agent/agent_ctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ func (r *AgentReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
agent.Spec.Role = sw.Spec.Role
agent.Spec.Description = sw.Spec.Description
agent.Spec.Config.ControlVIP = r.Cfg.ControlVIP
agent.Spec.Config.VS = r.Cfg.VS
agent.Spec.Switch = sw.Spec
agent.Spec.Switches = switches
agent.Spec.Connections = conns
Expand Down
1 change: 1 addition & 0 deletions pkg/manager/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Fabric struct {
SNATAllowed bool `json:"snatAllowed,omitempty"`
VPCSubnet string `json:"vpcSubnet,omitempty"`
FabricMode FabricMode `json:"fabricMode,omitempty"`
VS bool `json:"vs,omitempty"`
}

type FabricMode string
Expand Down

0 comments on commit e4930c5

Please sign in to comment.