X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FL2Util.py;h=724ec0cdceb48fbeef2653ed24943fe84ac6ab25;hp=0d34ce3e41adfab0028d9a5365ea8231d9d633bf;hb=e300d155302d493e0f4cf36b20081a1653909521;hpb=476ea70ea42ccd6f0486fa799058d47647bc0942 diff --git a/resources/libraries/python/L2Util.py b/resources/libraries/python/L2Util.py index 0d34ce3e41..724ec0cdce 100644 --- a/resources/libraries/python/L2Util.py +++ b/resources/libraries/python/L2Util.py @@ -18,6 +18,7 @@ from resources.libraries.python.topology import Topology from resources.libraries.python.VatExecutor import VatExecutor, VatTerminal from resources.libraries.python.ssh import exec_cmd_no_error + class L2Util(object): """Utilities for l2 configuration""" @@ -218,3 +219,29 @@ class L2Util(object): """ cmd = 'brctl delbr {0}'.format(br_name) exec_cmd_no_error(node, cmd, sudo=True) + + @staticmethod + def vpp_get_bridge_domain_data(node, bd_id=None): + """Get all bridge domain data from a VPP node. If a domain ID number is + provided, return only data for the matching bridge domain. + + :param node: VPP node to get bridge domain data from. + :param bd_id: Numeric ID of a specific bridge domain. + :type node: dict + :type bd_id: int + :return: List of dictionaries containing data for each bridge domain, or + a single dictionary for the specified bridge domain. + :rtype: list or dict + """ + with VatTerminal(node) as vat: + response = vat.vat_terminal_exec_cmd_from_template("l2_bd_dump.vat") + + data = response[0] + + if bd_id is not None: + for bridge_domain in data: + if bridge_domain["bd_id"] == bd_id: + + return bridge_domain + + return data