Exemplo n.º 1
0
    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()
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    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
Exemplo n.º 5
0
    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
Exemplo n.º 6
0
    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()
Exemplo n.º 7
0
 def get_build_info(self):
     return self.send_and_recv_thrift_obj(
         lm_types.LinkMonitorRequest(
             lm_types.LinkMonitorCommand.GET_BUILD_INFO),
         lm_types.BuildInfo,
     )
Exemplo n.º 8
0
 def get_openr_version(self):
     return self.send_and_recv_thrift_obj(
         lm_types.LinkMonitorRequest(
             lm_types.LinkMonitorCommand.GET_VERSION),
         lm_types.OpenrVersions,
     )