예제 #1
0
    def _remove_bgp_speaker_from_dragent(self, context, agent_id, speaker_id):
        with db_api.CONTEXT_WRITER.using(context):
            agent_db = self._get_agent(context, agent_id)
            is_agent_bgp = (
                agent_db['agent_type'] == bgp_consts.AGENT_TYPE_BGP_ROUTING)
            if not is_agent_bgp:
                raise bgp_dras_ext.DrAgentInvalid(id=agent_id)

            query = context.session.query(BgpSpeakerDrAgentBinding)
            query = query.filter_by(bgp_speaker_id=speaker_id,
                                    agent_id=agent_id)

            num_deleted = query.delete()
            if not num_deleted:
                raise bgp_dras_ext.DrAgentNotHostingBgpSpeaker(
                    bgp_speaker_id=speaker_id, agent_id=agent_id)
            LOG.debug(
                'BgpSpeaker %(bgp_speaker_id)s removed from '
                'BgpDrAgent %(agent_id)s', {
                    'bgp_speaker_id': speaker_id,
                    'agent_id': agent_id
                })
예제 #2
0
    def remove_bgp_speaker_from_dragent(self, context, agent_id, speaker_id):
        with context.session.begin(subtransactions=True):
            agent_db = self._get_agent(context, agent_id)
            is_agent_bgp = (agent_db['agent_type'] ==
                            bgp_consts.AGENT_TYPE_BGP_ROUTING)
            if not is_agent_bgp:
                raise bgp_dras_ext.DrAgentInvalid(id=agent_id)

            query = context.session.query(BgpSpeakerDrAgentBinding)
            query = query.filter_by(bgp_speaker_id=speaker_id,
                                    agent_id=agent_id)

            num_deleted = query.delete()
            if not num_deleted:
                raise bgp_dras_ext.DrAgentNotHostingBgpSpeaker(
                    bgp_speaker_id=speaker_id,
                    agent_id=agent_id)
            LOG.debug('BgpSpeaker %(bgp_speaker_id)s removed from '
                      'BgpDrAgent %(agent_id)s',
                      {'bgp_speaker_id': speaker_id,
                       'agent_id': agent_id})

        self._bgp_rpc.bgp_speaker_removed(context, speaker_id, agent_db.host)