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();
}
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();
}
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();
}
Aggregations