use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.PortsBuilder in project openflowplugin by opendaylight.
the class MultipartReplyPortDescDeserializer method deserialize.
@Override
public MultipartReplyBody deserialize(ByteBuf message) {
final MultipartReplyPortDescBuilder builder = new MultipartReplyPortDescBuilder();
final List<Ports> items = new ArrayList<>();
while (message.readableBytes() > 0) {
final PortsBuilder itemBuilder = new PortsBuilder();
itemBuilder.setPortNumber(new PortNumberUni(message.readUnsignedInt()));
message.skipBytes(PADDING_IN_PORT_DESC_HEADER_01);
itemBuilder.setHardwareAddress(ByteBufUtils.readIetfMacAddress(message));
message.skipBytes(PADDING_IN_PORT_DESC_HEADER_02);
items.add(itemBuilder.setName(ByteBufUtils.decodeNullTerminatedString(message, EncodeConstants.MAX_PORT_NAME_LENGTH)).setConfiguration(readPortConfig(message)).setState(readPortState(message)).setCurrentFeature(readPortFeatures(message)).setAdvertisedFeatures(readPortFeatures(message)).setSupported(readPortFeatures(message)).setPeerFeatures(readPortFeatures(message)).setCurrentSpeed(message.readUnsignedInt()).setMaximumSpeed(message.readUnsignedInt()).build());
}
return builder.setPorts(items).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.PortsBuilder in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorUtilTest method translatePortDesc.
@Test
public void translatePortDesc() {
final MultipartReply multipartReply = buildReply(MultipartType.OFPMPPORTDESC, new MultipartReplyPortDescCaseBuilder().setMultipartReplyPortDesc(new MultipartReplyPortDescBuilder().setPorts(Collections.singletonList(new PortsBuilder().build())).build()).build());
dummyAssertReply(multipartReply);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.PortsBuilder in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method createPortList.
private static List<Ports> createPortList() {
PortsBuilder builder = new PortsBuilder();
builder.setPortNo(1L);
builder.setHwAddr(new MacAddress("94:de:80:a6:61:40"));
builder.setName("Port name");
builder.setConfig(new PortConfig(true, false, true, false));
builder.setState(new PortState(true, false, true));
builder.setCurrentFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false));
builder.setAdvertisedFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false));
builder.setSupportedFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false));
builder.setPeerFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false));
builder.setCurrSpeed(1234L);
builder.setMaxSpeed(1234L);
List<Ports> list = new ArrayList<>();
list.add(builder.build());
return list;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.PortsBuilder in project openflowplugin by opendaylight.
the class PortConvertor method toPortDesc.
/**
* This method is called as a reply to OFPMP_PORT_DESCRIPTION message(OF1.3.1).
*
* @param source FlowCapablePort
* @param version openflow version
* @return OF:Ports
*/
@VisibleForTesting
static Ports toPortDesc(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.FlowCapablePort source, short version) {
PortsBuilder ofPortDescDataBuilder = new PortsBuilder();
ofPortDescDataBuilder.setPortNo(OpenflowPortsUtil.getProtocolPortNumber(OpenflowVersion.get(version), // portNO
source.getPortNumber()));
ofPortDescDataBuilder.setHwAddr(source.getHardwareAddress());
ofPortDescDataBuilder.setName(source.getName());
PortConfig config = maskPortConfigFields(source.getConfiguration());
ofPortDescDataBuilder.setConfig(config);
PortState portState = getPortState(source.getState());
ofPortDescDataBuilder.setState(portState);
ofPortDescDataBuilder.setCurrentFeatures(getPortFeatures(source.getCurrentFeature()));
ofPortDescDataBuilder.setAdvertisedFeatures(getPortFeatures(source.getAdvertisedFeatures()));
ofPortDescDataBuilder.setSupportedFeatures(getPortFeatures(source.getSupported()));
ofPortDescDataBuilder.setPeerFeatures(getPortFeatures(source.getPeerFeatures()));
ofPortDescDataBuilder.setCurrSpeed(source.getCurrentSpeed());
ofPortDescDataBuilder.setMaxSpeed(source.getMaximumSpeed());
return ofPortDescDataBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.PortsBuilder in project netvirt by opendaylight.
the class FloatingIPListener method updateOperationalDS.
static void updateOperationalDS(DataBroker dataBroker, String routerId, String interfaceName, Uint32 label, String internalIp, String externalIp) {
LOG.info("updateOperationalDS : Updating operational DS for floating ip config : {} with label {}", internalIp, label);
InstanceIdentifier<Ports> portsId = NatUtil.getPortsIdentifier(routerId, interfaceName);
Optional<Ports> optPorts = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, portsId);
InternalToExternalPortMap intExtPortMap = new InternalToExternalPortMapBuilder().withKey(new InternalToExternalPortMapKey(internalIp)).setInternalIp(internalIp).setExternalIp(externalIp).setLabel(label).build();
if (optPorts.isPresent()) {
LOG.debug("updateOperationalDS : Ports {} entry already present. Updating intExtPortMap for internal ip {}", interfaceName, internalIp);
MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, portsId.child(InternalToExternalPortMap.class, new InternalToExternalPortMapKey(internalIp)), intExtPortMap);
} else {
LOG.debug("updateOperationalDS : Adding Ports entry {} along with intExtPortMap {}", interfaceName, internalIp);
List<InternalToExternalPortMap> intExtPortMapList = new ArrayList<>();
intExtPortMapList.add(intExtPortMap);
Ports ports = new PortsBuilder().withKey(new PortsKey(interfaceName)).setPortName(interfaceName).setInternalToExternalPortMap(intExtPortMapList).build();
MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, portsId, ports);
}
}
Aggregations