org.onosproject.net.Device.annotations()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.onosproject.net.Device.annotations()方法的一些代码示例,展示了Device.annotations()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Device.annotations()方法的具体详情如下:
包路径:org.onosproject.net.Device
类名称:Device
方法名:annotations

Device.annotations介绍

暂无

代码示例

代码示例来源:origin: org.onosproject/onos-app-sfc-mgr

/**
 * Get the ControllerIp from the device .
 *
 * @param device Device
 * @return Controller Ip
 */
public String getControllerIpOfSwitch(Device device) {
  String url = device.annotations().value(SWITCH_CHANNEL_ID);
  return url.substring(0, url.lastIndexOf(":"));
}

代码示例来源:origin: org.onosproject/onos-app-vtn-mgr

/**
 * Get the ControllerIp from the device .
 *
 * @param device Device
 * @return Controller Ip
 */
public static String getControllerIpOfSwitch(Device device) {
  String url = device.annotations().value(SWITCH_CHANNEL_ID);
  return url.substring(0, url.lastIndexOf(":"));
}

代码示例来源:origin: org.onosproject/onos-core-net

private boolean canMarkOnline(Device device) {
  final boolean providerMarkOnline = Boolean.parseBoolean(
      device.annotations().value(AnnotationKeys.PROVIDER_MARK_ONLINE));
  return !providerMarkOnline;
}

代码示例来源:origin: org.onosproject/onos-core-net

private DomainId getAnnotatedDomainId(Device device) {
    if (!device.annotations().keys().contains(DOMAIN_ID)) {
      return DomainId.LOCAL;
    } else {
      return DomainId.domainId(
          device.annotations().value(DOMAIN_ID));
    }
  }
}

代码示例来源:origin: org.onosproject/onos-lldp-provider

public boolean isSuppressed(Device device) {
  if (suppressedDeviceType.contains(device.type())) {
    return true;
  }
  final Annotations annotations = device.annotations();
  if (containsSuppressionAnnotation(annotations)) {
    return true;
  }
  return false;
}

代码示例来源:origin: org.onosproject/onos-protocols-pcep-ctl

/**
 * Retrieve lsr-id from device annotation.
 *
 * @param deviceId specific device id from which lsr-id needs to be retrieved
 * @return lsr-id of a device
 */
public String getLsrId(DeviceId deviceId) {
  checkNotNull(deviceId, DEVICE_ID_NULL);
  Device device = deviceService.getDevice(deviceId);
  if (device == null) {
    log.debug("Device is not available for device id {} in device service.", deviceId.toString());
    return null;
  }
  // Retrieve lsr-id from device
  if (device.annotations() == null) {
    log.debug("Device {} does not have annotation.", device.toString());
    return null;
  }
  String lsrId = device.annotations().value(LSR_ID);
  if (lsrId == null) {
    log.debug("The lsr-id of device {} is null.", device.toString());
    return null;
  }
  return lsrId;
}

代码示例来源:origin: org.onosproject/onos-app-pce

/**
 * Retrieve lsr-id from device annotation.
 *
 * @param deviceId specific device id from which lsr-id needs to be retrieved
 * @return lsr-id of a device
 */
public String getLsrId(DeviceId deviceId) {
  checkNotNull(deviceId, DEVICE_ID_NULL);
  Device device = deviceService.getDevice(deviceId);
  if (device == null) {
    log.debug("Device is not available for device id {} in device service.", deviceId.toString());
    return null;
  }
  // Retrieve lsr-id from device
  if (device.annotations() == null) {
    log.debug("Device {} does not have annotation.", device.toString());
    return null;
  }
  String lsrId = device.annotations().value(LSR_ID);
  if (lsrId == null) {
    log.debug("The lsr-id of device {} is null.", device.toString());
    return null;
  }
  return lsrId;
}

代码示例来源:origin: org.onosproject/onos-pcep-provider-tunnel

private DeviceId getDevice(PccId pccId) {
  // Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID.
  IpAddress lsrId = pccId.ipAddress();
  String lsrIdentifier = String.valueOf(lsrId);
  // Find PCC deviceID from lsrId stored as annotations
  Iterable<Device> devices = deviceService.getAvailableDevices();
  for (Device dev : devices) {
    if (dev.annotations().value(AnnotationKeys.TYPE).equals("L3")
        && dev.annotations().value(LSRID).equals(lsrIdentifier)) {
      return dev.id();
    }
  }
  return null;
}

代码示例来源:origin: org.onosproject/onos-app-bgp-flowmgr

/**
 * Validates the device id is a flow peer or not.
 *
 * @param deviceId device to which the flow needed to be pushed.
 * @return true if success else false
 */
boolean validatePeer(DeviceId deviceId) {
  boolean ret = false;
  Device d = deviceService.getDevice(deviceId);
  Annotations a = d != null ? d.annotations() : null;
  String ipAddress = a.value(FLOW_PEER);
  if (ipAddress != null) {
    ret = true;
  }
  return ret;
}

代码示例来源:origin: org.onosproject/onos-protocols-pcep-ctl

if (specificDevice.annotations() == null) {
  log.debug("Device {} does not have annotations.", specificDevice.toString());
  return;
String lsrId = specificDevice.annotations().value(LSRID);
if (lsrId == null) {
  log.debug("Unable to retrieve lsr-id of a device {}.", specificDevice.toString());

代码示例来源:origin: org.onosproject/onos-core-net

private void invalidatePipelinerIfNecessary(Device device) {
  DriverHandler handler = driverHandlers.get(device.id());
  if (handler != null &&
      !Objects.equals(handler.driver().name(),
              device.annotations().value(DRIVER))) {
    invalidatePipeliner(device.id());
  }
}

代码示例来源:origin: org.onosproject/onos-app-pce

if (specificDevice.annotations() == null) {
  log.debug("Device {} does not have annotations.", specificDevice.toString());
  return;
String lsrId = specificDevice.annotations().value(LSRID);
if (lsrId == null) {
  log.debug("Unable to retrieve lsr-id of a device {}.", specificDevice.toString());

代码示例来源:origin: org.onosproject/onos-app-vtn-mgr

@Override
public void onControllerVanished(Device controllerDevice) {
  if (controllerDevice == null) {
    log.error("The device is null");
    return;
  }
  String dstIp = controllerDevice.annotations().value(CONTROLLER_IP_KEY);
  IpAddress dstIpAddress = IpAddress.valueOf(dstIp);
  DeviceId controllerDeviceId = controllerDevice.id();
  if (mastershipService.isLocalMaster(controllerDeviceId)) {
    switchesOfController.remove(dstIpAddress);
  }
}

代码示例来源:origin: org.onosproject/onos-protocols-pcep-ctl

/**
  * Returns PCEP client.
  *
  * @return PCEP client
  */
  private PcepClient getPcepClient(DeviceId deviceId) {
    Device device = deviceService.getDevice(deviceId);

    // In future projections instead of annotations will be used to fetch LSR ID.
    String lsrId = device.annotations().value(LSRID);
    PcepClient pcc = clientController.getClient(PccId.pccId(IpAddress.valueOf(lsrId)));
    return pcc;
  }
}

代码示例来源:origin: org.onosproject/onos-protocols-pcep-ctl

/**
   * Returns PCEP client.
   *
   * @return PCEP client
   */
  private PcepClient getPcepClient(DeviceId deviceId) {
    Device device = deviceService.getDevice(deviceId);

    // In future projections instead of annotations will be used to fetch LSR ID.
    String lsrId = device.annotations().value(LSR_ID);
    PcepClient pcc = clientController.getClient(PccId.pccId(IpAddress.valueOf(lsrId)));
    return pcc;
  }
}

代码示例来源:origin: org.onosproject/onos-core-net

/**
   * Returns a description of the given device.
   *
   * @param device the device
   * @return a description of the device
   */
  public static DeviceDescription descriptionOf(Device device) {
    checkNotNull(device, "Must supply non-null Device");
    return new DefaultDeviceDescription(device.id().uri(), device.type(),
        device.manufacturer(), device.hwVersion(),
        device.swVersion(), device.serialNumber(),
        device.chassisId(), (SparseAnnotations) device.annotations());
  }
}

代码示例来源:origin: org.onosproject/onos-app-pceweb

@Override
  public void process(long sid, ObjectNode payload) {
    String srcId = string(payload, SRCID);
    ElementId src = elementId(srcId);
    String dstId = string(payload, DSTID);
    ElementId dst = elementId(dstId);
    Device srcDevice = deviceService.getDevice((DeviceId) src);
    Device dstDevice = deviceService.getDevice((DeviceId) dst);
    TunnelEndPoint tunSrc = IpTunnelEndPoint.ipTunnelPoint(IpAddress
        .valueOf(srcDevice.annotations().value("lsrId")));
    TunnelEndPoint tunDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress
        .valueOf(dstDevice.annotations().value("lsrId")));
    Collection<Tunnel> tunnelSet = tunnelService.queryTunnel(tunSrc, tunDst);
    ObjectNode result = objectNode();
    ArrayNode arrayNode = arrayNode();
    for (Tunnel tunnel : tunnelSet) {
      if (tunnel.type() == MPLS) {
        arrayNode.add(tunnel.tunnelId().toString());
      }
    }
    result.putArray(BUFFER_ARRAY).addAll(arrayNode);
    sendMessage(PCEWEB_SHOW_TUNNEL, sid, result);
  }
}

代码示例来源:origin: org.onosproject/onos-app-pceweb

@Override
  public void process(long sid, ObjectNode payload) {
    String srcId = string(payload, SRCID);
    ElementId src = elementId(srcId);
    String dstId = string(payload, DSTID);
    ElementId dst = elementId(dstId);
    Device srcDevice = deviceService.getDevice((DeviceId) src);
    Device dstDevice = deviceService.getDevice((DeviceId) dst);
    TunnelEndPoint tunSrc = IpTunnelEndPoint.ipTunnelPoint(IpAddress
        .valueOf(srcDevice.annotations().value("lsrId")));
    TunnelEndPoint tunDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress
        .valueOf(dstDevice.annotations().value("lsrId")));
    Collection<Tunnel> tunnelSet = tunnelService.queryTunnel(tunSrc, tunDst);
    ObjectNode result = objectNode();
    ArrayNode arrayNode = arrayNode();
    for (Tunnel tunnel : tunnelSet) {
      if (tunnel.type() == MPLS) {
        arrayNode.add(tunnel.tunnelId().toString());
      }
    }
    result.putArray(BUFFER_ARRAY).addAll(arrayNode);
    sendMessage(PCEWEB_SHOW_TUNNEL_REMOVE, sid, result);
  }
}

代码示例来源:origin: org.onosproject/onos-core-net

@Override
public Driver getDriver(DeviceId deviceId) {
  checkPermission(DRIVER_READ);
  Driver driver;
  // Special processing for devices with pipeconf.
  if (pipeconfService.ofDevice(deviceId).isPresent()) {
    // No fallback for pipeconf merged drivers. Returns null if driver
    // does not exist.
    return getPipeconfMergedDriver(deviceId);
  }
  // Primary source of driver configuration is the network config.
  BasicDeviceConfig cfg = networkConfigService.getConfig(deviceId, BasicDeviceConfig.class);
  driver = lookupDriver(cfg != null ? cfg.driver() : null);
  if (driver != null) {
    return driver;
  }
  // Secondary source of the driver selection is driver annotation.
  Device device = nullIsNotFound(deviceService.getDevice(deviceId), NO_DEVICE);
  driver = lookupDriver(device.annotations().value(DRIVER));
  if (driver != null) {
    return driver;
  }
  // Tertiary source of the driver selection is the primordial information
  // obtained from the device.
  return nullIsNotFound(getDriver(device.manufacturer(),
                  device.hwVersion(), device.swVersion()),
             NO_DRIVER);
}

代码示例来源:origin: org.onosproject/onos-cli

/**
   * Prints information about the specified device.
   *
   * @param deviceService device service
   * @param device        infrastructure device
   */
  protected void printDevice(DeviceService deviceService, Device device) {
    if (device != null) {
      String driver = get(DriverService.class).getDriver(device.id()).name();
      if (shortOnly) {
        print(FMT_SHORT, device.id(), deviceService.isAvailable(device.id()),
           deviceService.getRole(device.id()), device.type(), driver);
      } else {
        print(FMT, device.id(), deviceService.isAvailable(device.id()),
           deviceService.localStatus(device.id()),
           deviceService.getRole(device.id()), device.type(),
           device.manufacturer(), device.hwVersion(), device.swVersion(),
           device.serialNumber(), device.chassisId(), driver,
           annotations(device.annotations(), ImmutableSet.of(AnnotationKeys.DRIVER)));
      }
    }
  }
}

相关文章