use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.
the class VirtualNetworkFlowRuleManager method getFlowRulesByGroupId.
@Override
public Iterable<FlowRule> getFlowRulesByGroupId(ApplicationId appId, short groupId) {
DeviceService deviceService = manager.get(networkId(), DeviceService.class);
Set<FlowRule> matches = Sets.newHashSet();
long toLookUp = ((long) appId.id() << 16) | groupId;
for (Device d : deviceService.getDevices()) {
for (FlowEntry flowEntry : store.getFlowEntries(networkId(), d.id())) {
if ((flowEntry.id().value() >>> 32) == toLookUp) {
matches.add(flowEntry);
}
}
}
return matches;
}
use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.
the class VirtualNetworkFlowRuleManager method getFlowEntriesById.
@Override
public Iterable<FlowEntry> getFlowEntriesById(ApplicationId id) {
DeviceService deviceService = manager.get(networkId(), DeviceService.class);
Set<FlowEntry> flowEntries = Sets.newHashSet();
for (Device d : deviceService.getDevices()) {
for (FlowEntry flowEntry : store.getFlowEntries(networkId(), d.id())) {
if (flowEntry.appId() == id.id()) {
flowEntries.add(flowEntry);
}
}
}
return flowEntries;
}
use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.
the class EncodeInstructionCodecHelper method encodeExtension.
/**
* Encodes a extension instruction.
*
* @param result json node that the instruction attributes are added to
*/
private void encodeExtension(ObjectNode result) {
final Instructions.ExtensionInstructionWrapper extensionInstruction = (Instructions.ExtensionInstructionWrapper) instruction;
DeviceId deviceId = extensionInstruction.deviceId();
ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
DeviceService deviceService = serviceDirectory.get(DeviceService.class);
Device device = deviceService.getDevice(deviceId);
if (device == null) {
throw new IllegalArgumentException("Device not found");
}
if (device.is(ExtensionTreatmentCodec.class)) {
// for extension instructions, encoding device id is needed for the corresponding decoder
result.put("deviceId", deviceId.toString());
ExtensionTreatmentCodec treatmentCodec = device.as(ExtensionTreatmentCodec.class);
ObjectNode node = treatmentCodec.encode(extensionInstruction.extensionInstruction(), context);
result.set(InstructionCodec.EXTENSION, node);
} else {
throw new IllegalArgumentException("There is no codec to encode extension for device " + deviceId.toString());
}
}
use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.
the class OpenstackNodeCheckCommand method doExecute.
@Override
protected void doExecute() {
OpenstackNodeService osNodeService = get(OpenstackNodeService.class);
DeviceService deviceService = get(DeviceService.class);
OpenstackNode osNode = osNodeService.node(hostname);
if (osNode == null) {
print("Cannot find %s from registered nodes", hostname);
return;
}
if (osNode.type() == CONTROLLER) {
print("[Openstack Controller Status]");
OSClient client = getConnectedClient(osNode);
if (client == null) {
error("The given keystone info is incorrect to get authorized to openstack");
print("keystoneConfig=%s", osNode.keystoneConfig());
}
if (osNode.keystoneConfig() != null) {
print("%s keystoneConfig=%s, neutronConfig=%s", osNode.state() == NodeState.COMPLETE && client != null ? MSG_OK : MSG_ERROR, osNode.keystoneConfig(), osNode.neutronConfig());
} else {
print("%s keystoneConfig is missing", MSG_ERROR);
}
} else {
print("[Integration Bridge Status]");
Device device = deviceService.getDevice(osNode.intgBridge());
Device ovsdbDevice = deviceService.getDevice(osNode.ovsdb());
if (device != null) {
print("%s OvsdbDeviceId=%s available=%s", deviceService.isAvailable(ovsdbDevice.id()) ? MSG_OK : MSG_ERROR, ovsdbDevice.id(), deviceService.isAvailable(ovsdbDevice.id()));
print("%s %s=%s available=%s %s", deviceService.isAvailable(device.id()) ? MSG_OK : MSG_ERROR, INTEGRATION_BRIDGE, device.id(), deviceService.isAvailable(device.id()), device.annotations());
if (osNode.dataIp() != null) {
printPortState(deviceService, osNode.intgBridge(), VXLAN_TUNNEL);
printPortState(deviceService, osNode.intgBridge(), GRE_TUNNEL);
printPortState(deviceService, osNode.intgBridge(), GENEVE_TUNNEL);
}
if (osNode.vlanIntf() != null) {
printPortState(deviceService, osNode.intgBridge(), osNode.vlanIntf());
}
osNode.phyIntfs().forEach(intf -> {
printPortState(deviceService, osNode.intgBridge(), structurePortName(INTEGRATION_TO_PHYSICAL_PREFIX + intf.network()));
});
if (osNode.type() == GATEWAY) {
printPortState(deviceService, osNode.intgBridge(), osNode.uplinkPort());
}
} else {
print("%s %s=%s is not available", MSG_ERROR, INTEGRATION_BRIDGE, osNode.intgBridge());
}
}
}
use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.
the class DefaultOpenstackNode method tunnelPortNum.
private PortNumber tunnelPortNum(String tunnelType) {
if (dataIp == null) {
return null;
}
DeviceService deviceService = DefaultServiceDirectory.getService(DeviceService.class);
Port port = deviceService.getPorts(intgBridge).stream().filter(p -> p.isEnabled() && Objects.equals(p.annotations().value(PORT_NAME), tunnelType)).findAny().orElse(null);
return port != null ? port.number() : null;
}
Aggregations