def mount_honeycomb_on_odl(node): """Tell ODL client to mount Honeycomb instance over netconf. :param node: Honeycomb node. :type node: dict :raises HoneycombError: When the response is not code 200: OK. """ path = HcUtil.read_path_from_url_file( "odl_client/odl_netconf_connector") url_file = "{0}/{1}".format(Const.RESOURCES_TPL_HC, "odl_client/mount_honeycomb.json") with open(url_file) as template: data = template.read() data = loads(data) status_code, _ = HTTPRequest.post(node, path, headers={ "Content-Type": "application/json", "Accept": "text/plain" }, json=data, timeout=10, enable_logging=False) if status_code == HTTPCodes.OK: logger.info("ODL mount point configured successfully.") elif status_code == HTTPCodes.CONFLICT: logger.info("ODL mount point was already configured.") else: raise HoneycombError('Mount point configuration not successful')
def get_lisp_operational_data(node): """Retrieve Lisp properties from Honeycomb operational data. :param node: Honeycomb node. :type node: dict :returns: List operational data. :rtype: bytearray """ status_code, resp = HcUtil.get_honeycomb_data(node, "oper_lisp") if status_code != HTTPCodes.OK: raise HoneycombError("Could not retrieve Lisp operational data." "Status code: {0}.".format(status_code)) else: # get rid of empty vni-table entry resp["lisp-state"]["lisp-feature-data"]["eid-table"][ "vni-table"].remove({ "virtual-network-identifier": 0, "vrf-subtable": { "table-id": 0 } }) return resp
def set_acl_plugin_interface(node, interface, acl_name, direction, macip=False): """Assign an interface to an ietf-acl classify chain. :param node: Honeycomb node. :param interface: Name of an interface on the node. :param acl_name: Name of an ACL chain configured through ACL-plugin. :param direction: Classify incoming or outgiong packets. Valid options are: ingress, egress :param macip: Use simple MAC+IP classifier. Optional. :type node: dict :type interface: str or int :type acl_name: str :type direction: str :type macip: bool :returns: Content of response. :rtype: bytearray :raises ValueError: If the direction argument is incorrect. :raises HoneycombError: If the operation fails. """ interface = Topology.convert_interface_reference( node, interface, "name") interface = interface.replace("/", "%2F") if direction not in ("ingress", "egress"): raise ValueError( "Unknown traffic direction {0}. " "Valid options are: ingress, egress.".format(direction)) path = "/interface/{0}/interface-acl:acl/{1}".format( interface, direction) if macip: data = { direction: { "vpp-macip-acl": { "type": "vpp-acl:vpp-macip-acl", "name": acl_name } } } else: data = { direction: { "vpp-acls": [{ "type": "vpp-acl:vpp-acl", "name": acl_name }] } } status_code, resp = HcUtil.put_honeycomb_data(node, "config_vpp_interfaces", data, path) if status_code not in (HTTPCodes.OK, HTTPCodes.ACCEPTED): raise HoneycombError("Could not configure ACL on interface. " "Status code: {0}.".format(status_code)) return resp