-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix interface_split, add tests
- Loading branch information
Showing
8 changed files
with
96 additions
and
6 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
vrf definition VRF-A | ||
rd 65421:1327 | ||
description | ||
! | ||
address-family ipv4 | ||
route-target export 65000:1327 | ||
|
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 |
---|---|---|
@@ -1,3 +1,44 @@ | ||
{ | ||
"vrfs": {} | ||
"VRF-A": { | ||
"rd": "65421:1327", | ||
"description": null, | ||
"address_families": [ | ||
{ | ||
"afi": "ipv4", | ||
"import": [ | ||
"65000:327" | ||
], | ||
"export": [ | ||
"65000:1327" | ||
] | ||
} | ||
] | ||
}, | ||
"VRF-B": { | ||
"rd": "65421:11", | ||
"description": null, | ||
"address_families": [ | ||
{ | ||
"afi": "ipv4", | ||
"import": [ | ||
"65000:10" | ||
], | ||
"export": [ | ||
"65000:11" | ||
] | ||
} | ||
] | ||
}, | ||
"Mgmt-intf": { | ||
"rd": null, | ||
"description": null, | ||
"address_families": [ | ||
{ | ||
"afi": "ipv4" | ||
}, | ||
{ | ||
"afi": "ipv6" | ||
} | ||
] | ||
} | ||
} |
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,36 @@ | ||
import unittest | ||
from ccutils.utils.common_utils import split_interface_name, convert_interface_name | ||
import json | ||
|
||
|
||
class TestCommonUtils(unittest.TestCase): | ||
|
||
def test_split_interface_name(self): | ||
testmap = { | ||
"FastEthernet0/20": ["FastEthernet", "0/20"], | ||
"Vlan1": ["Vlan", "1"], | ||
"Port-channel1": ["Port-channel", "1"], | ||
"GigabitEthernet1/0/1.20": ["GigabitEthernet", "1/0/1.20"], | ||
} | ||
for interface, parts in testmap.items(): | ||
with self.subTest(msg="{}".format(interface)): | ||
want = parts | ||
have = split_interface_name(interface=interface) | ||
self.assertEqual(want, have) | ||
|
||
def test_convert_interface_name(self): | ||
testmap = { | ||
"FastEthernet0/20": "Fa0/20", | ||
"Vlan1": "Vl1", | ||
"Port-channel1": "Po1", | ||
"GigabitEthernet1/0/1.20": "Gi1/0/1.20", | ||
"Port-channel10.20": "Po10.20", | ||
} | ||
for interface, parts in testmap.items(): | ||
with self.subTest(msg="{}".format(interface)): | ||
want = parts | ||
have = convert_interface_name(interface=interface, out="short") | ||
self.assertEqual(want, have) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |