X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FSRv6.py;h=eca22a2b1744457bd9b4258a9996f38ab3d1cc31;hp=063bcd5f2a7aaa61dc42f026036e7764a08fb7a3;hb=b6606e7625e308a66bdfb9d5a9c065b58e429a99;hpb=a0d8705217e6f480d103e16d00fa63289019848f diff --git a/resources/libraries/python/SRv6.py b/resources/libraries/python/SRv6.py index 063bcd5f2a..eca22a2b17 100644 --- a/resources/libraries/python/SRv6.py +++ b/resources/libraries/python/SRv6.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Cisco and/or its affiliates. +# Copyright (c) 2021 Cisco and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: @@ -207,10 +207,7 @@ class SRv6: :type node: dict """ cmd = u"sr_localsids_dump" - err_msg = f"Failed to get SR localSID dump on host {node[u'host']}" - - with PapiSocketExecutor(node) as papi_exec: - papi_exec.add(cmd).get_details(err_msg) + PapiSocketExecutor.dump_and_log(node, (cmd,)) @staticmethod def configure_sr_policy(node, bsid, sid_list, mode=u"encap"): @@ -247,10 +244,7 @@ class SRv6: :type node: dict """ cmd = u"sr_policies_dump" - err_msg = f"Failed to get SR policies dump on host {node[u'host']}" - - with PapiSocketExecutor(node) as papi_exec: - papi_exec.add(cmd).get_details(err_msg) + PapiSocketExecutor.dump_and_log(node, (cmd,)) @staticmethod def _get_sr_steer_policy_args( @@ -298,10 +292,10 @@ class SRv6: ip_addr = ip_address(ip_addr) prefix = IPUtil.create_prefix_object(ip_addr, int(prefix)) traffic_type = getattr( - SRv6PolicySteeringTypes, u"SR_STEER_IPV4" - ).value if ip_addr.version == 4 else getattr( - SRv6PolicySteeringTypes, u"SR_STEER_IPV6" - ).value + SRv6PolicySteeringTypes, u"SR_STEER_IPV4" + ).value if ip_addr.version == 4 else getattr( + SRv6PolicySteeringTypes, u"SR_STEER_IPV6" + ).value else: raise ValueError(f"Unsupported mode: {mode}") @@ -332,8 +326,8 @@ class SRv6: is missing. """ sw_if_index, prefix, traffic_type = SRv6._get_sr_steer_policy_args( - node, mode, interface, ip_addr, prefix - ) + node, mode, interface, ip_addr, prefix + ) cmd = u"sr_steering_add_del" args = dict( @@ -359,10 +353,7 @@ class SRv6: :type node: dict """ cmd = u"sr_steering_pol_dump" - err_msg = f"Failed to get SR localSID dump on host {node[u'host']}" - - with PapiSocketExecutor(node) as papi_exec: - papi_exec.add(cmd).get_details(err_msg) + PapiSocketExecutor.dump_and_log(node, (cmd,)) @staticmethod def set_sr_encaps_source_address(node, ip6_addr):