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

switch: implemented test environment

parent 11c2db2d
No related branches found
No related tags found
1 merge request!2repo: added new directory where utils scripts will be
{"ConfigDir":"","ControllerIP":"192.168.122.60","NodeName":"ant-machine","NedName":"ant-machine-example-network-controller"}
{"name":"ant-machine","nodeIP":"192.168.122.60","neighborNodes":["192.168.122.244"]}
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())
}
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