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

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

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

Device.type介绍

暂无

代码示例

代码示例来源: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-core-net

@Override
public Iterable<Device> getAvailableDevices(Type type) {
  checkPermission(DEVICE_READ);
  Set<Device> results = new HashSet<>();
  Iterable<Device> availableDevices = store.getAvailableDevices();
  if (availableDevices != null) {
    availableDevices.forEach(d -> {
      if (type.equals(d.type())) {
        results.add(d);
      }
    });
  }
  return results;
}

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

@Override
public Iterable<Device> getDevices(Type type) {
  checkPermission(DEVICE_READ);
  Set<Device> results = new HashSet<>();
  Iterable<Device> devices = store.getDevices();
  if (devices != null) {
    devices.forEach(d -> {
      if (type.equals(d.type())) {
        results.add(d);
      }
    });
  }
  return results;
}

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

private String getDeviceString(Device dev) {
  StringBuilder buf = new StringBuilder();
  if (dev != null) {
    buf.append(String.format("Device: %s, ", dev.id()));
    buf.append(String.format("%s, ", dev.type()));
    buf.append(String.format("%s, ", dev.manufacturer()));
    buf.append(String.format("%s, ", dev.hwVersion()));
    buf.append(String.format("%s, ", dev.swVersion()));
    if (dev instanceof DefaultDevice) {
      DefaultDevice dfltDev = (DefaultDevice) dev;
      if (dfltDev.driver() != null) {
        buf.append(String.format("%s, ", dfltDev.driver().name()));
      }
      String channelId = dfltDev.annotations().value("channelId");
      if (channelId != null) {
        buf.append(String.format("%s, ", channelId));
      }
    }
  }
  return buf.toString();
}

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

/**
 * Get the ControllerId from the device .
 *
 * @param device Device
 * @param devices Devices
 * @return Controller Id
 */
public DeviceId getControllerId(Device device, Iterable<Device> devices) {
  for (Device d : devices) {
    if (d.type() == Device.Type.CONTROLLER && d.id().toString()
        .contains(getControllerIpOfSwitch(device))) {
      return d.id();
    }
  }
  log.info("Can not find controller for device : {}", device.id());
  return null;
}

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

/**
 * Get the ControllerId from the device .
 *
 * @param device Device
 * @param devices Devices
 * @return Controller Id
 */
public static DeviceId getControllerId(Device device,
                    Iterable<Device> devices) {
  for (Device d : devices) {
    if (d.type() == Device.Type.CONTROLLER && d.id().toString()
        .contains(getControllerIpOfSwitch(device))) {
      return d.id();
    }
  }
  log.info("Can not find controller for device : {}", device.id());
  return null;
}

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

String tunnelName = "vxlan-" + DEFAULT_IP;
Sets.newHashSet(devices).stream()
    .filter(d -> d.type() == Device.Type.CONTROLLER)
    .filter(d -> !("ovsdb:" + ipAddress).equals(d.id().toString()))
    .forEach(d -> {

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

@Override
public ObjectNode encode(Device device, CodecContext context) {
  checkNotNull(device, "Device cannot be null");
  DeviceService service = context.getService(DeviceService.class);
  DriverService driveService = context.getService(DriverService.class);
  ObjectNode result = context.mapper().createObjectNode()
      .put(ID, device.id().toString())
      .put(TYPE, device.type().name())
      .put(AVAILABLE, service.isAvailable(device.id()))
      .put(ROLE, service.getRole(device.id()).toString())
      .put(MFR, device.manufacturer())
      .put(HW, device.hwVersion())
      .put(SW, device.swVersion())
      .put(SERIAL, device.serialNumber())
      .put(DRIVER, driveService.getDriver(device.id()).name())
      .put(CHASSIS_ID, device.chassisId().toString())
      .put(LAST_UPDATE, Long.toString(service.getLastUpdatedInstant(device.id())))
      .put(HUMAN_READABLE_LAST_UPDATE, service.localStatus(device.id()));
  return annotate(result, device, context);
}

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

return;
if ((Type.ROADM.equals(device.type())) || (Type.OTN.equals(device.type())) ||
    (Type.OLS.equals(device.type())) || (Type.TERMINAL_DEVICE.equals(device.type()))) {

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

/**
 * Removes packet intercept flow rules from the device.
 *
 * @param device  the device to remove the rules deom
 * @param request the packet request
 */
private void removeRule(Device device, PacketRequest request) {
  if (!device.type().equals(Device.Type.SWITCH)) {
    return;
  }
  ForwardingObjective forwarding = createBuilder(request)
      .remove(new ObjectiveContext() {
        @Override
        public void onError(Objective objective, ObjectiveError error) {
          log.warn("Failed to withdraw packet request {} from {}: {}",
               request, device.id(), error);
        }
      });
  objectiveService.forward(device.id(), forwarding);
}

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

private void applyL3ArpFlows(DeviceId deviceId, VirtualPort gwPort,
               Objective.Operation operation) {
  IpAddress ip = null;
  Iterator<FixedIp> gwIps = gwPort.fixedIps().iterator();
  if (gwIps.hasNext()) {
    ip = gwIps.next().ip();
  }
  IpAddress gwIp = ip;
  MacAddress gwMac = gwPort.macAddress();
  TenantNetwork network = tenantNetworkService
      .getNetwork(gwPort.networkId());
  if (deviceId != null) {
    // Arp rules
    DriverHandler handler = driverService.createHandler(deviceId);
    arpService.programArpRules(handler, deviceId, gwIp,
                  network.segmentationId(), gwMac,
                  operation);
  } else {
    Iterable<Device> devices = deviceService.getAvailableDevices();
    Sets.newHashSet(devices).stream()
    .filter(d -> Device.Type.SWITCH == d.type()).forEach(d -> {
      // Arp rules
      DriverHandler handler = driverService.createHandler(d.id());
      arpService.programArpRules(handler, d.id(), gwIp,
                    network.segmentationId(), gwMac,
                    operation);
    });
  }
}

代码示例来源: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-apps-optical-model

if (!(srcDevice.type().equals(dstDevice.type()))) {
  log.debug("Devices without same deviceType: SRC={} and DST={}", srcDevice.type(), dstDevice.type());
  return intent;
if (Type.ROADM.equals(srcDevice.type()) ||
    Type.ROADM_OTN.equals(srcDevice.type()) ||
    Type.OLS.equals(srcDevice.type())) {
  intent = OpticalCircuitIntent.builder()
      .appId(appId)
      .bidirectional(bidirectional)
      .build();
} else if (Type.OTN.equals(srcDevice.type()) || Type.TERMINAL_DEVICE.equals(srcDevice.type())) {
  intent = OpticalOduIntent.builder()
      .appId(appId)
  log.error("Wrong Device Type for connect points: " +
      "ingress {} of type {}; egress {} of type {}",
      ingress, srcDevice.type(), egress, dstDevice.type());

代码示例来源:origin: org.onosproject/onos-apps-optical-model

if (!(srcDevice.type().equals(dstDevice.type()))) {
  log.debug("Devices without same deviceType: SRC {} and DST={}", srcDevice.type(), dstDevice.type());
  return intent;
if (Type.ROADM.equals(srcDevice.type()) ||
    Type.ROADM_OTN.equals(srcDevice.type()) ||
    Type.OLS.equals(srcDevice.type())) {
  intent = OpticalCircuitIntent.builder()
      .appId(appId)
      .bidirectional(bidirectional)
      .build();
} else if (Type.OTN.equals(srcDevice.type()) || Type.TERMINAL_DEVICE.equals(srcDevice.type())) {
  intent = OpticalOduIntent.builder()
      .appId(appId)

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

Sets.newHashSet(devices)
.stream()
.filter(d -> d.type() == Device.Type.CONTROLLER)
.filter(d -> !deviceId.equals(d.id()))
.forEach(d -> {

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

@Override
  public void event(DeviceEvent event) {
    Device device = event.subject();
    if (Device.Type.CONTROLLER == device.type()) {
      if (DeviceEvent.Type.DEVICE_ADDED == event.type()) {
        onControllerDetected(device);
      }
      if (DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED == event.type()) {
        if (deviceService.isAvailable(device.id())) {
          onControllerDetected(device);
        } else {
          onControllerVanished(device);
        }
      }
    } else if (Device.Type.SWITCH == device.type()) {
      if (DeviceEvent.Type.DEVICE_ADDED == event.type()) {
        onOvsDetected(device);
      }
      if (DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED == event.type()) {
        if (deviceService.isAvailable(device.id())) {
          onOvsDetected(device);
        } else {
          onOvsVanished(device);
        }
      }
    } else {
      log.info("Do nothing for this device type");
    }
  }
}

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

/**
 * Pushes packet intercept flow rules to the device.
 *
 * @param device  the device to push the rules to
 * @param request the packet request
 */
private void pushRule(Device device, PacketRequest request) {
  if (!device.type().equals(Device.Type.SWITCH)) {
    return;
  }
  if (!deviceService.isAvailable(device.id())) {
    return;
  }
  ForwardingObjective forwarding = createBuilder(request)
      .add(new ObjectiveContext() {
        @Override
        public void onError(Objective objective, ObjectiveError error) {
          log.warn("Failed to install packet request {} to {}: {}",
               request, device.id(), error);
        }
      });
  objectiveService.forward(device.id(), forwarding);
}

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

private void sendEastWestL3Flows(Host h, MacAddress srcVmGwMac,
                 SegmentationId l3vni, IpAddress srcGwIp,
                 TenantNetwork network, IpAddress dstVmIP,
                 MacAddress dstVmGwMac,
                 Objective.Operation operation) {
  classifierService
      .programL3InPortClassifierRules(h.location().deviceId(),
                      h.location().port(), h.mac(),
                      srcVmGwMac, l3vni, operation);
  classifierService
      .programArpClassifierRules(h.location().deviceId(),
                    h.location().port(), srcGwIp,
                    network.segmentationId(), operation);
  Iterable<Device> devices = deviceService.getAvailableDevices();
  Sets.newHashSet(devices).stream()
      .filter(d -> Device.Type.SWITCH == d.type()).forEach(d -> {
        // L3FWD rules
        l3ForwardService.programRouteRules(d.id(), l3vni, dstVmIP,
                          network.segmentationId(),
                          dstVmGwMac, h.mac(),
                          operation);
      });
}

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

if (deviceOwner.equalsIgnoreCase("network:dhcp")) {
  Sets.newHashSet(devices).stream()
      .filter(d -> d.type() == Device.Type.SWITCH)
      .forEach(d -> {
        if (subnet != null) {

代码示例来源: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)));
      }
    }
  }
}

相关文章