use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey in project netvirt by opendaylight.
the class VPNServiceChainHandlerTest method stubGetVpnInstance.
private void stubGetVpnInstance(String rd, String ipAddress, String ifaceName) throws Exception {
IpAddresses ipAddr = new IpAddressesBuilder().setIpAddress(ipAddress).setKey(new IpAddressesKey(ipAddress)).build();
List<VpnInterfaces> ifacesList = Collections.singletonList(new VpnInterfacesBuilder().setInterfaceName(ifaceName).build());
VpnToDpnListBuilder vtdlb = new VpnToDpnListBuilder().setKey(new VpnToDpnListKey(DPN_ID)).setDpnId(DPN_ID).setIpAddresses(Collections.singletonList(ipAddr)).setVpnInterfaces(ifacesList);
VpnInstanceOpDataEntry vpnInstanceOpDataEntry = new VpnInstanceOpDataEntryBuilder().setKey(new VpnInstanceOpDataEntryKey(rd)).setVpnId(VPN_ID).setVpnToDpnList(Collections.singletonList(vtdlb.build())).setVrfId("1").build();
CheckedFuture chkdFuture = mock(CheckedFuture.class);
when(chkdFuture.checkedGet()).thenReturn(Optional.of(vpnInstanceOpDataEntry));
when(readTx.read(eq(LogicalDatastoreType.OPERATIONAL), eq(VpnServiceChainUtils.getVpnInstanceOpDataIdentifier(rd)))).thenReturn(chkdFuture);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey in project netvirt by opendaylight.
the class VPNServiceChainHandlerTest method stubNoVpnInstanceForRD.
private void stubNoVpnInstanceForRD(String rd) throws Exception {
CheckedFuture<Optional<VpnInstanceOpDataEntry>, ReadFailedException> chkdFuture = mock(CheckedFuture.class);
when(chkdFuture.checkedGet()).thenReturn(Optional.absent());
InstanceIdentifier<VpnInstanceOpDataEntry> id = InstanceIdentifier.create(VpnInstanceOpData.class).child(VpnInstanceOpDataEntry.class, new VpnInstanceOpDataEntryKey(rd));
when(readTx.read(eq(LogicalDatastoreType.OPERATIONAL), eq(id))).thenReturn(chkdFuture);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey in project netvirt by opendaylight.
the class NeutronvpnUtils method updateVpnInstanceOpWithType.
public void updateVpnInstanceOpWithType(VpnInstanceOpDataEntry.BgpvpnType choice, @Nonnull Uuid vpn) {
String primaryRd = getVpnRd(vpn.getValue());
if (primaryRd == null) {
LOG.debug("updateVpnInstanceOpWithType: Update BgpvpnType {} for {}." + "Primary RD not found", choice, vpn.getValue());
return;
}
InstanceIdentifier<VpnInstanceOpDataEntry> id = InstanceIdentifier.builder(VpnInstanceOpData.class).child(VpnInstanceOpDataEntry.class, new VpnInstanceOpDataEntryKey(primaryRd)).build();
Optional<VpnInstanceOpDataEntry> vpnInstanceOpDataEntryOptional = read(LogicalDatastoreType.OPERATIONAL, id);
if (!vpnInstanceOpDataEntryOptional.isPresent()) {
LOG.debug("updateVpnInstanceOpWithType: Update BgpvpnType {} for {}." + "VpnInstanceOpDataEntry not found", choice, vpn.getValue());
return;
}
VpnInstanceOpDataEntry vpnInstanceOpDataEntry = vpnInstanceOpDataEntryOptional.get();
if (vpnInstanceOpDataEntry.getBgpvpnType().equals(choice)) {
LOG.debug("updateVpnInstanceOpWithType: Update BgpvpnType {} for {}." + "VpnInstanceOpDataEntry already set", choice, vpn.getValue());
return;
}
VpnInstanceOpDataEntryBuilder builder = new VpnInstanceOpDataEntryBuilder(vpnInstanceOpDataEntry);
builder.setBgpvpnType(choice);
WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
writeTxn.merge(LogicalDatastoreType.OPERATIONAL, id, builder.build(), false);
LOG.debug("updateVpnInstanceOpWithType: sent merge to operDS BgpvpnType {} for {}", choice, vpn.getValue());
try {
writeTxn.submit().get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("updateVpnInstanceOpWithType: on merge execution, error: {}", e);
}
return;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey in project netvirt by opendaylight.
the class VpnServiceChainUtils method getAllVpnIfaceNames.
public static List<String> getAllVpnIfaceNames(DataBroker dataBroker, String vpnName) {
String vpnRd = getVpnRd(dataBroker, vpnName);
InstanceIdentifier<VpnInstanceOpDataEntry> vpnOpDataIid = InstanceIdentifier.builder(VpnInstanceOpData.class).child(VpnInstanceOpDataEntry.class, new VpnInstanceOpDataEntryKey(vpnRd)).build();
try {
VpnInstanceOpDataEntry vpnOpData = SingleTransactionDataBroker.syncRead(dataBroker, LogicalDatastoreType.OPERATIONAL, vpnOpDataIid);
if (vpnOpData == null) {
return Collections.emptyList();
}
List<VpnToDpnList> dpnToVpns = vpnOpData.getVpnToDpnList();
if (dpnToVpns == null) {
return Collections.emptyList();
}
return dpnToVpns.stream().filter(dpn -> dpn.getVpnInterfaces() != null).flatMap(dpn -> dpn.getVpnInterfaces().stream()).map(VpnInterfaces::getInterfaceName).collect(Collectors.toList());
} catch (ReadFailedException e) {
LOG.warn("getAllVpnInterfaces for vpn {}: Failure on read operation", vpnName, e);
return Collections.emptyList();
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey in project netvirt by opendaylight.
the class FibUtil method getVpnInstance.
VpnInstanceOpDataEntry getVpnInstance(String rd) {
InstanceIdentifier<VpnInstanceOpDataEntry> id = InstanceIdentifier.create(VpnInstanceOpData.class).child(VpnInstanceOpDataEntry.class, new VpnInstanceOpDataEntryKey(rd));
Optional<VpnInstanceOpDataEntry> vpnInstanceOpData = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
return vpnInstanceOpData.isPresent() ? vpnInstanceOpData.get() : null;
}
Aggregations