use of org.opendaylight.yangtools.yang.binding.InstanceIdentifier in project netvirt by opendaylight.
the class NatUtil method getDpnsForRouter.
@Nonnull
public static List<BigInteger> getDpnsForRouter(DataBroker dataBroker, String routerUuid) {
InstanceIdentifier id = InstanceIdentifier.builder(NeutronRouterDpns.class).child(RouterDpnList.class, new RouterDpnListKey(routerUuid)).build();
Optional<RouterDpnList> routerDpnListData = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
List<BigInteger> dpns = new ArrayList<>();
if (routerDpnListData.isPresent()) {
List<DpnVpninterfacesList> dpnVpninterfacesList = routerDpnListData.get().getDpnVpninterfacesList();
for (DpnVpninterfacesList dpnVpnInterface : dpnVpninterfacesList) {
dpns.add(dpnVpnInterface.getDpnId());
}
}
return dpns;
}
use of org.opendaylight.yangtools.yang.binding.InstanceIdentifier in project netvirt by opendaylight.
the class VpnFloatingIpHandler method removeFromFloatingIpPortInfo.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void removeFromFloatingIpPortInfo(Uuid floatingIpId) {
InstanceIdentifier id = buildfloatingIpIdToPortMappingIdentifier(floatingIpId);
try {
Optional<FloatingIpIdToPortMapping> optFloatingIpIdToPortMapping = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
if (optFloatingIpIdToPortMapping.isPresent() && optFloatingIpIdToPortMapping.get().isFloatingIpDeleted()) {
LOG.debug("Deleting floating IP UUID {} to Floating IP neutron port mapping from Floating " + "IP Port Info Config DS", floatingIpId.getValue());
MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
}
} catch (Exception e) {
LOG.error("removeFromFloatingIpPortInfo : Deleting floating IP UUID {} to Floating IP neutron port " + "mapping from Floating IP Port Info Config DS failed", floatingIpId.getValue(), e);
}
}
use of org.opendaylight.yangtools.yang.binding.InstanceIdentifier in project netvirt by opendaylight.
the class NaptSwitchHA method removeFibEntry.
private void removeFibEntry(String rd, String prefix) {
InstanceIdentifier.InstanceIdentifierBuilder<VrfEntry> idBuilder = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).child(VrfEntry.class, new VrfEntryKey(prefix));
InstanceIdentifier<VrfEntry> vrfEntryId = idBuilder.build();
Optional<VrfEntry> ent = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
if (ent.isPresent()) {
LOG.debug("removeFibEntry : Removing Fib entry rd {} prefix {}", rd, prefix);
fibManager.removeFibEntry(rd, prefix, null);
}
}
use of org.opendaylight.yangtools.yang.binding.InstanceIdentifier in project netvirt by opendaylight.
the class NatOverVxlanUtil method getIdPoolInstance.
private static InstanceIdentifier<IdPool> getIdPoolInstance(String poolName) {
InstanceIdentifier.InstanceIdentifierBuilder<IdPool> idPoolBuilder = InstanceIdentifier.builder(IdPools.class).child(IdPool.class, new IdPoolKey(poolName));
InstanceIdentifier<IdPool> id = idPoolBuilder.build();
return id;
}
use of org.opendaylight.yangtools.yang.binding.InstanceIdentifier in project netvirt by opendaylight.
the class NeutronUtils method writePortStatus.
private static boolean writePortStatus(String uuid, String portStatus, DataBroker dataBroker, boolean create) {
Uuid uuidObj = new Uuid(uuid);
PortBuilder portBuilder = new PortBuilder();
portBuilder.setUuid(uuidObj);
portBuilder.setStatus(portStatus);
InstanceIdentifier iid = InstanceIdentifier.create(Neutron.class).child(Ports.class).child(Port.class, new PortKey(uuidObj));
SingleTransactionDataBroker tx = new SingleTransactionDataBroker(dataBroker);
try {
if (create) {
tx.syncWrite(LogicalDatastoreType.OPERATIONAL, iid, portBuilder.build());
} else {
tx.syncUpdate(LogicalDatastoreType.OPERATIONAL, iid, portBuilder.build());
}
} catch (TransactionCommitFailedException e) {
LOG.error("writePortStatus: failed neutron port status write. isCreate: {}", create, e);
return false;
}
return true;
}
Aggregations