use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.port._case.PortsBuilder in project netvirt by opendaylight.
the class NeutronFloatingToFixedIpMappingChangeListener method addToFloatingIpInfo.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void addToFloatingIpInfo(String routerName, Uuid extNetworkId, String fixedNeutronPortName, String fixedIpAddress, String floatingIpAddress, Uuid floatingIpId) {
RouterPortsBuilder routerPortsBuilder;
boolean isLockAcquired = false;
InstanceIdentifier<RouterPorts> routerPortsIdentifier = InstanceIdentifier.builder(FloatingIpInfo.class).child(RouterPorts.class, new RouterPortsKey(routerName)).build();
try {
Optional<RouterPorts> optionalRouterPorts = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsIdentifier);
if (optionalRouterPorts.isPresent()) {
LOG.debug("Updating routerPorts node {} in floatingIpInfo DS for floating IP {} on fixed " + "neutron port {} : ", routerName, floatingIpAddress, fixedNeutronPortName);
routerPortsBuilder = new RouterPortsBuilder(optionalRouterPorts.get());
} else {
LOG.debug("Creating new routerPorts node {} in floatingIpInfo DS for floating IP {} on fixed " + "neutron port {} : ", routerName, floatingIpAddress, fixedNeutronPortName);
routerPortsBuilder = new RouterPortsBuilder().setKey(new RouterPortsKey(routerName)).setRouterId(routerName);
}
if (extNetworkId != null) {
routerPortsBuilder.setExternalNetworkId(extNetworkId);
}
if (fixedNeutronPortName != null) {
List<Ports> portsList = routerPortsBuilder.getPorts();
if (portsList == null) {
portsList = new ArrayList<>();
}
PortsBuilder fixedNeutronPortBuilder = null;
for (Ports neutronPort : portsList) {
if (neutronPort.getPortName().equals(fixedNeutronPortName)) {
fixedNeutronPortBuilder = new PortsBuilder(neutronPort);
break;
}
}
if (fixedNeutronPortBuilder == null) {
fixedNeutronPortBuilder = new PortsBuilder().setKey(new PortsKey(fixedNeutronPortName)).setPortName(fixedNeutronPortName);
}
if (fixedIpAddress != null) {
List<InternalToExternalPortMap> intExtPortMapList = fixedNeutronPortBuilder.getInternalToExternalPortMap();
if (intExtPortMapList == null) {
intExtPortMapList = new ArrayList<>();
}
InternalToExternalPortMap intExtPortMap = new InternalToExternalPortMapBuilder().setKey(new InternalToExternalPortMapKey(fixedIpAddress)).setInternalIp(fixedIpAddress).setExternalIp(floatingIpAddress).setExternalId(floatingIpId).setLabel(null).build();
intExtPortMapList.add(intExtPortMap);
fixedNeutronPortBuilder.setInternalToExternalPortMap(intExtPortMapList);
}
portsList.add(fixedNeutronPortBuilder.build());
routerPortsBuilder.setPorts(portsList);
}
isLockAcquired = routerLock.tryLock(routerName, LOCK_WAIT_TIME, TimeUnit.SECONDS);
LOG.debug("Creating/Updating routerPorts node {} in floatingIpInfo DS for floating IP {} on fixed " + "neutron port {} : ", routerName, floatingIpAddress, fixedNeutronPortName);
MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsIdentifier, routerPortsBuilder.build());
LOG.debug("FloatingIpInfo DS updated for floating IP {} ", floatingIpAddress);
} catch (ReadFailedException | RuntimeException e) {
LOG.error("addToFloatingIpInfo failed for floating IP: {} ", floatingIpAddress, e);
} finally {
if (isLockAcquired) {
routerLock.unlock(routerName);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.port._case.PortsBuilder in project bgpcep by opendaylight.
the class FSPortHandler method parsePort.
private static List<Ports> parsePort(final ByteBuf nlri) {
final List<Ports> ports = new ArrayList<>();
boolean end = false;
// we can do this as all fields will be rewritten in the cycle
final PortsBuilder builder = new PortsBuilder();
while (!end) {
final byte b = nlri.readByte();
final NumericOperand op = NumericOneByteOperandParser.INSTANCE.parse(b);
builder.setOp(op);
final short length = AbstractOperandParser.parseLength(b);
builder.setValue(ByteArray.bytesToInt(ByteArray.readBytes(nlri, length)));
end = op.isEndOfList();
ports.add(builder.build());
}
return ports;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.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.rev171207.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.rev171207.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;
}
Aggregations