use of org.onosproject.tl1.Tl1Controller in project onos by opennetworkinglab.
the class LumentumWaveReadyDiscovery method logout.
// Unused but provided here for convenience.
private void logout() {
DeviceId deviceId = handler().data().deviceId();
Tl1Controller ctrl = checkNotNull(handler().get(Tl1Controller.class));
Optional<Tl1Device> device = ctrl.getDevice(deviceId);
if (!device.isPresent()) {
return;
}
// Logout command
Tl1Command logoutCmd = DefaultTl1Command.builder().withVerb(CANC).withModifier(USER).withAid(device.get().username()).withCtag(103).build();
Future<String> logout = ctrl.sendMsg(deviceId, logoutCmd);
try {
String logoutResponse = logout.get(TIMEOUT, TimeUnit.MILLISECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("Lougout failed", e);
}
}
use of org.onosproject.tl1.Tl1Controller in project onos by opennetworkinglab.
the class LumentumWaveReadyDiscovery method discoverDeviceDetails.
@Override
public DeviceDescription discoverDeviceDetails() {
DeviceId deviceId = handler().data().deviceId();
Tl1Controller ctrl = checkNotNull(handler().get(Tl1Controller.class));
// Something reasonable, unavailable by default
DeviceDescription defaultDescription = new DefaultDeviceDescription(deviceId.uri(), Device.Type.OTN, LUMENTUM, WAVEREADY, SWVERSION, SERIAL, new ChassisId(), false, DefaultAnnotations.EMPTY);
Optional<Tl1Device> device = ctrl.getDevice(deviceId);
if (!device.isPresent()) {
return defaultDescription;
}
// Login
Tl1Command loginCmd = DefaultTl1Command.builder().withVerb(ACT).withModifier(USER).withAid(device.get().username()).withCtag(100).withParameters(device.get().password()).build();
Future<String> login = ctrl.sendMsg(deviceId, loginCmd);
try {
String loginResponse = login.get(TIMEOUT, TimeUnit.MILLISECONDS);
if (loginResponse.contains("Access denied")) {
log.error("Access denied: {}", loginResponse);
return defaultDescription;
}
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("Login failed", e);
return defaultDescription;
}
// Fetch device description
Tl1Command ddCmd = DefaultTl1Command.builder().withVerb(RTRV).withModifier(NETYPE).withCtag(101).build();
Future<String> dd = ctrl.sendMsg(deviceId, ddCmd);
try {
String ddResponse = dd.get(TIMEOUT, TimeUnit.MILLISECONDS);
return new DefaultDeviceDescription(defaultDescription, true, extractAnnotations(ddResponse));
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("Device description not found", e);
return defaultDescription;
}
}
use of org.onosproject.tl1.Tl1Controller in project onos by opennetworkinglab.
the class LumentumWaveReadyDiscovery method discoverPortDetails.
@Override
public List<PortDescription> discoverPortDetails() {
DeviceId deviceId = handler().data().deviceId();
Tl1Controller ctrl = checkNotNull(handler().get(Tl1Controller.class));
// Assume we're successfully logged in
// Fetch port descriptions
Tl1Command pdCmd = DefaultTl1Command.builder().withVerb(RTRV).withModifier(PLUGGABLE_INV).withCtag(102).build();
Future<String> pd = ctrl.sendMsg(deviceId, pdCmd);
try {
String pdResponse = pd.get(TIMEOUT, TimeUnit.MILLISECONDS);
return extractPorts(pdResponse);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("Port description not found", e);
return Collections.EMPTY_LIST;
}
}
Aggregations