{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "nbsphinx": "hidden" }, "outputs": [], "source": [ "import pandas as pd\n", "from pybatfish.client.session import Session\n", "from pybatfish.datamodel import *\n", "\n", "pd.set_option(\"display.width\", 300) \n", "pd.set_option(\"display.max_columns\", 30) \n", "pd.set_option(\"display.max_rows\", 1000) \n", "pd.set_option(\"display.max_colwidth\", None)\n", "\n", "# Configure all pybatfish loggers to use WARN level\n", "import logging\n", "logging.getLogger('pybatfish').setLevel(logging.WARN)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "nbsphinx": "hidden" }, "outputs": [], "source": [ "bf = Session(host=\"localhost\")\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### VXLAN and EVPN" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This category of questions allows you to query aspects of VXLAN and EVPN\n", "configuration and behavior.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* [VXLAN VNI Properties](#VXLAN-VNI-Properties)\n", "* [VXLAN Edges](#VXLAN-Edges)\n", "* [L3 EVPN VNIs](#L3-EVPN-VNIs)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "nbsphinx": "hidden" }, "outputs": [ { "data": { "text/plain": [ "'generate_questions'" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bf.set_network('generate_questions')" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "nbsphinx": "hidden" }, "outputs": [ { "data": { "text/plain": [ "'aristaevpn'" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bf.set_snapshot('aristaevpn')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### VXLAN VNI Properties" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Returns configuration settings of VXLANs." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Lists VNI-level network segment settings configured for VXLANs." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "###### **Inputs**" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Name | Description | Type | Optional | Default Value\n", "--- | --- | --- | --- | --- \n", "nodes | Include nodes matching this specifier. | [NodeSpec](../specifiers.md#node-specifier) | True | \n", "properties | Include properties matching this specifier. | [VxlanVniPropertySpec](../specifiers.md#vxlan-vni-property-specifier) | True | " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "###### **Invocation**" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "result = bf.q.vxlanVniProperties().answer().frame()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "###### **Return Value**" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Name | Description | Type\n", "--- | --- | ---\n", "Node | Node | str\n", "VRF | VRF | str\n", "VNI | VXLAN Segment ID | int\n", "Local_VTEP_IP | IPv4 address of the local VTEP | str\n", "Multicast_Group | IPv4 address of the multicast group | str\n", "VLAN | VLAN number for the VNI | int\n", "VTEP_Flood_List | All IPv4 addresses in the VTEP flood list | List of str\n", "VXLAN_Port | Destination port number for the VXLAN tunnel | int" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Print the first 5 rows of the returned Dataframe" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
NodeVRFVNILocal_VTEP_IPMulticast_GroupVLANVTEP_Flood_ListVXLAN_Port
0dc1-svc3adefault10140192.168.254.6None140['192.168.254.3', '192.168.254.4', '192.168.254.8']4789
1dc1-svc3bdefault10140192.168.254.6None140['192.168.254.3', '192.168.254.4', '192.168.254.8']4789
2dc1-leaf2adefault10130192.168.254.4None130['192.168.254.3', '192.168.254.6', '192.168.254.8']4789
3dc1-leaf2adefault10160192.168.254.4None160['192.168.254.3', '192.168.254.6', '192.168.254.8']4789
4dc1-leaf2bdefault10130192.168.254.4None130['192.168.254.3', '192.168.254.6', '192.168.254.8']4789
\n", "
" ], "text/plain": [ " Node VRF VNI Local_VTEP_IP Multicast_Group VLAN VTEP_Flood_List VXLAN_Port\n", "0 dc1-svc3a default 10140 192.168.254.6 None 140 ['192.168.254.3', '192.168.254.4', '192.168.254.8'] 4789\n", "1 dc1-svc3b default 10140 192.168.254.6 None 140 ['192.168.254.3', '192.168.254.4', '192.168.254.8'] 4789\n", "2 dc1-leaf2a default 10130 192.168.254.4 None 130 ['192.168.254.3', '192.168.254.6', '192.168.254.8'] 4789\n", "3 dc1-leaf2a default 10160 192.168.254.4 None 160 ['192.168.254.3', '192.168.254.6', '192.168.254.8'] 4789\n", "4 dc1-leaf2b default 10130 192.168.254.4 None 130 ['192.168.254.3', '192.168.254.6', '192.168.254.8'] 4789" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result.head(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Print the first row of the returned Dataframe" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Node dc1-svc3a\n", "VRF default\n", "VNI 10140\n", "Local_VTEP_IP 192.168.254.6\n", "Multicast_Group None\n", "VLAN 140\n", "VTEP_Flood_List ['192.168.254.3', '192.168.254.4', '192.168.254.8']\n", "VXLAN_Port 4789\n", "Name: 0, dtype: object" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result.iloc[0]" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "nbsphinx": "hidden" }, "outputs": [ { "data": { "text/plain": [ "'generate_questions'" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bf.set_network('generate_questions')" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "nbsphinx": "hidden" }, "outputs": [ { "data": { "text/plain": [ "'aristaevpn'" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bf.set_snapshot('aristaevpn')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### VXLAN Edges" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Returns VXLAN edges." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Lists all VXLAN edges in the network." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "###### **Inputs**" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Name | Description | Type | Optional | Default Value\n", "--- | --- | --- | --- | --- \n", "nodes | Include edges whose first node matches this name or regex. | [NodeSpec](../specifiers.md#node-specifier) | True | .*\n", "remoteNodes | Include edges whose second node matches this name or regex. | [NodeSpec](../specifiers.md#node-specifier) | True | .*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "###### **Invocation**" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "result = bf.q.vxlanEdges().answer().frame()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "###### **Return Value**" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Name | Description | Type\n", "--- | --- | ---\n", "VNI | VNI of the VXLAN tunnel edge | int\n", "Node | Node from which the edge originates | str\n", "Remote_Node | Node at which the edge terminates | str\n", "VTEP_Address | VTEP IP of node from which the edge originates | str\n", "Remote_VTEP_Address | VTEP IP of node at which the edge terminates | str\n", "VLAN | VLAN associated with VNI on node from which the edge originates | int\n", "Remote_VLAN | VLAN associated with VNI on node at which the edge terminates | int\n", "UDP_Port | UDP port of the VXLAN tunnel transport | int\n", "Multicast_Group | Multicast group of the VXLAN tunnel transport | str" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Print the first 5 rows of the returned Dataframe" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
VNINodeRemote_NodeVTEP_AddressRemote_VTEP_AddressVLANRemote_VLANUDP_PortMulticast_Group
010130dc1-leaf2bdc1-svc3a192.168.254.4192.168.254.61301304789None
110140dc1-leaf2adc1-svc3a192.168.254.4192.168.254.61401404789None
210130dc1-svc3adc1-leaf2a192.168.254.6192.168.254.41301304789None
310111dc1-leaf1adc1-leaf2b192.168.254.3192.168.254.41111114789None
410130dc1-svc3bdc1-leaf2b192.168.254.6192.168.254.41301304789None
\n", "
" ], "text/plain": [ " VNI Node Remote_Node VTEP_Address Remote_VTEP_Address VLAN Remote_VLAN UDP_Port Multicast_Group\n", "0 10130 dc1-leaf2b dc1-svc3a 192.168.254.4 192.168.254.6 130 130 4789 None\n", "1 10140 dc1-leaf2a dc1-svc3a 192.168.254.4 192.168.254.6 140 140 4789 None\n", "2 10130 dc1-svc3a dc1-leaf2a 192.168.254.6 192.168.254.4 130 130 4789 None\n", "3 10111 dc1-leaf1a dc1-leaf2b 192.168.254.3 192.168.254.4 111 111 4789 None\n", "4 10130 dc1-svc3b dc1-leaf2b 192.168.254.6 192.168.254.4 130 130 4789 None" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result.head(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Print the first row of the returned Dataframe" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "VNI 10130\n", "Node dc1-leaf2b\n", "Remote_Node dc1-svc3a\n", "VTEP_Address 192.168.254.4\n", "Remote_VTEP_Address 192.168.254.6\n", "VLAN 130\n", "Remote_VLAN 130\n", "UDP_Port 4789\n", "Multicast_Group None\n", "Name: 0, dtype: object" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result.iloc[0]" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "nbsphinx": "hidden" }, "outputs": [ { "data": { "text/plain": [ "'generate_questions'" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bf.set_network('generate_questions')" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "nbsphinx": "hidden" }, "outputs": [ { "data": { "text/plain": [ "'aristaevpn'" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bf.set_snapshot('aristaevpn')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### L3 EVPN VNIs" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Returns configuration settings of VXLANs." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Lists VNI-level network segment settings configured for VXLANs." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "###### **Inputs**" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Name | Description | Type | Optional | Default Value\n", "--- | --- | --- | --- | --- \n", "nodes | Include nodes matching this specifier. | [NodeSpec](../specifiers.md#node-specifier) | True | " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "###### **Invocation**" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "result = bf.q.evpnL3VniProperties().answer().frame()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "###### **Return Value**" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Name | Description | Type\n", "--- | --- | ---\n", "Node | Node | str\n", "VRF | VRF | str\n", "VNI | VXLAN Segment ID | int\n", "Route_Distinguisher | Route distinguisher | str\n", "Import_Route_Target | Import route target | str\n", "Export_Route_Target | Export route target | str" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Print the first 5 rows of the returned Dataframe" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
NodeVRFVNIRoute_DistinguisherImport_Route_TargetExport_Route_Target
0dc1-bl1aTenant_A_WAN_Zone15005192.168.255.8:1500515005:1500515005:15005
1dc1-bl1aTenant_B_WAN_Zone25021192.168.255.8:2502125021:2502125021:25021
2dc1-bl1aTenant_C_WAN_Zone35031192.168.255.8:3503135031:3503135031:35031
3dc1-bl1bTenant_A_WAN_Zone15005192.168.255.9:1500515005:1500515005:15005
4dc1-bl1bTenant_B_WAN_Zone25021192.168.255.9:2502125021:2502125021:25021
\n", "
" ], "text/plain": [ " Node VRF VNI Route_Distinguisher Import_Route_Target Export_Route_Target\n", "0 dc1-bl1a Tenant_A_WAN_Zone 15005 192.168.255.8:15005 15005:15005 15005:15005\n", "1 dc1-bl1a Tenant_B_WAN_Zone 25021 192.168.255.8:25021 25021:25021 25021:25021\n", "2 dc1-bl1a Tenant_C_WAN_Zone 35031 192.168.255.8:35031 35031:35031 35031:35031\n", "3 dc1-bl1b Tenant_A_WAN_Zone 15005 192.168.255.9:15005 15005:15005 15005:15005\n", "4 dc1-bl1b Tenant_B_WAN_Zone 25021 192.168.255.9:25021 25021:25021 25021:25021" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result.head(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Print the first row of the returned Dataframe" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Node dc1-bl1a\n", "VRF Tenant_A_WAN_Zone\n", "VNI 15005\n", "Route_Distinguisher 192.168.255.8:15005\n", "Import_Route_Target 15005:15005\n", "Export_Route_Target 15005:15005\n", "Name: 0, dtype: object" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result.iloc[0]" ] } ], "metadata": { "celltoolbar": "Edit Metadata", "hide_input": false, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.6" } }, "nbformat": 4, "nbformat_minor": 2 }