Skip to content

Commit

Permalink
Updated review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
tapashdas committed Dec 17, 2020
1 parent d9e9df6 commit 24958ff
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 31 deletions.
4 changes: 4 additions & 0 deletions tests/mock_tables/config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,10 @@
"vni" : "200",
"vlan": "Vlan200"
},
"VRF|Vrf1": {
"fallback": "false",
"vni" : "1000"
},
"BUFFER_POOL|egress_lossless_pool": {
"mode": "dynamic",
"size": "13945824",
Expand Down
19 changes: 19 additions & 0 deletions tests/vxlan_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@
"""

show_vxlan_vrfvnimap_output="""\
+-------+-------+
| VRF | VNI |
+=======+=======+
| Vrf1 | 1000 |
+-------+-------+
Total count : 1
"""


show_vxlan_tunnel_output="""\
+---------+-------------+-------------------+--------------+
| SIP | DIP | Creation Source | OperStatus |
Expand Down Expand Up @@ -110,6 +121,14 @@ def test_show_vxlan_vlanvnimap(self):
assert result.exit_code == 0
assert result.output == show_vxlan_vlanvnimap_output

def test_show_vxlan_vrfvnimap(self):
runner = CliRunner()
result = runner.invoke(show.cli.commands["vxlan"].commands["vrfvnimap"], [])
print(result.exit_code)
print(result.output)
assert result.exit_code == 0
assert result.output == show_vxlan_vrfvnimap_output

def test_show_vxlan_tunnel(self):
runner = CliRunner()
result = runner.invoke(show.cli.commands["vxlan"].commands["remotevtep"], [])
Expand Down
31 changes: 0 additions & 31 deletions utilities_common/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,37 +301,6 @@ def is_port_mirror_dst_port(config_db, port):

return False

#
# Use this method to validate unicast IPv4 address
#
def is_ip4_addr_valid(addr, display):
v4_invalid_list = [ipaddress.IPv4Address(unicode('0.0.0.0')), ipaddress.IPv4Address(unicode('255.255.255.255'))]
try:
ip = ipaddress.ip_address(unicode(addr))
if (ip.version == 4):
if (ip.is_reserved):
if display:
click.echo ("{} Not Valid, Reason: IPv4 reserved address range.".format(addr))
return False
elif (ip.is_multicast):
if display:
click.echo ("{} Not Valid, Reason: IPv4 Multicast address range.".format(addr))
return False
elif (ip in v4_invalid_list):
if display:
click.echo ("{} Not Valid.".format(addr))
return False
else:
return True

else:
if display:
click.echo ("{} Not Valid, Reason: Not an IPv4 address".format(addr))
return False

except ValueError:
return False

def vni_id_is_valid(vni):
"""Check if the vni id is in acceptable range (between 1 and 2^24)
"""
Expand Down

0 comments on commit 24958ff

Please sign in to comment.