aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/honeycomb
diff options
context:
space:
mode:
authorjan.hradil <jan.hradil@pantheon.tech>2017-04-27 12:07:59 +0200
committerTibor Frank <tifrank@cisco.com>2017-05-17 07:26:08 +0000
commit03bb1e5611946a53f243a3d923c8f2d1aeee079a (patch)
tree5d6c2a6efd92c8ad1dfa28b49d0dfcea2fd143c7 /resources/libraries/python/honeycomb
parente7959d92d3cfd7c1ea917986e95d080f60ea4ea5 (diff)
CSIT-563: HC Test: improved Lisp test coverage
added TC09-TC14 with following features: Map Resolver Map Server PETR configuration RLOC Probing Map Register Map Request mode Change-Id: I0e8a573e9a0f7ef3c688a014ff879e2b3d6b9b1e Signed-off-by: jan.hradil <jan.hradil@pantheon.tech> Signed-off-by: selias <samelias@cisco.com>
Diffstat (limited to 'resources/libraries/python/honeycomb')
-rw-r--r--resources/libraries/python/honeycomb/Lisp.py206
1 files changed, 200 insertions, 6 deletions
diff --git a/resources/libraries/python/honeycomb/Lisp.py b/resources/libraries/python/honeycomb/Lisp.py
index 7ec259347c..8c124d194c 100644
--- a/resources/libraries/python/honeycomb/Lisp.py
+++ b/resources/libraries/python/honeycomb/Lisp.py
@@ -94,24 +94,88 @@ class LispKeywords(object):
return resp
@staticmethod
- def set_lisp_state(node, state):
+ def verify_map_server_data_from_honeycomb(data, ip_addresses):
+ """Verify whether MAP server data from Honeycomb is correct.
+
+ :param data: Lisp operational data containing map server IP addresses.
+ :param ip_addresses: IP addresses to verify map server data against.
+ :type data: dict
+ :type ip_addresses: list
+ :returns: Boolean Value indicating equality of IP Lists.
+ :rtype: bool
+ """
+
+ data =\
+ data['lisp-state']['lisp-feature-data']['map-servers']['map-server']
+
+ data = sorted([entry['ip-address'] for entry in data])
+ ip_addresses.sort()
+
+ return data == ip_addresses
+
+ @staticmethod
+ def verify_map_server_data_from_vat(data, ip_addresses):
+ """Verify whether MAP server data from VAT is correct.
+
+ :param data: Lisp operational data containing map server IP addresses.
+ :param ip_addresses: IP addresses to verify map server data against.
+ :type data: dict
+ :type ip_addresses: list
+ :returns: Boolean Value indicating equality of IP Lists.
+ :rtype: bool
+ """
+
+ data = sorted([entry['map-server'] for entry in data])
+ ip_addresses.sort()
+
+ return data == ip_addresses
+
+ @staticmethod
+ def set_lisp_state(node, state=True):
"""Enable or disable the Lisp feature.
:param node: Honeycomb node.
- :param state: Desired Lisp state, enable or disable.
+ :param state: Enable or disable Lisp.
:type node: dict
- :type state: str
+ :type state: bool
:returns: Content of response.
:rtype: bytearray
+ :raises HoneycombError: If the return code is not 200:OK
+ or 404:NOT FOUND.
"""
+ ret_code, data = HcUtil.get_honeycomb_data(node, "config_lisp")
+ if ret_code == HTTPCodes.OK:
+ data["lisp"]["enable"] = bool(state)
+ elif ret_code == HTTPCodes.NOT_FOUND:
+ data = {"lisp": {"enable": bool(state)}}
+ else:
+ raise HoneycombError("Unexpected return code when getting existing"
+ " Lisp configuration.")
+
+ return LispKeywords._set_lisp_properties(node, '', data)
+
+ @staticmethod
+ def set_rloc_probe_state(node, state=False):
+ """Enable or disable the Routing Locator probe.
+
+ :param node: Honeycomb node.
+ :param state: Enable or Disable the Rloc probe.
+ :type node: dict
+ :type state: bool
+ :returns: Content of response.
+ :rtype: bytearray
+ """
+
+ path = "/lisp-feature-data/rloc-probe"
+
data = {
- "lisp": {
- "enable": True if state.lower() == "enable" else False
+ "rloc-probe": {
+ "enabled": bool(state)
}
}
- return LispKeywords._set_lisp_properties(node, '', data)
+ return LispKeywords._set_lisp_properties(node, path, data)
@staticmethod
def add_locator(node, interface, locator_set, priority=1, weight=1):
@@ -163,6 +227,27 @@ class LispKeywords(object):
return LispKeywords._set_lisp_properties(node, path, data)
@staticmethod
+ def configure_lisp_map_request_mode(node, option):
+ """Modify Lisp Map Request Mode configuration to the data provided.
+
+ :param node: Honeycomb node.
+ :param option: Settings for the Lisp map request mode.
+ :type node: dict
+ :type option: str
+ :returns: Content of response.
+ :rtype: bytearray
+ """
+
+ data = {
+ "map-request-mode": {
+ "mode": option
+ }
+ }
+
+ path = "/lisp-feature-data/map-request-mode"
+ return LispKeywords._set_lisp_properties(node, path, data)
+
+ @staticmethod
def add_lisp_adjacency(node, vni_id, map_name, adjacency_name, data):
"""Add an adjacency to an existing Lisp mapping.
@@ -217,6 +302,51 @@ class LispKeywords(object):
return LispKeywords._set_lisp_properties(node, path, data)
@staticmethod
+ def set_map_register(node, map_register=False):
+ """Configure Map Register.
+
+ :param node: Honeycomb node.
+ :param map_register: Enable or disable Map Register.
+ :type node: dict
+ :type map_register: bool
+ :returns: Content of response.
+ :rtype: bytearray
+ """
+
+ path = "/lisp-feature-data/map-register"
+
+ data = {
+ "map-register": {
+ "enabled": bool(map_register)
+ }
+ }
+
+ return LispKeywords._set_lisp_properties(node, path, data)
+
+ @staticmethod
+ def set_map_request_mode(node, src_dst=False):
+ """Configure Map Request Mode.
+
+ :param node: Honeycomb node.
+ :param src_dst: Configure Map Request Mode with source destination.
+ :type node: dict
+ :type src_dst: bool
+ :returns: Content of response.
+ :rtype: bytearray
+ """
+
+ path = "/lisp-feature-data/map-request-mode"
+
+ data = {
+ "map-request-mode": {
+ "mode": "source-destination" if src_dst
+ else "target-destination"
+ }
+ }
+
+ return LispKeywords._set_lisp_properties(node, path, data)
+
+ @staticmethod
def delete_map_resolver(node):
"""Delete an existing map resolver.
@@ -231,6 +361,44 @@ class LispKeywords(object):
return LispKeywords._set_lisp_properties(node, path)
@staticmethod
+ def add_map_server(node, *ip_addresses):
+ """Configure map server with the specified IP addresses.
+
+ :param node: Honeycomb node.
+ :param ip_addresses: IP addresses to configure map server with.
+ :type node: dict
+ :type ip_addresses: list
+ :returns: Content of response.
+ :rtype: bytearray
+ """
+
+ path = "/lisp-feature-data/map-servers"
+
+ data = {
+ "map-servers": {
+ "map-server": [
+ {"ip-address": ip_address} for ip_address in ip_addresses
+ ]
+ }
+ }
+
+ return LispKeywords._set_lisp_properties(node, path, data)
+
+ @staticmethod
+ def delete_map_server(node):
+ """Delete all map servers.
+
+ :param node: Honeycomb node
+ :type node: dict
+ :returns: Content of response
+ :rtype: bytearray
+ """
+
+ path = "/lisp-feature-data/map-servers"
+
+ return LispKeywords._set_lisp_properties(node, path)
+
+ @staticmethod
def configure_pitr(node, locator_set=None):
"""Configure PITR feature with the specified locator set. If not locator
set is specified, disable PITR instead.
@@ -257,6 +425,32 @@ class LispKeywords(object):
return LispKeywords._set_lisp_properties(node, path, data)
@staticmethod
+ def configure_petr(node, ip_address):
+ """Configure PETR feature with the specified IP. If no IP
+ specified, disable PETR instead.
+
+ :param node: Honeycomb node.
+ :param ip_address: IPv6 address.
+ :type node: dict
+ :type ip_address: str
+ :returns: Content of response.
+ :rtype: bytearray
+ """
+
+ path = "/lisp-feature-data/petr-cfg"
+
+ if ip_address:
+ data = {
+ "petr-cfg": {
+ "petr-address": ip_address
+ }
+ }
+ else:
+ data = None
+
+ return LispKeywords._set_lisp_properties(node, path, data)
+
+ @staticmethod
def disable_lisp(node):
"""Remove all Lisp settings on the node.