Search in sources :

Example 1 with OpenConfigLogicalChannelsHandler

use of org.onosproject.odtn.utils.openconfig.OpenConfigLogicalChannelsHandler in project onos by opennetworkinglab.

the class ZteTransceiver method enable.

@Override
public List<CharSequence> enable(PortNumber client, PortNumber line, boolean enable) {
    DeviceId deviceId = handler().data().deviceId();
    log.info("Discovering ZTE device {}", deviceId);
    Port clientPort = handler().get(DeviceService.class).getPort(deviceId, client);
    if (clientPort == null) {
        log.warn("{} does not exist on {}", client, deviceId);
        return Collections.emptyList();
    }
    String clientName = clientPort.annotations().value(OC_NAME);
    if (Strings.isNullOrEmpty(clientName)) {
        log.warn("{} annotations not exist on {}@{}", OC_NAME, client, deviceId);
        return Collections.emptyList();
    }
    Port linePort = handler().get(DeviceService.class).getPort(deviceId, line);
    if (linePort == null) {
        log.warn("{} does not exist on {}", line, deviceId);
        return Collections.emptyList();
    }
    String lineName = linePort.annotations().value(OC_NAME);
    if (Strings.isNullOrEmpty(lineName)) {
        log.warn("{} annotations not exist on {}@{}", OC_NAME, line, deviceId);
        return Collections.emptyList();
    }
    int clientIndex, lineIndex;
    try {
        clientIndex = getPortIndex(clientName);
        lineIndex = getPortIndex(lineName);
    } catch (IllegalArgumentException e) {
        return Collections.emptyList();
    }
    // create <terminal-device xmlns="http://openconfig.net/yang/terminal-device">
    // </terminal-device>
    OpenConfigTerminalDeviceHandler terminalDevice = new OpenConfigTerminalDeviceHandler();
    // add <logical-channels></logical-channels>
    OpenConfigLogicalChannelsHandler logicalChannels = new OpenConfigLogicalChannelsHandler(terminalDevice);
    // add <channel><index>"clientIndex"</index></channel>
    OpenConfigChannelHandler channel = new OpenConfigChannelHandler(clientIndex, logicalChannels);
    // add <channel xc:operation="merge/delete">
    if (enable) {
        channel.addAnnotation(ANOTATION_NAME, Operation.MERGE.value());
    } else {
        channel.addAnnotation(ANOTATION_NAME, Operation.DELETE.value());
    }
    // add <config><index>"clientIndex"</index></config>
    OpenConfigConfigOfChannelHandler configOfChannel = new OpenConfigConfigOfChannelHandler(channel);
    configOfChannel.addIndex(clientIndex);
    // add <logical-channel-assignments></logical-channel-assignments>
    OpenConfigLogicalChannelAssignmentsHandler logicalChannelAssignments = new OpenConfigLogicalChannelAssignmentsHandler(channel);
    // add <assignment><index>1</index></assignment>
    OpenConfigAssignmentHandler assignment = new OpenConfigAssignmentHandler(1, logicalChannelAssignments);
    // add <config><assignment-type>LOGICAL_CHANNEL</assignment-type>
    // <logical-channel>"lineIndex"</logical-channel>
    // </config>
    OpenConfigConfigOfAssignmentHandler configOfAssignment = new OpenConfigConfigOfAssignmentHandler(assignment);
    configOfAssignment.addAssignmentType(AssignmentTypeEnum.LOGICAL_CHANNEL);
    configOfAssignment.addLogicalChannel("" + lineIndex);
    return terminalDevice.getListCharSequence();
}
Also used : OpenConfigConfigOfChannelHandler(org.onosproject.odtn.utils.openconfig.OpenConfigConfigOfChannelHandler) OpenConfigConfigOfAssignmentHandler(org.onosproject.odtn.utils.openconfig.OpenConfigConfigOfAssignmentHandler) DeviceId(org.onosproject.net.DeviceId) Port(org.onosproject.net.Port) DeviceService(org.onosproject.net.device.DeviceService) OpenConfigAssignmentHandler(org.onosproject.odtn.utils.openconfig.OpenConfigAssignmentHandler) OpenConfigTerminalDeviceHandler(org.onosproject.odtn.utils.openconfig.OpenConfigTerminalDeviceHandler) OpenConfigLogicalChannelAssignmentsHandler(org.onosproject.odtn.utils.openconfig.OpenConfigLogicalChannelAssignmentsHandler) OpenConfigChannelHandler(org.onosproject.odtn.utils.openconfig.OpenConfigChannelHandler) OpenConfigLogicalChannelsHandler(org.onosproject.odtn.utils.openconfig.OpenConfigLogicalChannelsHandler)

Example 2 with OpenConfigLogicalChannelsHandler

use of org.onosproject.odtn.utils.openconfig.OpenConfigLogicalChannelsHandler in project onos by opennetworkinglab.

the class CassiniTransceiver method enable.

@Override
public List<CharSequence> enable(PortNumber client, PortNumber line, boolean enable) {
    DeviceId did = this.data().deviceId();
    Port clientPort = handler().get(DeviceService.class).getPort(did, client);
    if (clientPort == null) {
        log.warn("{} does not exist on {}", client, did);
        return Collections.emptyList();
    }
    String clientName = clientPort.annotations().value(OC_LOGICAL_CHANNEL);
    if (Strings.isNullOrEmpty(clientName)) {
        log.warn("{} annotations not exist on {}@{}", OC_LOGICAL_CHANNEL, client, did);
        return Collections.emptyList();
    }
    Port linePort = handler().get(DeviceService.class).getPort(did, line);
    if (linePort == null) {
        log.warn("{} does not exist on {}", line, did);
        return Collections.emptyList();
    }
    String lineName = linePort.annotations().value(OC_LOGICAL_CHANNEL);
    if (Strings.isNullOrEmpty(lineName)) {
        log.warn("{} annotations not exist on {}@{}", OC_LOGICAL_CHANNEL, line, did);
        return Collections.emptyList();
    }
    // create <terminal-device xmlns="http://openconfig.net/yang/terminal-device">
    // </terminal-device>
    OpenConfigTerminalDeviceHandler terminalDevice = new OpenConfigTerminalDeviceHandler();
    // add <logical-channels></logical-channels>
    OpenConfigLogicalChannelsHandler logicalChannels = new OpenConfigLogicalChannelsHandler(terminalDevice);
    // add <channel><index>"clientName"</index></channel>
    OpenConfigChannelHandler channel = new OpenConfigChannelHandler(Integer.parseInt(clientName), logicalChannels);
    // add <config><index>"clientName"</index></config>
    OpenConfigConfigOfChannelHandler configOfChannel = new OpenConfigConfigOfChannelHandler(channel);
    configOfChannel.addIndex(Integer.parseInt(clientName));
    // add <logical-channel-assignments></logical-channel-assignments>
    OpenConfigLogicalChannelAssignmentsHandler logicalChannelAssignments = new OpenConfigLogicalChannelAssignmentsHandler(channel);
    // add <assignment (none)/xc:operation="delete"><index>"clientName"</index></assignment>
    OpenConfigAssignmentHandler assignment = new OpenConfigAssignmentHandler(Integer.parseInt(clientName), logicalChannelAssignments);
    if (!enable) {
        assignment.addAnnotation(ANOTATION_NAME, Operation.DELETE.value());
    }
    // add <config><index>"clientName"</index>
    // <assignment-type>LOGICAL_CHANNEL</assignment-type>
    // <logical-channel>"lineName"</logical-channel>
    // <allocation>100</allocation>
    // </config>
    OpenConfigConfigOfAssignmentHandler configOfAssignment = new OpenConfigConfigOfAssignmentHandler(assignment);
    configOfAssignment.addIndex(Long.parseLong(clientName));
    configOfAssignment.addAssignmentType(AssignmentTypeEnum.LOGICAL_CHANNEL);
    configOfAssignment.addLogicalChannel(lineName);
    configOfAssignment.addAllocation(BigDecimal.valueOf(100));
    return terminalDevice.getListCharSequence();
}
Also used : OpenConfigConfigOfChannelHandler(org.onosproject.odtn.utils.openconfig.OpenConfigConfigOfChannelHandler) OpenConfigConfigOfAssignmentHandler(org.onosproject.odtn.utils.openconfig.OpenConfigConfigOfAssignmentHandler) OpenConfigLogicalChannelAssignmentsHandler(org.onosproject.odtn.utils.openconfig.OpenConfigLogicalChannelAssignmentsHandler) DeviceId(org.onosproject.net.DeviceId) Port(org.onosproject.net.Port) DeviceService(org.onosproject.net.device.DeviceService) OpenConfigChannelHandler(org.onosproject.odtn.utils.openconfig.OpenConfigChannelHandler) OpenConfigAssignmentHandler(org.onosproject.odtn.utils.openconfig.OpenConfigAssignmentHandler) OpenConfigLogicalChannelsHandler(org.onosproject.odtn.utils.openconfig.OpenConfigLogicalChannelsHandler) OpenConfigTerminalDeviceHandler(org.onosproject.odtn.utils.openconfig.OpenConfigTerminalDeviceHandler)

Example 3 with OpenConfigLogicalChannelsHandler

use of org.onosproject.odtn.utils.openconfig.OpenConfigLogicalChannelsHandler in project onos by opennetworkinglab.

the class InfineraTransceiver method enable.

@Override
public List<CharSequence> enable(PortNumber client, PortNumber line, boolean enable) {
    log.debug("enable() infinera route");
    DeviceId did = this.data().deviceId();
    Port clientPort = handler().get(DeviceService.class).getPort(did, client);
    if (clientPort == null) {
        log.warn("{} does not exist on {}", client, did);
        return Collections.emptyList();
    }
    String clientName = clientPort.annotations().value(OC_NAME);
    if (Strings.isNullOrEmpty(clientName)) {
        log.warn("{} annotations not exist on {}@{}", OC_NAME, client, did);
        return Collections.emptyList();
    }
    Port linePort = handler().get(DeviceService.class).getPort(did, line);
    if (linePort == null) {
        log.warn("{} does not exist on {}", line, did);
        return Collections.emptyList();
    }
    String lineName = linePort.annotations().value(OC_NAME);
    if (Strings.isNullOrEmpty(lineName)) {
        log.warn("{} annotations not exist on {}@{}", OC_NAME, line, did);
        return Collections.emptyList();
    }
    // create <terminal-device xmlns="http://openconfig.net/yang/terminal-device">
    // </terminal-device>
    OpenConfigTerminalDeviceHandler terminalDevice = new OpenConfigTerminalDeviceHandler();
    // add <logical-channels></logical-channels>
    OpenConfigLogicalChannelsHandler logicalChannels = new OpenConfigLogicalChannelsHandler(terminalDevice);
    // add <channel><index>"clientName"</index></channel>
    OpenConfigChannelHandler channel = new OpenConfigChannelHandler(Integer.parseInt(clientName), logicalChannels);
    // add <config><index>"clientName"</index></config>
    OpenConfigConfigOfChannelHandler configOfChannel = new OpenConfigConfigOfChannelHandler(channel);
    configOfChannel.addIndex(Integer.parseInt(clientName));
    // add <logical-channel-assignments xc:operation="merge/delete">
    OpenConfigLogicalChannelAssignmentsHandler logicalChannelAssignments = new OpenConfigLogicalChannelAssignmentsHandler(channel);
    if (enable) {
        logicalChannelAssignments.addAnnotation(ANOTATION_NAME, Operation.MERGE.value());
    } else {
        logicalChannelAssignments.addAnnotation(ANOTATION_NAME, Operation.DELETE.value());
    }
    // add <assignment><index>"clientName"</index></assignment>
    OpenConfigAssignmentHandler assignment = new OpenConfigAssignmentHandler(Integer.parseInt(clientName), logicalChannelAssignments);
    // add <config><assignment-type>LOGICAL_CHANNEL</assignment-type>
    // <logical-channel>"lineName"</logical-channel>
    // <allocation>100</allocation>
    // </config>
    OpenConfigConfigOfAssignmentHandler configOfAssignment = new OpenConfigConfigOfAssignmentHandler(assignment);
    configOfAssignment.addAssignmentType(AssignmentTypeEnum.LOGICAL_CHANNEL);
    configOfAssignment.addLogicalChannel(lineName);
    configOfAssignment.addAllocation(BigDecimal.valueOf(100));
    return terminalDevice.getListCharSequence();
}
Also used : OpenConfigConfigOfChannelHandler(org.onosproject.odtn.utils.openconfig.OpenConfigConfigOfChannelHandler) OpenConfigConfigOfAssignmentHandler(org.onosproject.odtn.utils.openconfig.OpenConfigConfigOfAssignmentHandler) OpenConfigLogicalChannelAssignmentsHandler(org.onosproject.odtn.utils.openconfig.OpenConfigLogicalChannelAssignmentsHandler) DeviceId(org.onosproject.net.DeviceId) Port(org.onosproject.net.Port) DeviceService(org.onosproject.net.device.DeviceService) OpenConfigChannelHandler(org.onosproject.odtn.utils.openconfig.OpenConfigChannelHandler) OpenConfigAssignmentHandler(org.onosproject.odtn.utils.openconfig.OpenConfigAssignmentHandler) OpenConfigLogicalChannelsHandler(org.onosproject.odtn.utils.openconfig.OpenConfigLogicalChannelsHandler) OpenConfigTerminalDeviceHandler(org.onosproject.odtn.utils.openconfig.OpenConfigTerminalDeviceHandler)

Aggregations

DeviceId (org.onosproject.net.DeviceId)3 Port (org.onosproject.net.Port)3 DeviceService (org.onosproject.net.device.DeviceService)3 OpenConfigAssignmentHandler (org.onosproject.odtn.utils.openconfig.OpenConfigAssignmentHandler)3 OpenConfigChannelHandler (org.onosproject.odtn.utils.openconfig.OpenConfigChannelHandler)3 OpenConfigConfigOfAssignmentHandler (org.onosproject.odtn.utils.openconfig.OpenConfigConfigOfAssignmentHandler)3 OpenConfigConfigOfChannelHandler (org.onosproject.odtn.utils.openconfig.OpenConfigConfigOfChannelHandler)3 OpenConfigLogicalChannelAssignmentsHandler (org.onosproject.odtn.utils.openconfig.OpenConfigLogicalChannelAssignmentsHandler)3 OpenConfigLogicalChannelsHandler (org.onosproject.odtn.utils.openconfig.OpenConfigLogicalChannelsHandler)3 OpenConfigTerminalDeviceHandler (org.onosproject.odtn.utils.openconfig.OpenConfigTerminalDeviceHandler)3