bgp: add parameter for site_of_origins to neighbor_add and vrf_add method

Fujita-san,
thank you for your comment and finding the bug that causes test case failure.
I fixed the second and resend the whole patch.

The first is the addition of site_of_origins parameter to neighbor_add and
vrf_add method and fixes to some import error.

Signed-off-by: Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Hiroshi Yokoi 2014-07-31 14:59:48 +09:00 committed by FUJITA Tomonori
parent 6630328fcc
commit cc3c00b663
3 changed files with 16 additions and 2 deletions

View File

@ -48,6 +48,7 @@ from ryu.services.protocols.bgp.rtconf.base import CAP_MBGP_IPV6
from ryu.services.protocols.bgp.rtconf.base import CAP_MBGP_VPNV4
from ryu.services.protocols.bgp.rtconf.base import CAP_MBGP_VPNV6
from ryu.services.protocols.bgp.rtconf.base import MULTI_EXIT_DISC
from ryu.services.protocols.bgp.rtconf.base import SITE_OF_ORIGINS
from ryu.services.protocols.bgp.rtconf.neighbors import DEFAULT_CAP_MBGP_IPV4
from ryu.services.protocols.bgp.rtconf.neighbors import DEFAULT_CAP_MBGP_VPNV4
from ryu.services.protocols.bgp.rtconf.neighbors import DEFAULT_CAP_MBGP_VPNV6
@ -175,7 +176,8 @@ class BGPSpeaker(object):
enable_ipv4=DEFAULT_CAP_MBGP_IPV4,
enable_vpnv4=DEFAULT_CAP_MBGP_VPNV4,
enable_vpnv6=DEFAULT_CAP_MBGP_VPNV6,
next_hop=None, password=None, multi_exit_disc=None):
next_hop=None, password=None, multi_exit_disc=None,
site_of_origins=None):
""" This method registers a new neighbor. The BGP speaker tries to
establish a bgp session with the peer (accepts a connection
from the peer and also tries to connect to it).
@ -206,6 +208,8 @@ class BGPSpeaker(object):
The default is None and if not specified, MED value is
not sent to the neighbor. It must be an integer.
``site_of_origins`` specifies site_of_origin values.
This parameter must be a list of string.
"""
bgp_neighbor = {}
bgp_neighbor[neighbors.IP_ADDRESS] = address
@ -230,6 +234,9 @@ class BGPSpeaker(object):
if multi_exit_disc:
bgp_neighbor[MULTI_EXIT_DISC] = multi_exit_disc
if site_of_origins:
bgp_neighbor[SITE_OF_ORIGINS] = site_of_origins
call('neighbor.create', **bgp_neighbor)
def neighbor_del(self, address):
@ -332,12 +339,16 @@ class BGPSpeaker(object):
``export_rts`` specifies route targets to be exported.
``site_of_origins`` specifies site_of_origin values.
This parameter must be a list of string.
"""
vrf = {}
vrf[vrfs.ROUTE_DISTINGUISHER] = route_dist
vrf[vrfs.IMPORT_RTS] = import_rts
vrf[vrfs.EXPORT_RTS] = export_rts
vrf[vrfs.SITE_OF_ORIGINS] = site_of_origins
call('vrf.create', **vrf)
def vrf_del(self, route_dist):

View File

@ -222,7 +222,7 @@ class VrfTable(Table):
local_administrator=int(local_admin),
subtype=subtype))
for soo in vrf_conf.soo_list:
as_num, local_admin = rt.split(':')
as_num, local_admin = soo.split(':')
subtype = 3
communities.append(BGPTwoOctetAsSpecificExtendedCommunity(
as_number=int(as_num),

View File

@ -79,6 +79,9 @@ from ryu.lib.packet.bgp import BGP_ATTR_TYPE_MULTI_EXIT_DISC
from ryu.lib.packet.bgp import BGP_ATTR_TYPE_COMMUNITIES
from ryu.lib.packet.bgp import BGP_ATTR_TYPE_EXTENDED_COMMUNITIES
from ryu.lib.packet.bgp import BGPTwoOctetAsSpecificExtendedCommunity
from ryu.lib.packet.bgp import BGPIPv4AddressSpecificExtendedCommunity
LOG = logging.getLogger('bgpspeaker.peer')