예제 #1
0
    def update_port_postcommit(self, context):
        updated_port = context.current
        topic = df_utils.get_obj_topic(updated_port)
        lean_port = l2.LogicalPort(id=updated_port['id'], topic=topic)
        if not self.nb_api.get(lean_port):
            # REVISIT(xiaohhui): Should we unify the check before update nb db?
            LOG.debug(
                "The port %s has been deleted from dragonflow NB DB, "
                "by concurrent operation.", updated_port['id'])
            return

        # Here we do not want port status update to trigger
        # sending event to other compute node.
        if (cfg.CONF.df.enable_neutron_notifier
                and n_const.DEVICE_OWNER_COMPUTE_PREFIX
                in updated_port['device_owner']
                and context.status != context.original_status
                and (context.status == n_const.PORT_STATUS_DOWN
                     or context.status == n_const.PORT_STATUS_ACTIVE)):
            return None

        lport = neutron_l2.logical_port_from_neutron_port(updated_port)
        # Update topic for FIP ports
        if lport.topic == '':
            lport.topic = self._get_lswitch_topic(updated_port)
        self.nb_api.update(lport)

        LOG.info("DFMechDriver: update port %s", updated_port['id'])
        return updated_port
예제 #2
0
    def create_port_postcommit(self, context):
        port = context.current

        lport = neutron_l2.logical_port_from_neutron_port(port)
        self.nb_api.create(lport)

        LOG.info("DFMechDriver: create port %s", port['id'])
        return port
예제 #3
0
    def test_subport_status_parent_already_active(self):
        self.nb_api = self.mech_driver.nb_api
        with self.port(status=constants.PORT_STATUS_ACTIVE) as parent,\
                self.port() as subport:
            df_parent = l2.logical_port_from_neutron_port(parent['port'])
            df_subport = l2.logical_port_from_neutron_port(subport['port'])

            @utils.with_nb_objects(df_parent, df_subport)
            def run_test(self):
                self.driver.update_port_status(self.context,
                                               parent['port']['id'],
                                               constants.PORT_STATUS_ACTIVE)
                self.context.session.expire_all()
                trunk = self.trunk_plugin.create_trunk(
                    self.context, {
                        'trunk': {
                            'port_id': parent['port']['id'],
                            'tenant_id': 'project1',
                            'sub_ports': [],
                        }
                    })
                subport_obj = {
                    'segmentation_type': 'vlan',
                    'segmentation_id': 123,
                    'port_id': subport['port']['id']
                }
                self.trunk_plugin.add_subports(self.context, trunk['id'],
                                               {'sub_ports': [subport_obj]})
                self.addCleanup(self.trunk_plugin.remove_subports,
                                self.context, trunk['id'],
                                {'sub_ports': [subport_obj]})

                subport2 = self.driver.get_port(self.context,
                                                subport['port']['id'])
                self.assertEqual(constants.PORT_STATUS_ACTIVE,
                                 subport2['status'])
                self.driver.update_port_status(self.context,
                                               parent['port']['id'],
                                               constants.PORT_STATUS_DOWN)
                self.context.session.expire_all()
                subport3 = self.driver.get_port(self.context,
                                                subport['port']['id'])
                self.assertEqual(constants.PORT_STATUS_DOWN,
                                 subport3['status'])

            run_test(self)
예제 #4
0
    def create_port_postcommit(self, context):
        port = context.current
        chassis, remote_vtep = self._get_chassis_and_remote_vtep(port)

        lport = neutron_l2.logical_port_from_neutron_port(port)
        lport.chassis = chassis
        lport.remote_vtep = remote_vtep
        self.nb_api.create(lport)

        LOG.info("DFMechDriver: create port %s", port['id'])
        return port
예제 #5
0
    def create_port_postcommit(self, context):
        port = context.current

        lport = neutron_l2.logical_port_from_neutron_port(port)

        # Update topic for FIP ports
        if lport.topic == '':
            lport.topic = self._get_lswitch_topic(port)

        self.nb_api.create(lport)

        LOG.info("DFMechDriver: create port %s", port['id'])
        return port
예제 #6
0
    def update_port_postcommit(self, context):
        updated_port = context.current
        lean_port = l2.LogicalPort(id=updated_port['id'],
                                   topic=updated_port['tenant_id'])
        if not self.nb_api.get(lean_port):
            # REVISIT(xiaohhui): Should we unify the check before update nb db?
            LOG.debug(
                "The port %s has been deleted from dragonflow NB DB, "
                "by concurrent operation.", updated_port['id'])
            return

        # Here we do not want port status update to trigger
        # sending event to other compute node.
        if (cfg.CONF.df.enable_neutron_notifier
                and n_const.DEVICE_OWNER_COMPUTE_PREFIX
                in updated_port['device_owner']
                and context.status != context.original_status
                and (context.status == n_const.PORT_STATUS_DOWN
                     or context.status == n_const.PORT_STATUS_ACTIVE)):
            return None

        # If a subnet enabled dhcp, the DFMechDriver will create a dhcp server
        # port. When delete this subnet, the port should be deleted.
        # In ml2/plugin.py, when delete subnet, it will call
        # update_port_postcommit, DFMechDriver should judge the port is dhcp
        # port or not, if it is, then delete it.
        if self._is_dhcp_port_after_subnet_delete(updated_port):
            self._delete_subnet_dhcp_port(context._plugin_context,
                                          updated_port)
            return None

        chassis, remote_vtep = self._get_chassis_and_remote_vtep(updated_port)

        lport = neutron_l2.logical_port_from_neutron_port(updated_port)
        lport.chassis = chassis
        lport.remote_vtep = remote_vtep
        self.nb_api.update(lport)

        LOG.info("DFMechDriver: update port %s", updated_port['id'])
        return updated_port