Skip to content
Snippets Groups Projects
Commit 53b9b09d authored by S.H.'s avatar S.H.
Browse files

venv.go: Added ApplyRoutes() to go through all links and create route

for them (untested)
parent 1e3e218d
No related branches found
No related tags found
No related merge requests found
Pipeline #262729 failed
...@@ -260,6 +260,38 @@ func (v *VEnv) DeriveTopologyFromClabData() error { ...@@ -260,6 +260,38 @@ func (v *VEnv) DeriveTopologyFromClabData() error {
} }
return nil return nil
} }
func (v *VEnv) ApplyRoutes() error {
conn := v.auth.GetConn()
hostIP := int64(1)
for _, link := range v.topology.Links {
req := topoPb.AddRoutingTableRequest{
Timestamp: util.Now(),
RoutingTable: &topoPb.RoutingTable{
Id: uuid.NewString(),
Routes: []*topoPb.Route{
{
Id: uuid.NewString(),
TargetIPRange: "16",
NextHopIP: "192.168.178." + strconv.FormatInt(hostIP, 10),
PortID: link.SourcePort.ID,
},
},
},
}
hostIP++
routeService := topoPb.NewRoutingTableServiceClient(conn)
ctx := v.auth.CreateContextWithAuthorization()
reply, err := routeService.AddRoutingTable(ctx, &req)
if err != nil {
return fmt.Errorf("AddRoutingTable failed: %v\n", err)
}
fmt.Println("Successfully added Link:", reply)
}
return nil
}
func (v *VEnv) UploadTopology() error { func (v *VEnv) UploadTopology() error {
conn := v.auth.GetConn() conn := v.auth.GetConn()
topoService := topoPb.NewTopologyServiceClient(conn) topoService := topoPb.NewTopologyServiceClient(conn)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment