-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
163 additions
and
432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) 2022 NTT Communications Corporation | ||
// | ||
// This software is released under the MIT License. | ||
// see https://github.com/nttcom/pola/blob/main/LICENSE | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"log" | ||
"net" | ||
"time" | ||
|
||
"google.golang.org/grpc" | ||
"google.golang.org/grpc/credentials/insecure" | ||
|
||
pb "github.com/nttcom/pola/api/grpc" | ||
) | ||
|
||
func main() { | ||
flag.Parse() | ||
conn, err := grpc.Dial("localhost:50051", grpc.WithTransportCredentials(insecure.NewCredentials())) | ||
if err != nil { | ||
log.Fatalf("Can't connect: %v", err) | ||
} | ||
defer conn.Close() | ||
c := pb.NewPceServiceClient(conn) | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), time.Second) | ||
defer cancel() | ||
|
||
r, err := c.CreateSrPolicy(ctx, &pb.CreateSrPolicyInput{ | ||
Asn: 65000, | ||
SrPolicy: &pb.SrPolicy{ | ||
PcepSessionAddr: []byte(net.ParseIP("192.0.2.1").To4()), | ||
SrcRouterId: "0000.0aff.0001", | ||
DstRouterId: "0000.0aff.0004", | ||
Color: uint32(100), | ||
PolicyName: "sample-name", | ||
Type: pb.SrPolicyType_DYNAMIC, | ||
Metric: pb.MetricType_TE, | ||
}, | ||
}) | ||
if err != nil { | ||
log.Fatalf("CreateLsp error: %v", err) | ||
} | ||
log.Printf("Success: %#v", r) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) 2022 NTT Communications Corporation | ||
// | ||
// This software is released under the MIT License. | ||
// see https://github.com/nttcom/pola/blob/main/LICENSE | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"log" | ||
"net" | ||
"time" | ||
|
||
"google.golang.org/grpc" | ||
"google.golang.org/grpc/credentials/insecure" | ||
|
||
pb "github.com/nttcom/pola/api/grpc" | ||
) | ||
|
||
func main() { | ||
flag.Parse() | ||
conn, err := grpc.Dial("localhost:50051", grpc.WithTransportCredentials(insecure.NewCredentials())) | ||
if err != nil { | ||
log.Fatalf("Can't connect: %v", err) | ||
} | ||
defer conn.Close() | ||
c := pb.NewPceServiceClient(conn) | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), time.Second) | ||
defer cancel() | ||
|
||
r, err := c.CreateSrPolicyWithoutLinkState(ctx, &pb.CreateSrPolicyInput{ | ||
SrPolicy: &pb.SrPolicy{ | ||
PcepSessionAddr: []byte(net.ParseIP("192.0.2.1").To4()), | ||
SrcAddr: []byte(net.ParseIP("192.0.2.1").To4()), | ||
DstAddr: []byte(net.ParseIP("192.0.2.2").To4()), | ||
Color: uint32(100), | ||
PolicyName: "sample-name", | ||
SegmentList: []*pb.Segment{{Sid: 16002, LoAddr: []byte(net.ParseIP("10.255.0.2").To4())}, | ||
{Sid: 16003, LoAddr: []byte(net.ParseIP("10.255.0.3").To4())}, | ||
{Sid: 16004, LoAddr: []byte(net.ParseIP("10.255.0.4").To4())}, | ||
}, | ||
}, | ||
}) | ||
if err != nil { | ||
log.Fatalf("CreateLsp error: %v", err) | ||
} | ||
log.Printf("Success: %#v", r) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) 2022 NTT Communications Corporation | ||
// | ||
// This software is released under the MIT License. | ||
// see https://github.com/nttcom/pola/blob/main/LICENSE | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"fmt" | ||
"log" | ||
"time" | ||
|
||
"google.golang.org/grpc" | ||
"google.golang.org/grpc/credentials/insecure" | ||
|
||
empty "github.com/golang/protobuf/ptypes/empty" | ||
pb "github.com/nttcom/pola/api/grpc" | ||
) | ||
|
||
func main() { | ||
flag.Parse() | ||
conn, err := grpc.Dial("localhost:50051", grpc.WithTransportCredentials(insecure.NewCredentials())) | ||
if err != nil { | ||
log.Fatalf("did not connect: %v", err) | ||
} | ||
defer conn.Close() | ||
c := pb.NewPceServiceClient(conn) | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), time.Second) | ||
defer cancel() | ||
var empty empty.Empty | ||
|
||
ret, err := c.GetTed(ctx, &empty) | ||
if err != nil { | ||
log.Fatalf("did not get TED info: %v", err) | ||
} | ||
|
||
for _, node := range ret.GetLsNodes() { | ||
fmt.Printf("node info:\n") | ||
fmt.Printf("%#v\n", node) | ||
for _, prefix := range node.GetLsPrefixes() { | ||
fmt.Printf("prefix info:\n") | ||
fmt.Printf("%#v\n", prefix) | ||
} | ||
for _, link := range node.GetLsLinks() { | ||
fmt.Printf("link info:\n") | ||
fmt.Printf("%#v\n", link) | ||
} | ||
fmt.Printf("\n\n") | ||
} | ||
} |
Oops, something went wrong.