X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FL2Util.py;h=4ca0c47308ce3dbab9739400edcdb2a08ee0c3be;hb=f88a3d9178dfbd73d0479f9aa2f5224e0c89ca1f;hp=f1476044a6f7ab8b015b21e89c8956d9b963326d;hpb=fe1975eb1ac994df1bd759deda7154bb7dd9d7a7;p=csit.git diff --git a/resources/libraries/python/L2Util.py b/resources/libraries/python/L2Util.py index f1476044a6..4ca0c47308 100644 --- a/resources/libraries/python/L2Util.py +++ b/resources/libraries/python/L2Util.py @@ -19,7 +19,7 @@ from textwrap import wrap from enum import IntEnum from resources.libraries.python.Constants import Constants -from resources.libraries.python.PapiExecutor import PapiExecutor +from resources.libraries.python.PapiExecutor import PapiSocketExecutor from resources.libraries.python.topology import Topology from resources.libraries.python.ssh import exec_cmd_no_error @@ -129,9 +129,8 @@ class L2Util(object): static_mac=int(static_mac), filter_mac=int(filter_mac), bvi_mac=int(bvi_mac)) - with PapiExecutor(node) as papi_exec: - papi_exec.add(cmd, **args).get_replies(err_msg).\ - verify_reply(err_msg=err_msg) + with PapiSocketExecutor(node) as papi_exec: + papi_exec.add(cmd, **args).get_reply(err_msg) @staticmethod def create_l2_bd(node, bd_id, flood=1, uu_flood=1, forward=1, learn=1, @@ -169,9 +168,8 @@ class L2Util(object): learn=int(learn), arp_term=int(arp_term), is_add=1) - with PapiExecutor(node) as papi_exec: - papi_exec.add(cmd, **args).get_replies(err_msg).\ - verify_reply(err_msg=err_msg) + with PapiSocketExecutor(node) as papi_exec: + papi_exec.add(cmd, **args).get_reply(err_msg) @staticmethod def add_interface_to_l2_bd(node, interface, bd_id, shg=0, port_type=0): @@ -202,9 +200,8 @@ class L2Util(object): shg=int(shg), port_type=int(port_type), enable=1) - with PapiExecutor(node) as papi_exec: - papi_exec.add(cmd, **args).get_replies(err_msg).\ - verify_reply(err_msg=err_msg) + with PapiSocketExecutor(node) as papi_exec: + papi_exec.add(cmd, **args).get_reply(err_msg) @staticmethod def vpp_add_l2_bridge_domain(node, bd_id, port_1, port_2, learn=True): @@ -251,9 +248,9 @@ class L2Util(object): err_msg = 'Failed to add L2 bridge domain with 2 interfaces on host' \ ' {host}'.format(host=node['host']) - with PapiExecutor(node) as papi_exec: - papi_exec.add(cmd1, **args1).add(cmd2, **args2).add(cmd2, **args3).\ - get_replies(err_msg).verify_replies(err_msg=err_msg) + with PapiSocketExecutor(node) as papi_exec: + papi_exec.add(cmd1, **args1).add(cmd2, **args2).add(cmd2, **args3) + papi_exec.get_replies(err_msg) @staticmethod def vpp_setup_bidirectional_cross_connect(node, interface1, interface2): @@ -288,9 +285,8 @@ class L2Util(object): err_msg = 'Failed to add L2 cross-connect between two interfaces on' \ ' host {host}'.format(host=node['host']) - with PapiExecutor(node) as papi_exec: - papi_exec.add(cmd, **args1).add(cmd, **args2).get_replies(err_msg).\ - verify_replies(err_msg=err_msg) + with PapiSocketExecutor(node) as papi_exec: + papi_exec.add(cmd, **args1).add(cmd, **args2).get_replies(err_msg) @staticmethod def vpp_setup_bidirectional_l2_patch(node, interface1, interface2): @@ -325,9 +321,8 @@ class L2Util(object): err_msg = 'Failed to add L2 patch between two interfaces on' \ ' host {host}'.format(host=node['host']) - with PapiExecutor(node) as papi_exec: - papi_exec.add(cmd, **args1).add(cmd, **args2).get_replies(err_msg).\ - verify_replies(err_msg=err_msg) + with PapiSocketExecutor(node) as papi_exec: + papi_exec.add(cmd, **args1).add(cmd, **args2).get_replies(err_msg) @staticmethod def linux_add_bridge(node, br_name, if_1, if_2, set_up=True): @@ -393,24 +388,17 @@ class L2Util(object): """ cmd = 'bridge_domain_dump' - cmd_reply = 'bridge_domain_details' args = dict(bd_id=int(bd_id)) err_msg = 'Failed to get L2FIB dump on host {host}'.format( host=node['host']) - with PapiExecutor(node) as papi_exec: - papi_resp = papi_exec.add(cmd, **args).get_dump(err_msg) + with PapiSocketExecutor(node) as papi_exec: + details = papi_exec.add(cmd, **args).get_details(err_msg) - data = papi_resp.reply[0]['api_reply'] - - bd_data = list() if bd_id == Constants.BITWISE_NON_ZERO else dict() - for bridge_domain in data: - if bd_id == Constants.BITWISE_NON_ZERO: - bd_data.append(bridge_domain[cmd_reply]) - else: - if bridge_domain[cmd_reply]['bd_id'] == bd_id: - return bridge_domain[cmd_reply] - - return bd_data + if bd_id == Constants.BITWISE_NON_ZERO: + return details + for bridge_domain in details: + if bridge_domain['bd_id'] == bd_id: + return bridge_domain @staticmethod def l2_vlan_tag_rewrite(node, interface, tag_rewrite_method, @@ -452,9 +440,8 @@ class L2Util(object): tag2=tag2_id) err_msg = 'Failed to set VLAN TAG rewrite on host {host}'.format( host=node['host']) - with PapiExecutor(node) as papi_exec: - papi_exec.add(cmd, **args).get_replies(err_msg).\ - verify_reply(err_msg=err_msg) + with PapiSocketExecutor(node) as papi_exec: + papi_exec.add(cmd, **args).get_reply(err_msg) @staticmethod def get_l2_fib_table(node, bd_id): @@ -469,22 +456,16 @@ class L2Util(object): """ cmd = 'l2_fib_table_dump' - cmd_reply = 'l2_fib_table_details' args = dict(bd_id=int(bd_id)) err_msg = 'Failed to get L2FIB dump on host {host}'.format( host=node['host']) - with PapiExecutor(node) as papi_exec: - papi_resp = papi_exec.add(cmd, **args).get_dump(err_msg) - - data = papi_resp.reply[0]['api_reply'] + with PapiSocketExecutor(node) as papi_exec: + details = papi_exec.add(cmd, **args).get_details(err_msg) - fib_data = list() - for fib in data: - fib_item = fib[cmd_reply] + for fib_item in details: fib_item['mac'] = L2Util.bin_to_mac(fib_item['mac']) - fib_data.append(fib_item) - return fib_data + return details @staticmethod def get_l2_fib_entry_by_mac(node, bd_index, mac):