Search in sources :

Example 1 with Tl1Controller

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);
    }
}
Also used : Tl1Command(org.onosproject.tl1.Tl1Command) DefaultTl1Command(org.onosproject.tl1.DefaultTl1Command) Tl1Controller(org.onosproject.tl1.Tl1Controller) DeviceId(org.onosproject.net.DeviceId) Tl1Device(org.onosproject.tl1.Tl1Device) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Example 2 with Tl1Controller

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;
    }
}
Also used : DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceDescription(org.onosproject.net.device.DeviceDescription) ChassisId(org.onlab.packet.ChassisId) Tl1Command(org.onosproject.tl1.Tl1Command) DefaultTl1Command(org.onosproject.tl1.DefaultTl1Command) DeviceId(org.onosproject.net.DeviceId) Tl1Controller(org.onosproject.tl1.Tl1Controller) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) Tl1Device(org.onosproject.tl1.Tl1Device) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Example 3 with Tl1Controller

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;
    }
}
Also used : Tl1Command(org.onosproject.tl1.Tl1Command) DefaultTl1Command(org.onosproject.tl1.DefaultTl1Command) Tl1Controller(org.onosproject.tl1.Tl1Controller) DeviceId(org.onosproject.net.DeviceId) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

ExecutionException (java.util.concurrent.ExecutionException)3 TimeoutException (java.util.concurrent.TimeoutException)3 DeviceId (org.onosproject.net.DeviceId)3 DefaultTl1Command (org.onosproject.tl1.DefaultTl1Command)3 Tl1Command (org.onosproject.tl1.Tl1Command)3 Tl1Controller (org.onosproject.tl1.Tl1Controller)3 Tl1Device (org.onosproject.tl1.Tl1Device)2 ChassisId (org.onlab.packet.ChassisId)1 DefaultDeviceDescription (org.onosproject.net.device.DefaultDeviceDescription)1 DeviceDescription (org.onosproject.net.device.DeviceDescription)1