Skip to content

Commit

Permalink
refactor(port): 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 3, 2023
1 parent 594a3ee commit 5af3773
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 158 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ Run `docker-compose up -d`
```bash
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 '{"interface" : {"spec" : {"ifid": 11, "l3_if_spec": {"vpc_name_ref": "//network.opiproject.org/bridges/testbridge", mac_address: "qrvMAAAB"}} }, "interface_id" : "testinterface", "parent" : "todo" }' localhost:50151 opi_api.network.cloud.v1alpha1.CloudInfraService.CreateInterface
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 '{"name": "//network.opiproject.org/interfaces/testinterface"}' localhost:50151 opi_api.network.cloud.v1alpha1.CloudInfraService.GetInterface
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/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/interfaces/testinterface"}' localhost:50151 opi_api.network.cloud.v1alpha1.CloudInfraService.DeleteInterface
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/vrfs/testvrf"}' localhost:50151 opi_api.network.evpn-gw.v1alpha1.VrfService.DeleteVrf
Expand Down
1 change: 1 addition & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func main() {
// TODO: replace cloud -> evpn
pb.RegisterCloudInfraServiceServer(s, opi)
pe.RegisterLogicalBridgeServiceServer(s, opi)
pe.RegisterBridgePortServiceServer(s, opi)
pe.RegisterVrfServiceServer(s, opi)

reflection.Register(s)
Expand Down
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ services:
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.LogicalBridgeService.GetLogicalBridge -l && \
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.LogicalBridgeService.DeleteLogicalBridge -l && \
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.LogicalBridgeService.UpdateLogicalBridge -l && \
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.BridgePortService -l && \
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.BridgePortService.CreateBridgePort -l && \
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.BridgePortService.ListBridgePorts -l && \
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.BridgePortService.GetBridgePort -l && \
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.BridgePortService.DeleteBridgePort -l && \
/entrypoint.sh ls localhost:50151 opi_api.network.evpn_gw.v1alpha1.BridgePortService.UpdateBridgePort -l && \
echo toremove && \
apt update && apt install iproute2 -y && \
ip link add br-tenant type bridge vlan_default_pvid 0 vlan_filtering 1 vlan_protocol 802.1Q && \
Expand All @@ -293,13 +299,17 @@ services:
/entrypoint.sh call --json_input --json_output localhost:50151 CreateLogicalBridge "{\"logical_bridge\" : {\"spec\" : {\"vni\" : 11, \"vlan_id\": 11 }}, \"logical_bridge_id\" : \"vxlan11\" }" && \
/entrypoint.sh call --json_input --json_output localhost:50151 CreateLogicalBridge "{\"logical_bridge\" : {\"spec\" : {\"vni\" : 22, \"vlan_id\": 22 }}, \"logical_bridge_id\" : \"vxlan22\" }" && \
/entrypoint.sh call --json_input --json_output localhost:50151 CreateLogicalBridge "{\"logical_bridge\" : {\"spec\" : {\"vni\" : 33, \"vlan_id\": 33 }}, \"logical_bridge_id\" : \"vxlan33\" }" && \
/entrypoint.sh call --json_input --json_output localhost:50151 CreateBridgePort "{\"bridge_port\" : {\"spec\" : {\"mac_address\" : \"qrvMAAAB\", \"ptype\": \"ACCESS\", \"logical_bridges\": [] }}, \"bridge_port_id\" : \"eth2\" }" && \
/entrypoint.sh call --json_input --json_output localhost:50151 CreateBridgePort "{\"bridge_port\" : {\"spec\" : {\"mac_address\" : \"qrvMAAAB\", \"ptype\": \"TRUNK\" , \"logical_bridges\": [] }}, \"bridge_port_id\" : \"eth3\" }" && \
echo get && \
/entrypoint.sh call --json_input --json_output localhost:50151 GetVrf "{\"name\" : \"//network.opiproject.org/vrfs/blue\" }" && \
/entrypoint.sh call --json_input --json_output localhost:50151 GetVrf "{\"name\" : \"//network.opiproject.org/vrfs/green\" }" && \
/entrypoint.sh call --json_input --json_output localhost:50151 GetVrf "{\"name\" : \"//network.opiproject.org/vrfs/yellow\" }" && \
/entrypoint.sh call --json_input --json_output localhost:50151 GetLogicalBridge "{\"name\" : \"//network.opiproject.org/bridges/vxlan11\" }" && \
/entrypoint.sh call --json_input --json_output localhost:50151 GetLogicalBridge "{\"name\" : \"//network.opiproject.org/bridges/vxlan22\" }" && \
/entrypoint.sh call --json_input --json_output localhost:50151 GetLogicalBridge "{\"name\" : \"//network.opiproject.org/bridges/vxlan33\" }" && \
/entrypoint.sh call --json_input --json_output localhost:50151 GetBridgePort "{\"name\" : \"//network.opiproject.org/ports/eth2\" }" && \
/entrypoint.sh call --json_input --json_output localhost:50151 GetBridgePort "{\"name\" : \"//network.opiproject.org/ports/eth3\" }" && \
echo toremove && \
ip link add br10 type bridge && \
ip link set br10 addr aa:bb:cc:00:00:11 && \
Expand Down
17 changes: 9 additions & 8 deletions pkg/evpn/evpn.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@ type Server struct {
pb.UnimplementedCloudInfraServiceServer
pe.UnimplementedVrfServiceServer
pe.UnimplementedLogicalBridgeServiceServer
Bridges map[string]*pe.LogicalBridge
Interfaces map[string]*pb.Interface
Tunnels map[string]*pb.Tunnel
Vrfs map[string]*pe.Vrf
pe.UnimplementedBridgePortServiceServer
Bridges map[string]*pe.LogicalBridge
Ports map[string]*pe.BridgePort
Tunnels map[string]*pb.Tunnel
Vrfs map[string]*pe.Vrf
}

// NewServer creates initialized instance of EVPN server
func NewServer() *Server {
return &Server{
Bridges: make(map[string]*pe.LogicalBridge),
Interfaces: make(map[string]*pb.Interface),
Tunnels: make(map[string]*pb.Tunnel),
Vrfs: make(map[string]*pe.Vrf),
Bridges: make(map[string]*pe.LogicalBridge),
Ports: make(map[string]*pe.BridgePort),
Tunnels: make(map[string]*pb.Tunnel),
Vrfs: make(map[string]*pe.Vrf),
}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/evpn/evpn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func dialer(opi *Server) func(context.Context, string) (net.Conn, error) {
// TODO: replace cloud -> evpn
pb.RegisterCloudInfraServiceServer(server, opi)
pe.RegisterLogicalBridgeServiceServer(server, opi)
pe.RegisterBridgePortServiceServer(server, opi)
pe.RegisterVrfServiceServer(server, opi)

go func() {
Expand Down
Loading

0 comments on commit 5af3773

Please sign in to comment.