mirror of
https://github.com/osrg/gobgp.git
synced 2024-05-11 05:55:10 +00:00
test: enable parallel execution of policy test
Signed-off-by: ISHIDA Wataru <[email protected]>
This commit is contained in:
@@ -36,6 +36,7 @@ BGP_ATTR_TYPE_AS_PATH = 2
|
||||
BGP_ATTR_TYPE_NEXT_HOP = 3
|
||||
BGP_ATTR_TYPE_MULTI_EXIT_DISC = 4
|
||||
BGP_ATTR_TYPE_LOCAL_PREF = 5
|
||||
BGP_ATTR_TYPE_COMMUNITIES = 8
|
||||
BGP_ATTR_TYPE_MP_REACH_NLRI = 14
|
||||
BGP_ATTR_TYPE_EXTENDED_COMMUNITIES = 16
|
||||
|
||||
@@ -158,7 +159,13 @@ class Container(object):
|
||||
for sv in self.shared_volumes:
|
||||
c << "-v {0}:{1}".format(sv[0], sv[1])
|
||||
c << "--name {0} -id {1}".format(self.docker_name(), self.image)
|
||||
self.id = local(str(c), capture=True)
|
||||
for i in range(3):
|
||||
try:
|
||||
self.id = local(str(c), capture=True)
|
||||
except:
|
||||
time.sleep(1)
|
||||
else:
|
||||
break
|
||||
self.is_running = True
|
||||
self.local("ip li set up dev lo")
|
||||
return 0
|
||||
@@ -216,7 +223,7 @@ class BGPContainer(Container):
|
||||
super(BGPContainer, self).run()
|
||||
return self.WAIT_FOR_BOOT
|
||||
|
||||
def add_peer(self, peer, passwd='', evpn=False, is_rs_client=False,
|
||||
def add_peer(self, peer, passwd=None, evpn=False, is_rs_client=False,
|
||||
policies=None, passive=False,
|
||||
is_rr_client=False, cluster_id='',
|
||||
flowspec=False):
|
||||
@@ -231,7 +238,7 @@ class BGPContainer(Container):
|
||||
raise Exception('peer {0} seems not ip reachable'.format(peer))
|
||||
|
||||
if not policies:
|
||||
policies = []
|
||||
policies = {}
|
||||
|
||||
self.peers[peer] = {'neigh_addr': neigh_addr,
|
||||
'passwd': passwd,
|
||||
@@ -259,10 +266,16 @@ class BGPContainer(Container):
|
||||
def enable_peer(self, peer):
|
||||
raise Exception('implement enable_peer() method')
|
||||
|
||||
def add_route(self, route, rf='ipv4', attribute=None, matchs=None, thens=None):
|
||||
def add_route(self, route, rf='ipv4', attribute=None, aspath=None,
|
||||
community=None, med=None, extendedcommunity=None,
|
||||
matchs=None, thens=None):
|
||||
self.routes[route] = {'prefix': route,
|
||||
'rf': rf,
|
||||
'attr': attribute,
|
||||
'as-path': aspath,
|
||||
'community': community,
|
||||
'med': med,
|
||||
'extended-community': extendedcommunity,
|
||||
'matchs': matchs,
|
||||
'thens' : thens}
|
||||
if self.is_running:
|
||||
@@ -272,7 +285,7 @@ class BGPContainer(Container):
|
||||
def add_policy(self, policy, peer=None):
|
||||
self.policies[policy['name']] = policy
|
||||
if peer in self.peers:
|
||||
self.peers[peer]['policies'].append(policy)
|
||||
self.peers[peer]['policies'][policy['name']] = policy
|
||||
if self.is_running:
|
||||
self.create_config()
|
||||
self.reload_config()
|
||||
|
||||
@@ -76,15 +76,25 @@ class ExaBGPContainer(BGPContainer):
|
||||
cmd << ' local-as {0};'.format(self.asn)
|
||||
cmd << ' peer-as {0};'.format(peer.asn)
|
||||
|
||||
routes = [r for r in self.routes.values() if r['rf'] == 'ipv4']
|
||||
routes = [r for r in self.routes.values() if r['rf'] == 'ipv4' or r['rf'] == 'ipv6']
|
||||
|
||||
if len(routes) > 0:
|
||||
cmd << ' static {'
|
||||
for route in routes:
|
||||
r = CmdBuffer(' ')
|
||||
r << ' route {0} next-hop {1}'.format(route['prefix'], local_addr)
|
||||
if route['as-path']:
|
||||
r << 'as-path [{0}]'.format(' '.join(str(i) for i in route['as-path']))
|
||||
if route['community']:
|
||||
r << 'community [{0}]'.format(' '.join(c for c in route['community']))
|
||||
if route['med']:
|
||||
r << 'med {0}'.format(route['med'])
|
||||
if route['extended-community']:
|
||||
r << 'extended-community [{0}]'.format(route['extended-community'])
|
||||
if route['attr']:
|
||||
cmd << ' route {0} next-hop {1};'.format(route['prefix'], local_addr)
|
||||
else:
|
||||
cmd << ' route {0} next-hop {1} attribute {2};'.format(route['prefix'], local_addr, attr)
|
||||
r << 'attribute {0}'.format(route['attr'])
|
||||
|
||||
cmd << '{0};'.format(str(r))
|
||||
cmd << ' }'
|
||||
|
||||
routes = [r for r in self.routes.values() if r['rf'] == 'ipv4-flowspec']
|
||||
|
||||
@@ -21,8 +21,6 @@ from itertools import chain
|
||||
|
||||
class GoBGPContainer(BGPContainer):
|
||||
|
||||
PEER_TYPE_INTERNAL = 0
|
||||
PEER_TYPE_EXTERNAL = 1
|
||||
SHARED_VOLUME = '/root/shared_volume'
|
||||
|
||||
def __init__(self, name, asn, router_id, ctn_image_name='gobgp',
|
||||
@@ -31,6 +29,10 @@ class GoBGPContainer(BGPContainer):
|
||||
ctn_image_name)
|
||||
self.shared_volumes.append((self.config_dir, self.SHARED_VOLUME))
|
||||
self.log_level = log_level
|
||||
self.prefix_set = None
|
||||
self.neighbor_set = None
|
||||
self.bgp_set = None
|
||||
self.default_policy = None
|
||||
|
||||
def _start_gobgp(self):
|
||||
c = CmdBuffer()
|
||||
@@ -75,11 +77,17 @@ class GoBGPContainer(BGPContainer):
|
||||
def enable_peer(self, peer):
|
||||
self._trigger_peer_cmd('enable', peer)
|
||||
|
||||
def get_local_rib(self, peer, rf='ipv4'):
|
||||
def reset(self, peer):
|
||||
self._trigger_peer_cmd('reset', peer)
|
||||
|
||||
def softreset(self, peer, rf='ipv4', type='in'):
|
||||
self._trigger_peer_cmd('softreset{0} -a {1}'.format(type, rf), peer)
|
||||
|
||||
def get_local_rib(self, peer, prefix='', rf='ipv4'):
|
||||
if peer not in self.peers:
|
||||
raise Exception('not found peer {0}'.format(peer.router_id))
|
||||
peer_addr = self.peers[peer]['neigh_addr'].split('/')[0]
|
||||
cmd = 'gobgp -j neighbor {0} local -a {1}'.format(peer_addr, rf)
|
||||
cmd = 'gobgp -j neighbor {0} local {1} -a {2}'.format(peer_addr, prefix, rf)
|
||||
output = self.local(cmd, capture=True)
|
||||
ret = json.loads(output)
|
||||
for d in ret:
|
||||
@@ -126,14 +134,26 @@ class GoBGPContainer(BGPContainer):
|
||||
output = self.local(cmd, capture=True)
|
||||
return json.loads(output)['info']['bgp_state']
|
||||
|
||||
def clear_policy(self):
|
||||
self.policies = {}
|
||||
for info in self.peers.itervalues():
|
||||
info['policies'] = {}
|
||||
self.prefix_set = []
|
||||
self.neighbor_set = []
|
||||
self.statements = []
|
||||
|
||||
def set_prefix_set(self, ps):
|
||||
self.prefix_set = ps
|
||||
|
||||
def set_neighbor_set(self, ns):
|
||||
self.neighbor_set = ns
|
||||
|
||||
def set_bgp_defined_set(self, bs):
|
||||
self.bgp_set = bs
|
||||
|
||||
def create_config(self):
|
||||
config = {'Global': {'GlobalConfig': {'As': self.asn, 'RouterId': self.router_id}}}
|
||||
for peer, info in self.peers.iteritems():
|
||||
if self.asn == peer.asn:
|
||||
peer_type = self.PEER_TYPE_INTERNAL
|
||||
else:
|
||||
peer_type = self.PEER_TYPE_EXTERNAL
|
||||
|
||||
afi_safi_list = []
|
||||
version = netaddr.IPNetwork(info['neigh_addr']).version
|
||||
if version == 4:
|
||||
@@ -155,7 +175,6 @@ class GoBGPContainer(BGPContainer):
|
||||
{'NeighborAddress': info['neigh_addr'].split('/')[0],
|
||||
'PeerAs': peer.asn,
|
||||
'AuthPassword': info['passwd'],
|
||||
'PeerType': peer_type,
|
||||
},
|
||||
'AfiSafis': {'AfiSafiList': afi_safi_list}
|
||||
}
|
||||
@@ -171,11 +190,68 @@ class GoBGPContainer(BGPContainer):
|
||||
n['RouteReflector'] = {'RouteReflectorClient': True,
|
||||
'RouteReflectorClusterId': clusterId}
|
||||
|
||||
f = lambda typ: [p for p in info['policies'].itervalues() if p['type'] == typ]
|
||||
import_policies = f('import')
|
||||
export_policies = f('export')
|
||||
in_policies = f('in')
|
||||
f = lambda typ: [p['default'] for p in info['policies'].itervalues() if p['type'] == typ and 'default' in p]
|
||||
default_import_policy = f('import')
|
||||
default_export_policy = f('export')
|
||||
default_in_policy = f('in')
|
||||
|
||||
if len(import_policies) + len(export_policies) + len(in_policies) + len(default_import_policy) \
|
||||
+ len(default_export_policy) + len(default_in_policy) > 0:
|
||||
n['ApplyPolicy'] = {'ApplyPolicyConfig': {}}
|
||||
|
||||
if len(import_policies) > 0:
|
||||
n['ApplyPolicy']['ApplyPolicyConfig']['ImportPolicy'] = [p['name'] for p in import_policies]
|
||||
|
||||
if len(export_policies) > 0:
|
||||
n['ApplyPolicy']['ApplyPolicyConfig']['ExportPolicy'] = [p['name'] for p in export_policies]
|
||||
|
||||
if len(in_policies) > 0:
|
||||
n['ApplyPolicy']['ApplyPolicyConfig']['InPolicy'] = [p['name'] for p in in_policies]
|
||||
|
||||
def f(v):
|
||||
if v == 'reject':
|
||||
return 1
|
||||
elif v == 'accept':
|
||||
return 0
|
||||
raise Exception('invalid default policy type {0}'.format(v))
|
||||
|
||||
if len(default_import_policy) > 0:
|
||||
n['ApplyPolicy']['ApplyPolicyConfig']['DefaultImportPolicy'] = f(default_import_policy[0])
|
||||
|
||||
if len(default_export_policy) > 0:
|
||||
n['ApplyPolicy']['ApplyPolicyConfig']['DefaultExportPolicy'] = f(default_export_policy[0])
|
||||
|
||||
if len(default_in_policy) > 0:
|
||||
n['ApplyPolicy']['ApplyPolicyConfig']['DefaultInPolicy'] = f(default_in_policy[0])
|
||||
|
||||
if 'Neighbors' not in config:
|
||||
config['Neighbors'] = {'NeighborList': []}
|
||||
|
||||
config['Neighbors']['NeighborList'].append(n)
|
||||
|
||||
config['DefinedSets'] = {}
|
||||
if self.prefix_set:
|
||||
config['DefinedSets']['PrefixSets'] = {'PrefixSetList': [self.prefix_set]}
|
||||
|
||||
if self.neighbor_set:
|
||||
config['DefinedSets']['NeighborSets'] = {'NeighborSetList': [self.neighbor_set]}
|
||||
|
||||
if self.bgp_set:
|
||||
config['DefinedSets']['BgpDefinedSets'] = self.bgp_set
|
||||
|
||||
policy_list = []
|
||||
for p in self.policies.itervalues():
|
||||
policy = {'Name': p['name'],
|
||||
'Statements':{'StatementList': p['statements']}}
|
||||
policy_list.append(policy)
|
||||
|
||||
if len(policy_list) > 0:
|
||||
config['PolicyDefinitions'] = {'PolicyDefinitionList': policy_list}
|
||||
|
||||
with open('{0}/gobgpd.conf'.format(self.config_dir), 'w') as f:
|
||||
print colors.yellow('[{0}\'s new config]'.format(self.name))
|
||||
print colors.yellow(indent(toml.dumps(config)))
|
||||
|
||||
@@ -61,6 +61,7 @@ class QuaggaBGPContainer(BGPContainer):
|
||||
tn.write('show bgp {0} unicast\n'.format(rf))
|
||||
tn.read_until(' Network Next Hop Metric '
|
||||
'LocPrf Weight Path')
|
||||
read_next = False
|
||||
for line in tn.read_until('bgpd#').split('\n'):
|
||||
if line[:2] == '*>':
|
||||
line = line[2:]
|
||||
@@ -68,9 +69,24 @@ class QuaggaBGPContainer(BGPContainer):
|
||||
if line[0] == 'i':
|
||||
line = line[1:]
|
||||
ibgp = True
|
||||
elems = line.split()
|
||||
rib.append({'prefix': elems[0], 'nexthop': elems[1],
|
||||
'ibgp': ibgp})
|
||||
elif not read_next:
|
||||
continue
|
||||
|
||||
elems = line.split()
|
||||
|
||||
if len(elems) == 1:
|
||||
read_next = True
|
||||
prefix = elems[0]
|
||||
continue
|
||||
elif read_next:
|
||||
nexthop = elems[0]
|
||||
else:
|
||||
prefix = elems[0]
|
||||
nexthop = elems[1]
|
||||
read_next = False
|
||||
|
||||
rib.append({'prefix': prefix, 'nexthop': nexthop,
|
||||
'ibgp': ibgp})
|
||||
|
||||
return rib
|
||||
|
||||
@@ -149,12 +165,11 @@ class QuaggaBGPContainer(BGPContainer):
|
||||
c << 'no bgp default ipv4-unicast'
|
||||
|
||||
c << 'neighbor {0} remote-as {1}'.format(n_addr, peer.asn)
|
||||
for policy in info['policies']:
|
||||
name = policy['name']
|
||||
for name, policy in info['policies'].iteritems():
|
||||
direction = policy['direction']
|
||||
c << 'neighbor {0} route-map {1} {2}'.format(n_addr, name,
|
||||
direction)
|
||||
if info['passwd'] != '':
|
||||
if info['passwd']:
|
||||
c << 'neighbor {0} password {1}'.format(n_addr, info['passwd'])
|
||||
if version == 6:
|
||||
c << 'address-family ipv6 unicast'
|
||||
|
||||
@@ -14,6 +14,7 @@ class OptionParser(Plugin):
|
||||
parser.add_option('--go-path', action="store", dest="go_path", default="")
|
||||
parser.add_option('--gobgp-log-level', action="store",
|
||||
dest="gobgp_log_level", default="info")
|
||||
parser.add_option('--test-index', action="store", type="int", dest="test_index", default=0)
|
||||
|
||||
def configure(self, options, conf):
|
||||
super(OptionParser, self).configure(options, conf)
|
||||
|
||||
@@ -1,789 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/jessevdk/go-flags"
|
||||
"github.com/osrg/gobgp/config"
|
||||
)
|
||||
|
||||
func bindPolicy(outputDir, peer, target, policyName string, isReplace bool, defaultReject bool) {
|
||||
|
||||
newConf := config.Bgp{}
|
||||
_, d_err := toml.DecodeFile(fmt.Sprintf("%s/gobgpd.conf", outputDir), &newConf)
|
||||
if d_err != nil {
|
||||
log.Fatal(d_err)
|
||||
}
|
||||
|
||||
for idx, neighbor := range newConf.Neighbors.NeighborList {
|
||||
ip := net.ParseIP(peer)
|
||||
|
||||
if ip.String() == neighbor.NeighborConfig.NeighborAddress.String() {
|
||||
ap := &neighbor.ApplyPolicy.ApplyPolicyConfig
|
||||
switch target {
|
||||
case "import":
|
||||
if isReplace {
|
||||
ap.ImportPolicy = []string{policyName}
|
||||
} else {
|
||||
ap.ImportPolicy = append(ap.ImportPolicy, policyName)
|
||||
}
|
||||
if defaultReject {
|
||||
ap.DefaultImportPolicy = 1
|
||||
}
|
||||
case "export":
|
||||
if isReplace {
|
||||
ap.ExportPolicy = []string{policyName}
|
||||
} else {
|
||||
ap.ExportPolicy = append(ap.ExportPolicy, policyName)
|
||||
}
|
||||
if defaultReject {
|
||||
ap.DefaultExportPolicy = 1
|
||||
}
|
||||
case "distribute":
|
||||
if isReplace {
|
||||
ap.InPolicy = []string{policyName}
|
||||
} else {
|
||||
ap.InPolicy = append(ap.InPolicy, policyName)
|
||||
}
|
||||
if defaultReject {
|
||||
ap.DefaultInPolicy = 1
|
||||
}
|
||||
}
|
||||
newConf.Neighbors.NeighborList[idx] = neighbor
|
||||
}
|
||||
}
|
||||
|
||||
policyConf := createPolicyConfig()
|
||||
var buffer bytes.Buffer
|
||||
encoder := toml.NewEncoder(&buffer)
|
||||
encoder.Encode(newConf)
|
||||
encoder.Encode(policyConf)
|
||||
|
||||
e_err := ioutil.WriteFile(fmt.Sprintf("%s/gobgpd.conf", outputDir), buffer.Bytes(), 0644)
|
||||
if e_err != nil {
|
||||
log.Fatal(e_err)
|
||||
}
|
||||
}
|
||||
|
||||
func createPolicyConfig() *config.RoutingPolicy {
|
||||
|
||||
ps0 := config.PrefixSet{
|
||||
PrefixSetName: "ps0",
|
||||
PrefixList: []config.Prefix{
|
||||
config.Prefix{
|
||||
IpPrefix: "192.168.0.0/16",
|
||||
MasklengthRange: "16..24",
|
||||
}},
|
||||
}
|
||||
|
||||
ps1 := config.PrefixSet{
|
||||
PrefixSetName: "ps1",
|
||||
PrefixList: []config.Prefix{
|
||||
config.Prefix{
|
||||
IpPrefix: "192.168.20.0/24",
|
||||
}, config.Prefix{
|
||||
IpPrefix: "192.168.200.0/24",
|
||||
}},
|
||||
}
|
||||
|
||||
ps2 := config.PrefixSet{
|
||||
PrefixSetName: "ps2",
|
||||
PrefixList: []config.Prefix{
|
||||
config.Prefix{
|
||||
IpPrefix: "192.168.20.0/24",
|
||||
}},
|
||||
}
|
||||
|
||||
ps3 := config.PrefixSet{
|
||||
PrefixSetName: "ps3",
|
||||
PrefixList: []config.Prefix{
|
||||
config.Prefix{
|
||||
IpPrefix: "2001:0:10:2::/64",
|
||||
MasklengthRange: "64..128",
|
||||
}},
|
||||
}
|
||||
|
||||
ps4 := config.PrefixSet{
|
||||
PrefixSetName: "ps4",
|
||||
PrefixList: []config.Prefix{
|
||||
config.Prefix{
|
||||
IpPrefix: "2001:0:10:20::/64",
|
||||
}, config.Prefix{
|
||||
IpPrefix: "2001:0:10:200::/64",
|
||||
}},
|
||||
}
|
||||
|
||||
ps5 := config.PrefixSet{
|
||||
PrefixSetName: "ps5",
|
||||
PrefixList: []config.Prefix{
|
||||
config.Prefix{
|
||||
IpPrefix: "2001:0:10:20::/64",
|
||||
}},
|
||||
}
|
||||
|
||||
ps6 := config.PrefixSet{
|
||||
PrefixSetName: "ps6",
|
||||
PrefixList: []config.Prefix{
|
||||
config.Prefix{
|
||||
IpPrefix: "192.168.10.0/24",
|
||||
}},
|
||||
}
|
||||
|
||||
nsPeer2 := config.NeighborSet{
|
||||
NeighborSetName: "nsPeer2",
|
||||
NeighborInfoList: []config.NeighborInfo{
|
||||
config.NeighborInfo{
|
||||
Address: net.ParseIP("10.0.0.2"),
|
||||
}},
|
||||
}
|
||||
|
||||
nsPeer2V6 := config.NeighborSet{
|
||||
NeighborSetName: "nsPeer2V6",
|
||||
NeighborInfoList: []config.NeighborInfo{
|
||||
config.NeighborInfo{
|
||||
Address: net.ParseIP("2001::0:192:168:0:2"),
|
||||
}},
|
||||
}
|
||||
|
||||
nsExabgp := config.NeighborSet{
|
||||
NeighborSetName: "nsExabgp",
|
||||
NeighborInfoList: []config.NeighborInfo{
|
||||
config.NeighborInfo{
|
||||
Address: net.ParseIP("10.0.0.100"),
|
||||
}},
|
||||
}
|
||||
|
||||
psExabgp := config.PrefixSet{
|
||||
PrefixSetName: "psExabgp",
|
||||
PrefixList: []config.Prefix{
|
||||
config.Prefix{
|
||||
IpPrefix: "192.168.100.0/24",
|
||||
MasklengthRange: "16..24",
|
||||
}},
|
||||
}
|
||||
|
||||
aspathFrom := config.AsPathSet{
|
||||
AsPathSetName: "aspathFrom",
|
||||
AsPathList: []config.AsPath{
|
||||
config.AsPath{"^65100"},
|
||||
},
|
||||
}
|
||||
|
||||
aspathAny := config.AsPathSet{
|
||||
AsPathSetName: "aspAny",
|
||||
AsPathList: []config.AsPath{
|
||||
config.AsPath{"65098"},
|
||||
},
|
||||
}
|
||||
|
||||
aspathOrigin := config.AsPathSet{
|
||||
AsPathSetName: "aspOrigin",
|
||||
AsPathList: []config.AsPath{
|
||||
config.AsPath{"65091$"},
|
||||
},
|
||||
}
|
||||
|
||||
aspathOnly := config.AsPathSet{
|
||||
AsPathSetName: "aspOnly",
|
||||
AsPathList: []config.AsPath{
|
||||
config.AsPath{"^65100$"},
|
||||
},
|
||||
}
|
||||
|
||||
comStr := config.CommunitySet{
|
||||
CommunitySetName: "comStr",
|
||||
CommunityList: []config.Community{
|
||||
config.Community{"65100:10"},
|
||||
},
|
||||
}
|
||||
|
||||
comRegExp := config.CommunitySet{
|
||||
CommunitySetName: "comRegExp",
|
||||
CommunityList: []config.Community{
|
||||
config.Community{"6[0-9]+:[0-9]+"},
|
||||
},
|
||||
}
|
||||
eComOrigin := config.ExtCommunitySet{
|
||||
ExtCommunitySetName: "eComOrigin",
|
||||
ExtCommunityList: []config.ExtCommunity{
|
||||
config.ExtCommunity{"SoO:65001.65100:200"},
|
||||
},
|
||||
}
|
||||
eComTarget := config.ExtCommunitySet{
|
||||
ExtCommunitySetName: "eComTarget",
|
||||
ExtCommunityList: []config.ExtCommunity{
|
||||
config.ExtCommunity{"RT:6[0-9]+:3[0-9]+"},
|
||||
},
|
||||
}
|
||||
|
||||
createStatement := func(name string, ps, ns string, accept bool) config.Statement {
|
||||
st := config.Statement{}
|
||||
st.Name = name
|
||||
st.Actions.RouteDisposition.AcceptRoute = accept
|
||||
|
||||
if ps != "" {
|
||||
st.Conditions.MatchPrefixSet.PrefixSet = ps
|
||||
}
|
||||
|
||||
if ns != "" {
|
||||
st.Conditions.MatchNeighborSet.NeighborSet = ns
|
||||
}
|
||||
|
||||
return st
|
||||
}
|
||||
|
||||
st0 := createStatement("st0", "ps0", "nsPeer2", false)
|
||||
st1 := createStatement("st1", "ps1", "nsPeer2", false)
|
||||
st2 := createStatement("st2", "ps2", "nsPeer2", false)
|
||||
st3 := createStatement("st3", "ps3", "nsPeer2V6", false)
|
||||
st4 := createStatement("st4", "ps4", "nsPeer2V6", false)
|
||||
st5 := createStatement("st5", "ps5", "nsPeer2V6", false)
|
||||
|
||||
st_aspathlen := createStatement("st_aspathlen", "psExabgp", "nsExabgp", false)
|
||||
st_aspathlen.Conditions.BgpConditions.AsPathLength.Operator = "ge"
|
||||
st_aspathlen.Conditions.BgpConditions.AsPathLength.Value = 10
|
||||
|
||||
st_aspathFrom := createStatement("st_aspathFrom", "psExabgp", "nsExabgp", false)
|
||||
st_aspathFrom.Conditions.BgpConditions.MatchAsPathSet.AsPathSet = "aspathFrom"
|
||||
|
||||
st_aspathAny := createStatement("st_aspathAny", "psExabgp", "nsExabgp", false)
|
||||
st_aspathAny.Conditions.BgpConditions.MatchAsPathSet.AsPathSet = "aspAny"
|
||||
|
||||
st_aspathOrigin := createStatement("st_aspathOrigin", "psExabgp", "nsExabgp", false)
|
||||
st_aspathOrigin.Conditions.BgpConditions.MatchAsPathSet.AsPathSet = "aspOrigin"
|
||||
|
||||
st_aspathOnly := createStatement("st_aspathOnly", "psExabgp", "nsExabgp", false)
|
||||
st_aspathOnly.Conditions.BgpConditions.MatchAsPathSet.AsPathSet = "aspOnly"
|
||||
|
||||
st_comStr := createStatement("st_community", "psExabgp", "nsExabgp", false)
|
||||
st_comStr.Conditions.BgpConditions.MatchCommunitySet.CommunitySet = "comStr"
|
||||
|
||||
st_comRegExp := createStatement("st_community_regexp", "psExabgp", "nsExabgp", false)
|
||||
st_comRegExp.Conditions.BgpConditions.MatchCommunitySet.CommunitySet = "comRegExp"
|
||||
|
||||
st_comAdd := createStatement("st_community_regexp", "psExabgp", "nsExabgp", true)
|
||||
st_comAdd.Conditions.BgpConditions.MatchCommunitySet.CommunitySet = "comStr"
|
||||
st_comAdd.Actions.BgpActions.SetCommunity.SetCommunityMethod.Communities = []string{"65100:20"}
|
||||
st_comAdd.Actions.BgpActions.SetCommunity.Options = "ADD"
|
||||
|
||||
st_comReplace := createStatement("st_community_regexp", "psExabgp", "nsExabgp", true)
|
||||
st_comReplace.Conditions.BgpConditions.MatchCommunitySet.CommunitySet = "comStr"
|
||||
st_comReplace.Actions.BgpActions.SetCommunity.SetCommunityMethod.Communities = []string{"65100:20", "65100:30"}
|
||||
st_comReplace.Actions.BgpActions.SetCommunity.Options = "REPLACE"
|
||||
|
||||
st_comRemove := createStatement("st_community_regexp", "psExabgp", "nsExabgp", true)
|
||||
st_comRemove.Conditions.BgpConditions.MatchCommunitySet.CommunitySet = "comStr"
|
||||
st_comRemove.Actions.BgpActions.SetCommunity.SetCommunityMethod.Communities = []string{"65100:20", "65100:30"}
|
||||
st_comRemove.Actions.BgpActions.SetCommunity.Options = "REMOVE"
|
||||
|
||||
st_comNull := createStatement("st_community_regexp", "psExabgp", "nsExabgp", true)
|
||||
st_comNull.Conditions.BgpConditions.MatchCommunitySet.CommunitySet = "comStr"
|
||||
st_comNull.Actions.BgpActions.SetCommunity.SetCommunityMethod.Communities = []string{}
|
||||
//use REPLACE instead of NULL
|
||||
st_comNull.Actions.BgpActions.SetCommunity.Options = "REPLACE"
|
||||
|
||||
st_medReplace := createStatement("st_medReplace", "psExabgp", "nsExabgp", true)
|
||||
st_medReplace.Actions.BgpActions.SetMed = "100"
|
||||
|
||||
st_medAdd := createStatement("st_medAdd", "psExabgp", "nsExabgp", true)
|
||||
st_medAdd.Actions.BgpActions.SetMed = "+100"
|
||||
|
||||
st_medSub := createStatement("st_medSub", "psExabgp", "nsExabgp", true)
|
||||
st_medSub.Actions.BgpActions.SetMed = "-100"
|
||||
|
||||
st_distribute_reject := createStatement("st_community_distriibute", "", "", false)
|
||||
st_distribute_reject.Conditions.BgpConditions.MatchCommunitySet.CommunitySet = "comStr"
|
||||
|
||||
st_distribute_accept := createStatement("st_distriibute_accept", "ps6", "", true)
|
||||
|
||||
st_distribute_comm_add := createStatement("st_distribute_comm_add", "", "", true)
|
||||
st_distribute_comm_add.Conditions.BgpConditions.MatchCommunitySet.CommunitySet = "comStr"
|
||||
st_distribute_comm_add.Actions.BgpActions.SetCommunity.SetCommunityMethod.Communities = []string{"65100:20"}
|
||||
st_distribute_comm_add.Actions.BgpActions.SetCommunity.Options = "ADD"
|
||||
|
||||
st_distribute_med_add := createStatement("st_distribute_med_add", "psExabgp", "nsExabgp", true)
|
||||
st_distribute_med_add.Actions.BgpActions.SetMed = "+100"
|
||||
|
||||
st_asprepend := createStatement("st_asprepend", "psExabgp", "nsExabgp", true)
|
||||
st_asprepend.Actions.BgpActions.SetAsPathPrepend.As = "65005"
|
||||
st_asprepend.Actions.BgpActions.SetAsPathPrepend.RepeatN = 5
|
||||
|
||||
st_asprepend_lastas := createStatement("st_asprepend_lastas", "psExabgp", "nsExabgp", true)
|
||||
st_asprepend_lastas.Actions.BgpActions.SetAsPathPrepend.As = "last-as"
|
||||
st_asprepend_lastas.Actions.BgpActions.SetAsPathPrepend.RepeatN = 5
|
||||
|
||||
st_eComOrigin := createStatement("st_eComAS4", "psExabgp", "nsExabgp", false)
|
||||
st_eComOrigin.Conditions.BgpConditions.MatchExtCommunitySet.ExtCommunitySet = "eComOrigin"
|
||||
|
||||
st_eComTarget := createStatement("st_eComRegExp", "psExabgp", "nsExabgp", false)
|
||||
st_eComTarget.Conditions.BgpConditions.MatchExtCommunitySet.ExtCommunitySet = "eComTarget"
|
||||
|
||||
st_only_prefix_condition_accept := createStatement("st_only_prefix_condition_accept", "psExabgp", "", true)
|
||||
|
||||
st_extcomAdd := createStatement("st_extcommunity_add", "psExabgp", "nsExabgp", true)
|
||||
st_extcomAdd.Actions.BgpActions.SetExtCommunity.SetExtCommunityMethod.Communities = []string{"0:2:0xfd:0xe8:0:0:0:1"}
|
||||
st_extcomAdd.Actions.BgpActions.SetExtCommunity.Options = "ADD"
|
||||
|
||||
st_extcomAdd_append := createStatement("st_extcommunity_add_append", "psExabgp", "nsExabgp", true)
|
||||
st_extcomAdd_append.Actions.BgpActions.SetExtCommunity.SetExtCommunityMethod.Communities = []string{"0:2:0xfe:0x4c:0:0:0:0x64"}
|
||||
st_extcomAdd_append.Actions.BgpActions.SetExtCommunity.Options = "ADD"
|
||||
|
||||
st_extcomAdd_multiple := createStatement("st_extcommunity_add_multiple", "psExabgp", "nsExabgp", true)
|
||||
st_extcomAdd_multiple.Actions.BgpActions.SetExtCommunity.SetExtCommunityMethod.Communities = []string{"0:2:0xfe:0x4c:0:0:0:0x64", "0:2:0:0x64:0:0:0:0x64"}
|
||||
st_extcomAdd_multiple.Actions.BgpActions.SetExtCommunity.Options = "ADD"
|
||||
|
||||
test_01_import_policy_initial := config.PolicyDefinition{
|
||||
Name: "test_01_import_policy_initial",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st0},
|
||||
},
|
||||
}
|
||||
|
||||
test_02_export_policy_initial := config.PolicyDefinition{
|
||||
Name: "test_02_export_policy_initial",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st0},
|
||||
},
|
||||
}
|
||||
|
||||
test_03_import_policy_update := config.PolicyDefinition{
|
||||
Name: "test_03_import_policy_update",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st1},
|
||||
},
|
||||
}
|
||||
|
||||
test_03_import_policy_update_softreset := config.PolicyDefinition{
|
||||
Name: "test_03_import_policy_update_softreset",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st2},
|
||||
},
|
||||
}
|
||||
|
||||
test_04_export_policy_update := config.PolicyDefinition{
|
||||
Name: "test_04_export_policy_update",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st1},
|
||||
},
|
||||
}
|
||||
|
||||
test_04_export_policy_update_softreset := config.PolicyDefinition{
|
||||
Name: "test_04_export_policy_update_softreset",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st2},
|
||||
},
|
||||
}
|
||||
|
||||
test_05_import_policy_initial_ipv6 := config.PolicyDefinition{
|
||||
Name: "test_05_import_policy_initial_ipv6",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st3},
|
||||
},
|
||||
}
|
||||
|
||||
test_06_export_policy_initial_ipv6 := config.PolicyDefinition{
|
||||
Name: "test_06_export_policy_initial_ipv6",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st3},
|
||||
},
|
||||
}
|
||||
|
||||
test_07_import_policy_update := config.PolicyDefinition{
|
||||
Name: "test_07_import_policy_update",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st4},
|
||||
},
|
||||
}
|
||||
|
||||
test_07_import_policy_update_softreset := config.PolicyDefinition{
|
||||
Name: "test_07_import_policy_update_softreset",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st5},
|
||||
},
|
||||
}
|
||||
|
||||
test_08_export_policy_update := config.PolicyDefinition{
|
||||
Name: "test_08_export_policy_update",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st4},
|
||||
},
|
||||
}
|
||||
|
||||
test_08_export_policy_update_softreset := config.PolicyDefinition{
|
||||
Name: "test_08_export_policy_update_softreset",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st5},
|
||||
},
|
||||
}
|
||||
|
||||
test_09_aspath_length_condition_import := config.PolicyDefinition{
|
||||
Name: "test_09_aspath_length_condition_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_aspathlen},
|
||||
},
|
||||
}
|
||||
|
||||
test_10_aspath_from_condition_import := config.PolicyDefinition{
|
||||
Name: "test_10_aspath_from_condition_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_aspathFrom},
|
||||
},
|
||||
}
|
||||
|
||||
test_11_aspath_any_condition_import := config.PolicyDefinition{
|
||||
Name: "test_11_aspath_any_condition_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_aspathAny},
|
||||
},
|
||||
}
|
||||
|
||||
test_12_aspath_origin_condition_import := config.PolicyDefinition{
|
||||
Name: "test_12_aspath_origin_condition_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_aspathOrigin},
|
||||
},
|
||||
}
|
||||
|
||||
test_13_aspath_only_condition_import := config.PolicyDefinition{
|
||||
Name: "test_13_aspath_only_condition_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_aspathOnly},
|
||||
},
|
||||
}
|
||||
|
||||
test_14_aspath_only_condition_import := config.PolicyDefinition{
|
||||
Name: "test_14_aspath_only_condition_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_comStr},
|
||||
},
|
||||
}
|
||||
|
||||
test_15_community_condition_import := config.PolicyDefinition{
|
||||
Name: "test_15_community_condition_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_comStr},
|
||||
},
|
||||
}
|
||||
|
||||
test_16_community_condition_regexp_import := config.PolicyDefinition{
|
||||
Name: "test_16_community_condition_regexp_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_comRegExp},
|
||||
},
|
||||
}
|
||||
|
||||
test_17_community_add_action_import := config.PolicyDefinition{
|
||||
Name: "test_17_community_add_action_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_comAdd},
|
||||
},
|
||||
}
|
||||
|
||||
test_18_community_replace_action_import := config.PolicyDefinition{
|
||||
Name: "test_18_community_replace_action_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_comReplace},
|
||||
},
|
||||
}
|
||||
|
||||
test_19_community_remove_action_import := config.PolicyDefinition{
|
||||
Name: "test_19_community_remove_action_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_comRemove},
|
||||
},
|
||||
}
|
||||
|
||||
test_20_community_null_action_import := config.PolicyDefinition{
|
||||
Name: "test_20_community_null_action_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_comNull},
|
||||
},
|
||||
}
|
||||
|
||||
test_21_community_add_action_export := config.PolicyDefinition{
|
||||
Name: "test_21_community_add_action_export",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_comAdd},
|
||||
},
|
||||
}
|
||||
|
||||
test_22_community_replace_action_export := config.PolicyDefinition{
|
||||
Name: "test_22_community_replace_action_export",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_comReplace},
|
||||
},
|
||||
}
|
||||
|
||||
test_23_community_remove_action_export := config.PolicyDefinition{
|
||||
Name: "test_23_community_remove_action_export",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_comRemove},
|
||||
},
|
||||
}
|
||||
|
||||
test_24_community_null_action_export := config.PolicyDefinition{
|
||||
Name: "test_24_community_null_action_export",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_comNull},
|
||||
},
|
||||
}
|
||||
|
||||
test_25_med_replace_action_import := config.PolicyDefinition{
|
||||
Name: "test_25_med_replace_action_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_medReplace},
|
||||
},
|
||||
}
|
||||
|
||||
test_26_med_add_action_import := config.PolicyDefinition{
|
||||
Name: "test_26_med_add_action_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_medAdd},
|
||||
},
|
||||
}
|
||||
|
||||
test_27_med_subtract_action_import := config.PolicyDefinition{
|
||||
Name: "test_27_med_subtract_action_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_medSub},
|
||||
},
|
||||
}
|
||||
|
||||
test_28_med_replace_action_export := config.PolicyDefinition{
|
||||
Name: "test_28_med_replace_action_export",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_medReplace},
|
||||
},
|
||||
}
|
||||
|
||||
test_29_med_add_action_export := config.PolicyDefinition{
|
||||
Name: "test_29_med_add_action_export",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_medAdd},
|
||||
},
|
||||
}
|
||||
|
||||
test_30_med_subtract_action_export := config.PolicyDefinition{
|
||||
Name: "test_30_med_subtract_action_export",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_medSub},
|
||||
},
|
||||
}
|
||||
|
||||
test_31_distribute_reject := config.PolicyDefinition{
|
||||
Name: "test_31_distribute_reject",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_distribute_reject},
|
||||
},
|
||||
}
|
||||
|
||||
test_32_distribute_accept := config.PolicyDefinition{
|
||||
Name: "test_32_distribute_accept",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_distribute_accept},
|
||||
},
|
||||
}
|
||||
|
||||
test_33_distribute_set_community_action := config.PolicyDefinition{
|
||||
Name: "test_33_distribute_set_community_action",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_distribute_comm_add},
|
||||
},
|
||||
}
|
||||
|
||||
test_34_distribute_set_med_action := config.PolicyDefinition{
|
||||
Name: "test_34_distribute_set_med_action",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_distribute_med_add},
|
||||
},
|
||||
}
|
||||
|
||||
test_35_distribute_policy_update := config.PolicyDefinition{
|
||||
Name: "test_35_distribute_policy_update",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st1},
|
||||
},
|
||||
}
|
||||
|
||||
test_35_distribute_policy_update_softreset := config.PolicyDefinition{
|
||||
Name: "test_35_distribute_policy_update_softreset",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st2},
|
||||
},
|
||||
}
|
||||
|
||||
test_36_aspath_prepend_action_import := config.PolicyDefinition{
|
||||
Name: "test_36_aspath_prepend_action_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_asprepend},
|
||||
},
|
||||
}
|
||||
|
||||
test_37_aspath_prepend_action_export := config.PolicyDefinition{
|
||||
Name: "test_37_aspath_prepend_action_export",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_asprepend},
|
||||
},
|
||||
}
|
||||
|
||||
test_38_aspath_prepend_action_lastas_import := config.PolicyDefinition{
|
||||
Name: "test_38_aspath_prepend_action_lastas_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_asprepend_lastas},
|
||||
},
|
||||
}
|
||||
|
||||
test_39_aspath_prepend_action_lastas_export := config.PolicyDefinition{
|
||||
Name: "test_39_aspath_prepend_action_lastas_export",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_asprepend_lastas},
|
||||
},
|
||||
}
|
||||
|
||||
test_40_ecommunity_origin_condition_import := config.PolicyDefinition{
|
||||
Name: "test_40_ecommunity_origin_condition_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_eComOrigin},
|
||||
},
|
||||
}
|
||||
|
||||
test_41_ecommunity_target_condition_export := config.PolicyDefinition{
|
||||
Name: "test_41_ecommunity_target_condition_export",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_eComTarget},
|
||||
},
|
||||
}
|
||||
|
||||
test_42_only_prefix_condition_accept := config.PolicyDefinition{
|
||||
Name: "test_42_only_prefix_condition_accept",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_only_prefix_condition_accept},
|
||||
},
|
||||
}
|
||||
|
||||
test_43_extcommunity_add_action_import := config.PolicyDefinition{
|
||||
Name: "test_43_extcommunity_add_action_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_extcomAdd},
|
||||
},
|
||||
}
|
||||
|
||||
test_44_extcommunity_add_action_append_import := config.PolicyDefinition{
|
||||
Name: "test_44_extcommunity_add_action_append_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_extcomAdd_append},
|
||||
},
|
||||
}
|
||||
|
||||
test_45_extcommunity_add_action_multiple_import := config.PolicyDefinition{
|
||||
Name: "test_45_extcommunity_add_action_multiple_import",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_extcomAdd_multiple},
|
||||
},
|
||||
}
|
||||
|
||||
test_46_extcommunity_add_action_export := config.PolicyDefinition{
|
||||
Name: "test_46_extcommunity_add_action_export",
|
||||
Statements: config.Statements{
|
||||
StatementList: []config.Statement{st_extcomAdd},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
ds := config.DefinedSets{}
|
||||
ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps0, ps1, ps2, ps3, ps4, ps5, ps6, psExabgp}
|
||||
ds.NeighborSets.NeighborSetList = []config.NeighborSet{nsPeer2, nsPeer2V6, nsExabgp}
|
||||
ds.BgpDefinedSets.AsPathSets.AsPathSetList = []config.AsPathSet{aspathFrom, aspathAny, aspathOrigin, aspathOnly}
|
||||
ds.BgpDefinedSets.CommunitySets.CommunitySetList = []config.CommunitySet{comStr, comRegExp}
|
||||
ds.BgpDefinedSets.ExtCommunitySets.ExtCommunitySetList = []config.ExtCommunitySet{eComOrigin, eComTarget}
|
||||
|
||||
p := &config.RoutingPolicy{
|
||||
DefinedSets: ds,
|
||||
PolicyDefinitions: config.PolicyDefinitions{
|
||||
PolicyDefinitionList: []config.PolicyDefinition{
|
||||
test_01_import_policy_initial,
|
||||
test_02_export_policy_initial,
|
||||
test_03_import_policy_update,
|
||||
test_03_import_policy_update_softreset,
|
||||
test_04_export_policy_update,
|
||||
test_04_export_policy_update_softreset,
|
||||
test_05_import_policy_initial_ipv6,
|
||||
test_06_export_policy_initial_ipv6,
|
||||
test_07_import_policy_update,
|
||||
test_07_import_policy_update_softreset,
|
||||
test_08_export_policy_update,
|
||||
test_08_export_policy_update_softreset,
|
||||
test_09_aspath_length_condition_import,
|
||||
test_10_aspath_from_condition_import,
|
||||
test_11_aspath_any_condition_import,
|
||||
test_12_aspath_origin_condition_import,
|
||||
test_13_aspath_only_condition_import,
|
||||
test_14_aspath_only_condition_import,
|
||||
test_15_community_condition_import,
|
||||
test_16_community_condition_regexp_import,
|
||||
test_17_community_add_action_import,
|
||||
test_18_community_replace_action_import,
|
||||
test_19_community_remove_action_import,
|
||||
test_20_community_null_action_import,
|
||||
test_21_community_add_action_export,
|
||||
test_22_community_replace_action_export,
|
||||
test_23_community_remove_action_export,
|
||||
test_24_community_null_action_export,
|
||||
test_25_med_replace_action_import,
|
||||
test_26_med_add_action_import,
|
||||
test_27_med_subtract_action_import,
|
||||
test_28_med_replace_action_export,
|
||||
test_29_med_add_action_export,
|
||||
test_30_med_subtract_action_export,
|
||||
test_31_distribute_reject,
|
||||
test_32_distribute_accept,
|
||||
test_33_distribute_set_community_action,
|
||||
test_34_distribute_set_med_action,
|
||||
test_35_distribute_policy_update,
|
||||
test_35_distribute_policy_update_softreset,
|
||||
test_36_aspath_prepend_action_import,
|
||||
test_37_aspath_prepend_action_export,
|
||||
test_38_aspath_prepend_action_lastas_import,
|
||||
test_39_aspath_prepend_action_lastas_export,
|
||||
test_40_ecommunity_origin_condition_import,
|
||||
test_41_ecommunity_target_condition_export,
|
||||
test_42_only_prefix_condition_accept,
|
||||
test_43_extcommunity_add_action_import,
|
||||
test_44_extcommunity_add_action_append_import,
|
||||
test_45_extcommunity_add_action_multiple_import,
|
||||
test_46_extcommunity_add_action_export,
|
||||
},
|
||||
},
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func main() {
|
||||
var opts struct {
|
||||
OutputDir string `short:"d" long:"output" description:"specifing the output directory"`
|
||||
Neighbor string `short:"n" long:"neighbor" description:"neighbor ip adress to which add policy config"`
|
||||
Target string `short:"t" long:"target" description:"target such as export or import to which add policy"`
|
||||
PolicyName string `short:"p" long:"policy" description:"policy name bound to peer"`
|
||||
Replace bool `short:"r" long:"replace" description:"Replace existing policy with new one" default:"false"`
|
||||
Reject bool `short:"j" long:"reject" description:"Set default policy reject" default:"false"`
|
||||
}
|
||||
|
||||
parser := flags.NewParser(&opts, flags.Default)
|
||||
_, err := parser.Parse()
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if _, err := os.Stat(opts.OutputDir + "/gobgpd.conf"); os.IsNotExist(err) {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
bindPolicy(opts.OutputDir, opts.Neighbor, opts.Target, opts.PolicyName, opts.Replace, opts.Reject)
|
||||
}
|
||||
@@ -85,7 +85,7 @@ class GoBGPIPv6Test(unittest.TestCase):
|
||||
for _ in range(self.retry_limit):
|
||||
if done:
|
||||
break
|
||||
local_rib = self.gobgp.get_local_rib(rs_client, rf)
|
||||
local_rib = self.gobgp.get_local_rib(rs_client, rf=rf)
|
||||
local_rib = [p['prefix'] for p in local_rib]
|
||||
if len(local_rib) < len(ctns)-1:
|
||||
time.sleep(self.wait_per_retry)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -39,11 +39,12 @@ if [ $RET1 != 0 ]; then
|
||||
fi
|
||||
|
||||
# route server policy test
|
||||
sudo -E python route_server_policy_test.py --gobgp-image $GOBGP_IMAGE --go-path $GOROOT/bin -s --with-xunit --xunit-file=${WS}/nosetest_policy.xml
|
||||
RET2=$?
|
||||
if [ $RET2 != 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
NUM=`sudo -E python route_server_policy_test.py -s 2>1 | awk '/invalid/{print $NF}'`
|
||||
for (( i = 1; i < $NUM; ++i ))
|
||||
do
|
||||
sudo -E python route_server_policy_test.py --gobgp-image $GOBGP_IMAGE --test-prefix p$i --test-index $i -s -x --with-xunit --xunit-file=${WS}/nosetest_policy${i}.xml &
|
||||
PIDS=("${PIDS[@]}" $!)
|
||||
done
|
||||
|
||||
# route server test
|
||||
sudo -E python route_server_test.py --gobgp-image $GOBGP_IMAGE --test-prefix rs -s -x --with-xunit --xunit-file=${WS}/nosetest.xml &
|
||||
|
||||
Reference in New Issue
Block a user