Example #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)
Example #2
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])