private PortsImpl(PortsBuilder base) { if (base.getKey() == null) { this._key = new PortsKey( base.getPortName() ); this._portName = base.getPortName(); } else { this._key = base.getKey(); this._portName = _key.getPortName(); } this._ipMapping = base.getIpMapping(); switch (base.augmentation.size()) { case 0: this.augmentation = Collections.emptyMap(); break; case 1: final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports>> e = base.augmentation.entrySet().iterator().next(); this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports>>singletonMap(e.getKey(), e.getValue()); break; default : this.augmentation = new HashMap<>(base.augmentation); } }
public PortsBuilder(Ports base) { if (base.getKey() == null) { this._key = new PortsKey( base.getPortName() ); this._portName = base.getPortName(); } else { this._key = base.getKey(); this._portName = _key.getPortName(); } this._ipMapping = base.getIpMapping(); if (base instanceof PortsImpl) { PortsImpl impl = (PortsImpl) base; if (!impl.augmentation.isEmpty()) { this.augmentation = new HashMap<>(impl.augmentation); } } else if (base instanceof AugmentationHolder) { @SuppressWarnings("unchecked") AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports>) base; if (!casted.augmentations().isEmpty()) { this.augmentation = new HashMap<>(casted.augmentations()); } } }
static InstanceIdentifier<Ports> buildPortToIpMapIdentifier(String routerId, String portName) { InstanceIdentifier<Ports> ipPortMapId = InstanceIdentifier.builder(FloatingIpInfo.class).child (RouterPorts.class, new RouterPortsKey(routerId)).child(Ports.class, new PortsKey(portName)).build(); return ipPortMapId; }
static InstanceIdentifier<Ports> getPortsIdentifier(String routerId, String portName) { return InstanceIdentifier.builder(FloatingIpInfo.class).child(RouterPorts.class, new RouterPortsKey(routerId)) .child(Ports.class, new PortsKey(portName)).build(); }
.Ports> portsIdentifierBuilder = routerPortsIdentifierBuilder.child(org .opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111 .floating.ip.info.router.ports.Ports.class, new PortsKey(fixedNeutronPortName)); try {
void updateOperationalDS(String routerId, String interfaceName, long label, String internalIp, String externalIp) { LOG.info("Updating operational DS for floating ip config : {} with label {}", internalIp, label); InstanceIdentifier<Ports> portsId = NatUtil.getPortsIdentifier(routerId, interfaceName); Optional<Ports> optPorts = NatUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, portsId); IpMapping ipMapping = new IpMappingBuilder().setKey(new IpMappingKey(internalIp)).setInternalIp(internalIp) .setExternalIp(externalIp).setLabel(label).build(); if(optPorts.isPresent()) { LOG.debug("Ports {} entry already present. Updating ipmapping for internal ip {}", interfaceName, internalIp); MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, portsId.child(IpMapping.class, new IpMappingKey(internalIp)), ipMapping); } else { LOG.debug("Adding Ports entry {} along with ipmapping {}", interfaceName, internalIp); List<IpMapping> ipMappings = new ArrayList<>(); ipMappings.add(ipMapping); Ports ports = new PortsBuilder().setKey(new PortsKey(interfaceName)).setPortName(interfaceName).setIpMapping(ipMappings).build(); MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, portsId, ports); } }
static InstanceIdentifier<IpMapping> getIpMappingIdentifier(String routerId, String portName, String internalIp) { return InstanceIdentifier.builder(FloatingIpInfo.class).child(RouterPorts.class, new RouterPortsKey(routerId)) .child(Ports.class, new PortsKey(portName)) .child(IpMapping.class, new IpMappingKey(internalIp)).build(); }
portsIdentifierBuilder = routerPortsIdentifierBuilder.child(Ports.class, new PortsKey (fixedNeutronPortName)); try {
fixedNeutronPortBuilder = new PortsBuilder().setKey(new PortsKey(fixedNeutronPortName)) .setPortName(fixedNeutronPortName);