Skip to content

Commit

Permalink
Merge pull request #61 from nttcom/refactor/rename_Sr_SR
Browse files Browse the repository at this point in the history
Refactor for v1.2.0
  • Loading branch information
Motok1 committed Feb 21, 2023
2 parents 9f2ee7c + 3cd49c0 commit 44ff8d0
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 97 deletions.
80 changes: 40 additions & 40 deletions cmd/pola/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Displays the peer addresses of the active session.

JSON formatted response
```
```json
{
"sessions": [
{
Expand All @@ -25,7 +25,7 @@ JSON formatted response
Displays the lsp list managed by polad.

JSON formatted response
```
```json
{
"lsps": [
{
Expand Down Expand Up @@ -57,7 +57,7 @@ JSON formatted response
```

※ want to change to this format later.
```
```json
{
"peers": [
{
Expand Down Expand Up @@ -118,20 +118,20 @@ Create a new SR Policy using TED
#### Case: Dynamic Path calculate

YAML input format
```
```yaml
asn: 65000
srPolicy:
pcepSessionAddr: 192.0.2.1
name: policy-name
srcRouterId: 0000.0aff.0001
dstRouterId: 0000.0aff.0004
color: 100
type: dynamic
metric: igp / te / delay
pcepSessionAddr: 192.0.2.1
name: policy-name
srcRouterId: 0000.0aff.0001
dstRouterId: 0000.0aff.0004
color: 100
type: dynamic
metric: igp / te / delay
```

JSON formatted response
```
```json
{
"status": "success"
}
Expand All @@ -140,23 +140,23 @@ JSON formatted response
#### Case: Explicit Path

YAML input format
```
```yaml
asn: 65000
srPolicy:
pcepSessionAddr: 192.0.2.1
name: policy-name
srcRouterId: 0000.0aff.0001
dstRouterId: 0000.0aff.0004
color: 100
type: explicit
segmentList:
- sid: 16003
- sid: 16002
- sid: 16004
pcepSessionAddr: 192.0.2.1
name: policy-name
srcRouterId: 0000.0aff.0001
dstRouterId: 0000.0aff.0004
color: 100
type: explicit
segmentList:
- sid: 16003
- sid: 16002
- sid: 16004
```

JSON formatted response
```
```json
{
"status": "success"
}
Expand All @@ -167,22 +167,22 @@ JSON formatted response
Create a new SR Policy without using TED

YAML input format
```
```yaml
srPolicy:
pcepSessionAddr: 192.0.2.1
srcAddr: 192.0.2.1
dstAddr: 192.0.2.2
name: name
color: 100
segmentList:
- sid: 16003
nai: 192.0.2.3
- sid: 16002
nai: 192.0.2.2
pcepSessionAddr: 192.0.2.1
srcAddr: 192.0.2.1
dstAddr: 192.0.2.2
name: name
color: 100
segmentList:
- sid: 16003
nai: 192.0.2.3
- sid: 16002
nai: 192.0.2.2
```

json formatted response
```
```json
{
"status": "success"
}
Expand All @@ -192,7 +192,7 @@ json formatted response
Displays the ted managed by polad.

JSON formatted response
```
```json
{
"ted": [
{
Expand Down Expand Up @@ -340,19 +340,19 @@ JSON formatted response
## Completion

## Bash
```
```bash
pola completion bash | sudo tee -a /usr/share/bash-completion/completions/pola >/dev/null
source /usr/share/bash-completion/completions/pola
```

## Zsh
```
```sh
pola completion zsh > /usr/local/share/zsh/site-functions/_pola
compinit
```

## Fish
```
```sh
pola completion fish > ~/.config/fish/completions/pola.fish
fish_update_completions
```
8 changes: 4 additions & 4 deletions cmd/pola/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,20 @@ func getSRPolicyList(client pb.PceServiceClient) (map[netip.Addr][]table.SRPolic
return srPolicies, nil
}

func createSRPolicy(client pb.PceServiceClient, createSrPolicyInput *pb.CreateSRPolicyInput) error {
func createSRPolicy(client pb.PceServiceClient, createSRPolicyInput *pb.CreateSRPolicyInput) error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
_, err := client.CreateSRPolicy(ctx, createSrPolicyInput)
_, err := client.CreateSRPolicy(ctx, createSRPolicyInput)
if err != nil {
return err
}
return nil
}

func createSrPolicyWithoutLinkState(client pb.PceServiceClient, createSrPolicyInput *pb.CreateSRPolicyInput) error {
func createSRPolicyWithoutLinkState(client pb.PceServiceClient, createSRPolicyInput *pb.CreateSRPolicyInput) error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
_, err := client.CreateSRPolicyWithoutLinkState(ctx, createSrPolicyInput)
_, err := client.CreateSRPolicyWithoutLinkState(ctx, createSRPolicyInput)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/pola/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ func newRootCmd() *cobra.Command {
rootCmd.PersistentFlags().String("host", "127.0.0.1", "polad connection address")
rootCmd.PersistentFlags().StringP("port", "p", "50051", "polad connection port")

rootCmd.AddCommand(newSessionCmd(), newSrPolicyCmd(), newTedCmd())
rootCmd.AddCommand(newSessionCmd(), newSRPolicyCmd(), newTedCmd())
return rootCmd
}
4 changes: 2 additions & 2 deletions cmd/pola/sr_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/spf13/cobra"
)

func newSrPolicyCmd() *cobra.Command {
func newSRPolicyCmd() *cobra.Command {

srPolicyCmd := &cobra.Command{
Use: "sr-policy",
Expand All @@ -18,6 +18,6 @@ func newSrPolicyCmd() *cobra.Command {
},
}

srPolicyCmd.AddCommand(newSrPolicyListCmd(), newSrPolicyAddCmd())
srPolicyCmd.AddCommand(newSRPolicyListCmd(), newSRPolicyAddCmd())
return srPolicyCmd
}
5 changes: 2 additions & 3 deletions cmd/pola/sr_policy_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
yaml "gopkg.in/yaml.v2"
)

func newSrPolicyAddCmd() *cobra.Command {
func newSRPolicyAddCmd() *cobra.Command {

srPolicyAddCmd := &cobra.Command{
Use: "add",
Expand Down Expand Up @@ -119,7 +119,7 @@ func addSRPolicy(input InputFormat, jsonFlag bool, noLinkStateFlag bool) error {
inputData := &pb.CreateSRPolicyInput{
SRPolicy: srPolicy,
}
if err := createSrPolicyWithoutLinkState(client, inputData); err != nil {
if err := createSRPolicyWithoutLinkState(client, inputData); err != nil {
return err
}
} else {
Expand Down Expand Up @@ -170,7 +170,6 @@ func addSRPolicy(input InputFormat, jsonFlag bool, noLinkStateFlag bool) error {
for _, seg := range input.SRPolicy.SegmentList {
segmentList = append(segmentList, &pb.Segment{Sid: seg.Sid})
}

case "dynamic":
if input.SRPolicy.Metric == "" {
errMsg := "invalid input\n" +
Expand Down
6 changes: 3 additions & 3 deletions cmd/pola/sr_policy_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import (
"github.com/spf13/cobra"
)

func newSrPolicyListCmd() *cobra.Command {
func newSRPolicyListCmd() *cobra.Command {

srPolicyListCmd := &cobra.Command{
Use: "list",
RunE: func(cmd *cobra.Command, args []string) error {
if err := showSrPolicyList(jsonFmt); err != nil {
if err := showSRPolicyList(jsonFmt); err != nil {
return err
}
return nil
Expand All @@ -27,7 +27,7 @@ func newSrPolicyListCmd() *cobra.Command {
return srPolicyListCmd
}

func showSrPolicyList(jsonFlag bool) error {
func showSRPolicyList(jsonFlag bool) error {

srPolicies, err := getSRPolicyList(client)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion internal/pkg/gobgp/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ func ConvertToTedElem(dst *api.Destination) ([]table.TedElem, error) {
}
}
tedElems = append(tedElems, lsNode)

case *api.LsLinkNLRI:
// Get information from MP-REACH-NLRI Attr
localNodeId := typedLinkStateNlri.GetLocalNode().GetIgpRouterId()
Expand Down
4 changes: 2 additions & 2 deletions pkg/packet/pcep/capability.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ func PolaCapability() []CapabilityInterface {
Length: uint16(10),
PathSetupTypes: Psts{PST_RSVP_TE, PST_SR_TE, PST_SRV6_TE},
SubTlvs: []TlvInterface{
&SrPceCapability{
&SRPceCapability{
UnlimitedMSD: false,
SupportNAI: false,
MaximumSidDepth: uint8(16),
},
},
},
&SrPceCapability{
&SRPceCapability{
UnlimitedMSD: false,
SupportNAI: false,
MaximumSidDepth: uint8(16),
Expand Down
1 change: 0 additions & 1 deletion pkg/packet/pcep/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ func (m *PCUpdMessage) Serialize() ([]uint8, error) {
}

func NewPCUpdMessage(srpId uint32, lspName string, plspId uint32, segmentList []table.Segment) (*PCUpdMessage, error) {

m := &PCUpdMessage{}
var err error

Expand Down
Loading

0 comments on commit 44ff8d0

Please sign in to comment.