diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-07-11 18:49:57 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-01-09 05:17:57 -0800 |
commit | 26c03bb779fbb59bb3de1c98a2c9d65e192b50bb (patch) | |
tree | f68629f1089561e494b26291bf3ec548c7eb93ef /table | |
parent | 6733b6afb27f3dd3943d8325d2656f9e98740c17 (diff) |
tools: avoid adding a new option to bgpyang2golang.py and fix gobgp.yang
pyang has an internal flag "multiple_modules" to handle multiple yang modules.
use it instead of introducing a new option --augment
also, fix warnings and errors in gobgp.yang which were there but not has been
detected for a while due to the usage of --augment.
by using "multiple_modules" flag, pyang detected them.
most notable error is wrong usage of list, which needs a key in its
substatement.
this patch adds key to some of them, and for others uses leaf-list
instead.
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r-- | table/policy.go | 65 | ||||
-rw-r--r-- | table/policy_test.go | 285 |
2 files changed, 111 insertions, 239 deletions
diff --git a/table/policy.go b/table/policy.go index 83c8f882..c9e65300 100644 --- a/table/policy.go +++ b/table/policy.go @@ -508,16 +508,16 @@ func NewNeighborSetFromApiStruct(a *api.DefinedSet) (*NeighborSet, error) { func NewNeighborSet(c config.NeighborSet) (*NeighborSet, error) { name := c.NeighborSetName if name == "" { - if len(c.NeighborInfoList) == 0 { + if len(c.NeighborInfo) == 0 { return nil, nil } return nil, fmt.Errorf("empty neighbor set name") } - list := make([]net.IP, 0, len(c.NeighborInfoList)) - for _, x := range c.NeighborInfoList { - addr := net.ParseIP(x.Address) + list := make([]net.IP, 0, len(c.NeighborInfo)) + for _, x := range c.NeighborInfo { + addr := net.ParseIP(x) if addr == nil { - return nil, fmt.Errorf("invalid address: %s", x.Address) + return nil, fmt.Errorf("invalid address: %s", x) } list = append(list, addr) } @@ -695,10 +695,7 @@ func (s *AsPathSet) ToApiStruct() *api.DefinedSet { func NewAsPathSetFromApiStruct(a *api.DefinedSet) (*AsPathSet, error) { c := config.AsPathSet{ AsPathSetName: a.Name, - AsPathList: make([]config.AsPath, 0, len(a.List)), - } - for _, x := range a.List { - c.AsPathList = append(c.AsPathList, config.AsPath{AsPath: x}) + AsPath: a.List, } return NewAsPathSet(c) } @@ -706,18 +703,18 @@ func NewAsPathSetFromApiStruct(a *api.DefinedSet) (*AsPathSet, error) { func NewAsPathSet(c config.AsPathSet) (*AsPathSet, error) { name := c.AsPathSetName if name == "" { - if len(c.AsPathList) == 0 { + if len(c.AsPath) == 0 { return nil, nil } return nil, fmt.Errorf("empty as-path set name") } - list := make([]*regexp.Regexp, 0, len(c.AsPathList)) - singleList := make([]*singleAsPathMatch, 0, len(c.AsPathList)) - for _, x := range c.AsPathList { - if s := NewSingleAsPathMatch(x.AsPath); s != nil { + list := make([]*regexp.Regexp, 0, len(c.AsPath)) + singleList := make([]*singleAsPathMatch, 0, len(c.AsPath)) + for _, x := range c.AsPath { + if s := NewSingleAsPathMatch(x); s != nil { singleList = append(singleList, s) } else { - exp, err := regexp.Compile(strings.Replace(x.AsPath, "_", ASPATH_REGEXP_MAGIC, -1)) + exp, err := regexp.Compile(strings.Replace(x, "_", ASPATH_REGEXP_MAGIC, -1)) if err != nil { return nil, fmt.Errorf("invalid regular expression: %s", x) } @@ -900,10 +897,7 @@ func ParseExtCommunityRegexp(arg string) (bgp.ExtendedCommunityAttrSubType, *reg func NewCommunitySetFromApiStruct(a *api.DefinedSet) (*CommunitySet, error) { c := config.CommunitySet{ CommunitySetName: a.Name, - CommunityList: make([]config.Community, 0, len(a.List)), - } - for _, x := range a.List { - c.CommunityList = append(c.CommunityList, config.Community{Community: x}) + Community: a.List, } return NewCommunitySet(c) } @@ -911,14 +905,14 @@ func NewCommunitySetFromApiStruct(a *api.DefinedSet) (*CommunitySet, error) { func NewCommunitySet(c config.CommunitySet) (*CommunitySet, error) { name := c.CommunitySetName if name == "" { - if len(c.CommunityList) == 0 { + if len(c.Community) == 0 { return nil, nil } return nil, fmt.Errorf("empty community set name") } - list := make([]*regexp.Regexp, 0, len(c.CommunityList)) - for _, x := range c.CommunityList { - exp, err := ParseCommunityRegexp(x.Community) + list := make([]*regexp.Regexp, 0, len(c.Community)) + for _, x := range c.Community { + exp, err := ParseCommunityRegexp(x) if err != nil { return nil, err } @@ -963,10 +957,7 @@ func (s *ExtCommunitySet) ToApiStruct() *api.DefinedSet { func NewExtCommunitySetFromApiStruct(a *api.DefinedSet) (*ExtCommunitySet, error) { c := config.ExtCommunitySet{ ExtCommunitySetName: a.Name, - ExtCommunityList: make([]config.ExtCommunity, 0, len(a.List)), - } - for _, x := range a.List { - c.ExtCommunityList = append(c.ExtCommunityList, config.ExtCommunity{ExtCommunity: x}) + ExtCommunity: a.List, } return NewExtCommunitySet(c) } @@ -974,15 +965,15 @@ func NewExtCommunitySetFromApiStruct(a *api.DefinedSet) (*ExtCommunitySet, error func NewExtCommunitySet(c config.ExtCommunitySet) (*ExtCommunitySet, error) { name := c.ExtCommunitySetName if name == "" { - if len(c.ExtCommunityList) == 0 { + if len(c.ExtCommunity) == 0 { return nil, nil } return nil, fmt.Errorf("empty ext-community set name") } - list := make([]*regexp.Regexp, 0, len(c.ExtCommunityList)) - subtypeList := make([]bgp.ExtendedCommunityAttrSubType, 0, len(c.ExtCommunityList)) - for _, x := range c.ExtCommunityList { - subtype, exp, err := ParseExtCommunityRegexp(x.ExtCommunity) + list := make([]*regexp.Regexp, 0, len(c.ExtCommunity)) + subtypeList := make([]bgp.ExtendedCommunityAttrSubType, 0, len(c.ExtCommunity)) + for _, x := range c.ExtCommunity { + subtype, exp, err := ParseExtCommunityRegexp(x) if err != nil { return nil, err } @@ -2794,18 +2785,16 @@ func NewRoutingPolicy() *RoutingPolicy { } func CanImportToVrf(v *Vrf, path *Path) bool { - f := func(arg []bgp.ExtendedCommunityInterface) []config.ExtCommunity { - ret := make([]config.ExtCommunity, 0, len(arg)) + f := func(arg []bgp.ExtendedCommunityInterface) []string { + ret := make([]string, 0, len(arg)) for _, a := range arg { - ret = append(ret, config.ExtCommunity{ - ExtCommunity: fmt.Sprintf("RT:%s", a.String()), - }) + ret = append(ret, fmt.Sprintf("RT:%s", a.String())) } return ret } set, _ := NewExtCommunitySet(config.ExtCommunitySet{ ExtCommunitySetName: v.Name, - ExtCommunityList: f(v.ImportRt), + ExtCommunity: f(v.ImportRt), }) matchSet := config.MatchExtCommunitySet{ ExtCommunitySet: v.Name, diff --git a/table/policy_test.go b/table/policy_test.go index 1ab6acce..099804d7 100644 --- a/table/policy_test.go +++ b/table/policy_test.go @@ -700,45 +700,32 @@ func TestAsPathConditionEvaluate(t *testing.T) { // create match condition asPathSet1 := config.AsPathSet{ AsPathSetName: "asset1", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "^65001"}, - }, + AsPath: []string{"^65001"}, } asPathSet2 := config.AsPathSet{ AsPathSetName: "asset2", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "65005$"}, - }, + AsPath: []string{"65005$"}, } asPathSet3 := config.AsPathSet{ AsPathSetName: "asset3", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "65004"}, - config.AsPath{AsPath: "65005$"}, - }, + AsPath: []string{"65004", "65005$"}, } asPathSet4 := config.AsPathSet{ AsPathSetName: "asset4", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "65000$"}, - }, + AsPath: []string{"65000$"}, } asPathSet5 := config.AsPathSet{ AsPathSetName: "asset5", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "65010"}, - }, + AsPath: []string{"65010"}, } asPathSet6 := config.AsPathSet{ AsPathSetName: "asset6", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "^65010$"}, - }, + AsPath: []string{"^65010$"}, } m := make(map[string]DefinedSet) @@ -798,65 +785,47 @@ func TestMultipleAsPathConditionEvaluate(t *testing.T) { // create match condition asPathSet1 := config.AsPathSet{ AsPathSetName: "asset1", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "^65001_65000"}, - }, + AsPath: []string{"^65001_65000"}, } asPathSet2 := config.AsPathSet{ AsPathSetName: "asset2", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "65004_65005$"}, - }, + AsPath: []string{"65004_65005$"}, } asPathSet3 := config.AsPathSet{ AsPathSetName: "asset3", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "65001_65000_54000"}, - }, + AsPath: []string{"65001_65000_54000"}, } asPathSet4 := config.AsPathSet{ AsPathSetName: "asset4", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "54000_65004_65005"}, - }, + AsPath: []string{"54000_65004_65005"}, } asPathSet5 := config.AsPathSet{ AsPathSetName: "asset5", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "^65001 65000 54000 65004 65005$"}, - }, + AsPath: []string{"^65001 65000 54000 65004 65005$"}, } asPathSet6 := config.AsPathSet{ AsPathSetName: "asset6", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: ".*_[0-9]+_65005"}, - }, + AsPath: []string{".*_[0-9]+_65005"}, } asPathSet7 := config.AsPathSet{ AsPathSetName: "asset7", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: ".*_5[0-9]+_[0-9]+"}, - }, + AsPath: []string{".*_5[0-9]+_[0-9]+"}, } asPathSet8 := config.AsPathSet{ AsPathSetName: "asset8", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "6[0-9]+_6[0-9]+_5[0-9]+"}, - }, + AsPath: []string{"6[0-9]+_6[0-9]+_5[0-9]+"}, } asPathSet9 := config.AsPathSet{ AsPathSetName: "asset9", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "6[0-9]+__6[0-9]+"}, - }, + AsPath: []string{"6[0-9]+__6[0-9]+"}, } m := make(map[string]DefinedSet) @@ -945,7 +914,7 @@ func TestAsPathCondition(t *testing.T) { for k, v := range tests { s, _ := NewAsPathSet(config.AsPathSet{ AsPathSetName: k, - AsPathList: []config.AsPath{config.AsPath{AsPath: k}}, + AsPath: []string{k}, }) c, _ := NewAsPathCondition(config.MatchAsPathSet{ AsPathSet: k, @@ -987,7 +956,7 @@ func TestAsPathConditionWithOtherCondition(t *testing.T) { // create policy asPathSet := config.AsPathSet{ AsPathSetName: "asset1", - AsPathList: []config.AsPath{config.AsPath{AsPath: "65005$"}}, + AsPath: []string{"65005$"}, } ps := createPrefixSet("ps1", "10.10.1.0/16", "21..24") @@ -1053,44 +1022,40 @@ func TestAs4PathConditionEvaluate(t *testing.T) { // create match condition asPathSet1 := config.AsPathSet{ AsPathSetName: "asset1", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("^%d", createAs4Value("65001.1"))}, - }, + AsPath: []string{fmt.Sprintf("^%d", createAs4Value("65001.1"))}, } asPathSet2 := config.AsPathSet{ AsPathSetName: "asset2", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("%d$", createAs4Value("65005.1"))}, - }, + AsPath: []string{fmt.Sprintf("%d$", createAs4Value("65005.1"))}, } asPathSet3 := config.AsPathSet{ AsPathSetName: "asset3", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("%d", createAs4Value("65004.1"))}, - config.AsPath{AsPath: fmt.Sprintf("%d$", createAs4Value("65005.1"))}, + AsPath: []string{ + fmt.Sprintf("%d", createAs4Value("65004.1")), + fmt.Sprintf("%d$", createAs4Value("65005.1")), }, } asPathSet4 := config.AsPathSet{ AsPathSetName: "asset4", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("%d$", createAs4Value("65000.1"))}, + AsPath: []string{ + fmt.Sprintf("%d$", createAs4Value("65000.1")), }, } asPathSet5 := config.AsPathSet{ AsPathSetName: "asset5", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("%d", createAs4Value("65010.1"))}, + AsPath: []string{ + fmt.Sprintf("%d", createAs4Value("65010.1")), }, } asPathSet6 := config.AsPathSet{ AsPathSetName: "asset6", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("%d$", createAs4Value("65010.1"))}, + AsPath: []string{ + fmt.Sprintf("%d$", createAs4Value("65010.1")), }, } @@ -1160,65 +1125,59 @@ func TestMultipleAs4PathConditionEvaluate(t *testing.T) { // create match condition asPathSet1 := config.AsPathSet{ AsPathSetName: "asset1", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("^%d_%d", createAs4Value("65001.1"), createAs4Value("65000.1"))}, + AsPath: []string{ + fmt.Sprintf("^%d_%d", createAs4Value("65001.1"), createAs4Value("65000.1")), }, } asPathSet2 := config.AsPathSet{ AsPathSetName: "asset2", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("%d_%d$", createAs4Value("65004.1"), createAs4Value("65005.1"))}, + AsPath: []string{ + fmt.Sprintf("%d_%d$", createAs4Value("65004.1"), createAs4Value("65005.1")), }, } asPathSet3 := config.AsPathSet{ AsPathSetName: "asset3", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("%d_%d_%d", createAs4Value("65001.1"), createAs4Value("65000.1"), createAs4Value("54000.1"))}, + AsPath: []string{ + fmt.Sprintf("%d_%d_%d", createAs4Value("65001.1"), createAs4Value("65000.1"), createAs4Value("54000.1")), }, } asPathSet4 := config.AsPathSet{ AsPathSetName: "asset4", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("%d_%d_%d", createAs4Value("54000.1"), createAs4Value("65004.1"), createAs4Value("65005.1"))}, + AsPath: []string{ + fmt.Sprintf("%d_%d_%d", createAs4Value("54000.1"), createAs4Value("65004.1"), createAs4Value("65005.1")), }, } asPathSet5 := config.AsPathSet{ AsPathSetName: "asset5", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("^%d %d %d %d %d$", createAs4Value("65001.1"), createAs4Value("65000.1"), createAs4Value("54000.1"), createAs4Value("65004.1"), createAs4Value("65005.1"))}, + AsPath: []string{ + fmt.Sprintf("^%d %d %d %d %d$", createAs4Value("65001.1"), createAs4Value("65000.1"), createAs4Value("54000.1"), createAs4Value("65004.1"), createAs4Value("65005.1")), }, } asPathSet6 := config.AsPathSet{ AsPathSetName: "asset6", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf(".*_[0-9]+_%d", createAs4Value("65005.1"))}, + AsPath: []string{ + fmt.Sprintf(".*_[0-9]+_%d", createAs4Value("65005.1")), }, } asPathSet7 := config.AsPathSet{ AsPathSetName: "asset7", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: ".*_3[0-9]+_[0-9]+"}, - }, + AsPath: []string{".*_3[0-9]+_[0-9]+"}, } asPathSet8 := config.AsPathSet{ AsPathSetName: "asset8", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "4[0-9]+_4[0-9]+_3[0-9]+"}, - }, + AsPath: []string{"4[0-9]+_4[0-9]+_3[0-9]+"}, } asPathSet9 := config.AsPathSet{ AsPathSetName: "asset9", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "4[0-9]+__4[0-9]+"}, - }, + AsPath: []string{"4[0-9]+__4[0-9]+"}, } m := make(map[string]DefinedSet) @@ -1291,9 +1250,7 @@ func TestAs4PathConditionWithOtherCondition(t *testing.T) { // create policy asPathSet := config.AsPathSet{ AsPathSetName: "asset1", - AsPathList: []config.AsPath{config.AsPath{ - AsPath: fmt.Sprintf("%d$", createAs4Value("65005.1")), - }}, + AsPath: []string{fmt.Sprintf("%d$", createAs4Value("65005.1"))}, } ps := createPrefixSet("ps1", "10.10.1.0/16", "21..24") @@ -1351,52 +1308,37 @@ func TestAs4PathConditionEvaluateMixedWith2byteAS(t *testing.T) { // create match condition asPathSet1 := config.AsPathSet{ AsPathSetName: "asset1", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("^%d", createAs4Value("65001.1"))}, - }, + AsPath: []string{fmt.Sprintf("^%d", createAs4Value("65001.1"))}, } asPathSet2 := config.AsPathSet{ AsPathSetName: "asset2", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "4000$"}, - }, + AsPath: []string{"4000$"}, } asPathSet3 := config.AsPathSet{ AsPathSetName: "asset3", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("%d", createAs4Value("65004.1"))}, - config.AsPath{AsPath: "4000$"}, - }, + AsPath: []string{fmt.Sprintf("%d", createAs4Value("65004.1")), "4000$"}, } asPathSet4 := config.AsPathSet{ AsPathSetName: "asset4", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: fmt.Sprintf("%d_%d_%d", createAs4Value("54000.1"), 100, 5000)}, - }, + AsPath: []string{fmt.Sprintf("%d_%d_%d", createAs4Value("54000.1"), 100, 5000)}, } asPathSet5 := config.AsPathSet{ AsPathSetName: "asset5", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: ".*_[0-9]+_100"}, - }, + AsPath: []string{".*_[0-9]+_100"}, } asPathSet6 := config.AsPathSet{ AsPathSetName: "asset6", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: ".*_3[0-9]+_[0]+"}, - }, + AsPath: []string{".*_3[0-9]+_[0]+"}, } asPathSet7 := config.AsPathSet{ AsPathSetName: "asset7", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: ".*_3[0-9]+_[1]+"}, - }, + AsPath: []string{".*_3[0-9]+_[1]+"}, } m := make(map[string]DefinedSet) @@ -1478,76 +1420,58 @@ func TestCommunityConditionEvaluate(t *testing.T) { // create match condition comSet1 := config.CommunitySet{ CommunitySetName: "comset1", - CommunityList: []config.Community{ - config.Community{Community: "65001:10"}, - config.Community{Community: "65001:50"}, - config.Community{Community: "65001:100"}, - }, + Community: []string{"65001:10", "65001:50", "65001:100"}, } comSet2 := config.CommunitySet{ CommunitySetName: "comset2", - CommunityList: []config.Community{ - config.Community{Community: "65001:200"}, - }, + Community: []string{"65001:200"}, } comSet3 := config.CommunitySet{ CommunitySetName: "comset3", - CommunityList: []config.Community{ - config.Community{Community: "4259905936"}, - }, + Community: []string{"4259905936"}, } comSet4 := config.CommunitySet{ CommunitySetName: "comset4", - CommunityList: []config.Community{ - config.Community{Community: "^[0-9]*:300$"}, - }, + Community: []string{"^[0-9]*:300$"}, } comSet5 := config.CommunitySet{ CommunitySetName: "comset5", - CommunityList: []config.Community{ - config.Community{Community: "INTERNET"}, - }, + Community: []string{"INTERNET"}, } comSet6 := config.CommunitySet{ CommunitySetName: "comset6", - CommunityList: []config.Community{ - config.Community{Community: "NO_EXPORT"}, - }, + Community: []string{"NO_EXPORT"}, } comSet7 := config.CommunitySet{ CommunitySetName: "comset7", - CommunityList: []config.Community{ - config.Community{Community: "NO_ADVERTISE"}, - }, + Community: []string{"NO_ADVERTISE"}, } comSet8 := config.CommunitySet{ CommunitySetName: "comset8", - CommunityList: []config.Community{ - config.Community{Community: "NO_EXPORT_SUBCONFED"}, - }, + Community: []string{"NO_EXPORT_SUBCONFED"}, } comSet9 := config.CommunitySet{ CommunitySetName: "comset9", - CommunityList: []config.Community{ - config.Community{Community: "65001:\\d+"}, - config.Community{Community: "\\d+:\\d00"}, + Community: []string{ + "65001:\\d+", + "\\d+:\\d00", }, } comSet10 := config.CommunitySet{ CommunitySetName: "comset10", - CommunityList: []config.Community{ - config.Community{Community: "65001:1"}, - config.Community{Community: "65001:2"}, - config.Community{Community: "65001:3"}, + Community: []string{ + "65001:1", + "65001:2", + "65001:3", }, } @@ -1628,25 +1552,17 @@ func TestCommunityConditionEvaluateWithOtherCondition(t *testing.T) { // create policy asPathSet := config.AsPathSet{ AsPathSetName: "asset1", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "65005$"}, - }, + AsPath: []string{"65005$"}, } comSet1 := config.CommunitySet{ CommunitySetName: "comset1", - CommunityList: []config.Community{ - config.Community{Community: "65001:100"}, - config.Community{Community: "65001:200"}, - config.Community{Community: "65001:300"}, - }, + Community: []string{"65001:100", "65001:200", "65001:300"}, } comSet2 := config.CommunitySet{ CommunitySetName: "comset2", - CommunityList: []config.Community{ - config.Community{Community: "65050:\\d+"}, - }, + Community: []string{"65050:\\d+"}, } ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24") @@ -2044,72 +1960,48 @@ func TestExtCommunityConditionEvaluate(t *testing.T) { // create match condition ecomSet1 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet1", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "RT:65001:200"}, - }, + ExtCommunity: []string{"RT:65001:200"}, } ecomSet2 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet2", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "RT:10.0.0.1:300"}, - }, + ExtCommunity: []string{"RT:10.0.0.1:300"}, } ecomSet3 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet3", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: fmt.Sprintf("RT:%s:200", convUintStr(65030000))}, - }, + ExtCommunity: []string{fmt.Sprintf("RT:%s:200", convUintStr(65030000))}, } ecomSet4 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet4", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "RT:65002:200"}, - }, + ExtCommunity: []string{"RT:65002:200"}, } ecomSet5 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet5", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "RT:10.0.0.2:300"}, - }, + ExtCommunity: []string{"RT:10.0.0.2:300"}, } ecomSet6 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet6", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: fmt.Sprintf("RT:%s:200", convUintStr(65030001))}, - }, + ExtCommunity: []string{fmt.Sprintf("RT:%s:200", convUintStr(65030001))}, } ecomSet7 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet7", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "SoO:65010:300"}, - }, + ExtCommunity: []string{"SoO:65010:300"}, } ecomSet8 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet8", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "SoO:10.0.10.10:[0-9]+"}, - }, + ExtCommunity: []string{"SoO:10.0.10.10:[0-9]+"}, } ecomSet9 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet9", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "RT:[0-9]+:[0-9]+"}, - }, + ExtCommunity: []string{"RT:[0-9]+:[0-9]+"}, } ecomSet10 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet10", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "RT:.+:\\d00"}, - config.ExtCommunity{ExtCommunity: "SoO:.+:\\d00"}, - }, + ExtCommunity: []string{"RT:.+:\\d00", "SoO:.+:\\d00"}, } ecomSet11 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet11", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "RT:65001:2"}, - config.ExtCommunity{ExtCommunity: "SoO:11.0.10.10:[0-9]+"}, - }, + ExtCommunity: []string{"RT:65001:2", "SoO:11.0.10.10:[0-9]+"}, } m := make(map[string]DefinedSet) @@ -2240,22 +2132,16 @@ func TestExtCommunityConditionEvaluateWithOtherCondition(t *testing.T) { // create policy asPathSet := config.AsPathSet{ AsPathSetName: "asset1", - AsPathList: []config.AsPath{ - config.AsPath{AsPath: "65005$"}, - }, + AsPath: []string{"65005$"}, } ecomSet1 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet1", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "RT:65001:201"}, - }, + ExtCommunity: []string{"RT:65001:201"}, } ecomSet2 := config.ExtCommunitySet{ ExtCommunitySetName: "ecomSet2", - ExtCommunityList: []config.ExtCommunity{ - config.ExtCommunity{ExtCommunity: "RT:[0-9]+:[0-9]+"}, - }, + ExtCommunity: []string{"RT:[0-9]+:[0-9]+"}, } ps := createPrefixSet("ps1", "10.10.1.0/16", "21..24") @@ -2837,10 +2723,7 @@ func createPrefixSet(name string, prefix string, maskLength string) config.Prefi func createNeighborSet(name string, addr string) config.NeighborSet { ns := config.NeighborSet{ NeighborSetName: name, - NeighborInfoList: []config.NeighborInfo{ - config.NeighborInfo{ - Address: addr, - }}, + NeighborInfo: []string{addr}, } return ns } |