Пример #1
0
    def _port_update(resource, event, trigger, payload):
        l3plugin = directory.get_plugin(plugin_constants.L3)
        if not l3plugin:
            return

        context = payload.context
        current = payload.latest_state
        original = payload.states[0]

        # The OVN NB DB has a constraint where network has to be
        # greater than 0. Updating it with an empty network would
        # cause a constraint violation error. This problem happens
        # when the last IP of a LRP is deleted, in order to avoid it
        # an exception needs to be thrown before any write is performed
        # to the DB, since if not it would leave the Neutron DB and the
        # OVN DB unsync.
        # https://bugs.launchpad.net/neutron/+bug/1948457
        if (event == events.BEFORE_UPDATE and 'fixed_ips' in current
                and not current['fixed_ips']
                and utils.is_lsp_router_port(original)):
            reason = _("Router port must have at least one IP.")
            raise n_exc.ServicePortInUse(port_id=original['id'], reason=reason)

        if event == events.AFTER_UPDATE and utils.is_lsp_router_port(current):
            # We call the update_router port with if_exists, because neutron,
            # internally creates the port, and then calls update, which will
            # trigger this callback even before we had the chance to create
            # the OVN NB DB side
            l3plugin._ovn_client.update_router_port(context,
                                                    current,
                                                    if_exists=True)
Пример #2
0
 def _prevent_local_port_delete_callback(resource,
                                         event,
                                         trigger,
                                         payload=None):
     port_id = payload.resource_id
     if lip_obj.LocalIP.count(payload.context, local_port_id=port_id):
         reason = _('still referenced by Local IPs')
         raise lib_exc.ServicePortInUse(port_id=port_id, reason=reason)
Пример #3
0
 def prevent_l2gw_port_deletion(self, context, port_id):
     """Prevent core plugin from deleting L2 gateway port."""
     try:
         port = self._core_plugin.get_port(context, port_id)
     except n_exc.PortNotFound:
         return
     if port['device_owner'] == nsx_constants.BRIDGE_ENDPOINT:
         reason = _("has device owner %s") % port['device_owner']
         raise n_exc.ServicePortInUse(port_id=port_id, reason=reason)
 def prevent_lbaasv2_port_deletion(self, context, port_id):
     try:
         port_db = self._core_plugin._get_port(context, port_id)
     except n_exc.PortNotFound:
         return
     if port_db['device_owner'] == n_const.DEVICE_OWNER_LOADBALANCERV2:
         filters = {'vip_port_id': [port_id]}
         if len(self.get_loadbalancers(context, filters=filters)) > 0:
             reason = _('has device owner %s') % port_db['device_owner']
             raise n_exc.ServicePortInUse(port_id=port_db['id'],
                                          reason=reason)