def get_lm_link_db(self, cli_opts): self.lm_client = lm_client.LMClient( cli_opts.zmq_ctx, "tcp://[{}]:{}".format(cli_opts.host, cli_opts.lm_cmd_port), cli_opts.timeout, cli_opts.proto_factory) return self.lm_client.dump_links()
def run(self, cli_opts): try: # fetch routes from decision module (decision_unicast_routes, decision_mpls_routes) = utils.get_shortest_routes( decision_client.DecisionClient(cli_opts).get_route_db()) # fetch routes from fib module (fib_unicast_routes, fib_mpls_routes) = utils.get_shortest_routes( fib_client.FibClient(cli_opts).get_route_db()) # fetch route from net_agent module agent_unicast_routes = self.client.getRouteTableByClient( self.client.client_id) agent_mpls_routes = self.client.getMplsRouteTableByClient( self.client.client_id) # fetch link_db from link-monitor module lm_links = lm_client.LMClient( cli_opts).dump_links().interfaceDetails except Exception as e: print("Failed to validate Fib routes.") print("Exception: {}".format(e)) raise e # return 1 (res1_unicast, _) = utils.compare_route_db( decision_unicast_routes, fib_unicast_routes, "unicast", ["Decision:unicast", "Openr-Fib:unicast"], cli_opts.enable_color, ) (res1_mpls, _) = utils.compare_route_db( decision_mpls_routes, fib_mpls_routes, "mpls", ["Decision:mpls", "Openr-Fib:mpls"], cli_opts.enable_color, ) (res2_unicast, _) = utils.compare_route_db( fib_unicast_routes, agent_unicast_routes, "unicast", ["Openr-Fib:unicast", "FibAgent:unicast"], cli_opts.enable_color, ) (res2_mpls, _) = utils.compare_route_db( fib_mpls_routes, agent_mpls_routes, "mpls", ["Openr-Fib:mpls", "FibAgent:mpls"], cli_opts.enable_color, ) (res3, _) = utils.validate_route_nexthops( fib_unicast_routes, lm_links, ["Openr-Fib:unicast", "LinkMonitor"], cli_opts.enable_color, ) return (0 if res1_unicast and res1_mpls and res2_unicast and res2_mpls and res3 else -1)
def _lm_client(): lm_client_inst = lm_client.LMClient( bunch.Bunch( {"ctx": zmq.Context(), "host": "localhost", "lm_cmd_port": 5000} ) ) self.assertEqual(lm_client_inst.dump_links(), dump_links_cache)
def __init__(self, cli_opts): ''' initialize the Link Monitor client ''' self.client = lm_client.LMClient( cli_opts.zmq_ctx, "tcp://[{}]:{}".format(cli_opts.host, cli_opts.lm_cmd_port), cli_opts.timeout, cli_opts.proto_factory) self.enable_color = cli_opts.enable_color
def __init__(self, cli_opts): """ initialize the Link Monitor client """ self.client = lm_client.LMClient(cli_opts) self.enable_color = cli_opts.enable_color
def get_lm_link_db(self, cli_opts): self.lm_client = lm_client.LMClient(cli_opts) return self.lm_client.dump_links()
def _lm_client(): lm_client_inst = lm_client.LMClient(zmq.Context(), "tcp://localhost:5000") self.assertEqual(lm_client_inst.dump_links(), dump_links_cache)