示例#1
0
    def activate(self, device):
        self.log.info('activating')

        self.device_parent_id = device.parent_id
        self.proxy_address = device.proxy_address

        # populate device info
        device.root = False
        device.vendor = 'ponsim'
        device.model = 'n/a'
        device.serial_number = device.serial_number
        device.mac_address = "AA:BB:CC:DD:E0:00"
        yield self.core_proxy.device_update(device)

        # Now set the initial PM configuration for this device
        self.pm_metrics = AdapterPmMetrics(device)
        pm_config = self.pm_metrics.make_proto()
        log.info("initial-pm-config", pm_config=pm_config)
        yield self.core_proxy.device_pm_config_update(pm_config, init=True)

        # Use the channel Id, assigned by the parent device to me, as the port number
        uni_port = 2
        if device.proxy_address is not None:
            if device.proxy_address.channel_id != 0:
                uni_port = device.proxy_address.channel_id

        # register physical ports
        self.uni_port = Port(port_no=uni_port,
                             label="uni-" + str(uni_port),
                             type=Port.ETHERNET_UNI,
                             admin_state=AdminState.ENABLED,
                             oper_status=OperStatus.ACTIVE)
        self.pon_port = Port(port_no=1,
                             label='pon-1',
                             type=Port.PON_ONU,
                             admin_state=AdminState.ENABLED,
                             oper_status=OperStatus.ACTIVE,
                             peers=[
                                 Port.PeerPort(device_id=device.parent_id,
                                               port_no=device.parent_port_no)
                             ])
        yield self.core_proxy.port_created(device.id, self.uni_port)
        yield self.core_proxy.port_created(device.id, self.pon_port)

        yield self.core_proxy.device_state_update(
            device.id,
            connect_status=ConnectStatus.REACHABLE,
            oper_status=OperStatus.ACTIVE)

        # Start collecting stats from the device after a brief pause
        self.start_kpi_collection(device.id)
    def get_port(self):
        """
        Get the VOLTHA PORT object for this port
        :return: VOLTHA Port object
        """

        cap = OFPPF_1GB_FD | OFPPF_FIBER

        hw_addr = mac_str_to_tuple(
            '08:%02x:%02x:%02x:%02x:%02x' %
            ((self.parent_port_no >> 8 & 0xff), self.parent_port_no & 0xff,
             (self.port_number >> 16) & 0xff,
             (self.port_number >> 8) & 0xff, self.port_number & 0xff))

        name = self.serial_number + '-' + str(self.mac_bridge_port_num)

        ofstate = OFPPS_LINK_DOWN
        if self.operstatus is OperStatus.ACTIVE:
            ofstate = OFPPS_LIVE

        self._port = Port(port_no=self.port_number,
                          label=self.port_id_name(),
                          type=Port.ETHERNET_UNI,
                          admin_state=self._admin_state,
                          oper_status=self._oper_status,
                          ofp_port=ofp_port(name=name,
                                            hw_addr=hw_addr,
                                            config=0,
                                            state=ofstate,
                                            curr=cap,
                                            advertised=cap,
                                            peer=cap,
                                            curr_speed=OFPPF_1GB_FD,
                                            max_speed=OFPPF_1GB_FD))
        return self._port
 def get_port(self):
     """
     Get the VOLTHA PORT object for this port
     :return: VOLTHA Port object
     """
     self._port = Port(port_no=self.port_number,
                       label=self.port_id_name(),
                       type=Port.ETHERNET_UNI,
                       admin_state=self._admin_state,
                       oper_status=self._oper_status)
     return self._port
示例#4
0
    def disable_port(self, device_id, port, **kwargs):
        if not device_id:
            return False, Error(code=ErrorCode.INVALID_PARAMETER,
                                reason="device")
        p = Port()
        if port:
            port.Unpack(p)
        else:
            return False, Error(code=ErrorCode.INVALID_PARAMETERS,
                                reason="port-invalid")

        return (True, self.adapter.disable_port(device_id, port))
示例#5
0
    def disable_port(self, deviceId, port, **_kwargs):  # pylint: disable=invalid-name
        if not deviceId:
            return False, Error(code=ErrorCode.INVALID_PARAMETER,
                                reason="device-id")
        if not port:
            return False, Error(code=ErrorCode.INVALID_PARAMETER,
                                reason="port-invalid")
        str_arg = StrType()
        deviceId.Unpack(str_arg)
        port_arg = Port()
        port.Unpack(port_arg)

        return True, self.adapter.disable_port(str_arg.val, port_arg.port_no)
示例#6
0
    def get_port(self):
        """
        Get the VOLTHA PORT object for this port
        :return: VOLTHA Port object
        """

        self._port = Port(port_no=self.port_number,
                          label='PON port',
                          type=Port.PON_ONU,
                          admin_state=self._admin_state,
                          oper_status=self._oper_status,
                          peers=self._peers)
        return self._port
示例#7
0
    def add_port(self, intf_id, port_type, oper_status):
        port_no = self.platform.intf_id_to_port_no(intf_id, port_type)

        label = self.port_name(port_no, port_type, intf_id)

        self.log.debug('adding-port',
                       port_no=port_no,
                       label=label,
                       port_type=port_type)

        port = Port(port_no=port_no,
                    label=label,
                    type=port_type,
                    admin_state=AdminState.ENABLED,
                    oper_status=oper_status)

        yield self.core_proxy.port_created(self.device_id, port)
示例#8
0
    def activate(self, device):
        try:
            self.log.info('activating')

            if not device.host_and_port:
                device.oper_status = OperStatus.FAILED
                device.reason = 'No host_and_port field provided'
                self.core_proxy.device_update(device)
                return

            yield self.get_channel()
            stub = PonSimStub(self.channel)
            info = stub.GetDeviceInfo(Empty())
            log.info('got-info', info=info, device_id=device.id)
            self.ofp_port_no = info.nni_port

            device.root = True
            device.vendor = 'ponsim'
            device.model = 'n/a'
            device.serial_number = device.host_and_port
            device.mac_address = "AA:BB:CC:DD:EE:FF"
            yield self.core_proxy.device_update(device)

            # Now set the initial PM configuration for this device
            self.pm_metrics = AdapterPmMetrics(device)
            pm_config = self.pm_metrics.make_proto()
            log.info("initial-pm-config", pm_config=pm_config)
            yield self.core_proxy.device_pm_config_update(pm_config, init=True)

            # Setup alarm handler
            self.alarms = AdapterAlarms(self.adapter, device)

            nni_port = Port(port_no=info.nni_port,
                            label='nni-' + str(info.nni_port),
                            type=Port.ETHERNET_NNI,
                            oper_status=OperStatus.ACTIVE)
            self.nni_port = nni_port
            yield self.core_proxy.port_created(device.id, nni_port)
            yield self.core_proxy.port_created(
                device.id,
                Port(port_no=1,
                     label='pon-1',
                     type=Port.PON_OLT,
                     oper_status=OperStatus.ACTIVE))

            yield self.core_proxy.device_state_update(
                device.id,
                connect_status=ConnectStatus.REACHABLE,
                oper_status=OperStatus.ACTIVE)

            # register ONUS
            self.log.info('onu-found', onus=info.onus, len=len(info.onus))
            for onu in info.onus:
                vlan_id = onu.uni_port
                yield self.core_proxy.child_device_detected(
                    parent_device_id=device.id,
                    parent_port_no=1,
                    child_device_type='ponsim_onu',
                    channel_id=vlan_id,
                    serial_number=onu.serial_number,
                )

            self.log.info('starting-frame-grpc-stream')
            reactor.callInThread(self.rcv_grpc)
            self.log.info('started-frame-grpc-stream')

            # Start collecting stats from the device after a brief pause
            self.start_kpi_collection(device.id)
        except Exception as e:
            log.exception("Exception-activating", e=e)
示例#9
0
 def add_peer(self, parent_device_id, parent_port_no):
     self.log.debug('add-peer-port', parent_device_id=parent_device_id, parent_port_no=parent_port_no)
     new_peer = Port.PeerPort(device_id=parent_device_id, port_no=parent_port_no)
     self._peers.extend([new_peer])