X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=csit%2Flibraries%2FBgpRpcClient.py;h=55dba2b35f52f6b50cf69f3f9ddf660085fd3999;hb=b2cd74063cbcdfadcbe20746116ec276e27ea0cb;hp=b42c43a49cf9647a041cb1a74ad6519ab9e23868;hpb=69f2bb83aa1140a117ac79e71e4b51453b3cf11d;p=integration%2Ftest.git diff --git a/csit/libraries/BgpRpcClient.py b/csit/libraries/BgpRpcClient.py index b42c43a49c..55dba2b35f 100644 --- a/csit/libraries/BgpRpcClient.py +++ b/csit/libraries/BgpRpcClient.py @@ -6,15 +6,16 @@ exa_ methods apply to test/tools/exabgp_files/exarpc.py play_ methods apply to test/tool/fastbgp/play.py (only with --evpn used) """ +import re import xmlrpclib class BgpRpcClient(object): """The client for SimpleXMLRPCServer.""" - def __init__(self, peer_addr): + def __init__(self, peer_addr, port=8000): """Setup destination point of the rpc server""" - self.proxy = xmlrpclib.ServerProxy("http://{}:8000".format(peer_addr)) + self.proxy = xmlrpclib.ServerProxy("http://{}:{}".format(peer_addr, port)) def exa_announce(self, full_exabgp_cmd): """The full command to be passed to exabgp.""" @@ -95,3 +96,8 @@ class BgpRpcClient(object): def play_clean(self, what='update'): """Cleans the message (update) on the server.""" return self.proxy.clean(what) + + def sum_hex_message(self, hex_string): + """Verifies two hex messages are equal even in case, their arguments are misplaced. + Converts hex message arguments to integers and sums them up and returns the sum.""" + return sum(map(lambda x: int(x, 16), re.compile('[a-f\d]{2}').findall(hex_string[32:])))