-
Notifications
You must be signed in to change notification settings - Fork 684
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
What I did Created a new CLI Command Show vnet endpoint with option to give IPv4 or IPv6 address parameter. How I did it This command goes over all vxlan tunnels and checks each endpoints monitor session to populate the endpoint state. while doing so it also tracks the prefixes pointing to an endpoint. How to verify it run show vnet endpoint or show vnet endpoint<ipv4 address/ipv6 address>. >>show vnet endpoint Endpoint Endpoint Monitor prefix count status --------------------- --------------------- -------------- -------- fddd:a100:a251::a10:1 fddd:a100:a251::a10:1 1 Unknown fddd:a101:a251::a10:1 fddd:a101:a251::a10:1 1 Down 100.251.7.1 100.251.7.1 3 Up >>show vnet endpoint fddd:a101:a251::a10:1 Endpoint Endpoint Monitor prefix status --------------------- ------------------------- ---------------------------- -------- fddd:a101:a251::a10:1 ['fddd:a101:a251::a10:1'] ['fddd:a156:a251::a6:1/128'] Down >>show vnet endpoint 100.251.7.1 Endpoint Endpoint Monitor prefix status ----------- ------------------ ------------------------------------------------------------ -------- 100.251.7.1 ['100.251.7.1'] ['160.162.191.1/32', '160.163.191.1/32', '160.164.191.1/32'] Up Previous command output (if the output of a command-line utility has changed) None New command output (if the output of a command-line utility has changed) NA
- Loading branch information
1 parent
b1b3661
commit 0bbe54a
Showing
6 changed files
with
233 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import os | ||
import sys | ||
import traceback | ||
import mock_tables.dbconnector | ||
from click.testing import CliRunner | ||
from unittest import mock | ||
from utilities_common.db import Db | ||
import show.main as show | ||
|
||
#test_path = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
|
||
|
||
class TestShowVnet(object): | ||
@classmethod | ||
def setup_class(cls): | ||
print("SETUP") | ||
os.environ["UTILITIES_UNIT_TESTING"] = "1" | ||
|
||
def test_show_vnet_routes_all_basic(self): | ||
runner = CliRunner() | ||
db = Db() | ||
result = runner.invoke(show.cli.commands['vnet'].commands['routes'].commands['all'], [], obj=db) | ||
assert result.exit_code == 0 | ||
expected_output = """\ | ||
vnet name prefix nexthop interface | ||
----------- -------- --------- ----------- | ||
vnet name prefix endpoint mac address vni status | ||
--------------- ------------------------ ------------------------------------------- ------------- ----- -------- | ||
Vnet_v6_in_v6-0 fddd:a156:a251::a6:1/128 fddd:a100:a251::a10:1,fddd:a101:a251::a10:1 active | ||
test_v4_in_v4-0 160.162.191.1/32 100.251.7.1 active | ||
test_v4_in_v4-0 160.163.191.1/32 100.251.7.1 active | ||
test_v4_in_v4-0 160.164.191.1/32 100.251.7.1 | ||
""" | ||
assert result.output == expected_output | ||
|
||
def test_show_vnet_endpoint(self): | ||
runner = CliRunner() | ||
db = Db() | ||
result = runner.invoke(show.cli.commands['vnet'].commands['endpoint'], [], obj=db) | ||
assert result.exit_code == 0 | ||
expected_output = """\ | ||
Endpoint Endpoint Monitor prefix count status | ||
--------------------- --------------------- -------------- -------- | ||
fddd:a100:a251::a10:1 fddd:a100:a251::a10:1 1 Unknown | ||
fddd:a101:a251::a10:1 fddd:a101:a251::a10:1 1 Down | ||
100.251.7.1 100.251.7.1 3 Up | ||
""" | ||
assert result.output == expected_output | ||
|
||
def test_show_vnet_endpoint_ipv4(self): | ||
runner = CliRunner() | ||
db = Db() | ||
result = runner.invoke(show.cli.commands['vnet'].commands['endpoint'], ['100.251.7.1'], obj=db) | ||
assert result.exit_code == 0 | ||
expected_output = """\ | ||
Endpoint Endpoint Monitor prefix status | ||
----------- ------------------ ------------------------------------------------------------ -------- | ||
100.251.7.1 ['100.251.7.1'] ['160.162.191.1/32', '160.163.191.1/32', '160.164.191.1/32'] Up | ||
""" | ||
assert result.output == expected_output | ||
|
||
def test_show_vnet_endpoint_ipv6(self): | ||
runner = CliRunner() | ||
db = Db() | ||
result = runner.invoke(show.cli.commands['vnet'].commands['endpoint'], ['fddd:a101:a251::a10:1'], obj=db) | ||
assert result.exit_code == 0 | ||
expected_output = """\ | ||
Endpoint Endpoint Monitor prefix status | ||
--------------------- ------------------------- ---------------------------- -------- | ||
fddd:a101:a251::a10:1 ['fddd:a101:a251::a10:1'] ['fddd:a156:a251::a6:1/128'] Down | ||
""" | ||
assert result.output == expected_output |