use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpn in project netvirt by opendaylight.
the class SubnetOpDpnManager method addPortOpDataEntry.
public void addPortOpDataEntry(String intfName, Uuid subnetId, BigInteger dpnId) {
try {
// Add to PortOpData as well.
PortOpDataEntryBuilder portOpBuilder = null;
PortOpDataEntry portOpEntry = null;
InstanceIdentifier<PortOpDataEntry> portOpIdentifier = InstanceIdentifier.builder(PortOpData.class).child(PortOpDataEntry.class, new PortOpDataEntryKey(intfName)).build();
Optional<PortOpDataEntry> optionalPortOp = VpnUtil.read(broker, LogicalDatastoreType.OPERATIONAL, portOpIdentifier);
if (!optionalPortOp.isPresent()) {
// Create PortOpDataEntry only if not present
portOpBuilder = new PortOpDataEntryBuilder().setKey(new PortOpDataEntryKey(intfName)).setPortId(intfName);
List<Uuid> listSubnet = new ArrayList<>();
listSubnet.add(subnetId);
portOpBuilder.setSubnetIds(listSubnet);
} else {
List<Uuid> listSubnet = optionalPortOp.get().getSubnetIds();
portOpBuilder = new PortOpDataEntryBuilder(optionalPortOp.get());
if (listSubnet == null) {
listSubnet = new ArrayList<>();
}
if (!listSubnet.contains(subnetId)) {
listSubnet.add(subnetId);
}
portOpBuilder.setSubnetIds(listSubnet);
}
if (dpnId != null && !dpnId.equals(BigInteger.ZERO)) {
portOpBuilder.setDpnId(dpnId);
}
portOpEntry = portOpBuilder.build();
SingleTransactionDataBroker.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, portOpIdentifier, portOpEntry);
LOG.info("addPortOpDataEntry: Created PortOpData entry for port {} with DPNId {} subnetId {}", intfName, dpnId, subnetId.getValue());
} catch (TransactionCommitFailedException ex) {
LOG.error("addPortOpDataEntry: Addition of Interface {} for SubnetToDpn on subnet {} with DPN {} failed", intfName, subnetId.getValue(), dpnId, ex);
}
}
Aggregations