{
"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",
" Node | \n",
" VRF | \n",
" VNI | \n",
" Local_VTEP_IP | \n",
" Multicast_Group | \n",
" VLAN | \n",
" VTEP_Flood_List | \n",
" VXLAN_Port | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" dc1-svc3a | \n",
" default | \n",
" 10140 | \n",
" 192.168.254.6 | \n",
" None | \n",
" 140 | \n",
" ['192.168.254.3', '192.168.254.4', '192.168.254.8'] | \n",
" 4789 | \n",
"
\n",
" \n",
" | 1 | \n",
" dc1-svc3b | \n",
" default | \n",
" 10140 | \n",
" 192.168.254.6 | \n",
" None | \n",
" 140 | \n",
" ['192.168.254.3', '192.168.254.4', '192.168.254.8'] | \n",
" 4789 | \n",
"
\n",
" \n",
" | 2 | \n",
" dc1-leaf2a | \n",
" default | \n",
" 10130 | \n",
" 192.168.254.4 | \n",
" None | \n",
" 130 | \n",
" ['192.168.254.3', '192.168.254.6', '192.168.254.8'] | \n",
" 4789 | \n",
"
\n",
" \n",
" | 3 | \n",
" dc1-leaf2a | \n",
" default | \n",
" 10160 | \n",
" 192.168.254.4 | \n",
" None | \n",
" 160 | \n",
" ['192.168.254.3', '192.168.254.6', '192.168.254.8'] | \n",
" 4789 | \n",
"
\n",
" \n",
" | 4 | \n",
" dc1-leaf2b | \n",
" default | \n",
" 10130 | \n",
" 192.168.254.4 | \n",
" None | \n",
" 130 | \n",
" ['192.168.254.3', '192.168.254.6', '192.168.254.8'] | \n",
" 4789 | \n",
"
\n",
" \n",
"
\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",
" VNI | \n",
" Node | \n",
" Remote_Node | \n",
" VTEP_Address | \n",
" Remote_VTEP_Address | \n",
" VLAN | \n",
" Remote_VLAN | \n",
" UDP_Port | \n",
" Multicast_Group | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 10130 | \n",
" dc1-leaf2b | \n",
" dc1-svc3a | \n",
" 192.168.254.4 | \n",
" 192.168.254.6 | \n",
" 130 | \n",
" 130 | \n",
" 4789 | \n",
" None | \n",
"
\n",
" \n",
" | 1 | \n",
" 10140 | \n",
" dc1-leaf2a | \n",
" dc1-svc3a | \n",
" 192.168.254.4 | \n",
" 192.168.254.6 | \n",
" 140 | \n",
" 140 | \n",
" 4789 | \n",
" None | \n",
"
\n",
" \n",
" | 2 | \n",
" 10130 | \n",
" dc1-svc3a | \n",
" dc1-leaf2a | \n",
" 192.168.254.6 | \n",
" 192.168.254.4 | \n",
" 130 | \n",
" 130 | \n",
" 4789 | \n",
" None | \n",
"
\n",
" \n",
" | 3 | \n",
" 10111 | \n",
" dc1-leaf1a | \n",
" dc1-leaf2b | \n",
" 192.168.254.3 | \n",
" 192.168.254.4 | \n",
" 111 | \n",
" 111 | \n",
" 4789 | \n",
" None | \n",
"
\n",
" \n",
" | 4 | \n",
" 10130 | \n",
" dc1-svc3b | \n",
" dc1-leaf2b | \n",
" 192.168.254.6 | \n",
" 192.168.254.4 | \n",
" 130 | \n",
" 130 | \n",
" 4789 | \n",
" None | \n",
"
\n",
" \n",
"
\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",
" Node | \n",
" VRF | \n",
" VNI | \n",
" Route_Distinguisher | \n",
" Import_Route_Target | \n",
" Export_Route_Target | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" dc1-bl1a | \n",
" Tenant_A_WAN_Zone | \n",
" 15005 | \n",
" 192.168.255.8:15005 | \n",
" 15005:15005 | \n",
" 15005:15005 | \n",
"
\n",
" \n",
" | 1 | \n",
" dc1-bl1a | \n",
" Tenant_B_WAN_Zone | \n",
" 25021 | \n",
" 192.168.255.8:25021 | \n",
" 25021:25021 | \n",
" 25021:25021 | \n",
"
\n",
" \n",
" | 2 | \n",
" dc1-bl1a | \n",
" Tenant_C_WAN_Zone | \n",
" 35031 | \n",
" 192.168.255.8:35031 | \n",
" 35031:35031 | \n",
" 35031:35031 | \n",
"
\n",
" \n",
" | 3 | \n",
" dc1-bl1b | \n",
" Tenant_A_WAN_Zone | \n",
" 15005 | \n",
" 192.168.255.9:15005 | \n",
" 15005:15005 | \n",
" 15005:15005 | \n",
"
\n",
" \n",
" | 4 | \n",
" dc1-bl1b | \n",
" Tenant_B_WAN_Zone | \n",
" 25021 | \n",
" 192.168.255.9:25021 | \n",
" 25021:25021 | \n",
" 25021:25021 | \n",
"
\n",
" \n",
"
\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
}