aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python
diff options
context:
space:
mode:
authorselias <samelias@cisco.com>2017-03-10 18:14:48 +0100
committerPeter Mikus <pmikus@cisco.com>2017-03-17 09:03:25 +0000
commit8003aa2c3d1a0d4c1dbf3b6286d841a47b5fbb4c (patch)
tree17771f9f37744f879f0f1e09b26cb387b166e7d7 /resources/libraries/python
parent7dafbbe0a06d69edd8a8bb347fa92832cf4ee833 (diff)
CSIT-528 HC Test: proxyARP test suite
Change-Id: I1f99d38aadee22a7354a1f89e9d7f395a401c96c Signed-off-by: selias <samelias@cisco.com>
Diffstat (limited to 'resources/libraries/python')
-rw-r--r--resources/libraries/python/honeycomb/proxyARP.py152
1 files changed, 152 insertions, 0 deletions
diff --git a/resources/libraries/python/honeycomb/proxyARP.py b/resources/libraries/python/honeycomb/proxyARP.py
new file mode 100644
index 0000000000..78e71a75e4
--- /dev/null
+++ b/resources/libraries/python/honeycomb/proxyARP.py
@@ -0,0 +1,152 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""This module implements keywords to configure proxyARP using Honeycomb
+REST API."""
+
+from resources.libraries.python.HTTPRequest import HTTPCodes
+from resources.libraries.python.honeycomb.HoneycombSetup import HoneycombError
+from resources.libraries.python.honeycomb.HoneycombUtil \
+ import HoneycombUtil as HcUtil
+from resources.libraries.python.honeycomb.HoneycombUtil \
+ import DataRepresentation
+from resources.libraries.python.topology import Topology
+
+
+class ProxyARPKeywords(object):
+ """Implementation of keywords which make it possible to:
+ - configure proxyARP behaviour
+ - enable/disable proxyARP on individual interfaces
+ """
+
+ def __init__(self):
+ """Initializer."""
+ pass
+
+ @staticmethod
+ def configure_proxyarp(node, data):
+ """Configure the proxyARP feature and check the return code.
+
+ :param node: Honeycomb node.
+ :param data: Configuration to use.
+ :type node: dict
+ :type data: dict
+ :returns: Content of response.
+ :rtype: bytearray
+ :raises HoneycombError: If the status code in response to PUT is not
+ 200 = OK or 201 = ACCEPTED.
+ """
+
+ data = {
+ "proxy-ranges": {
+ "proxy-range": [
+ data,
+ ]
+ }
+ }
+
+ status_code, resp = HcUtil.\
+ put_honeycomb_data(node, "config_proxyarp_ranges", data,
+ data_representation=DataRepresentation.JSON)
+
+ if status_code not in (HTTPCodes.OK, HTTPCodes.ACCEPTED):
+ raise HoneycombError(
+ "proxyARP configuration unsuccessful. "
+ "Status code: {0}.".format(status_code))
+ else:
+ return resp
+
+ @staticmethod
+ def remove_proxyarp_configuration(node):
+ """Delete the proxyARP node, removing all of its configuration.
+
+ :param node: Honeycomb node.
+ :type node: dict
+ :returns: Content of response.
+ :rtype: bytearray
+ :raises HoneycombError: If the status code in response is not 200 = OK.
+ """
+
+ status_code, resp = HcUtil. \
+ delete_honeycomb_data(node, "config_proxyarp_ranges")
+
+ if status_code != HTTPCodes.OK:
+ raise HoneycombError(
+ "proxyARP removal unsuccessful. "
+ "Status code: {0}.".format(status_code))
+ else:
+ return resp
+
+ @staticmethod
+ def get_proxyarp_operational_data(node):
+ """Retrieve proxyARP properties from Honeycomb operational data.
+ Note: The proxyARP feature has no operational data available.
+
+ :param node: Honeycomb node.
+ :type node: dict
+ :returns: proxyARP operational data.
+ :rtype: bytearray
+ """
+
+ raise NotImplementedError("Not supported in VPP.")
+
+ @staticmethod
+ def set_proxyarp_interface_config(node, interface, state):
+ """Enable or disable the proxyARP feature on the specified interface.
+
+ :param node: Honeycomb node.
+ :param interface: Name or sw_if_index of an interface on the node.
+ :param state: Desired proxyARP state: enable, disable.
+ :type node: dict
+ :type interface: str
+ :type state: str
+ :raises ValueError: If the state argument is incorrect.
+ :raises HoneycombError: If the status code in response is not
+ 200 = OK or 201 = ACCEPTED.
+ """
+
+ interface = Topology.convert_interface_reference(
+ node, interface, "name")
+ interface = interface.replace("/", "%2F")
+
+ path = "/interface/{0}/proxy-arp".format(interface)
+
+ if state == "disable":
+ status_code, resp = HcUtil.delete_honeycomb_data(
+ node, "config_vpp_interfaces", path)
+ elif state == "enable":
+ data = {"proxy-arp": {}}
+ status_code, resp = HcUtil.put_honeycomb_data(
+ node, "config_vpp_interfaces", data, path)
+ else:
+ raise ValueError("State argument has to be enable or disable.")
+
+ if status_code not in (HTTPCodes.OK, HTTPCodes.ACCEPTED):
+ raise HoneycombError(
+ "Interface proxyARP configuration on node {0} was not"
+ " successful.".format(node))
+
+ @staticmethod
+ def get_proxyarp_interface_assignment(node, interface):
+ """Read the status of proxyARP feature on the specified interface.
+ Note: The proxyARP feature has no operational data available.
+
+ :param node: Honeycomb node.
+ :param interface: Name or sw_if_index of an interface on the node.
+ :type node: dict
+ :type interface: str
+ :returns: Content of response.
+ :rtype: bytearray
+ """
+
+ raise NotImplementedError("Not supported in VPP.")
ed on slave of BondEthernet") \ _ (VALUE_EXIST, -81, "Value already exists") \ _ (SAME_SRC_DST, -82, "Source and destination are the same") \ _ (IP6_MULTICAST_ADDRESS_NOT_PRESENT, -83, \ "IP6 multicast address required") \ _ (SR_POLICY_NAME_NOT_PRESENT, -84, "Segment routing policy name required") \ _ (NOT_RUNNING_AS_ROOT, -85, "Not running as root") \ _ (ALREADY_CONNECTED, -86, "Connection to the data plane already exists") \ _ (UNSUPPORTED_JNI_VERSION, -87, "Unsupported JNI version") \ _ (IP_PREFIX_INVALID, -88, "IP prefix invalid (masked bits set in address") \ _ (INVALID_WORKER, -89, "Invalid worker thread") \ _ (LISP_DISABLED, -90, "LISP is disabled") \ _ (CLASSIFY_TABLE_NOT_FOUND, -91, "Classify table not found") \ _ (INVALID_EID_TYPE, -92, "Unsupported LISP EID type") \ _ (CANNOT_CREATE_PCAP_FILE, -93, "Cannot create pcap file") \ _ (INCORRECT_ADJACENCY_TYPE, -94, \ "Invalid adjacency type for this operation") \ _ (EXCEEDED_NUMBER_OF_RANGES_CAPACITY, -95, \ "Operation would exceed configured capacity of ranges") \ _ (EXCEEDED_NUMBER_OF_PORTS_CAPACITY, -96, \ "Operation would exceed capacity of number of ports") \ _ (INVALID_ADDRESS_FAMILY, -97, "Invalid address family") \ _ (INVALID_SUB_SW_IF_INDEX, -98, "Invalid sub-interface sw_if_index") \ _ (TABLE_TOO_BIG, -99, "Table too big") \ _ (CANNOT_ENABLE_DISABLE_FEATURE, -100, "Cannot enable/disable feature") \ _ (BFD_EEXIST, -101, "Duplicate BFD object") \ _ (BFD_ENOENT, -102, "No such BFD object") \ _ (BFD_EINUSE, -103, "BFD object in use") \ _ (BFD_NOTSUPP, -104, "BFD feature not supported") \ _ (ADDRESS_IN_USE, -105, "Address in use") \ _ (ADDRESS_NOT_IN_USE, -106, "Address not in use") \ _ (QUEUE_FULL, -107, "Queue full") \ _ (APP_UNSUPPORTED_CFG, -108, "Unsupported application config") \ _ (URI_FIFO_CREATE_FAILED, -109, "URI FIFO segment create failed") \ _ (LISP_RLOC_LOCAL, -110, "RLOC address is local") \ _ (BFD_EAGAIN, -111, "BFD object cannot be manipulated at this time") \ _ (INVALID_GPE_MODE, -112, "Invalid GPE mode") \ _ (LISP_GPE_ENTRIES_PRESENT, -113, "LISP GPE entries are present") \ _ (ADDRESS_FOUND_FOR_INTERFACE, -114, "Address found for interface") \ _ (SESSION_CONNECT, -115, "Session failed to connect") \ _ (ENTRY_ALREADY_EXISTS, -116, "Entry already exists") \ _ (SVM_SEGMENT_CREATE_FAIL, -117, "Svm segment create fail") \ _ (APPLICATION_NOT_ATTACHED, -118, "Application not attached") \ _ (BD_ALREADY_EXISTS, -119, "Bridge domain already exists") \ _ (BD_IN_USE, -120, "Bridge domain has member interfaces") \ _ (BD_NOT_MODIFIABLE, -121, "Bridge domain 0 can't be deleted/modified") \ _ (BD_ID_EXCEED_MAX, -122, "Bridge domain ID exceeds 16M limit") \ _ (SUBIF_DOESNT_EXIST, -123, "Subinterface doesn't exist") \ _ (L2_MACS_EVENT_CLINET_PRESENT, -124, \ "Client already exist for L2 MACs events") \ _ (INVALID_QUEUE, -125, "Invalid queue") \ _ (UNSUPPORTED, -126, "Unsupported") \ _ (DUPLICATE_IF_ADDRESS, -127, \ "Address already present on another interface") \ _ (APP_INVALID_NS, -128, "Invalid application namespace") \ _ (APP_WRONG_NS_SECRET, -129, "Wrong app namespace secret") \ _ (APP_CONNECT_SCOPE, -130, "Connect scope") \ _ (APP_ALREADY_ATTACHED, -131, "App already attached") \ _ (SESSION_REDIRECT, -132, "Redirect failed") \ _ (ILLEGAL_NAME, -133, "Illegal name") \ _ (NO_NAME_SERVERS, -134, "No name servers configured") \ _ (NAME_SERVER_NOT_FOUND, -135, "Name server not found") \ _ (NAME_RESOLUTION_NOT_ENABLED, -136, "Name resolution not enabled") \ _ (NAME_SERVER_FORMAT_ERROR, -137, "Server format error (bug!)") \ _ (NAME_SERVER_NO_SUCH_NAME, -138, "No such name") \ _ (NAME_SERVER_NO_ADDRESSES, -139, "No addresses available") \ _ (NAME_SERVER_NEXT_SERVER, -140, "Retry with new server") \ _ (APP_CONNECT_FILTERED, -141, "Connect was filtered") \ _ (ACL_IN_USE_INBOUND, -142, "Inbound ACL in use") \ _ (ACL_IN_USE_OUTBOUND, -143, "Outbound ACL in use") \ _ (INIT_FAILED, -144, "Initialization Failed") \ _ (NETLINK_ERROR, -145, "Netlink error") \ _ (BIER_BSL_UNSUP, -146, "BIER bit-string-length unsupported") \ _ (INSTANCE_IN_USE, -147, "Instance in use") \ _ (INVALID_SESSION_ID, -148, "Session ID out of range") \ _ (ACL_IN_USE_BY_LOOKUP_CONTEXT, -149, "ACL in use by a lookup context") \ _ (INVALID_VALUE_3, -150, "Invalid value #3") \ _ (NON_ETHERNET, -151, "Interface is not an Ethernet interface") \ _ (BD_ALREADY_HAS_BVI, -152, "Bridge domain already has a BVI interface") \ _ (INVALID_PROTOCOL, -153, "Invalid Protocol") \ _ (INVALID_ALGORITHM, -154, "Invalid Algorithm") \ _ (RSRC_IN_USE, -155, "Resource In Use") \ _ (KEY_LENGTH, -156, "invalid Key Length") \ _ (FIB_PATH_UNSUPPORTED_NH_PROTO, -157, "Unsupported FIB Path protocol") \ _ (API_ENDIAN_FAILED, -159, "Endian mismatch detected") \ _ (NO_CHANGE, -160, "No change in table") \ _ (MISSING_CERT_KEY, -161, "Missing certifcate or key") \ _ (LIMIT_EXCEEDED, -162, "limit exceeded") \ _ (IKE_NO_PORT, -163, "port not managed by IKE") \ _ (UDP_PORT_TAKEN, -164, "UDP port already taken") \ _ (EAGAIN, -165, "Retry stream call with cursor") \ _ (INVALID_VALUE_4, -166, "Invalid value #4") \ _ (BUSY, -167, "Busy") \ _ (BUG, -168, "Bug") \ _ (FEATURE_ALREADY_DISABLED, -169, "Feature already disabled") \ _ (FEATURE_ALREADY_ENABLED, -170, "Feature already enabled") typedef enum { #define _(a, b, c) VNET_ERR_##a = (b), foreach_vnet_error #undef _ VNET_N_ERROR, } vnet_error_t; clib_error_t __clib_warn_unused_result *vnet_error (vnet_error_t code, char *fmt, ...); format_function_t format_vnet_api_errno; #endif