Ejemplo n.º 1
0
 def create_port(self, vendor):
     port = Port(port_no=self.port_id,
                 label="{} ONU".format(vendor),
                 type=Port.ETHERNET_UNI,
                 admin_state=AdminState.ENABLED,
                 oper_status=OperStatus.ACTIVE)
     self.device.add_port(port)
Ejemplo n.º 2
0
    def update_device_info_from_pkt(self, pkt):

        self.device.root = True
        self.device.vendor = 'Celestica Inc.'
        self.device.model = 'Ruby'
        self.device.hardware_version = \
            '{}.{}'.format(hex(pkt.major_hardware_version),
                           pkt.minor_hardware_version)
        self.device.firmware_version = '{}.{}.{}'.format(
            pkt.major_firmware_version, pkt.minor_firmware_version,
            pkt.build_firmware_version)

        # There could be multiple software version on the device,
        # active, standby etc. Choose the active or running software
        # below. See simulated_olt for example implementation
        self.device.images.image.extend([Image(version="0.0.1")])
        self.device.serial_number = self.device.mac_address
        self.device.oper_status = ConnectStatus.REACHABLE
        self.adapter_agent.update_device(self.device)

        for i in CHANNELS:
            self.adapter_agent.add_port(
                self.device.id,
                Port(port_no=i,
                     label='PON port',
                     type=Port.PON_OLT,
                     admin_state=AdminState.ENABLED,
                     oper_status=OperStatus.ACTIVE))
Ejemplo n.º 3
0
    def get_port(self):
        """
        Get the VOLTHA PORT object for this port
        :return: VOLTHA Port object
        """
        self.log.debug('get-port-status-update',
                       port=self._port_no,
                       label=self._label)
        if self._port is None:
            self._port = Port(port_no=self._port_no,
                              label=self._label,
                              type=Port.ETHERNET_NNI,
                              admin_state=self._admin_state,
                              oper_status=self._oper_status)

        if self._port.admin_state != self._admin_state or\
           self._port.oper_status != self._oper_status:

            self.log.debug('get-port-status-update',
                           admin_state=self._admin_state,
                           oper_status=self._oper_status)
            self._port.admin_state = self._admin_state
            self._port.oper_status = self._oper_status

        return self._port
Ejemplo n.º 4
0
 def create_port(self, pkt):
     vendor = pkt['OmciGetResponse'].data['vendor_id']
     port = Port(port_no=self.port_id,
                 label="{} ONU".format(vendor),
                 type=Port.ETHERNET_UNI,
                 admin_state=AdminState.ENABLED,
                 oper_status=OperStatus.ACTIVE)
     self.device.add_port(port)
Ejemplo n.º 5
0
 def add_upstream_port(self, port):
     nni_port = Port(
         port_no=port,
         label='NNI',
         type=Port.ETHERNET_NNI,
         admin_state=AdminState.ENABLED,
         oper_status=OperStatus.ACTIVE
     )
     self.adapter_agent.add_port(self.device.id, nni_port)
Ejemplo n.º 6
0
    def onu_indication(self, onu_indication):
        self.log.debug("onu indication", intf_id=onu_indication.intf_id,
                onu_id=onu_indication.onu_id)

        # FIXME - handle onu_id/serial_number mismatch
        assert onu_indication.onu_id == self.lookup_onu(serial_number=onu_indication.serial_number)

        onu_device = self.adapter_agent.get_child_device(
            self.device_id, onu_id=onu_indication.onu_id)
        assert onu_device is not None

        msg = {'proxy_address':onu_device.proxy_address,
               'event':'activation-completed',
               'event_data':{'activation_successful':True}}
        self.adapter_agent.publish_inter_adapter_message(onu_device.id, msg)

        #
        # tcont create (onu)
        #
        alloc_id = self.mk_alloc_id(onu_indication.onu_id)
        msg = {'proxy_address':onu_device.proxy_address,
               'event':'create-tcont',
               'event_data':{'alloc_id':alloc_id}}
        self.adapter_agent.publish_inter_adapter_message(onu_device.id, msg)

        #
        # v_enet create (olt)
        #
        uni_no = self.mk_uni_port_num(onu_indication.intf_id, onu_indication.onu_id)
        uni_name = self.port_name(uni_no, Port.ETHERNET_UNI)
	self.adapter_agent.add_port(
            self.device_id,
            Port(
                port_no=uni_no,
                label=uni_name,
                type=Port.ETHERNET_UNI,
                admin_state=AdminState.ENABLED,
                oper_status=OperStatus.ACTIVE))

        #
        # v_enet create (onu)
        #
        interface_name = self.port_name(onu_indication.intf_id, Port.PON_OLT)
        msg = {'proxy_address':onu_device.proxy_address,
               'event':'create-venet',
               'event_data':{'uni_name':uni_name, 'interface_name':uni_name}}
        self.adapter_agent.publish_inter_adapter_message(onu_device.id, msg)

        #
        # gem port create
        #
        gemport_id = self.mk_gemport_id(onu_indication.onu_id)
        msg = {'proxy_address':onu_device.proxy_address,
               'event':'create-gemport',
               'event_data':{'gemport_id':gemport_id}}
        self.adapter_agent.publish_inter_adapter_message(onu_device.id, msg)
Ejemplo n.º 7
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=self.port_id_name(),
                       type=Port.ETHERNET_UNI,
                       admin_state=self._admin_state,
                       oper_status=self._oper_status)
     return self._port
Ejemplo n.º 8
0
 def get_port(self):
     """
     Get the VOLTHA PORT object for this port
     :return: VOLTHA Port object
     """
     if self._port is None:
         self._port = Port(port_no=self.port_number,
                           label='vEth-{}'.format(self.port_number),
                           type=Port.ETHERNET_UNI,
                           admin_state=self._admin_state,
                           oper_status=self._oper_status)
     return self._port
Ejemplo n.º 9
0
 def get_port(self):
     """
     Get the VOLTHA PORT object for this port
     :return: VOLTHA Port object
     """
     if self.port is None:
         self.port = Port(port_no=self.port_number,
                          label=self.label,
                          type=Port.PON_OLT,
                          admin_state=self.admin_state,
                          oper_status=self.oper_status)
     return self.port
Ejemplo n.º 10
0
 def get_port(self):
     """
     Get the VOLTHA PORT object for this port
     :return: VOLTHA Port object
     """
     if self._port is None:
         self._port = Port(port_no=self._port_no,
                           label=self._label,
                           type=Port.ETHERNET_NNI,
                           admin_state=self._admin_state,
                           oper_status=self._oper_status)
     return self._port
Ejemplo n.º 11
0
 def get_port(self):
     """
     Get the VOLTHA PORT object for this port
     :return: VOLTHA Port object
     """
     self.log.info('get nni gort', self._port_no)
     if self._port is None:
         self._port = Port(port_no=self._port_no,    \
                           label='NNI port',         \
                           type=Port.ETHERNET_NNI,   \
                           admin_state=self._admin_state,    \
                           oper_status=self._oper_status)
     return self._port
Ejemplo n.º 12
0
 def setUp(self):
     #calling the parent class setUp
     test_logical_device_agent.setUp(self)
     #re-initializing ports to VENET topology
     self.ports = {
         'olt': [
             Port(port_no=0, type=Port.ETHERNET_NNI, device_id='olt'),
             Port(port_no=1, type=Port.VENET_OLT, device_id='olt',
                  peers=[
                      Port.PeerPort(device_id='onu1', port_no=1),
                      Port.PeerPort(device_id='onu2', port_no=1)
                  ]
             )
         ],
         'onu1': [
             Port(port_no=0, type=Port.ETHERNET_UNI, device_id='onu1'),
             Port(port_no=1, type=Port.VENET_ONU, device_id='onu1',
                  peers=[
                      Port.PeerPort(device_id='olt', port_no=1),
                  ]
             )
         ],
         'onu2': [
             Port(port_no=0, type=Port.ETHERNET_UNI, device_id='onu2'),
             Port(port_no=1, type=Port.VENET_ONU, device_id='onu2',
                  peers=[
                      Port.PeerPort(device_id='olt', port_no=1),
                  ]
             )
         ],
     }
     #resetting root_proxy for VENET topology
     self.root_proxy = Mock()
     def get_devices(path):
         if path == '':
             return self.devices.values()
         if path.endswith('/ports'):
             return self.ports[path[:-len('/ports')]]
         elif path.find('/') == -1:
             return self.devices[path]
         else:
             raise Exception(
                 'Nothing to yield for path /devices/{}'.format(path))
     def update_devices(path, data):
         if path.endswith('/flows'):
             self.device_flows[path[:-len('/flows')]] = data
         elif path.endswith('/flow_groups'):
             self.device_groups[path[:-len('/flow_groups')]] = data
         else:
             raise NotImplementedError(
                 'not handling path /devices/{}'.format(path))
     self.root_proxy.get = lambda p: \
         get_devices(p[len('/devices/'):]) if p.startswith('/devices') \
             else None
     self.root_proxy.update = lambda p, d: \
         update_devices(p[len('/devices/'):], d) \
             if p.startswith('/devices') \
             else None
Ejemplo n.º 13
0
    def add_port(self, intf_id, port_type, oper_status):
        port_no = self.intf_id_to_port_no(intf_id, port_type)

        label = self.port_name(port_no, port_type)

        self.log.info('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)

        self.adapter_agent.add_port(self.device_id, port)

        return port_no, label
Ejemplo n.º 14
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 = OpenoltUtils.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)

        self.adapter_agent.add_port(self.device.id, port)

        return port_no, label
Ejemplo n.º 15
0
    def get_port(self):
        """
        Get the VOLTHA PORT object for this port
        :return: VOLTHA Port object
        """
        self.log.debug('function-entry')

        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=[])
        return self._port
Ejemplo n.º 16
0
 def get_port(self):
     """
     Get the VOLTHA PORT object for this port
     :return: VOLTHA Port object
     """
     if self._port is None:
         self._port = Port(port_no=self._port_no,
                           label=self._label,
                           type=Port.PON_OLT,
                           admin_state=AdminState.ENABLED,
                           oper_status=OperStatus.ACTIVE)
         # TODO: For now, no way to report the proper ADMIN or OPER status
         # admin_state=self._admin_state,
         # oper_status=self._oper_status)
     return self._port
Ejemplo n.º 17
0
 def get_port(self):
     """
     Get the VOLTHA PORT object for this port
     :return: VOLTHA Port object
     """
     device = self._handler.adapter_agent.get_device(
         self._handler.device_id)
     self._port = Port(
         port_no=self.port_number,
         label=device.serial_number,
         # label=self.port_id_name(),
         type=Port.ETHERNET_UNI,
         admin_state=self._admin_state,
         oper_status=self._oper_status)
     return self._port
Ejemplo n.º 18
0
    def get_port(self):
        """
        Get the VOLTHA PORT object for this port
        :return: VOLTHA Port object
        """
        if self._port is None:
            device = self._handler.adapter_agent.get_device(self._handler.device_id)

            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=[Port.PeerPort(device_id=device.parent_id,
                                                   port_no=device.parent_port_no)])
        return self._port
Ejemplo n.º 19
0
    def get_port(self):
        """
        Get the VOLTHA PORT object for this port
        :return: VOLTHA Port object
        """
        self.log.info('get pon gort', self._port_no)
        if self._port is None:
            self._port = Port(    \
                port_no=100 + self._port_no,    \
                #port_no=self._port_no,    \
                label=self._label,        \
                type=Port.PON_OLT,        \
                admin_state=self._admin_state,    \
                oper_status=self._oper_status     \
            )

        return self._port
Ejemplo n.º 20
0
    def add_port(self, port_no, port_type, label):
        self.log.info('adding-port', port_no=port_no, port_type=port_type)
        if port_type is Port.ETHERNET_NNI:
            oper_status = OperStatus.ACTIVE
        elif port_type is Port.PON_OLT:
            # To-Do The pon port status should be ACTIVATING.
            # For now make the status as Active.
            oper_status = OperStatus.ACTIVE
        else:
            self.log.erro('invalid-port-type', port_type=port_type)
            return

        port = Port(port_no=port_no,
                    label=label,
                    type=port_type,
                    admin_state=AdminState.ENABLED,
                    oper_status=oper_status)
        self.adapter_agent.add_port(self.device_id, port)
Ejemplo n.º 21
0
                def port_config():

                    # "v_enet" creation (olt)

                    # add_port update port when it exists
                    self.adapter_agent.add_port(
                        self.device_id,
                        Port(port_no=uni_no,
                             label=uni_name,
                             type=Port.ETHERNET_UNI,
                             admin_state=AdminState.ENABLED,
                             oper_status=OperStatus.ACTIVE))

                    # v_enet creation (onu)

                    venet = VEnetConfig(name=uni_name)
                    venet.interface.name = uni_name
                    onu_adapter_agent.create_interface(onu_device, venet)
Ejemplo n.º 22
0
    def onu_ports_down(self, onu_device, uni_no, uni_name, oper_state):
        # Set port oper state to Discovered
        # add port will update port if it exists
        self.adapter_agent.add_port(
            self.device_id,
            Port(port_no=uni_no,
                 label=uni_name,
                 type=Port.ETHERNET_UNI,
                 admin_state=onu_device.admin_state,
                 oper_status=oper_state))

        # Disable logical port
        onu_ports = self.proxy.get('devices/{}/ports'.format(onu_device.id))
        onu_port_id = None
        for onu_port in onu_ports:
            if onu_port.port_no == uni_no:
                onu_port_id = onu_port.label
        if onu_port_id is None:
            self.log.error('matching-onu-port-label-not-found',
                           onu_id=onu_device.id,
                           olt_id=self.device_id,
                           onu_ports=onu_ports)
            return
        try:
            onu_logical_port = self.adapter_agent.get_logical_port(
                logical_device_id=self.logical_device_id, port_id=onu_port_id)
            onu_logical_port.ofp_port.state = OFPPS_LINK_DOWN
            self.adapter_agent.update_logical_port(
                logical_device_id=self.logical_device_id,
                port=onu_logical_port)
            self.log.debug('cascading-oper-state-to-port-and-logical-port')
        except KeyError as e:
            self.log.error('matching-onu-port-label-invalid',
                           onu_id=onu_device.id,
                           olt_id=self.device_id,
                           onu_ports=onu_ports,
                           onu_port_id=onu_port_id,
                           error=e)
Ejemplo n.º 23
0
    def update_device_info_from_pkt(self, pkt):

        self.device.root = True
        self.device.vendor = 'Celestica Inc.'
        self.device.model = 'Ruby'
        self.device.hardware_version = \
            '{}.{}'.format(hex(pkt.major_hardware_version),
                           pkt.minor_hardware_version)
        self.device.firmware_version = '{}.{}.{}'.format(
            pkt.major_firmware_version, pkt.minor_firmware_version,
            pkt.build_firmware_version)
        self.device.software_version = '0.0.1'
        self.device.serial_number = self.device.mac_address
        self.device.oper_status = ConnectStatus.REACHABLE
        self.adapter_agent.update_device(self.device)

        for i in CHANNELS:
            self.adapter_agent.add_port(
                self.device.id,
                Port(port_no=i,
                     label='PON port',
                     type=Port.PON_OLT,
                     admin_state=AdminState.ENABLED,
                     oper_status=OperStatus.ACTIVE))
Ejemplo n.º 24
0
    def setUp(self):
        self.setup_mock_registry()

        self.flows = Flows(items=[])
        self.groups = FlowGroups(items=[])
        self.ld_ports = [
            LogicalPort(id='0',
                        device_id='olt',
                        device_port_no=0,
                        root_port=True,
                        ofp_port=ofp.ofp_port(port_no=0)),
            LogicalPort(id='1',
                        device_id='onu1',
                        device_port_no=0,
                        ofp_port=ofp.ofp_port(port_no=1)),
            LogicalPort(id='2',
                        device_id='onu2',
                        device_port_no=0,
                        ofp_port=ofp.ofp_port(port_no=2))
        ]

        self.devices = {
            'olt': Device(id='olt', root=True, parent_id='id'),
            'onu1': Device(id='onu1',
                           parent_id='olt',
                           parent_port_no=1,
                           vlan=101),
            'onu2': Device(id='onu2',
                           parent_id='olt',
                           parent_port_no=1,
                           vlan=102),
        }

        self.ports = {
            'olt': [
                Port(port_no=0, type=Port.ETHERNET_NNI, device_id='olt'),
                Port(port_no=1,
                     type=Port.PON_OLT,
                     device_id='olt',
                     peers=[
                         Port.PeerPort(device_id='onu1', port_no=1),
                         Port.PeerPort(device_id='onu2', port_no=1)
                     ])
            ],
            'onu1': [
                Port(port_no=0, type=Port.ETHERNET_UNI, device_id='onu1'),
                Port(port_no=1,
                     type=Port.PON_ONU,
                     device_id='onu1',
                     peers=[
                         Port.PeerPort(device_id='olt', port_no=1),
                     ])
            ],
            'onu2': [
                Port(port_no=0, type=Port.ETHERNET_UNI, device_id='onu2'),
                Port(port_no=1,
                     type=Port.PON_ONU,
                     device_id='onu2',
                     peers=[
                         Port.PeerPort(device_id='olt', port_no=1),
                     ])
            ],
        }

        self.device_flows = {'olt': Flows(), 'onu1': Flows(), 'onu2': Flows()}

        self.device_groups = {
            'olt': FlowGroups(),
            'onu1': FlowGroups(),
            'onu2': FlowGroups()
        }

        self.ld = LogicalDevice(id='id', root_device_id='olt')

        self.root_proxy = Mock()

        def get_devices(path):
            if path == '':
                return self.devices.values()
            if path.endswith('/ports'):
                return self.ports[path[:-len('/ports')]]
            elif path.find('/') == -1:
                return self.devices[path]
            else:
                raise Exception(
                    'Nothing to yield for path /devices/{}'.format(path))

        def update_devices(path, data):
            if path.endswith('/flows'):
                self.device_flows[path[:-len('/flows')]] = data
            elif path.endswith('/flow_groups'):
                self.device_groups[path[:-len('/flow_groups')]] = data
            else:
                raise NotImplementedError(
                    'not handling path /devices/{}'.format(path))

        self.root_proxy.get = lambda p: \
            get_devices(p[len('/devices/'):]) if p.startswith('/devices') \
                else None
        self.root_proxy.update = lambda p, d: \
            update_devices(p[len('/devices/'):], d) \
                if p.startswith('/devices') \
                else None
        self.ld_proxy = Mock()
        self.ld_proxy.get = lambda p: \
            self.ld_ports if p == '/ports' else (
                self.ld if p == '/' else None
            )

        self.flows_proxy = Mock()
        self.flows_proxy.get = lambda _: self.flows  # always '/' path

        def update_flows(_, flows):  # always '/' path
            self.flows = flows

        self.flows_proxy.update = update_flows

        self.groups_proxy = Mock()
        self.groups_proxy.get = lambda _: self.groups  # always '/' path

        def update_groups(_, groups):  # always '/' path
            self.groups = groups

        self.groups_proxy.update = update_groups

        self.core = Mock()
        self.core.get_proxy = lambda path: \
            self.root_proxy if path == '/' else (
                self.ld_proxy if path.endswith('id') else (
                    self.flows_proxy if path.endswith('flows') else
                    self.groups_proxy
                )
            )

        self.lda = LogicalDeviceAgent(self.core, self.ld)
Ejemplo n.º 25
0
    def activate(self, device):
        self.log.info('activating')

        # first we verify that we got parent reference and proxy info
        assert device.parent_id
        assert device.proxy_address.device_id
        assert device.proxy_address.channel_id

        # register for proxied messages right away
        self.proxy_address = device.proxy_address
        self.adapter_agent.register_for_proxied_messages(device.proxy_address)

        # populate device info
        device.root = True
        device.vendor = 'Broadcom'
        device.model = 'n/a'
        device.hardware_version = 'to be filled'
        device.firmware_version = 'to be filled'
        device.software_version = 'to be filled'
        device.serial_number = uuid4().hex
        device.connect_status = ConnectStatus.REACHABLE
        self.adapter_agent.update_device(device)

        # register physical ports
        uni_port = Port(port_no=2,
                        label='UNI facing Ethernet port',
                        type=Port.ETHERNET_UNI,
                        admin_state=AdminState.ENABLED,
                        oper_status=OperStatus.ACTIVE)
        self.adapter_agent.add_port(device.id, uni_port)
        self.adapter_agent.add_port(
            device.id,
            Port(port_no=1,
                 label='PON port',
                 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)
                 ]))

        # add uni port to logical device
        parent_device = self.adapter_agent.get_device(device.parent_id)
        logical_device_id = parent_device.parent_id
        assert logical_device_id
        port_no = device.proxy_address.channel_id
        cap = OFPPF_1GB_FD | OFPPF_FIBER
        self.adapter_agent.add_logical_port(
            logical_device_id,
            LogicalPort(id='uni-{}'.format(port_no),
                        ofp_port=ofp_port(
                            port_no=port_no,
                            hw_addr=mac_str_to_tuple(
                                '00:00:00:00:%02x:%02x' %
                                ((port_no >> 8) & 0xff, port_no & 0xff)),
                            name='uni-{}'.format(port_no),
                            config=0,
                            state=OFPPS_LIVE,
                            curr=cap,
                            advertised=cap,
                            peer=cap,
                            curr_speed=OFPPF_1GB_FD,
                            max_speed=OFPPF_1GB_FD),
                        device_id=device.id,
                        device_port_no=uni_port.port_no))

        reactor.callLater(10, self.message_exchange)

        device = self.adapter_agent.get_device(device.id)
        device.oper_status = OperStatus.ACTIVE
        self.adapter_agent.update_device(device)
Ejemplo n.º 26
0
    def _onu_device_activation(self, device):
        # first we verify that we got parent reference and proxy info
        assert device.parent_id
        assert device.proxy_address.device_id
        assert device.proxy_address.channel_id

        # TODO: For now, pretend that we were able to contact the device and obtain
        # additional information about it.  Should add real message.
        device.vendor = 'Tibit Communications, Inc.'
        device.model = '10G GPON ONU'
        device.hardware_version = 'fa161020'
        device.firmware_version = '16.12.02'
        device.software_version = '1.0'
        device.serial_number = uuid4().hex
        device.connect_status = ConnectStatus.REACHABLE
        self.adapter_agent.update_device(device)

        # then shortly after we create some ports for the device
        uni_port = Port(port_no=2,
                        label='UNI facing Ethernet port',
                        type=Port.ETHERNET_UNI,
                        admin_state=AdminState.ENABLED,
                        oper_status=OperStatus.ACTIVE)
        self.adapter_agent.add_port(device.id, uni_port)
        self.adapter_agent.add_port(
            device.id,
            Port(port_no=1,
                 label='PON port',
                 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)
                 ]))

        # TODO adding vports to the logical device shall be done by agent?
        # then we create the logical device port that corresponds to the UNI
        # port of the device

        # obtain logical device id
        parent_device = self.adapter_agent.get_device(device.parent_id)
        logical_device_id = parent_device.parent_id
        assert logical_device_id

        # we are going to use the proxy_address.channel_id as unique number
        # and name for the virtual ports, as this is guaranteed to be unique
        # in the context of the OLT port, so it is also unique in the context
        # of the logical device
        port_no = device.proxy_address.channel_id
        cap = OFPPF_10GB_FD | OFPPF_FIBER
        self.adapter_agent.add_logical_port(
            logical_device_id,
            LogicalPort(id=str(port_no),
                        ofp_port=ofp_port(port_no=port_no,
                                          hw_addr=mac_str_to_tuple(
                                              device.mac_address),
                                          name='uni-{}'.format(port_no),
                                          config=0,
                                          state=OFPPS_LIVE,
                                          curr=cap,
                                          advertised=cap,
                                          peer=cap,
                                          curr_speed=OFPPF_10GB_FD,
                                          max_speed=OFPPF_10GB_FD),
                        device_id=device.id,
                        device_port_no=uni_port.port_no))

        # simulate a proxied message sending and receving a reply
        reply = yield self._message_exchange(device)

        # and finally update to "ACTIVE"
        device = self.adapter_agent.get_device(device.id)
        device.oper_status = OperStatus.ACTIVE
        self.adapter_agent.update_device(device)

        self.start_kpi_collection(device.id)
Ejemplo n.º 27
0
    def _simulate_device_activation(self, device):

        # first we pretend that we were able to contact the device and obtain
        # additional information about it
        device.root = True
        device.vendor = 'simulated'
        device.model = 'n/a'
        device.hardware_version = 'n/a'
        device.firmware_version = 'n/a'
        device.serial_number = uuid4().hex
        device.connect_status = ConnectStatus.REACHABLE

        image1 = Image(name="olt_candidate1",
                       version="1.0",
                       hash="",
                       install_datetime=datetime.datetime.utcnow().isoformat(),
                       is_active=True,
                       is_committed=True,
                       is_valid=True)

        image2 = Image(name="olt_candidate2",
                       version="1.0",
                       hash="",
                       install_datetime=datetime.datetime.utcnow().isoformat(),
                       is_active=False,
                       is_committed=False,
                       is_valid=True)

        device.images.image.extend([image1, image2])

        self.adapter_agent.update_device(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)
        self.adapter_agent.update_device_pm_config(pm_config, init=True)

        # then shortly after we create some ports for the device
        yield asleep(0.05)
        nni_port = Port(port_no=2,
                        label='NNI facing Ethernet port',
                        type=Port.ETHERNET_NNI,
                        admin_state=AdminState.ENABLED,
                        oper_status=OperStatus.ACTIVE)
        self.adapter_agent.add_port(device.id, nni_port)
        self.adapter_agent.add_port(
            device.id,
            Port(port_no=1,
                 label='PON port',
                 type=Port.PON_OLT,
                 admin_state=AdminState.ENABLED,
                 oper_status=OperStatus.ACTIVE))

        # then shortly after we create the logical device with one port
        # that will correspond to the NNI port
        yield asleep(0.05)
        logical_device_id = uuid4().hex[:12]
        ld = LogicalDevice(
            # not setting id and datapth_id will let the adapter agent pick id
            desc=ofp_desc(mfr_desc='cord porject',
                          hw_desc='simualted pon',
                          sw_desc='simualted pon',
                          serial_num=uuid4().hex,
                          dp_desc='n/a'),
            switch_features=ofp_switch_features(
                n_buffers=256,  # TODO fake for now
                n_tables=2,  # TODO ditto
                capabilities=(  # TODO and ditto
                    OFPC_FLOW_STATS
                    | OFPC_TABLE_STATS
                    | OFPC_PORT_STATS
                    | OFPC_GROUP_STATS)),
            root_device_id=device.id)
        ld_initialized = self.adapter_agent.create_logical_device(ld)
        cap = OFPPF_1GB_FD | OFPPF_FIBER
        self.adapter_agent.add_logical_port(
            ld_initialized.id,
            LogicalPort(id='nni',
                        ofp_port=ofp_port(port_no=129,
                                          hw_addr=mac_str_to_tuple(
                                              '00:00:00:00:00:%02x' % 129),
                                          name='nni',
                                          config=0,
                                          state=OFPPS_LIVE,
                                          curr=cap,
                                          advertised=cap,
                                          peer=cap,
                                          curr_speed=OFPPF_1GB_FD,
                                          max_speed=OFPPF_1GB_FD),
                        device_id=device.id,
                        device_port_no=nni_port.port_no,
                        root_port=True))

        # and finally update to active
        device = self.adapter_agent.get_device(device.id)
        device.parent_id = ld_initialized.id
        device.oper_status = OperStatus.ACTIVE
        self.adapter_agent.update_device(device)

        reactor.callLater(0.1, self._simulate_detection_of_onus, device.id)
        self.start_kpi_collection(device.id)

        self.start_alarm_simulation(device.id)
Ejemplo n.º 28
0
    def _tmp_populate_stuff(self):
        """
        pretend that we discovered some devices and create:
        - devices
        - device ports for each
        - logical device
        - logical device ports
        """

        olt = Device(id='simulated_olt_1',
                     type='simulated_olt',
                     root=True,
                     vendor='simulated',
                     model='n/a',
                     hardware_version='n/a',
                     firmware_version='n/a',
                     software_version='1.0',
                     serial_number=uuid4().hex,
                     adapter=self.name,
                     oper_status=OperStatus.DISCOVERED)
        self.adapter_agent.add_device(olt)
        self.adapter_agent.add_port(
            olt.id, Port(port_no=1, label='pon', type=Port.PON_OLT))
        self.adapter_agent.add_port(
            olt.id, Port(port_no=2, label='eth', type=Port.ETHERNET_NNI))

        onu1 = Device(id='simulated_onu_1',
                      type='simulated_onu',
                      root=False,
                      parent_id=olt.id,
                      parent_port_no=1,
                      vendor='simulated',
                      model='n/a',
                      hardware_version='n/a',
                      firmware_version='n/a',
                      software_version='1.0',
                      serial_number=uuid4().hex,
                      adapter='simulated_onu',
                      oper_status=OperStatus.DISCOVERED,
                      vlan=101)
        self.adapter_agent.add_device(onu1)
        self.adapter_agent.add_port(
            onu1.id, Port(port_no=2, label='eth', type=Port.ETHERNET_UNI))
        self.adapter_agent.add_port(
            onu1.id,
            Port(port_no=1,
                 label='pon',
                 type=Port.PON_ONU,
                 peers=[Port.PeerPort(device_id=olt.id, port_no=1)]))

        onu2 = Device(id='simulated_onu_2',
                      type='simulated_onu',
                      root=False,
                      parent_id=olt.id,
                      parent_port_no=1,
                      vendor='simulated',
                      model='n/a',
                      hardware_version='n/a',
                      firmware_version='n/a',
                      software_version='1.0',
                      serial_number=uuid4().hex,
                      adapter='simulated_onu',
                      oper_status=OperStatus.DISCOVERED,
                      vlan=102)
        self.adapter_agent.add_device(onu2)
        self.adapter_agent.add_port(
            onu2.id, Port(port_no=2, label='eth', type=Port.ETHERNET_UNI))
        self.adapter_agent.add_port(
            onu2.id,
            Port(port_no=1,
                 label='pon',
                 type=Port.PON_ONU,
                 peers=[Port.PeerPort(device_id=olt.id, port_no=1)]))

        ld = LogicalDevice(
            id='simulated1',
            datapath_id=1,
            desc=ofp_desc(mfr_desc='cord project',
                          hw_desc='simualted pon',
                          sw_desc='simualted pon',
                          serial_num=uuid4().hex,
                          dp_desc='n/a'),
            switch_features=ofp_switch_features(
                n_buffers=256,  # TODO fake for now
                n_tables=2,  # TODO ditto
                capabilities=(  # TODO and ditto
                    OFPC_FLOW_STATS
                    | OFPC_TABLE_STATS
                    | OFPC_PORT_STATS
                    | OFPC_GROUP_STATS)),
            root_device_id=olt.id)
        self.adapter_agent.create_logical_device(ld)

        cap = OFPPF_1GB_FD | OFPPF_FIBER
        for port_no, name, device_id, device_port_no, root_port in [
            (1, 'onu1', onu1.id, 2, False), (2, 'onu2', onu2.id, 2, False),
            (129, 'olt1', olt.id, 2, True)
        ]:
            port = LogicalPort(id=name,
                               ofp_port=ofp_port(
                                   port_no=port_no,
                                   hw_addr=mac_str_to_tuple(
                                       '00:00:00:00:00:%02x' % port_no),
                                   name=name,
                                   config=0,
                                   state=OFPPS_LIVE,
                                   curr=cap,
                                   advertised=cap,
                                   peer=cap,
                                   curr_speed=OFPPF_1GB_FD,
                                   max_speed=OFPPF_1GB_FD),
                               device_id=device_id,
                               device_port_no=device_port_no,
                               root_port=root_port)
            self.adapter_agent.add_logical_port(ld.id, port)

        olt.parent_id = ld.id
        self.adapter_agent.update_device(olt)
Ejemplo n.º 29
0
    def _simulate_device_activation(self, device):

        # first we verify that we got parent reference and proxy info
        assert device.parent_id
        assert device.proxy_address.device_id
        assert device.proxy_address.channel_id

        # we pretend that we were able to contact the device and obtain
        # additional information about it
        device.vendor = 'simulated onu adapter'
        device.model = 'n/a'
        device.hardware_version = 'n/a'
        device.firmware_version = 'n/a'
        device.serial_number = uuid4().hex
        device.connect_status = ConnectStatus.REACHABLE

        image1 = Image(name="onu_candidate1",
                       version="1.0",
                       hash="1234567892",
                       install_datetime=datetime.datetime.utcnow().isoformat(),
                       is_active=True,
                       is_committed=True,
                       is_valid=True)
        image2 = Image(name="onu_candidate2",
                       version="1.0",
                       hash="1234567893",
                       install_datetime=datetime.datetime.utcnow().isoformat(),
                       is_active=False,
                       is_committed=False,
                       is_valid=True)

        device.images.image.extend([image1, image2])

        self.adapter_agent.update_device(device)

        # then shortly after we create some ports for the device
        yield asleep(0.05)
        uni_port = Port(port_no=2,
                        label='UNI facing Ethernet port',
                        type=Port.ETHERNET_UNI,
                        admin_state=AdminState.ENABLED,
                        oper_status=OperStatus.ACTIVE)
        self.adapter_agent.add_port(device.id, uni_port)
        self.adapter_agent.add_port(
            device.id,
            Port(port_no=1,
                 label='PON port',
                 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)
                 ]))

        # TODO adding vports to the logical device shall be done by agent?
        # then we create the logical device port that corresponds to the UNI
        # port of the device
        yield asleep(0.05)

        # obtain logical device id
        parent_device = self.adapter_agent.get_device(device.parent_id)
        logical_device_id = parent_device.parent_id
        assert logical_device_id

        # we are going to use the proxy_address.channel_id as unique number
        # and name for the virtual ports, as this is guaranteed to be unique
        # in the context of the OLT port, so it is also unique in the context
        # of the logical device
        port_no = device.proxy_address.channel_id
        cap = OFPPF_1GB_FD | OFPPF_FIBER
        self.adapter_agent.add_logical_port(
            logical_device_id,
            LogicalPort(id=str(port_no),
                        ofp_port=ofp_port(port_no=port_no,
                                          hw_addr=mac_str_to_tuple(
                                              '00:00:00:00:00:%02x' % port_no),
                                          name='uni-{}'.format(port_no),
                                          config=0,
                                          state=OFPPS_LIVE,
                                          curr=cap,
                                          advertised=cap,
                                          peer=cap,
                                          curr_speed=OFPPF_1GB_FD,
                                          max_speed=OFPPF_1GB_FD),
                        device_id=device.id,
                        device_port_no=uni_port.port_no))

        # simulate a proxied message sending and receving a reply
        reply = yield self._simulate_message_exchange(device)

        # and finally update to "ACTIVE"
        device = self.adapter_agent.get_device(device.id)
        device.oper_status = OperStatus.ACTIVE
        self.adapter_agent.update_device(device)
Ejemplo n.º 30
0
    def activate(self, device):
        self.log.info('activating')

        # first we verify that we got parent reference and proxy info
        assert device.parent_id
        assert device.proxy_address.device_id
        assert device.proxy_address.channel_id

        # register for proxied messages right away
        self.proxy_address = device.proxy_address
        self.adapter_agent.register_for_proxied_messages(device.proxy_address)

        # populate device info
        device.root = False
        device.vendor = 'ponsim'
        device.model = 'n/a'
        device.connect_status = ConnectStatus.REACHABLE
        self.adapter_agent.update_device(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)
        self.adapter_agent.update_device_pm_config(pm_config, init=True)

        # register physical ports
        self.uni_port = Port(port_no=2,
                             label='UNI facing Ethernet port',
                             type=Port.ETHERNET_UNI,
                             admin_state=AdminState.ENABLED,
                             oper_status=OperStatus.ACTIVE)
        self.pon_port = Port(port_no=1,
                             label='PON port',
                             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)
                             ])
        self.adapter_agent.add_port(device.id, self.uni_port)
        self.adapter_agent.add_port(device.id, self.pon_port)

        # add uni port to logical device
        parent_device = self.adapter_agent.get_device(device.parent_id)
        logical_device_id = parent_device.parent_id
        assert logical_device_id
        port_no = device.proxy_address.channel_id
        cap = OFPPF_1GB_FD | OFPPF_FIBER
        self.adapter_agent.add_logical_port(
            logical_device_id,
            LogicalPort(id='uni-{}'.format(port_no),
                        ofp_port=ofp_port(port_no=port_no,
                                          hw_addr=mac_str_to_tuple(
                                              '00:00:00:00:00:%02x' % port_no),
                                          name=device.serial_number,
                                          config=0,
                                          state=OFPPS_LIVE,
                                          curr=cap,
                                          advertised=cap,
                                          peer=cap,
                                          curr_speed=OFPPF_1GB_FD,
                                          max_speed=OFPPF_1GB_FD),
                        device_id=device.id,
                        device_port_no=self.uni_port.port_no))

        device = self.adapter_agent.get_device(device.id)
        device.oper_status = OperStatus.ACTIVE
        self.adapter_agent.update_device(device)

        # Start collecting stats from the device after a brief pause
        self.start_kpi_collection(device.id)