Skip to content

Commit

Permalink
refactor(svi): move from cloud APIs to evpn-gw APIs
Browse files Browse the repository at this point in the history
Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
  • Loading branch information
glimchb committed Aug 8, 2023
1 parent 837bd71 commit 8a1fa64
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 165 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ Run `docker-compose up -d`
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"vrf" : {"spec" : {"vni" : 1234, "loopback_ip_prefix" : {"addr": {"af": "IP_AF_INET", "v4_addr": 167772162} }, "len": 24}, "vtep_ip_prefix": {"addr": {"af": "IP_AF_INET", "v4_addr": 167772162} }, "len": 24} }}, "vrf_id" : "testvrf" }' localhost:50151 opi_api.network.evpn-gw.v1alpha1.VrfService.CreateVrf"
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"logical_bridge" : {"spec" : {"vni": 10, "vlan_id": 10 } }, "logical_bridge_id" : "testbridge" }' localhost:50151 opi_api.network.evpn-gw.v1alpha1.LogicalBridgeService.CreateLogicalBridge
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"bridge_port" : {"spec" : {mac_address: "qrvMAAAB", "ptype": "ACCESS", "logical_bridges": ["//network.opiproject.org/bridges/testbridge"] }}, "bridge_port_id" : "testport"}' localhost:50151 opi_api.network.evpn-gw.v1alpha1.BridgePortService.CreateBridgePort
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"tunnel" : {"spec" : {"vpc_name_ref": "//network.opiproject.org/bridges/testbridge", "local_ip": {"af": "IP_AF_INET", "v4_addr": 336860161}, "encap": {"type": "ENCAP_TYPE_VXLAN", "value": {"vnid": 100}} } }, "tunnel_id" : "testvxlan", "parent" : "todo" }' localhost:50151 opi_api.network.cloud.v1alpha1.CloudInfraService.CreateTunnel
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"svi" : {"spec" : {"vrf": "//network.opiproject.org/vrfs/testvrf", "logical_bridge": "//network.opiproject.org/bridges/testbridge", mac_address: "qrvMAAAB", "gw_ip_prefix": [{"addr": {"af": "IP_AF_INET", "v4_addr": 167772162} }, "len": 24}] } }, "svi_id" : "testsvi" }' localhost:50151 opi_api.network.evpn-gw.v1alpha1.SviService.CreateSvi
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"name": "//network.opiproject.org/ports/testinterface"}' localhost:50151 opi_api.network.evpn-gw.v1alpha1.BridgePortService.GetBridgePort
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"name": "//network.opiproject.org/bridges/testbridge"}' localhost:50151 opi_api.network.evpn-gw.v1alpha1.LogicalBridgeService.GetLogicalBridge
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"name": "//network.opiproject.org/tunnels/testvxlan"}' localhost:50151 opi_api.network.cloud.v1alpha1.CloudInfraService.GetTunnel
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"name": "//network.opiproject.org/svis/testsvi"}' localhost:50151 opi_api.network.evpn-gw.v1alpha1.SviService.GetSvi
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"name": "//network.opiproject.org/vrfs/testvrf"}' localhost:50151 opi_api.network.evpn-gw.v1alpha1.VrfService.GetVrf
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"name": "//network.opiproject.org/ports/testinterface"}' localhost:50151 opi_api.network.evpn-gw.v1alpha1.BridgePortService.DeleteBridgePort
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"name": "//network.opiproject.org/bridges/testbridge"}' localhost:50151 opi_api.network.evpn-gw.v1alpha1.LogicalBridgeService.DeleteLogicalBridge
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"name" : "//network.opiproject.org/tunnels/testvxlan"}' localhost:50151 opi_api.network.cloud.v1alpha1.CloudInfraService.DeleteTunnel
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"name" : "//network.opiproject.org/svis/testsvi"}' localhost:50151 opi_api.network.evpn-gw.v1alpha1.SviService.DeleteSvi
docker-compose exec opi-evpn-bridge grpcurl -plaintext -d '{"name" : "//network.opiproject.org/vrfs/testvrf"}' localhost:50151 opi_api.network.evpn-gw.v1alpha1.VrfService.DeleteVrf
```
Expand Down
4 changes: 1 addition & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"log"
"net"

pb "github.com/opiproject/opi-api/network/cloud/v1alpha1/gen/go"
pe "github.com/opiproject/opi-api/network/evpn-gw/v1alpha1/gen/go"
"github.com/opiproject/opi-evpn-bridge/pkg/evpn"

Expand All @@ -32,11 +31,10 @@ func main() {
s := grpc.NewServer()
opi := evpn.NewServer()

// TODO: replace cloud -> evpn
pb.RegisterCloudInfraServiceServer(s, opi)
pe.RegisterLogicalBridgeServiceServer(s, opi)
pe.RegisterBridgePortServiceServer(s, opi)
pe.RegisterVrfServiceServer(s, opi)
pe.RegisterSviServiceServer(s, opi)

reflection.Register(s)

Expand Down
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ services:
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.VrfService.GetVrf -l && \
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.VrfService.DeleteVrf -l && \
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.VrfService.UpdateVrf -l && \
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.SviService -l && \
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.SviService.CreateSvi -l && \
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.SviService.ListSvis -l && \
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.SviService.GetSvi -l && \
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.SviService.DeleteSvi -l && \
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.SviService.UpdateSvi -l && \
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.LogicalBridgeService -l && \
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.LogicalBridgeService.CreateLogicalBridge -l && \
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.LogicalBridgeService.ListLogicalBridges -l && \
Expand Down
1 change: 0 additions & 1 deletion pkg/evpn/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ func (s *Server) UpdateLogicalBridge(_ context.Context, in *pb.UpdateLogicalBrid
fmt.Printf("Failed to update link: %v", err)
return nil, err
}
// TODO: replace cloud -> evpn
response := proto.Clone(in.LogicalBridge).(*pb.LogicalBridge)
response.Status = &pb.LogicalBridgeStatus{OperStatus: pb.LBOperStatus_LB_OPER_STATUS_UP}
s.Bridges[in.LogicalBridge.Name] = response
Expand Down
7 changes: 3 additions & 4 deletions pkg/evpn/evpn.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@ import (
"crypto/rand"
"fmt"

pb "github.com/opiproject/opi-api/network/cloud/v1alpha1/gen/go"
pe "github.com/opiproject/opi-api/network/evpn-gw/v1alpha1/gen/go"
)

// Server represents the Server object
type Server struct {
pb.UnimplementedCloudInfraServiceServer
pe.UnimplementedVrfServiceServer
pe.UnimplementedSviServiceServer
pe.UnimplementedLogicalBridgeServiceServer
pe.UnimplementedBridgePortServiceServer
Bridges map[string]*pe.LogicalBridge
Ports map[string]*pe.BridgePort
Tunnels map[string]*pb.Tunnel
Svis map[string]*pe.Svi
Vrfs map[string]*pe.Vrf
}

Expand All @@ -30,7 +29,7 @@ func NewServer() *Server {
return &Server{
Bridges: make(map[string]*pe.LogicalBridge),
Ports: make(map[string]*pe.BridgePort),
Tunnels: make(map[string]*pb.Tunnel),
Svis: make(map[string]*pe.Svi),
Vrfs: make(map[string]*pe.Vrf),
}
}
Expand Down
4 changes: 1 addition & 3 deletions pkg/evpn/evpn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,17 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/test/bufconn"

pb "github.com/opiproject/opi-api/network/cloud/v1alpha1/gen/go"
pe "github.com/opiproject/opi-api/network/evpn-gw/v1alpha1/gen/go"
)

func dialer(opi *Server) func(context.Context, string) (net.Conn, error) {
listener := bufconn.Listen(1024 * 1024)
server := grpc.NewServer()

// TODO: replace cloud -> evpn
pb.RegisterCloudInfraServiceServer(server, opi)
pe.RegisterLogicalBridgeServiceServer(server, opi)
pe.RegisterBridgePortServiceServer(server, opi)
pe.RegisterVrfServiceServer(server, opi)
pe.RegisterSviServiceServer(server, opi)

go func() {
if err := server.Serve(listener); err != nil {
Expand Down
1 change: 0 additions & 1 deletion pkg/evpn/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ func (s *Server) UpdateBridgePort(_ context.Context, in *pb.UpdateBridgePortRequ
fmt.Printf("Failed to update link: %v", err)
return nil, err
}
// TODO: replace cloud -> evpn
response := proto.Clone(in.BridgePort).(*pb.BridgePort)
response.Status = &pb.BridgePortStatus{OperStatus: pb.BPOperStatus_BP_OPER_STATUS_UP}
s.Ports[in.BridgePort.Name] = response
Expand Down
Loading

0 comments on commit 8a1fa64

Please sign in to comment.