diff --git a/pkg/models/bridge.go b/pkg/models/bridge.go index 42af18c8..125d65ac 100644 --- a/pkg/models/bridge.go +++ b/pkg/models/bridge.go @@ -7,16 +7,19 @@ package models import ( // "encoding/binary" "net" + "time" pb "github.com/opiproject/opi-api/network/evpn-gw/v1alpha1/gen/go" ) // Bridge object, separate from protobuf for decoupling type Bridge struct { - Name string - Vni uint32 - VlanID uint32 - VtepIP net.IPNet + Name string + Vni uint32 + VlanID uint32 + VtepIP net.IPNet + CreatedAt time.Time + UpdatedAt time.Time } // build time check that struct implements interface @@ -28,7 +31,7 @@ func NewBridge(in *pb.LogicalBridge) *Bridge { // binary.BigEndian.PutUint32(vtepip, in.Spec.VtepIpPrefix.Addr.GetV4Addr()) // vip := net.IPNet{IP: vtepip, Mask: net.CIDRMask(int(in.Spec.VtepIpPrefix.Len), 32)} // TODO: Vni: *in.Spec.Vni - return &Bridge{VlanID: in.Spec.VlanId} + return &Bridge{VlanID: in.Spec.VlanId, CreatedAt: time.Now()} } // ToPb transforms SVI object to protobuf message diff --git a/pkg/models/port.go b/pkg/models/port.go index d95f2be6..853aae53 100644 --- a/pkg/models/port.go +++ b/pkg/models/port.go @@ -6,6 +6,7 @@ package models import ( "net" + "time" pb "github.com/opiproject/opi-api/network/evpn-gw/v1alpha1/gen/go" ) @@ -28,6 +29,8 @@ type Port struct { Ptype BridgePortType MacAddress net.HardwareAddr LogicalBridgeRefKeys []string + CreatedAt time.Time + UpdatedAt time.Time } // build time check that struct implements interface @@ -36,7 +39,12 @@ var _ EvpnObject[*pb.BridgePort] = (*Port)(nil) // NewPort creates new SVI object from protobuf message func NewPort(in *pb.BridgePort) *Port { mac := net.HardwareAddr(in.Spec.MacAddress) - return &Port{Ptype: BridgePortType(in.Spec.Ptype), MacAddress: mac, LogicalBridgeRefKeys: in.Spec.LogicalBridges} + return &Port{ + Ptype: BridgePortType(in.Spec.Ptype), + MacAddress: mac, + LogicalBridgeRefKeys: in.Spec.LogicalBridges, + CreatedAt: time.Now(), + } } // ToPb transforms SVI object to protobuf message diff --git a/pkg/models/svi.go b/pkg/models/svi.go index 7fe53103..1004061e 100644 --- a/pkg/models/svi.go +++ b/pkg/models/svi.go @@ -7,6 +7,7 @@ package models import ( "encoding/binary" "net" + "time" pb "github.com/opiproject/opi-api/network/evpn-gw/v1alpha1/gen/go" ) @@ -20,6 +21,8 @@ type Svi struct { GwIP []net.IPNet EnableBgp bool RemoteAs uint32 + CreatedAt time.Time + UpdatedAt time.Time } // build time check that struct implements interface @@ -42,6 +45,7 @@ func NewSvi(in *pb.Svi) *Svi { GwIP: gwIPList, EnableBgp: in.Spec.EnableBgp, RemoteAs: in.Spec.RemoteAs, + CreatedAt: time.Now(), } return svi } diff --git a/pkg/models/vrf.go b/pkg/models/vrf.go index 98e0170d..b4e7f6c6 100644 --- a/pkg/models/vrf.go +++ b/pkg/models/vrf.go @@ -7,6 +7,7 @@ package models import ( "encoding/binary" "net" + "time" pb "github.com/opiproject/opi-api/network/evpn-gw/v1alpha1/gen/go" ) @@ -20,6 +21,8 @@ type Vrf struct { LocalAs int RoutingTable uint32 MacAddress net.HardwareAddr + CreatedAt time.Time + UpdatedAt time.Time } // build time check that struct implements interface @@ -34,7 +37,7 @@ func NewVrf(in *pb.Vrf) *Vrf { // vtepip := make(net.IP, 4) // binary.BigEndian.PutUint32(vtepip, in.Spec.VtepIpPrefix.Addr.GetV4Addr()) // vip := net.IPNet{IP: vtepip, Mask: net.CIDRMask(int(in.Spec.VtepIpPrefix.Len), 32)} - return &Vrf{LoopbackIP: lip, MacAddress: mac, RoutingTable: in.Status.RoutingTable} + return &Vrf{LoopbackIP: lip, MacAddress: mac, RoutingTable: in.Status.RoutingTable, CreatedAt: time.Now()} } // ToPb transforms VRF object to protobuf message