use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.
the class VoltRebootOnuCommand method doExecute.
@Override
protected void doExecute() {
DriverService service = get(DriverService.class);
deviceId = DeviceId.deviceId(uri);
DriverHandler h = service.createHandler(deviceId);
VoltOnuOperConfig volt = h.behaviour(VoltOnuOperConfig.class);
String reply = volt.rebootOnu(target);
if (reply != null) {
print("%s", reply);
} else {
print("No reply from %s", deviceId.toString());
}
}
use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.
the class VoltSetAlertFilterCommand method doExecute.
@Override
protected void doExecute() {
DriverService service = get(DriverService.class);
deviceId = DeviceId.deviceId(uri);
DriverHandler h = service.createHandler(deviceId);
VoltAlertConfig volt = h.behaviour(VoltAlertConfig.class);
volt.setAlertFilter(severity);
}
use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.
the class VoltSetOnuCommand method doExecute.
@Override
protected void doExecute() {
DriverService service = get(DriverService.class);
deviceId = DeviceId.deviceId(uri);
DriverHandler h = service.createHandler(deviceId);
VoltOnuConfig volt = h.behaviour(VoltOnuConfig.class);
String reply = volt.setOnu(target);
if (reply != null) {
print("%s", reply);
} else {
print("No reply from %s", deviceId.toString());
}
}
use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.
the class VoltSetPonLinkCommand method doExecute.
@Override
protected void doExecute() {
DriverService service = get(DriverService.class);
deviceId = DeviceId.deviceId(uri);
DriverHandler h = service.createHandler(deviceId);
VoltPonLinkConfig volt = h.behaviour(VoltPonLinkConfig.class);
volt.setPonLink(target);
}
use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.
the class LinkDiscoveryAristaImpl method createLinksDescs.
private Set<LinkDescription> createLinksDescs(Optional<JsonNode> response) {
DriverHandler handler = checkNotNull(handler());
DeviceId localDeviceId = checkNotNull(handler.data().deviceId());
DeviceService deviceService = handler.get(DeviceService.class);
Set<LinkDescription> linkDescriptions = Sets.newHashSet();
List<Port> ports = deviceService.getPorts(localDeviceId);
if (ports.isEmpty() || Objects.isNull(response)) {
return linkDescriptions;
}
if (!response.isPresent()) {
return linkDescriptions;
}
log.debug("response: {}, {}", response, localDeviceId.toString());
JsonNode res = response.get();
if (res == null) {
log.warn("result is null");
return linkDescriptions;
}
JsonNode lldpNeighbors = res.findValue(LLDP_NEIGHBORS);
if (lldpNeighbors == null) {
log.warn("{} is null", LLDP_NEIGHBORS);
return linkDescriptions;
}
Iterator<Map.Entry<String, JsonNode>> lldpNeighborsIter = lldpNeighbors.fields();
while (lldpNeighborsIter.hasNext()) {
Map.Entry<String, JsonNode> neighbor = lldpNeighborsIter.next();
String lldpLocalPort = neighbor.getKey();
JsonNode neighborValue = neighbor.getValue();
log.debug("lldpLocalPort: {}", lldpLocalPort);
log.debug("neighborValue: {}", neighborValue.toString());
if (lldpLocalPort.isEmpty()) {
continue;
}
JsonNode neighborInfo = neighborValue.findValue(LLDP_NEIGHBOR_INFO);
if (neighborInfo == null) {
log.warn("{} is null", LLDP_NEIGHBOR_INFO);
continue;
}
Iterator<JsonNode> neighborInfoIter = neighborInfo.elements();
while (neighborInfoIter.hasNext()) {
JsonNode info = neighborInfoIter.next();
String chassisIdType = info.get(CHASSIS_ID_TYPE).asText("");
if (chassisIdType == null) {
log.warn("{} is null", CHASSIS_ID_TYPE);
continue;
}
if (!chassisIdType.equals(CHASSIS_ID_TYPE_MAC)) {
log.warn("{} is not mac: {}", CHASSIS_ID_TYPE_MAC, chassisIdType);
continue;
}
JsonNode remotePortNameNode = info.findValue(PORT_ID);
if (remotePortNameNode == null) {
continue;
}
String remoteChassisId = info.get(CHASSIS_ID).asText("");
String remotePortName = remotePortNameNode.asText("");
log.debug("{}: {}, {}: {}", CHASSIS_ID, remoteChassisId, PORT_ID, remotePortName);
Optional<Port> localPort = findLocalPortByName(ports, lldpLocalPort);
if (!localPort.isPresent()) {
log.warn("local port not found. lldpLocalPort value: {}", lldpLocalPort);
continue;
}
Optional<Device> remoteDevice = findRemoteDeviceByChassisId(deviceService, remoteChassisId);
if (!remoteDevice.isPresent()) {
log.warn("remote device not found. remoteChassisId value: {}", remoteChassisId);
continue;
}
Optional<Port> remotePort = findDestinationPortByName(remotePortName, deviceService, remoteDevice.get());
if (!remotePort.isPresent()) {
log.warn("remote port not found. remotePortName value: {}", remotePortName);
continue;
}
if (!localPort.get().isEnabled() || !remotePort.get().isEnabled()) {
log.debug("Ports are disabled. Cannot create a link between {}/{} and {}/{}", localDeviceId, localPort.get(), remoteDevice.get().id(), remotePort.get());
continue;
}
linkDescriptions.addAll(buildLinkPair(localDeviceId, localPort.get(), remoteDevice.get().id(), remotePort.get()));
}
}
log.debug("returning linkDescriptions: {}", linkDescriptions);
return linkDescriptions;
}
Aggregations