def send_link_monitor_cmd(self, command, interface="", metric=0, node=""): req_msg = lm_types.LinkMonitorRequest(command, interface, metric, node) self.send_and_recv_thrift_obj(req_msg, str) return self.dump_links()
def get_build_info(self): command = lm_types.LinkMonitorCommand.GET_BUILD_INFO req_msg = lm_types.LinkMonitorRequest(command) self._lm_cmd_socket.send_thrift_obj(req_msg) return self._lm_cmd_socket.recv_thrift_obj(lm_types.BuildInfo)
def get_openr_version(self): command = lm_types.LinkMonitorCommand.GET_VERSION req_msg = lm_types.LinkMonitorRequest(command) self._lm_cmd_socket.send_thrift_obj(req_msg) return self._lm_cmd_socket.recv_thrift_obj(lm_types.OpenrVersions)
def dump_links(self, all=True): ''' @param all: If set to false then links with no addresses will be filtered out. ''' req_msg = lm_types.LinkMonitorRequest() req_msg.cmd = lm_types.LinkMonitorCommand.DUMP_LINKS req_msg.interfaceName = '' self._lm_cmd_socket.send_thrift_obj(req_msg) links = self._lm_cmd_socket.recv_thrift_obj(lm_types.DumpLinksReply) # filter out link with no addresses if not all: links.interfaceDetails = { k: v for k, v in links.interfaceDetails.items() if len(v.info.v6LinkLocalAddrs + v.info.v4Addrs) != 0} return links
def dump_links(self, all=True): """ @param all: If set to false then links with no addresses will be filtered out. """ req_msg = lm_types.LinkMonitorRequest() req_msg.cmd = lm_types.LinkMonitorCommand.DUMP_LINKS links = self.send_and_recv_thrift_obj(req_msg, lm_types.DumpLinksReply) # filter out link with no addresses if not all: links.interfaceDetails = { k: v for k, v in links.interfaceDetails.items() if len(v.info.networks) != 0 } return links
def send_link_monitor_cmd(self, command, interface='', metric=0, node=''): req_msg = lm_types.LinkMonitorRequest(command, interface, metric, node) self._lm_cmd_socket.send_thrift_obj(req_msg) return self.dump_links()
def get_build_info(self): return self.send_and_recv_thrift_obj( lm_types.LinkMonitorRequest( lm_types.LinkMonitorCommand.GET_BUILD_INFO), lm_types.BuildInfo, )
def get_openr_version(self): return self.send_and_recv_thrift_obj( lm_types.LinkMonitorRequest( lm_types.LinkMonitorCommand.GET_VERSION), lm_types.OpenrVersions, )