本文整理了Java中org.onosproject.net.Device
类的一些代码示例,展示了Device
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Device
类的具体详情如下:
包路径:org.onosproject.net.Device
类名称:Device
暂无
代码示例来源: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-core-net
private void pollMeters() {
deviceService.getAvailableDevices().forEach(device -> {
if (mastershipService.isLocalMaster(device.id()) &&
device.is(MeterProgrammable.class)) {
pollDeviceMeters(device.id());
}
});
}
代码示例来源:origin: org.onosproject/onos-core-net
private GroupProgrammable getGroupProgrammable(DeviceId deviceId) {
Device device = deviceService.getDevice(deviceId);
if (device.is(GroupProgrammable.class)) {
return device.as(GroupProgrammable.class);
} else {
log.debug("Device {} is not group programmable", deviceId);
return null;
}
}
代码示例来源: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-fm-mgr
private void consumeAlarms(Device device) {
if (device.is(AlarmConsumer.class)) {
providerService.updateAlarmList(device.id(),
device.as(AlarmConsumer.class).consumeAlarms());
} else {
log.info("Device {} does not support alarm consumer behaviour", device.id());
}
}
代码示例来源:origin: org.onosproject/onos-core-net
@Override
public void onError(Objective objective, ObjectiveError error) {
log.warn("Failed to install packet request {} to {}: {}",
request, device.id(), error);
}
});
代码示例来源: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-core-trivial
private DeviceEvent updateDevice(ProviderId providerId, Device oldDevice, Device newDevice) {
!Objects.equals(oldDevice.hwVersion(), newDevice.hwVersion()) ||
!Objects.equals(oldDevice.swVersion(), newDevice.swVersion());
boolean annotationsChanged =
!AnnotationsUtil.isEqual(oldDevice.annotations(), newDevice.annotations());
(!providerId.isAncillary() && (propertiesChanged || annotationsChanged))) {
boolean replaced = devices.replace(newDevice.id(), oldDevice, newDevice);
if (!replaced) {
providerId, oldDevice, devices.get(newDevice.id())
, newDevice);
availableDevices.add(newDevice.id());
boolean added = availableDevices.add(newDevice.id());
return !added ? null :
new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, newDevice, null);
代码示例来源: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-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 void pollTableStatistics(Device device) {
try {
List<TableStatisticsEntry> tableStatsList = newArrayList(device.as(TableStatisticsDiscovery.class)
.getTableStatistics());
providerService.pushTableStatistics(device.id(), tableStatsList);
} catch (Exception e) {
log.warn("Exception thrown while polling table statistics for {}", device.id(), e);
}
}
代码示例来源: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 -> {
String ipAddress = d.annotations()
.value(CONTROLLER_IP_KEY);
Ip4Address dst = Ip4Address.valueOf(ipAddress);
代码示例来源:origin: org.onosproject/onos-providers-lldpcommon
private ONOSLLDP getLinkProbe(Long port) {
return ONOSLLDP.onosLLDP(device.id().toString(), device.chassisId(), port.intValue());
}
代码示例来源: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 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-core-net
/**
* {@inheritDoc}
* if the Device does not support {@link FlowRuleProgrammable}.
*/
@Override
protected synchronized FlowRuleProvider getProvider(DeviceId deviceId) {
checkNotNull(deviceId, DEVICE_ID_NULL);
// if device supports FlowRuleProgrammable,
// use FlowRuleProgrammable via FlowRuleDriverProvider
return Optional.ofNullable(deviceService.getDevice(deviceId))
.filter(dev -> dev.is(FlowRuleProgrammable.class))
.<FlowRuleProvider>map(x -> driverProvider)
.orElseGet(() -> super.getProvider(deviceId));
}
代码示例来源: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
/**
* 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)));
}
}
}
}
代码示例来源:origin: org.onosproject/onos-core-net
@Override
public void onError(Objective objective, ObjectiveError error) {
log.warn("Failed to withdraw packet request {} from {}: {}",
request, device.id(), error);
}
});
代码示例来源: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;
}
内容来源于网络,如有侵权,请联系作者删除!