Exemplo n.º 1
0
/*
 * Set the priority of a set of ports
 */
void OlaServerServiceImpl::SetPortPriority(
    RpcController* controller,
    const ola::proto::PortPriorityRequest* request,
    Ack*,
    ola::rpc::RpcService::CompletionCallback* done) {
  ClosureRunner runner(done);
  AbstractDevice *device =
    m_device_manager->GetDevice(request->device_alias());

  if (!device)
    return MissingDeviceError(controller);

  bool status;

  bool inherit_mode = true;
  uint8_t value = 0;
  if (request->priority_mode() == PRIORITY_MODE_STATIC) {
    if (request->has_priority()) {
      inherit_mode = false;
      value = request->priority();
    } else {
      OLA_INFO << "In Set Port Priority, override mode was set but the value "
        "wasn't specified";
      controller->SetFailed(
          "Invalid SetPortPriority request, see logs for more info");
      return;
    }
  }

  if (request->is_output()) {
    OutputPort *port = device->GetOutputPort(request->port_id());
    if (!port)
      return MissingPortError(controller);

    if (inherit_mode)
      status = m_port_manager->SetPriorityInherit(port);
    else
      status = m_port_manager->SetPriorityStatic(port, value);
  } else {
    InputPort *port = device->GetInputPort(request->port_id());
    if (!port)
      return MissingPortError(controller);

    if (inherit_mode)
      status = m_port_manager->SetPriorityInherit(port);
    else
      status = m_port_manager->SetPriorityStatic(port, value);
  }

  if (!status)
    controller->SetFailed(
        "Invalid SetPortPriority request, see logs for more info");
}
Exemplo n.º 2
0
/*
 * Check for loops.
 */
bool ShowNetInputPort::PreSetUniverse(Universe *old_universe,
                                      Universe *new_universe) {
  (void) old_universe;
  (void) new_universe;
  AbstractDevice *device = GetDevice();
  OutputPort *output_port = device->GetOutputPort(PortId());
  if (output_port && output_port->GetUniverse()) {
    OLA_WARN << "Avoiding possible shownet loop on " << Description();
    return false;
  }
  return true;
}
Exemplo n.º 3
0
/*
 * Patch a port to a universe
 */
void OlaServerServiceImpl::PatchPort(
    RpcController* controller,
    const PatchPortRequest* request,
    Ack*,
    ola::rpc::RpcService::CompletionCallback* done) {
  ClosureRunner runner(done);
  AbstractDevice *device =
    m_device_manager->GetDevice(request->device_alias());

  if (!device)
    return MissingDeviceError(controller);

  bool result;
  if (request->is_output()) {
    OutputPort *port = device->GetOutputPort(request->port_id());
    if (!port)
      return MissingPortError(controller);

    if (request->action() == ola::proto::PATCH)
      result = m_port_manager->PatchPort(port, request->universe());
    else
      result = m_port_manager->UnPatchPort(port);
  } else {
    InputPort *port = device->GetInputPort(request->port_id());
    if (!port)
      return MissingPortError(controller);

    if (request->action() == ola::proto::PATCH)
      result = m_port_manager->PatchPort(port, request->universe());
    else
      result = m_port_manager->UnPatchPort(port);
  }

  if (!result)
    controller->SetFailed("Patch port request failed");
}