use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.
the class DefaultKubevirtNode method tunnelPort.
private PortNumber tunnelPort(String tunnelType) {
if (dataIp == null) {
return null;
}
DeviceService deviceService = DefaultServiceDirectory.getService(DeviceService.class);
Port port = deviceService.getPorts(tunBridge).stream().filter(p -> p.isEnabled() && Objects.equals(p.annotations().value(PORT_NAME), tunnelType)).findAny().orElse(null);
return port != null ? port.number() : null;
}
use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.
the class MappingsListCommand method doExecute.
@Override
protected void doExecute() {
MappingStore.Type typeEnum = getTypeEnum(type);
DeviceService deviceService = get(DeviceService.class);
Iterable<Device> devices = deviceService.getDevices();
if (outputJson()) {
print(JSON_FORMAT, json(typeEnum, devices));
} else {
if (deviceId != null) {
mappings = newArrayList(mappingService.getMappingEntries(typeEnum, DeviceId.deviceId(deviceId)));
printMappings(DeviceId.deviceId(deviceId), mappings);
} else {
for (Device d : devices) {
mappings = newArrayList(mappingService.getMappingEntries(typeEnum, d.id()));
printMappings(d.id(), mappings);
}
}
}
}
use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.
the class TsCheckLoop method doExecute.
@Override
protected void doExecute() {
NetworkDiagnosticService service = getService(NetworkDiagnosticService.class);
DeviceService ds = getService(DeviceService.class);
HostService hs = getService(HostService.class);
FlowRuleService frs = getService(FlowRuleService.class);
LinkService ls = getService(LinkService.class);
service.findAnomalies(NetworkDiagnostic.Type.LOOP).forEach(loop -> print(loop.toString()));
}
use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.
the class ServiceApplicationComponent method createOpticalIntent.
/**
* Returns a new optical intent created from the method parameters.
*
* @param ingress ingress description (device/port)
* @param egress egress description (device/port)
* @param key intent key
* @param appId application id. As per Intent class, it cannot be null
*
* @return created intent
*/
protected Intent createOpticalIntent(ConnectPoint ingress, ConnectPoint egress, Key key, ApplicationId appId) {
if (ingress == null || egress == null) {
log.error("Invalid endpoint(s) for optical intent: ingress {}, egress {}", ingress, egress);
return null;
}
DeviceService ds = opticalView(deviceService);
Port srcPort = ds.getPort(ingress.deviceId(), ingress.port());
Port dstPort = ds.getPort(egress.deviceId(), egress.port());
if (srcPort == null || dstPort == null) {
log.error("Invalid port(s) for optical intent: src {}, dst {}", srcPort, dstPort);
return null;
}
OduSignalType signalType = ((OchPort) srcPort).signalType();
return OpticalConnectivityIntent.builder().appId(appId).key(key).src(ingress).dst(egress).signalType(signalType).bidirectional(// TODO Revisit this.
true).build();
}
use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.
the class OpenstackNetworkingUtilTest method testHasIntfAleadyInDevice.
/**
* Tests hasIntfAleadyInDevice method.
*/
@Test
public void testHasIntfAleadyInDevice() {
DeviceService deviceService = new TestDeviceService();
assertTrue(OpenstackNetworkingUtil.hasIntfAleadyInDevice(DeviceId.deviceId("deviceId"), "port1", deviceService));
assertTrue(OpenstackNetworkingUtil.hasIntfAleadyInDevice(DeviceId.deviceId("deviceId"), "port2", deviceService));
assertTrue(OpenstackNetworkingUtil.hasIntfAleadyInDevice(DeviceId.deviceId("deviceId"), "port3", deviceService));
assertFalse(OpenstackNetworkingUtil.hasIntfAleadyInDevice(DeviceId.deviceId("deviceId"), "port4", deviceService));
}
Aggregations