diff options
-rw-r--r-- | config/bgp_configs.go | 26 | ||||
-rw-r--r-- | tools/pyang_plugins/bgpyang2golang.py | 2 |
2 files changed, 13 insertions, 15 deletions
diff --git a/config/bgp_configs.go b/config/bgp_configs.go index 2c1298e4..713c7821 100644 --- a/config/bgp_configs.go +++ b/config/bgp_configs.go @@ -104,14 +104,14 @@ type BgpExtCommunityType string type BgpStdCommunityType string // typedef for typedef bgp-types:peer-type -type PeerTypeDef string +type PeerType string const ( - PEER_TYPE_INTERNAL PeerTypeDef = "internal" - PEER_TYPE_EXTERNAL PeerTypeDef = "external" + PEER_TYPE_INTERNAL PeerType = "internal" + PEER_TYPE_EXTERNAL PeerType = "external" ) -func (v PeerTypeDef) ToInt() int { +func (v PeerType) ToInt() int { for i, vv := range []string{"internal", "external"} { if string(v) == vv { return i @@ -120,18 +120,18 @@ func (v PeerTypeDef) ToInt() int { return -1 } -func (v PeerTypeDef) FromInt(i int) PeerTypeDef { +func (v PeerType) FromInt(i int) PeerType { for j, vv := range []string{"internal", "external"} { if i == j { - return PeerTypeDef(vv) + return PeerType(vv) } } - return PeerTypeDef("") + return PeerType("") } -func (v PeerTypeDef) Validate() error { +func (v PeerType) Validate() error { if v.ToInt() < 0 { - return fmt.Errorf("invalid PeerTypeDef: %s", v) + return fmt.Errorf("invalid PeerType: %s", v) } return nil } @@ -563,7 +563,7 @@ type PeerGroupState struct { //bgp:local-as's original type is inet:as-number LocalAs uint32 // original -> bgp:peer-type - PeerType PeerTypeDef + PeerType PeerType // original -> bgp:auth-password AuthPassword string // original -> bgp:remove-private-as @@ -592,7 +592,7 @@ type PeerGroupConfig struct { //bgp:local-as's original type is inet:as-number LocalAs uint32 // original -> bgp:peer-type - PeerType PeerTypeDef + PeerType PeerType // original -> bgp:auth-password AuthPassword string // original -> bgp:remove-private-as @@ -1001,7 +1001,7 @@ type NeighborState struct { //bgp:local-as's original type is inet:as-number LocalAs uint32 // original -> bgp:peer-type - PeerType PeerTypeDef + PeerType PeerType // original -> bgp:auth-password AuthPassword string // original -> bgp:remove-private-as @@ -1046,7 +1046,7 @@ type NeighborConfig struct { //bgp:local-as's original type is inet:as-number LocalAs uint32 // original -> bgp:peer-type - PeerType PeerTypeDef + PeerType PeerType // original -> bgp:auth-password AuthPassword string // original -> bgp:remove-private-as diff --git a/tools/pyang_plugins/bgpyang2golang.py b/tools/pyang_plugins/bgpyang2golang.py index b409a562..bbb8519e 100644 --- a/tools/pyang_plugins/bgpyang2golang.py +++ b/tools/pyang_plugins/bgpyang2golang.py @@ -330,8 +330,6 @@ def visit_typedef(ctx, module): # print(stmts.path) name = stmts.arg stmts.golang_name = convert_to_golang(name) - if stmts.golang_name == 'PeerType': - stmts.golang_name = 'PeerTypeDef' child_map[name] = stmts ctx.golang_typedef_map[prefix] = child_map |