Пример #1
0
 def update_dhcp_port(self, context, **kwargs):
     """Update the dhcp port."""
     host = kwargs.get('host')
     port = kwargs.get('port')
     port['id'] = kwargs.get('port_id')
     port['port'][portbindings.HOST_ID] = host
     plugin = directory.get_plugin()
     try:
         old_port = plugin.get_port(context, port['id'])
         if (old_port['device_id'] != n_const.DEVICE_ID_RESERVED_DHCP_PORT
                 and
                 old_port['device_id'] != utils.get_dhcp_agent_device_id(
                     port['port']['network_id'], host)):
             raise n_exc.DhcpPortInUse(port_id=port['id'])
         LOG.debug('Update dhcp port %(port)s '
                   'from %(host)s.', {
                       'port': port,
                       'host': host
                   })
         return self._port_action(plugin, context, port, 'update_port')
     except exceptions.PortNotFound:
         LOG.debug(
             'Host %(host)s tried to update port '
             '%(port_id)s which no longer exists.', {
                 'host': host,
                 'port_id': port['id']
             })
         return None
Пример #2
0
 def update_dhcp_port(self, context, **kwargs):
     """Update the dhcp port."""
     host = kwargs.get('host')
     port = kwargs.get('port')
     port['id'] = kwargs.get('port_id')
     port['port'][portbindings.HOST_ID] = host
     plugin = directory.get_plugin()
     try:
         old_port = plugin.get_port(context, port['id'])
         if (old_port['device_id'] != n_const.DEVICE_ID_RESERVED_DHCP_PORT
                 and old_port['device_id'] != port['port']['device_id']):
             raise n_exc.DhcpPortInUse(port_id=port['id'])
         else:
             network_id = port['port']['network_id']
             if not self.is_agent_bound_to_network(plugin, context, host,
                                                   network_id):
                 # NOTE(alegacy): avoid race condition of agent updating
                 # port after ownership has already been removed and given
                 # to another agent.
                 LOG.warning(
                     "Host %(host)s tried to update port "
                     "%(port_id)s on network %(network_id)s "
                     "but agent is not bound to that network.", {
                         'host': host,
                         'port_id': port['id'],
                         'network_id': network_id
                     })
                 raise n_exc.DhcpPortInUse(port_id=port['id'])
         LOG.debug('Update dhcp port %(port)s '
                   'from %(host)s.', {
                       'port': port,
                       'host': host
                   })
         return self._port_action(plugin, context, port, 'update_port')
     except exceptions.PortNotFound:
         LOG.debug(
             'Host %(host)s tried to update port '
             '%(port_id)s which no longer exists.', {
                 'host': host,
                 'port_id': port['id']
             })
         return None
Пример #3
0
 def update_dhcp_port(self, context, **kwargs):
     """Update the dhcp port."""
     host = kwargs.get('host')
     port = kwargs.get('port')
     port['id'] = kwargs.get('port_id')
     port['port'][portbindings.HOST_ID] = host
     plugin = manager.NeutronManager.get_plugin()
     old_port = plugin.get_port(context, port['id'])
     if (old_port['device_id'] != constants.DEVICE_ID_RESERVED_DHCP_PORT
         and old_port['device_id'] !=
         utils.get_dhcp_agent_device_id(port['port']['network_id'], host)):
         raise n_exc.DhcpPortInUse(port_id=port['id'])
     LOG.debug('Update dhcp port %(port)s '
               'from %(host)s.',
               {'port': port,
                'host': host})
     return self._port_action(plugin, context, port, 'update_port')