def update_port(self, context, id, port):
        deleted = port['port'].get('deleted', False)
        session = context.session

        need_port_update_notify = False
        with session.begin(subtransactions=True):
            original_port = super(RyuQuantumPluginV2, self).get_port(
                context, id)
            updated_port = super(RyuQuantumPluginV2, self).update_port(
                context, id, port)
            need_port_update_notify = self.update_security_group_on_port(
                context, id, port, original_port, updated_port)

        need_port_update_notify |= self.is_security_group_member_updated(
            context, original_port, updated_port)

        need_port_update_notify |= (original_port['admin_state_up'] !=
                                    updated_port['admin_state_up'])

        if need_port_update_notify:
            self.notifier.port_update(context, updated_port)

        if deleted:
            db_api_v2.set_port_status(session, id, q_const.PORT_STATUS_DOWN)
        return updated_port
Beispiel #2
0
    def update_port(self, context, id, port):
        deleted = port['port'].get('deleted', False)
        session = context.session

        need_port_update_notify = False
        with session.begin(subtransactions=True):
            original_port = super(RyuQuantumPluginV2,
                                  self).get_port(context, id)
            updated_port = super(RyuQuantumPluginV2,
                                 self).update_port(context, id, port)
            need_port_update_notify = self.update_security_group_on_port(
                context, id, port, original_port, updated_port)

        need_port_update_notify |= self.is_security_group_member_updated(
            context, original_port, updated_port)

        need_port_update_notify |= (original_port['admin_state_up'] !=
                                    updated_port['admin_state_up'])

        if need_port_update_notify:
            self.notifier.port_update(context, updated_port)

        if deleted:
            db_api_v2.set_port_status(session, id, q_const.PORT_STATUS_DOWN)
        return updated_port
Beispiel #3
0
 def update_port(self, context, id, port):
     deleted = port["port"].get("deleted", False)
     port = super(RyuQuantumPluginV2, self).update_port(context, id, port)
     if deleted:
         session = context.session
         db_api_v2.set_port_status(session, id, q_const.PORT_STATUS_DOWN)
     return port
Beispiel #4
0
 def update_port(self, context, id, port):
     deleted = port['port'].get('deleted', False)
     port = super(RyuQuantumPluginV2, self).update_port(context, id, port)
     if deleted:
         session = context.session
         db_api_v2.set_port_status(session, id, q_const.PORT_STATUS_DOWN)
     return port
Beispiel #5
0
    def update_port(self, context, id, port):
        p = super(RyuQuantumPluginV2, self).update_port(context, id, port)
        net_id = p['network_id']
        mac_address = p['mac_address']

        deleted = port['port'].get('deleted', False)
        if deleted:
            session = context.session
            try:
                db_api_v2.port_binding_destroy(session, id, net_id)
            except q_exc.PortNotFound:
                pass
            db_api_v2.set_port_status(session, id, q_const.PORT_STATUS_DOWN)
            return p

        datapath_id = port['port'].get('datapath_id', None)
        port_no = port['port'].get('port_no', None)
        if datapath_id is None or port_no is None:
            LOG.debug('p %s', p)
            return p

        try:
            port_binding = db_api_v2.port_binding_get(id, net_id)
        except orm_exc.NoResultFound:
            try:
                db_api_v2.port_binding_create(id, net_id, datapath_id, port_no)
            except IntegrityError:
                # TODO:XXX should do transaction?
                return p
            else:
                self.client.create_port(net_id, datapath_id, port_no)
                self.client.create_mac(net_id, datapath_id, port_no,
                                       mac_address)
        else:
            if (port_binding.dpid != datapath_id
                    or port_binding.port_no != port_no):
                variables = {
                    'datapath_id': datapath_id,
                    'port_no': port_no,
                    'port_binding_dpid': port_binding.dpid,
                    'port_binding_port_no': port_binding.port_no
                }
                raise q_exc.InvalidInput(
                    error_message=_('invalid (datapath_id, port_no) '
                                    'is requested'
                                    '(%(datapath_id)s, %(port_no)s), acutal'
                                    '(%(port_binding_dpid)s, '
                                    '%(port_binding_port_no)s)') % variables)
            self.client.update_network(net_id)
            self.client.update_port(net_id, datapath_id, port_no)
            self.client.update_mac(net_id, datapath_id, port_no, mac_address)
        return p
    def update_port(self, context, id, port):
        p = super(RyuQuantumPluginV2, self).update_port(context, id, port)
        net_id = p['network_id']
        mac_address = p['mac_address']

        deleted = port['port'].get('deleted', False)
        if deleted:
            session = context.session
            try:
                db_api_v2.port_binding_destroy(session, id, net_id)
            except q_exc.PortNotFound:
                pass
            db_api_v2.set_port_status(session, id, q_const.PORT_STATUS_DOWN)
            return p

        datapath_id = port['port'].get('datapath_id', None)
        port_no = port['port'].get('port_no', None)
        if datapath_id is None or port_no is None:
            LOG.debug('p %s', p)
            return p

        try:
            port_binding = db_api_v2.port_binding_get(id, net_id)
        except orm_exc.NoResultFound:
            try:
                db_api_v2.port_binding_create(id, net_id, datapath_id, port_no)
            except IntegrityError:
                # TODO:XXX should do transaction?
                return p
            else:
                self.client.create_port(net_id, datapath_id, port_no)
                self.client.create_mac(net_id, datapath_id, port_no,
                                       mac_address)
        else:
            if (port_binding.dpid != datapath_id or
                    port_binding.port_no != port_no):
                variables = {'datapath_id': datapath_id,
                             'port_no': port_no,
                             'port_binding_dpid': port_binding.dpid,
                             'port_binding_port_no': port_binding.port_no}
                raise q_exc.InvalidInput(
                    error_message=_('invalid (datapath_id, port_no) '
                                    'is requested'
                                    '(%(datapath_id)s, %(port_no)s), acutal'
                                    '(%(port_binding_dpid)s, '
                                    '%(port_binding_port_no)s)') % variables)
            self.client.update_network(net_id)
            self.client.update_port(net_id, datapath_id, port_no)
            self.client.update_mac(net_id, datapath_id, port_no, mac_address)
        return p