'Check that a port is available for an attachment to a router
:param context: The context of the request.
:param port_id: The port to be attached.
:param device_id: This method will check that device_id corresponds to
the device_id of the port. It raises PortInUse exception if it
doesn\'t.
:returns: The port description returned by the core plugin.
:raises: PortInUse if the device_id is not the same as the port\'s one.
:raises: BadRequest if the port has no fixed IP.'

def _check_router_port(self, context, port_id, device_id):

    port = self._core_plugin.get_port(context, port_id)
    if (port['device_id'] != device_id):
        raise n_exc.PortInUse(net_id=port['network_id'], port_id=port['id'], device_id=port['device_id'])
    if (not port['fixed_ips']):
        msg = _('Router    port    must    have    at    least    one    fixed    IP')
        raise n_exc.BadRequest(resource='router', msg=msg)
    return port
