aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/honeycomb
diff options
context:
space:
mode:
authorselias <samelias@cisco.com>2016-10-12 15:07:35 +0200
committerSamuel Eliáš <samelias@cisco.com>2016-10-20 08:54:26 +0000
commit21921596d22a72cc4e4f7dee172ff17d1e5853cd (patch)
treec8d62eb187f93a811c034f569e952d867e1f0240 /resources/libraries/python/honeycomb
parent233683de57527f477bf7e8d042a5f3d1f08c7744 (diff)
CSIT-427: Honeycomb ietf-ACL tests - L3
- add test cases for layer 3 ACL - IPv4, IPv6, protocol/next-header - update methods with L3 functionality - update test variables Change-Id: Ia7ec03268845191021366621040dc411da0a2a93 Signed-off-by: selias <samelias@cisco.com>
Diffstat (limited to 'resources/libraries/python/honeycomb')
-rw-r--r--resources/libraries/python/honeycomb/HcAPIKwACL.py63
1 files changed, 36 insertions, 27 deletions
diff --git a/resources/libraries/python/honeycomb/HcAPIKwACL.py b/resources/libraries/python/honeycomb/HcAPIKwACL.py
index 1042adc872..82a953e128 100644
--- a/resources/libraries/python/honeycomb/HcAPIKwACL.py
+++ b/resources/libraries/python/honeycomb/HcAPIKwACL.py
@@ -281,14 +281,19 @@ class ACLKeywords(object):
:rtype: bytearray
:raises HoneycombError: If the operation fails.
"""
- if layer.lower() == "l2":
- suffix = "eth"
- elif layer.lower() in ("l3_ip4", "l3_ip6", "l4"):
+ layer = layer.lower()
+ suffix_dict = {"l2": "eth",
+ "l3_ip4": "ipv4",
+ "l3_ip6": "ipv6"
+ }
+ if layer == "l4":
raise NotImplementedError
- else:
+ try:
+ suffix = suffix_dict[layer]
+ except KeyError:
raise ValueError("Unexpected value of layer argument {0}."
- "Valid options are: L2, L3_IP4, L3_IP6, L4."
- .format(layer))
+ "Valid options are: {1}"
+ .format(layer, suffix_dict.keys()))
path = "/acl/ietf-access-control-list:{0}-acl/{1}".format(
suffix, list_name)
@@ -328,6 +333,7 @@ class ACLKeywords(object):
:raises HoneycombError: If the operation fails.
"""
+ layer = layer.lower()
interface = Topology.convert_interface_reference(
node, interface, "name")
@@ -341,30 +347,33 @@ class ACLKeywords(object):
path = "/interface/{0}/ietf-acl/{1}/access-lists".format(
interface, direction)
- data = {
- "access-lists": {
- "acl": [{
- "type": None,
- "name": list_name
- }],
- "default-action": default_action,
- "mode": None
- }
- }
-
- acl_type = "ietf-access-control-list:{suffix}-acl"
-
- if layer.lower() == "l2":
- data["access-lists"]["mode"] = "l2"
- data["access-lists"]["acl"][0]["type"] = \
- acl_type.format(suffix="eth")
+ layers = {
+ "l2": {"mode": "l2", "suffix": "eth"},
+ "l3_ip4": {"mode": "l3", "suffix": "ipv4"},
+ "l3_ip6": {"mode": "l3", "suffix": "ipv6"}
+ }
- elif layer.lower() in ("l3_ip4", "l3_ip6", "L4"):
+ if layer == "L4":
raise NotImplementedError
else:
- raise ValueError("Unknown network layer {0}. "
- "Valid options are: "
- "L2, L3_IP4, L3_IP6, L4.".format(layer))
+ try:
+ data = {
+ "access-lists": {
+ "acl": [
+ {
+ "type": "ietf-access-control-list:{0}-acl"
+ .format(layers[layer]['suffix']),
+ "name": list_name
+ }
+ ],
+ "default-action": default_action,
+ "mode": layers[layer]['mode']
+ }
+ }
+ except KeyError:
+ raise ValueError("Unknown network layer {0}. "
+ "Valid options are: {1}".format(
+ layer, layers.keys()))
status_code, resp = HcUtil.put_honeycomb_data(
node, "config_vpp_interfaces", data, path)