本文整理汇总了Python中yabgp.message.attribute.extcommunity.ExtCommunity.construct方法的典型用法代码示例。如果您正苦于以下问题:Python ExtCommunity.construct方法的具体用法?Python ExtCommunity.construct怎么用?Python ExtCommunity.construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yabgp.message.attribute.extcommunity.ExtCommunity
的用法示例。
在下文中一共展示了ExtCommunity.construct方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parse_construct_flowspec_redirect_vrf
# 需要导入模块: from yabgp.message.attribute.extcommunity import ExtCommunity [as 别名]
# 或者: from yabgp.message.attribute.extcommunity.ExtCommunity import construct [as 别名]
def test_parse_construct_flowspec_redirect_vrf(self):
community_list = [[bgp_cons.BGP_EXT_REDIRECT_VRF, '4837:100']]
self.assertEqual(b'\xc0\x10\x08\x80\x08\x12\xe5\x00\x00\x00d', ExtCommunity.construct(value=community_list))
community_hex = b'\x80\x08\x12\xe5\x00\x00\x00d'
self.assertEqual(community_list, ExtCommunity.parse(value=community_hex))
示例2: test_construct_ro1
# 需要导入模块: from yabgp.message.attribute.extcommunity import ExtCommunity [as 别名]
# 或者: from yabgp.message.attribute.extcommunity.ExtCommunity import construct [as 别名]
def test_construct_ro1(self):
ext_community = ExtCommunity.construct(value=[(bgp_cons.BGP_EXT_COM_RO_1, '10.10.10.10:12')])
self.assertEqual(b'\xc0\x10\x08\x01\x03\x0a\x0a\x0a\x0a\x00\x0c', ext_community)
示例3: test_construct_ro2
# 需要导入模块: from yabgp.message.attribute.extcommunity import ExtCommunity [as 别名]
# 或者: from yabgp.message.attribute.extcommunity.ExtCommunity import construct [as 别名]
def test_construct_ro2(self):
ext_community = ExtCommunity.construct(value=[(bgp_cons.BGP_EXT_COM_RO_2, '65537:12')])
self.assertEqual(b'\xc0\x10\x08\x02\x03\x00\x01\x00\x01\x00\x0c', ext_community)
示例4: test_parse_construct_tarffic_rate
# 需要导入模块: from yabgp.message.attribute.extcommunity import ExtCommunity [as 别名]
# 或者: from yabgp.message.attribute.extcommunity.ExtCommunity import construct [as 别名]
def test_parse_construct_tarffic_rate(self):
community_list = [[bgp_cons.BGP_EXT_TRA_RATE, "100:6250000"]]
self.assertEqual(b'\xc0\x10\x08\x80\x06\x00dJ\xbe\xbc ', ExtCommunity.construct(value=community_list))
self.assertEqual([[bgp_cons.BGP_EXT_TRA_RATE, "100:6250000"]],
ExtCommunity.parse(value=b'\x80\x06\x00dJ\xbe\xbc '))
示例5: test_construct_rt0
# 需要导入模块: from yabgp.message.attribute.extcommunity import ExtCommunity [as 别名]
# 或者: from yabgp.message.attribute.extcommunity.ExtCommunity import construct [as 别名]
def test_construct_rt0(self):
ext_community = ExtCommunity.construct(value=[(bgp_cons.BGP_EXT_COM_RT_0, '100:12')])
self.assertEqual(b'\xc0\x10\x08\x00\x02\x00\x64\x00\x00\x00\x0c', ext_community)
示例6: construct_attributes
# 需要导入模块: from yabgp.message.attribute.extcommunity import ExtCommunity [as 别名]
# 或者: from yabgp.message.attribute.extcommunity.ExtCommunity import construct [as 别名]
def construct_attributes(attr_dict, asn4=False):
"""
construts BGP Update attirubte.
:param attr_dict: bgp attribute dictionary
:param asn4: support 4 bytes asn or not
"""
attr_raw_hex = b''
for type_code, value in attr_dict.items():
if type_code == bgp_cons.BGPTYPE_ORIGIN:
origin_hex = Origin.construct(value=value)
attr_raw_hex += origin_hex
elif type_code == bgp_cons.BGPTYPE_AS_PATH:
aspath_hex = ASPath.construct(value=value, asn4=asn4)
attr_raw_hex += aspath_hex
elif type_code == bgp_cons.BGPTYPE_NEXT_HOP:
nexthop_hex = NextHop.construct(value=value)
attr_raw_hex += nexthop_hex
elif type_code == bgp_cons.BGPTYPE_MULTI_EXIT_DISC:
med_hex = MED.construct(value=value)
attr_raw_hex += med_hex
elif type_code == bgp_cons.BGPTYPE_LOCAL_PREF:
localpre_hex = LocalPreference.construct(value=value)
attr_raw_hex += localpre_hex
elif type_code == bgp_cons.BGPTYPE_ATOMIC_AGGREGATE:
atomicaggregate_hex = AtomicAggregate.construct(value=value)
attr_raw_hex += atomicaggregate_hex
elif type_code == bgp_cons.BGPTYPE_AGGREGATOR:
aggregator_hex = Aggregator.construct(value=value, asn4=asn4)
attr_raw_hex += aggregator_hex
elif type_code == bgp_cons.BGPTYPE_COMMUNITIES:
community_hex = Community.construct(value=value)
attr_raw_hex += community_hex
elif type_code == bgp_cons.BGPTYPE_ORIGINATOR_ID:
originatorid_hex = OriginatorID.construct(value=value)
attr_raw_hex += originatorid_hex
elif type_code == bgp_cons.BGPTYPE_CLUSTER_LIST:
clusterlist_hex = ClusterList.construct(value=value)
attr_raw_hex += clusterlist_hex
elif type_code == bgp_cons.BGPTYPE_MP_REACH_NLRI:
mpreach_hex = MpReachNLRI().construct(value=value)
attr_raw_hex += mpreach_hex
elif type_code == bgp_cons.BGPTYPE_MP_UNREACH_NLRI:
mpunreach_hex = MpUnReachNLRI.construct(value=value)
attr_raw_hex += mpunreach_hex
elif type_code == bgp_cons.BGPTYPE_EXTENDED_COMMUNITY:
community_ext_hex = ExtCommunity.construct(value=value)
attr_raw_hex += community_ext_hex
return attr_raw_hex
示例7: test_parse_construct_flowspec_redirect_nh
# 需要导入模块: from yabgp.message.attribute.extcommunity import ExtCommunity [as 别名]
# 或者: from yabgp.message.attribute.extcommunity.ExtCommunity import construct [as 别名]
def test_parse_construct_flowspec_redirect_nh(self):
community_list = [[bgp_cons.BGP_EXT_REDIRECT_NH, '0.0.0.0', 0]]
self.assertEqual(b'\xc0\x10\x08\x08\x00\x00\x00\x00\x00\x00\x00', ExtCommunity.construct(value=community_list))
self.assertEqual([[bgp_cons.BGP_EXT_REDIRECT_NH, '0.0.0.0', 0]],
ExtCommunity.parse(value=b'\x08\x00\x00\x00\x00\x00\x00\x00'))
示例8: test_parse_construct_evpn_route_mac
# 需要导入模块: from yabgp.message.attribute.extcommunity import ExtCommunity [as 别名]
# 或者: from yabgp.message.attribute.extcommunity.ExtCommunity import construct [as 别名]
def test_parse_construct_evpn_route_mac(self):
comunity_list = [[1539, '74-A0-2F-DE-FE-FB']]
community_hex = b'\x06\x03\x74\xa0\x2f\xde\xfe\xfb'
self.assertEqual(comunity_list, ExtCommunity.parse(community_hex))
self.assertEqual(community_hex, ExtCommunity.construct(comunity_list)[3:])
示例9: test_parse_construct_mac_mobil
# 需要导入模块: from yabgp.message.attribute.extcommunity import ExtCommunity [as 别名]
# 或者: from yabgp.message.attribute.extcommunity.ExtCommunity import construct [as 别名]
def test_parse_construct_mac_mobil(self):
community_list = [[bgp_cons.BGP_EXT_COM_EVPN_MAC_MOBIL, 1, 500]]
community_hex = b'\x06\x00\x01\x00\x00\x00\x01\xf4'
self.assertEqual(community_hex, ExtCommunity.construct(community_list)[3:])
self.assertEqual(community_list, ExtCommunity.parse(community_hex))
示例10: test_parse_construct_els_label
# 需要导入模块: from yabgp.message.attribute.extcommunity import ExtCommunity [as 别名]
# 或者: from yabgp.message.attribute.extcommunity.ExtCommunity import construct [as 别名]
def test_parse_construct_els_label(self):
community_list = [[bgp_cons.BGP_EXT_COM_EVPN_ESI_MPLS_LABEL, 1, 20]]
community_hex = b'\x06\x01\x01\x00\x00\x00\x01\x41'
self.assertEqual(community_hex, ExtCommunity.construct(community_list)[3:])
self.assertEqual(community_list, ExtCommunity.parse(community_hex))
示例11: test_parse_construct_es_import
# 需要导入模块: from yabgp.message.attribute.extcommunity import ExtCommunity [as 别名]
# 或者: from yabgp.message.attribute.extcommunity.ExtCommunity import construct [as 别名]
def test_parse_construct_es_import(self):
community_list = [[bgp_cons.BGP_EXT_COM_EVPN_ES_IMPORT, '00-11-22-33-44-55']]
community_hex = b'\x06\x02\x00\x11\x22\x33\x44\x55'
self.assertEqual(community_list, ExtCommunity.parse(community_hex))
self.assertEqual(community_hex, ExtCommunity.construct(community_list)[3:])
示例12: test_parse_construct_transitive_opaque_encap
# 需要导入模块: from yabgp.message.attribute.extcommunity import ExtCommunity [as 别名]
# 或者: from yabgp.message.attribute.extcommunity.ExtCommunity import construct [as 别名]
def test_parse_construct_transitive_opaque_encap(self):
community_list = [[bgp_cons.BGP_EXT_COM_ENCAP, 8]]
community_hex = b'\x03\x0c\x00\x00\x00\x00\x00\x08'
self.assertEqual(community_list, ExtCommunity.parse(community_hex))
self.assertEqual(community_hex, ExtCommunity.construct(community_list)[3:])