Skip to content
Snippets Groups Projects
Commit f9fb2332 authored by Alejandro Tjaarda's avatar Alejandro Tjaarda
Browse files

switch: fine-tuned protobufs

Now its returned the interface number instead of openflow id, which will work better from the ned interface side. Added the main server code
parent 06f4c29a
No related branches found
No related tags found
1 merge request!2repo: added new directory where utils scripts will be
...@@ -4,12 +4,15 @@ package nedpb; ...@@ -4,12 +4,15 @@ package nedpb;
option go_package = "l2sm.local/ovs-switch/pkg/nedpb"; option go_package = "l2sm.local/ovs-switch/pkg/nedpb";
service VxlanService { service NedService {
// Creates a VxLAN with the specified IP address. // Creates a VxLAN with the specified IP address.
rpc CreateVxlan(CreateVxlanRequest) returns (CreateVxlanResponse); rpc CreateVxlan(CreateVxlanRequest) returns (CreateVxlanResponse);
// Attaches the specified interface to the bridge. // Attaches the specified interface to the bridge.
rpc AttachInterface(AttachInterfaceRequest) returns (AttachInterfaceResponse); rpc AttachInterface(AttachInterfaceRequest) returns (AttachInterfaceResponse);
// Returns this neds node name
rpc GetNodeName(GetNodeNameRequest) returns (GetNodeNameResponse);
} }
message CreateVxlanRequest { message CreateVxlanRequest {
...@@ -32,6 +35,11 @@ message AttachInterfaceRequest { ...@@ -32,6 +35,11 @@ message AttachInterfaceRequest {
message AttachInterfaceResponse { message AttachInterfaceResponse {
// The OpenFlow ID of the attached interface. // The OpenFlow ID of the attached interface.
int64 interface_num = 1; int64 interface_num = 1;
// The node name from the environment variable.
string node_name = 2;
} }
message GetNodeNameRequest {
}
message GetNodeNameResponse {
string node_name = 1;
}
\ No newline at end of file
...@@ -2,22 +2,84 @@ package main ...@@ -2,22 +2,84 @@ package main
import ( import (
"context" "context"
"errors"
"flag"
"fmt" "fmt"
"log" "log"
"net" "net"
"os" "os/exec"
"time"
"google.golang.org/grpc" "google.golang.org/grpc"
// Adjust the import path based on your module path // Adjust the import path based on your module path
nedv1 "l2sm.local/ovs-switch/api/v1"
"l2sm.local/ovs-switch/internal/inits"
"l2sm.local/ovs-switch/pkg/nedpb" "l2sm.local/ovs-switch/pkg/nedpb"
"l2sm.local/ovs-switch/pkg/ovs" "l2sm.local/ovs-switch/pkg/ovs"
) )
// server is used to implement nedpb.VxlanServiceServer // server is used to implement nedpb.VxlanServiceServer
type server struct { type server struct {
nedpb.UnimplementedVxlanServiceServer nedpb.UnimplementedNedServiceServer
Bridge ovs.Bridge
Settings nedv1.NedSettings
}
func main() {
configDir, neighborsDir, err := takeArguments()
if err != nil {
fmt.Println("Error with the arguments provided. Error:", err)
return
}
var settings nedv1.NedSettings
err = inits.ReadFile(configDir, &settings)
if err != nil {
fmt.Println("Error with the provided file. Error:", err)
return
}
fmt.Println("Initializing switch, connected to controller: ", settings.ControllerIP)
bridge, err := inits.InitializeSwitch(settings.NedName, settings.ControllerIP)
if err != nil {
log.Fatalf("error initializing ned: %v", err)
}
var node nedv1.Node
err = inits.ReadFile(neighborsDir, &node)
if err != nil {
fmt.Println("Error with the provided file. Error:", err)
return
}
err = inits.ConnectToNeighbors(bridge, node)
if err != nil {
fmt.Println("Could not connect neighbors: ", err)
return
}
// Listen on a TCP port
lis, err := net.Listen("tcp", ":50051") // Choose your port
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
// Create a gRPC server
grpcServer := grpc.NewServer()
// Register the server
nedpb.RegisterNedServiceServer(grpcServer, &server{Bridge: bridge, Settings: settings})
log.Printf("gRPC server listening on :50051")
if err := grpcServer.Serve(lis); err != nil {
log.Fatalf("failed to serve: %v", err)
}
} }
// CreateVxlan implements nedpb.VxlanServiceServer // CreateVxlan implements nedpb.VxlanServiceServer
...@@ -30,11 +92,11 @@ func (s *server) CreateVxlan(ctx context.Context, req *nedpb.CreateVxlanRequest) ...@@ -30,11 +92,11 @@ func (s *server) CreateVxlan(ctx context.Context, req *nedpb.CreateVxlanRequest)
// Placeholder implementation // Placeholder implementation
bridge := ovs.FromName("brtun") bridge := ovs.FromName("brtun")
bridge.CreateVxlan(ovs.Vxlan{"", "", ipAddress, ""}) bridge.CreateVxlan(ovs.Vxlan{VxlanId: "", LocalIp: "", RemoteIp: ipAddress, UdpPort: ""})
message := fmt.Sprintf("VxLAN with IP %s created successfully", ipAddress) message := fmt.Sprintf("VxLAN with IP %s created successfully", ipAddress)
return &nedpb.CreateVxlanResponse{ return &nedpb.CreateVxlanResponse{
Success: success, Success: true,
Message: message, Message: message,
}, nil }, nil
} }
...@@ -43,34 +105,70 @@ func (s *server) CreateVxlan(ctx context.Context, req *nedpb.CreateVxlanRequest) ...@@ -43,34 +105,70 @@ func (s *server) CreateVxlan(ctx context.Context, req *nedpb.CreateVxlanRequest)
func (s *server) AttachInterface(ctx context.Context, req *nedpb.AttachInterfaceRequest) (*nedpb.AttachInterfaceResponse, error) { func (s *server) AttachInterface(ctx context.Context, req *nedpb.AttachInterfaceRequest) (*nedpb.AttachInterfaceResponse, error) {
interfaceName := req.GetInterfaceName() interfaceName := req.GetInterfaceName()
// Implement your logic to attach the interface to the bridge // Create a new interface and attach it to the bridge
// For example, call a function from pkg/ovs/vsctl.go newPort, err := AddInterfaceToBridge(interfaceName)
// openflowID, err := ovs.AttachInterface(interfaceName) if err != nil {
return nil, fmt.Errorf("failed to add interface to bridge: %v", err)
}
// Placeholder implementation interfaceNum, err := s.Bridge.GetPortNumber(newPort)
nodeName := os.Getenv("NODE_NAME") if err != nil {
return nil, fmt.Errorf("failed to get port number: %v", err)
}
nodeName := s.Settings.NodeName
if nodeName == "" {
nodeName = "default-node" // Fallback if NODE_NAME is not set
}
return &nedpb.AttachInterfaceResponse{ return &nedpb.AttachInterfaceResponse{
OpenflowId: openflowID, InterfaceNum: interfaceNum,
NodeName: nodeName, NodeName: nodeName,
}, nil }, nil
} }
func main() { // AddInterfaceToBridge creates a new veth pair, attaches one end to the specified bridge,
// Listen on a TCP port // and returns the name of the other end.
lis, err := net.Listen("tcp", ":50051") // Choose your port func AddInterfaceToBridge(bridgeName string) (string, error) {
if err != nil { // Generate unique interface names
log.Fatalf("failed to listen: %v", err) timestamp := time.Now().UnixNano()
vethName := fmt.Sprintf("veth%d", timestamp)
peerName := fmt.Sprintf("vpeer%d", timestamp)
// Create the veth pair
if err := exec.Command("ip", "link", "add", vethName, "type", "veth", "peer", "name", peerName).Run(); err != nil {
return "", fmt.Errorf("failed to create veth pair: %v", err)
} }
// Create a gRPC server // Set both interfaces up
grpcServer := grpc.NewServer() if err := exec.Command("ip", "link", "set", vethName, "up").Run(); err != nil {
return "", fmt.Errorf("failed to set %s up: %v", vethName, err)
}
if err := exec.Command("ip", "link", "set", peerName, "up").Run(); err != nil {
return "", fmt.Errorf("failed to set %s up: %v", peerName, err)
}
// Register the server // Add one end to the Linux bridge
nedpb.RegisterVxlanServiceServer(grpcServer, &server{}) if err := exec.Command("ip", "link", "set", vethName, "master", bridgeName).Run(); err != nil {
return "", fmt.Errorf("failed to add %s to bridge %s: %v", vethName, bridgeName, err)
}
log.Printf("gRPC server listening on :50051") return peerName, nil
if err := grpcServer.Serve(lis); err != nil { }
log.Fatalf("failed to serve: %v", err)
func takeArguments() (string, string, error) {
configDir := flag.String("config_dir", "", "directory where the ned settings are specified. Required")
neighborsDir := flag.String("neighbors_dir", "", "directory where the ned's neighbors are specified. Required")
flag.Parse()
switch {
case *configDir == "":
return "", "", errors.New("config directory is not defined")
case *neighborsDir == "":
return "", "", errors.New("provider name is not defined")
} }
return *configDir, *neighborsDir, nil
} }
...@@ -179,7 +179,7 @@ type AttachInterfaceResponse struct { ...@@ -179,7 +179,7 @@ type AttachInterfaceResponse struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
// The OpenFlow ID of the attached interface. // The OpenFlow ID of the attached interface.
OpenflowId int64 `protobuf:"varint,1,opt,name=openflow_id,json=openflowId,proto3" json:"openflow_id,omitempty"` InterfaceNum int64 `protobuf:"varint,1,opt,name=interface_num,json=interfaceNum,proto3" json:"interface_num,omitempty"`
// The node name from the environment variable. // The node name from the environment variable.
NodeName string `protobuf:"bytes,2,opt,name=node_name,json=nodeName,proto3" json:"node_name,omitempty"` NodeName string `protobuf:"bytes,2,opt,name=node_name,json=nodeName,proto3" json:"node_name,omitempty"`
} }
...@@ -216,9 +216,9 @@ func (*AttachInterfaceResponse) Descriptor() ([]byte, []int) { ...@@ -216,9 +216,9 @@ func (*AttachInterfaceResponse) Descriptor() ([]byte, []int) {
return file_ned_proto_rawDescGZIP(), []int{3} return file_ned_proto_rawDescGZIP(), []int{3}
} }
func (x *AttachInterfaceResponse) GetOpenflowId() int64 { func (x *AttachInterfaceResponse) GetInterfaceNum() int64 {
if x != nil { if x != nil {
return x.OpenflowId return x.InterfaceNum
} }
return 0 return 0
} }
...@@ -246,25 +246,26 @@ var file_ned_proto_rawDesc = []byte{ ...@@ -246,25 +246,26 @@ var file_ned_proto_rawDesc = []byte{
0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x0e,
0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x4e,
0x61, 0x6d, 0x65, 0x22, 0x57, 0x0a, 0x17, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x49, 0x6e, 0x74, 0x61, 0x6d, 0x65, 0x22, 0x5b, 0x0a, 0x17, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x49, 0x6e, 0x74,
0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23,
0x0a, 0x0b, 0x6f, 0x70, 0x65, 0x6e, 0x66, 0x6c, 0x6f, 0x77, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x0a, 0x0d, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x18,
0x01, 0x28, 0x03, 0x52, 0x0a, 0x6f, 0x70, 0x65, 0x6e, 0x66, 0x6c, 0x6f, 0x77, 0x49, 0x64, 0x12, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65,
0x1b, 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x4e, 0x75, 0x6d, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65,
0x28, 0x09, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x32, 0xa6, 0x01, 0x0a, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4e, 0x61, 0x6d, 0x65,
0x0c, 0x56, 0x78, 0x6c, 0x61, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x44, 0x0a, 0x32, 0xa4, 0x01, 0x0a, 0x0a, 0x4e, 0x65, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12,
0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x78, 0x6c, 0x61, 0x6e, 0x12, 0x19, 0x2e, 0x6e, 0x44, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x78, 0x6c, 0x61, 0x6e, 0x12, 0x19,
0x65, 0x64, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x78, 0x6c, 0x61, 0x6e, 0x2e, 0x6e, 0x65, 0x64, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x78, 0x6c,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x6e, 0x65, 0x64, 0x70, 0x62, 0x2e, 0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x6e, 0x65, 0x64, 0x70,
0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x78, 0x6c, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x78, 0x6c, 0x61, 0x6e, 0x52, 0x65, 0x73,
0x6e, 0x73, 0x65, 0x12, 0x50, 0x0a, 0x0f, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x49, 0x6e, 0x74, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x50, 0x0a, 0x0f, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x49,
0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x12, 0x1d, 0x2e, 0x6e, 0x65, 0x64, 0x70, 0x62, 0x2e, 0x41, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x12, 0x1d, 0x2e, 0x6e, 0x65, 0x64, 0x70, 0x62,
0x74, 0x74, 0x61, 0x63, 0x68, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x65, 0x2e, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x6e, 0x65, 0x64, 0x70, 0x62, 0x2e, 0x41, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x6e, 0x65, 0x64, 0x70, 0x62, 0x2e,
0x74, 0x61, 0x63, 0x68, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x52,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x21, 0x5a, 0x1f, 0x6c, 0x32, 0x73, 0x6d, 0x2e, 0x6c, 0x6f, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x21, 0x5a, 0x1f, 0x6c, 0x32, 0x73, 0x6d, 0x2e,
0x63, 0x61, 0x6c, 0x2f, 0x6f, 0x76, 0x73, 0x2d, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x2f, 0x70, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x2f, 0x6f, 0x76, 0x73, 0x2d, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68,
0x6b, 0x67, 0x2f, 0x6e, 0x65, 0x64, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x6e, 0x65, 0x64, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
} }
var ( var (
...@@ -287,10 +288,10 @@ var file_ned_proto_goTypes = []any{ ...@@ -287,10 +288,10 @@ var file_ned_proto_goTypes = []any{
(*AttachInterfaceResponse)(nil), // 3: nedpb.AttachInterfaceResponse (*AttachInterfaceResponse)(nil), // 3: nedpb.AttachInterfaceResponse
} }
var file_ned_proto_depIdxs = []int32{ var file_ned_proto_depIdxs = []int32{
0, // 0: nedpb.VxlanService.CreateVxlan:input_type -> nedpb.CreateVxlanRequest 0, // 0: nedpb.NedService.CreateVxlan:input_type -> nedpb.CreateVxlanRequest
2, // 1: nedpb.VxlanService.AttachInterface:input_type -> nedpb.AttachInterfaceRequest 2, // 1: nedpb.NedService.AttachInterface:input_type -> nedpb.AttachInterfaceRequest
1, // 2: nedpb.VxlanService.CreateVxlan:output_type -> nedpb.CreateVxlanResponse 1, // 2: nedpb.NedService.CreateVxlan:output_type -> nedpb.CreateVxlanResponse
3, // 3: nedpb.VxlanService.AttachInterface:output_type -> nedpb.AttachInterfaceResponse 3, // 3: nedpb.NedService.AttachInterface:output_type -> nedpb.AttachInterfaceResponse
2, // [2:4] is the sub-list for method output_type 2, // [2:4] is the sub-list for method output_type
0, // [0:2] is the sub-list for method input_type 0, // [0:2] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension type_name
......
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v5.28.2
// source: ned.proto
package nedpb
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
NedService_CreateVxlan_FullMethodName = "/nedpb.NedService/CreateVxlan"
NedService_AttachInterface_FullMethodName = "/nedpb.NedService/AttachInterface"
)
// NedServiceClient is the client API for NedService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type NedServiceClient interface {
// Creates a VxLAN with the specified IP address.
CreateVxlan(ctx context.Context, in *CreateVxlanRequest, opts ...grpc.CallOption) (*CreateVxlanResponse, error)
// Attaches the specified interface to the bridge.
AttachInterface(ctx context.Context, in *AttachInterfaceRequest, opts ...grpc.CallOption) (*AttachInterfaceResponse, error)
}
type nedServiceClient struct {
cc grpc.ClientConnInterface
}
func NewNedServiceClient(cc grpc.ClientConnInterface) NedServiceClient {
return &nedServiceClient{cc}
}
func (c *nedServiceClient) CreateVxlan(ctx context.Context, in *CreateVxlanRequest, opts ...grpc.CallOption) (*CreateVxlanResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CreateVxlanResponse)
err := c.cc.Invoke(ctx, NedService_CreateVxlan_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *nedServiceClient) AttachInterface(ctx context.Context, in *AttachInterfaceRequest, opts ...grpc.CallOption) (*AttachInterfaceResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(AttachInterfaceResponse)
err := c.cc.Invoke(ctx, NedService_AttachInterface_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// NedServiceServer is the server API for NedService service.
// All implementations must embed UnimplementedNedServiceServer
// for forward compatibility.
type NedServiceServer interface {
// Creates a VxLAN with the specified IP address.
CreateVxlan(context.Context, *CreateVxlanRequest) (*CreateVxlanResponse, error)
// Attaches the specified interface to the bridge.
AttachInterface(context.Context, *AttachInterfaceRequest) (*AttachInterfaceResponse, error)
mustEmbedUnimplementedNedServiceServer()
}
// UnimplementedNedServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedNedServiceServer struct{}
func (UnimplementedNedServiceServer) CreateVxlan(context.Context, *CreateVxlanRequest) (*CreateVxlanResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateVxlan not implemented")
}
func (UnimplementedNedServiceServer) AttachInterface(context.Context, *AttachInterfaceRequest) (*AttachInterfaceResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method AttachInterface not implemented")
}
func (UnimplementedNedServiceServer) mustEmbedUnimplementedNedServiceServer() {}
func (UnimplementedNedServiceServer) testEmbeddedByValue() {}
// UnsafeNedServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to NedServiceServer will
// result in compilation errors.
type UnsafeNedServiceServer interface {
mustEmbedUnimplementedNedServiceServer()
}
func RegisterNedServiceServer(s grpc.ServiceRegistrar, srv NedServiceServer) {
// If the following call pancis, it indicates UnimplementedNedServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&NedService_ServiceDesc, srv)
}
func _NedService_CreateVxlan_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateVxlanRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(NedServiceServer).CreateVxlan(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: NedService_CreateVxlan_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(NedServiceServer).CreateVxlan(ctx, req.(*CreateVxlanRequest))
}
return interceptor(ctx, in, info, handler)
}
func _NedService_AttachInterface_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AttachInterfaceRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(NedServiceServer).AttachInterface(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: NedService_AttachInterface_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(NedServiceServer).AttachInterface(ctx, req.(*AttachInterfaceRequest))
}
return interceptor(ctx, in, info, handler)
}
// NedService_ServiceDesc is the grpc.ServiceDesc for NedService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var NedService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "nedpb.NedService",
HandlerType: (*NedServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "CreateVxlan",
Handler: _NedService_CreateVxlan_Handler,
},
{
MethodName: "AttachInterface",
Handler: _NedService_AttachInterface_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "ned.proto",
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment