Code Review
/
csit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Improve test tag string parsing
[csit.git]
/
resources
/
libraries
/
python
/
GBP.py
diff --git
a/resources/libraries/python/GBP.py
b/resources/libraries/python/GBP.py
index
ff0c133
..
3625640
100644
(file)
--- a/
resources/libraries/python/GBP.py
+++ b/
resources/libraries/python/GBP.py
@@
-42,8
+42,8
@@
class GBPBridgeDomainFlags(IntEnum):
class GBPSubnetType(IntEnum):
"""GBP Subnet Type."""
GBP_API_SUBNET_TRANSPORT = 1
class GBPSubnetType(IntEnum):
"""GBP Subnet Type."""
GBP_API_SUBNET_TRANSPORT = 1
- GBP_API_SUBNET_STITCHED_INTERNAL = 2
- GBP_API_SUBNET_STITCHED_EXTERNAL = 3
+ GBP_API_SUBNET_STITCHED_INTERNAL = 2
# pylint: disable=invalid-name
+ GBP_API_SUBNET_STITCHED_EXTERNAL = 3
# pylint: disable=invalid-name
GBP_API_SUBNET_L3_OUT = 4
GBP_API_SUBNET_ANON_L3_OUT = 5
GBP_API_SUBNET_L3_OUT = 4
GBP_API_SUBNET_ANON_L3_OUT = 5
@@
-61,6
+61,13
@@
class GBPRuleAction(IntEnum):
GBP_API_RULE_REDIRECT = 3
GBP_API_RULE_REDIRECT = 3
+class GBPHashMode(IntEnum):
+ """GBP Hash Mode."""
+ GBP_API_HASH_MODE_SRC_IP = 1
+ GBP_API_HASH_MODE_DST_IP = 2
+ GBP_API_HASH_MODE_SYMETRIC = 3
+
+
class GBP(object):
"""GBP utilities."""
class GBP(object):
"""GBP utilities."""
@@
-125,8
+132,8
@@
class GBP(object):
args_in = dict(
bd=dict(
args_in = dict(
bd=dict(
- flags=getattr(
GBPBridgeDomainFlags,
-
'GBP_BD_API_FLAG_NONE').value,
+ flags=getattr(
+
GBPBridgeDomainFlags,
'GBP_BD_API_FLAG_NONE').value,
bvi_sw_if_index=bvi_sw_if_index,
uu_fwd_sw_if_index=uu_fwd_sw_if_index,
bm_flood_sw_if_index=bm_flood_sw_if_index,
bvi_sw_if_index=bvi_sw_if_index,
uu_fwd_sw_if_index=uu_fwd_sw_if_index,
bm_flood_sw_if_index=bm_flood_sw_if_index,
@@
-213,8
+220,8
@@
class GBP(object):
n_ips=len(ips),
mac=L2Util.mac_to_bin(mac_addr),
sclass=sclass,
n_ips=len(ips),
mac=L2Util.mac_to_bin(mac_addr),
sclass=sclass,
- flags=getattr(
GBPEndpointFlags,
-
'GBP_API_ENDPOINT_FLAG_EXTERNAL').value,
+ flags=getattr(
+
GBPEndpointFlags,
'GBP_API_ENDPOINT_FLAG_EXTERNAL').value,
tun=dict(
src=tun_src,
dst=tun_dst
tun=dict(
src=tun_src,
dst=tun_dst
@@
-248,8
+255,7
@@
class GBP(object):
sw_if_index=sw_if_index,
bd_id=bd_id,
rd_id=rd_id,
sw_if_index=sw_if_index,
bd_id=bd_id,
rd_id=rd_id,
- flags=getattr(GBPExtItfFlags,
- 'GBP_API_EXT_ITF_F_NONE').value
+ flags=getattr(GBPExtItfFlags, 'GBP_API_EXT_ITF_F_NONE').value
)
)
)
)
@@
-282,8
+288,7
@@
class GBP(object):
args_in = dict(
is_add=1,
subnet=dict(
args_in = dict(
is_add=1,
subnet=dict(
- type=getattr(GBPSubnetType,
- 'GBP_API_SUBNET_L3_OUT').value,
+ type=getattr(GBPSubnetType, 'GBP_API_SUBNET_L3_OUT').value,
sw_if_index=sw_if_index,
sclass=sclass,
prefix=dict(
sw_if_index=sw_if_index,
sclass=sclass,
prefix=dict(
@@
-299,27
+304,30
@@
class GBP(object):
papi_exec.add(cmd, **args_in).get_reply(err_msg)
@staticmethod
papi_exec.add(cmd, **args_in).get_reply(err_msg)
@staticmethod
- def gbp_contract_add_del(node, sclass, dclass, acl_index=0):
+ def gbp_contract_add_del(node, sclass, dclass, acl_index=0
, hash_mode=None
):
"""Add GBP contract.
:param node: Node to add GBP contract on.
:param sclass: Source CLASS.
:param dclass: Destination CLASS.
:param acl_index: Index of ACL rule.
"""Add GBP contract.
:param node: Node to add GBP contract on.
:param sclass: Source CLASS.
:param dclass: Destination CLASS.
:param acl_index: Index of ACL rule.
+ :param hash_mode: GBP contract hash mode.
:type node: dict
:type sclass: int
:type dclass: int
:type acl_index: int
:type node: dict
:type sclass: int
:type dclass: int
:type acl_index: int
+ :type hash_mode: str
"""
cmd = 'gbp_contract_add_del'
err_msg = 'Failed to add GBP contract on {node}!'\
.format(node=node['host'])
"""
cmd = 'gbp_contract_add_del'
err_msg = 'Failed to add GBP contract on {node}!'\
.format(node=node['host'])
+ hash_mode = 'GBP_API_HASH_MODE_SRC_IP' if hash_mode is None \
+ else hash_mode
rule_permit = dict(
rule_permit = dict(
- action=getattr(GBPRuleAction,
- 'GBP_API_RULE_PERMIT').value,
+ action=getattr(GBPRuleAction, 'GBP_API_RULE_PERMIT').value,
nh_set=dict(
nh_set=dict(
- hash_mode=
list()
,
+ hash_mode=
getattr(GBPHashMode, hash_mode).value
,
n_nhs=8,
nhs=[dict()]*8,
)
n_nhs=8,
nhs=[dict()]*8,
)