Add get_bridgedomains()
This commit is contained in:
@ -21,6 +21,16 @@ class NullHandler(logging.Handler):
|
||||
pass
|
||||
|
||||
|
||||
def get_bridgedomains(yaml):
|
||||
""" Return a list of all bridgedomains. """
|
||||
ret = []
|
||||
if not 'bridgedomains' in yaml:
|
||||
return ret
|
||||
for ifname, iface in yaml['bridgedomains'].items():
|
||||
ret.append(ifname)
|
||||
return ret
|
||||
|
||||
|
||||
def get_by_name(yaml, ifname):
|
||||
""" Return the BridgeDomain by name, if it exists. Return None,None otherwise. """
|
||||
try:
|
||||
|
@ -34,3 +34,7 @@ class TestBridgeDomainMethods(unittest.TestCase):
|
||||
self.assertIn("BondEthernet0", ifs)
|
||||
self.assertIn("GigabitEthernet1/0/0", ifs)
|
||||
self.assertIn("GigabitEthernet2/0/0.100", ifs)
|
||||
|
||||
def test_get_bridgedomains(self):
|
||||
ifs = bridgedomain.get_bridgedomains(self.cfg)
|
||||
self.assertEqual(len(ifs), 3)
|
||||
|
Reference in New Issue
Block a user