Use correct system default prompt for start/stop mininet
[integration/test.git] / csit / libraries / BgpRpcClient.py
index b42c43a49cf9647a041cb1a74ad6519ab9e23868..55dba2b35f52f6b50cf69f3f9ddf660085fd3999 100644 (file)
@@ -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:])))