77 "cmp"
88 "context"
99 "crypto/rsa"
10+ "encoding/json"
1011 "errors"
1112 "fmt"
1213 "math"
@@ -28,7 +29,10 @@ import (
2829 "github.com/ironcore-dev/network-operator/internal/provider/cisco/gnmiext/v2"
2930)
3031
31- const SpanningTreePortTypeAnnotation = "nx.cisco.networking.metal.ironcore.dev/spanning-tree-port-type"
32+ const (
33+ SpanningTreePortTypeAnnotation = "nx.cisco.networking.metal.ironcore.dev/spanning-tree-port-type"
34+ VPCDomainAnnotation = "nx.cisco.networking.metal.ironcore.dev/vpc-domain"
35+ )
3236
3337var (
3438 _ provider.Provider = (* Provider )(nil )
@@ -550,6 +554,28 @@ func (p *Provider) DeleteEVPNInstance(ctx context.Context, req *provider.EVPNIns
550554 return p .client .Delete (ctx , conf ... )
551555}
552556
557+ var _ gnmiext.Configurable = (* VPCDom )(nil )
558+
559+ type VPCDom struct {
560+ ID int `json:"id"`
561+ AdminSt AdminSt `json:"adminSt"`
562+ PeerGw AdminSt `json:"peerGw"`
563+ PeerSwitch AdminSt `json:"peerSwitch"`
564+ KeepaliveItems struct {
565+ DestIP string `json:"destIp"`
566+ SrcIP string `json:"srcIp"`
567+ Vrf string `json:"vrf"`
568+ PeerlinkItems struct {
569+ AdminSt AdminSt `json:"adminSt"`
570+ ID string `json:"id"`
571+ } `json:"peerlink-items,omitzero"`
572+ } `json:"keepalive-items,omitzero"`
573+ }
574+
575+ func (v * VPCDom ) XPath () string {
576+ return "System/vpc-items/inst-items/dom-items"
577+ }
578+
553579func (p * Provider ) EnsureInterface (ctx context.Context , req * provider.EnsureInterfaceRequest ) error {
554580 name , err := ShortName (req .Interface .Spec .Name )
555581 if err != nil {
@@ -764,6 +790,33 @@ func (p *Provider) EnsureInterface(ctx context.Context, req *provider.EnsureInte
764790 conf = append (conf , v )
765791 }
766792
793+ if s , ok := req .Interface .GetAnnotations ()[VPCDomainAnnotation ]; ok {
794+ f2 := new (Feature )
795+ f2 .Name = "vpc"
796+ f2 .AdminSt = AdminStEnabled
797+ conf = append (conf , f2 )
798+
799+ var dom struct {
800+ Src string `json:"src"`
801+ Dst string `json:"dst"`
802+ Vrf string `json:"vrf"`
803+ }
804+ if err := json .Unmarshal ([]byte (s ), & dom ); err != nil {
805+ return err
806+ }
807+ v := new (VPCDom )
808+ v .ID = 1
809+ v .AdminSt = AdminStEnabled
810+ v .PeerGw = AdminStEnabled
811+ v .PeerSwitch = AdminStEnabled
812+ v .KeepaliveItems .DestIP = dom .Dst
813+ v .KeepaliveItems .SrcIP = dom .Src
814+ v .KeepaliveItems .Vrf = dom .Vrf
815+ v .KeepaliveItems .PeerlinkItems .ID = name
816+ v .KeepaliveItems .PeerlinkItems .AdminSt = AdminStEnabled
817+ conf = append (conf , v )
818+ }
819+
767820 case v1alpha1 .InterfaceTypeRoutedVLAN :
768821 f := new (Feature )
769822 f .Name = "ifvlan"
0 commit comments