示例#1
0
    def indications_process(self, topic, msg):

        ind = Parse(loads(msg),
                    openolt_pb2.Indication(),
                    ignore_unknown_fields=True)

        self.log.debug("received openolt indication", ind=ind)

        if self.device.admin_state is "down":
            if ind.HasField('intf_oper_ind') \
                    and (ind.intf_oper_ind.type == "nni"):
                self.log.warn('olt is admin down, allow nni ind',
                              admin_state=self.device.admin_state,
                              indications=ind)
            else:
                self.log.warn('olt is admin down, ignore indication',
                              admin_state=self.device.admin_state,
                              indications=ind)
                return

        # indication handlers run in the main event loop
        if ind.HasField('olt_ind'):
            reactor.callFromThread(self.device.olt_indication, ind.olt_ind)
        elif ind.HasField('intf_ind'):
            reactor.callFromThread(self.device.intf_indication, ind.intf_ind)
        elif ind.HasField('intf_oper_ind'):
            reactor.callFromThread(self.device.intf_oper_indication,
                                   ind.intf_oper_ind)
        elif ind.HasField('onu_disc_ind'):
            reactor.callFromThread(self.device.onu_discovery_indication,
                                   ind.onu_disc_ind)
        elif ind.HasField('onu_ind'):
            reactor.callFromThread(self.device.onu_indication, ind.onu_ind)
        elif ind.HasField('omci_ind'):
            reactor.callFromThread(self.device.omci_indication, ind.omci_ind)
        elif ind.HasField('port_stats'):
            reactor.callFromThread(
                self.device.stats_mgr.port_statistics_indication,
                ind.port_stats)
        elif ind.HasField('flow_stats'):
            reactor.callFromThread(
                self.device.stats_mgr.flow_statistics_indication,
                ind.flow_stats)
        elif ind.HasField('alarm_ind'):
            reactor.callFromThread(self.device.alarm_mgr.process_alarms,
                                   ind.alarm_ind)
        else:
            self.log.warn('unknown indication type')
示例#2
0
    def packet_in_process(self, topic, msg):

        ind = Parse(loads(msg), openolt_pb2.Indication(),
                    ignore_unknown_fields=True)
        assert(ind.HasField('pkt_ind'))
        pkt_ind = ind.pkt_ind

        self.log.debug("packet indication",
                       intf_type=pkt_ind.intf_type,
                       intf_id=pkt_ind.intf_id,
                       port_no=pkt_ind.port_no,
                       cookie=pkt_ind.cookie,
                       gemport_id=pkt_ind.gemport_id,
                       flow_id=pkt_ind.flow_id)
        try:
            logical_port_num = self.device.data_model.logical_port_num(
                pkt_ind.intf_type,
                pkt_ind.intf_id,
                pkt_ind.port_no,
                pkt_ind.gemport_id)
        except ValueError:
            self.log.error('No logical port found',
                           intf_type=pkt_ind.intf_type,
                           intf_id=pkt_ind.intf_id,
                           port_no=pkt_ind.port_no,
                           gemport_id=pkt_ind.gemport_id)
            return

        ether_pkt = Ether(pkt_ind.pkt)

        if isinstance(ether_pkt, Packet):
            ether_pkt = str(ether_pkt)

        self.handle_packet_in_event(logical_port_num, str(ether_pkt))