diff --git a/src/switch/config/config.json b/src/switch/config/config.json new file mode 100644 index 0000000000000000000000000000000000000000..1d717b7e14ee883adc20d04050dd66ffd1c6cda9 --- /dev/null +++ b/src/switch/config/config.json @@ -0,0 +1 @@ +{"ConfigDir":"","ControllerIP":"192.168.122.60","NodeName":"ant-machine","NedName":"ant-machine-example-network-controller"} diff --git a/src/switch/config/neighbors.json b/src/switch/config/neighbors.json new file mode 100644 index 0000000000000000000000000000000000000000..bf2730fb333138066c7d535f705bf20a5132c5fb --- /dev/null +++ b/src/switch/config/neighbors.json @@ -0,0 +1,2 @@ +{"name":"ant-machine","nodeIP":"192.168.122.60","neighborNodes":["192.168.122.244"]} + diff --git a/src/switch/test/client_test.go b/src/switch/test/client_test.go new file mode 100644 index 0000000000000000000000000000000000000000..eb52772a0726d787cd1ffd186b9e1b798d836242 --- /dev/null +++ b/src/switch/test/client_test.go @@ -0,0 +1,44 @@ +package main + +import ( + "context" + "fmt" + "log" + "time" + + "l2sm.local/ovs-switch/pkg/nedpb" + + "google.golang.org/grpc" +) + +func main() { + // Set up a connection to the gRPC server. + conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure()) // Update with the actual server address and credentials if needed + if err != nil { + log.Fatalf("Failed to connect to gRPC server: %v", err) + } + defer conn.Close() + + // Create a new client for the NedService. + client := nedpb.NewNedServiceClient(conn) + + // Create a context with a timeout to ensure that the request doesn't hang. + ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) + defer cancel() + + // Prepare the request with the interface name "br10". + req := &nedpb.AttachInterfaceRequest{ + InterfaceName: "br10", + } + + // Call the AttachInterface method. + resp, err := client.AttachInterface(ctx, req) + if err != nil { + log.Fatalf("Error calling AttachInterface: %v", err) + } + + // Handle and display the response. + fmt.Printf("Interface attached successfully:\n") + fmt.Printf("Interface Number: %d\n", resp.GetInterfaceNum()) + fmt.Printf("Node Name: %s\n", resp.GetNodeName()) +}