use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.dc.gateway.ip.list.DcGatewayIp in project genius by opendaylight.
the class ItmManagerRpcService method addExternalTunnelEndpoint.
@Override
public Future<RpcResult<Void>> addExternalTunnelEndpoint(AddExternalTunnelEndpointInput input) {
// TODO Auto-generated method stub
// Ignore the Futures for now
final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
Collection<DPNTEPsInfo> meshedDpnList = dpnTEPsInfoCache.getAllPresent();
externalTunnelAddWorker.buildTunnelsToExternalEndPoint(meshedDpnList, input.getDestinationIp(), input.getTunnelType());
InstanceIdentifier<DcGatewayIp> extPath = InstanceIdentifier.builder(DcGatewayIpList.class).child(DcGatewayIp.class, new DcGatewayIpKey(input.getDestinationIp())).build();
DcGatewayIp dcGatewayIp = new DcGatewayIpBuilder().setIpAddress(input.getDestinationIp()).setTunnnelType(input.getTunnelType()).build();
WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
writeTransaction.put(LogicalDatastoreType.CONFIGURATION, extPath, dcGatewayIp, true);
ListenableFuture<Void> futureCheck = writeTransaction.submit();
Futures.addCallback(futureCheck, new FutureCallback<Void>() {
@Override
public void onSuccess(Void voidInstance) {
result.set(RpcResultBuilder.<Void>success().build());
}
@Override
public void onFailure(Throwable error) {
String msg = "Unable to create DcGatewayIp {} in datastore for ip " + input.getDestinationIp() + "and " + "tunnel type " + input.getTunnelType();
LOG.error("Unable to create DcGatewayIp in datastore for ip {} and tunnel type {}", input.getDestinationIp(), input.getTunnelType());
result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, error).build());
}
});
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.dc.gateway.ip.list.DcGatewayIp in project genius by opendaylight.
the class ItmManagerRpcService method isDcgwPresent.
@Override
public Future<RpcResult<IsDcgwPresentOutput>> isDcgwPresent(IsDcgwPresentInput input) {
RpcResultBuilder<IsDcgwPresentOutput> resultBld = RpcResultBuilder.success();
List<DcGatewayIp> dcGatewayIpList = ItmUtils.getDcGatewayIpList(dataBroker);
String dcgwIpStr = input.getDcgwIp();
IpAddress dcgwIpAddr = IpAddressBuilder.getDefaultInstance(dcgwIpStr);
long retVal;
if (dcGatewayIpList != null && !dcGatewayIpList.isEmpty() && dcGatewayIpList.stream().anyMatch(gwIp -> Objects.equal(gwIp.getIpAddress(), dcgwIpAddr))) {
// Match found
retVal = 1;
IsDcgwPresentOutputBuilder output = new IsDcgwPresentOutputBuilder().setRetVal(retVal);
resultBld.withResult(output.build());
} else {
// Match not found
retVal = 2;
IsDcgwPresentOutputBuilder output = new IsDcgwPresentOutputBuilder().setRetVal(retVal);
resultBld.withResult(output.build());
}
return Futures.immediateFuture(resultBld.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.dc.gateway.ip.list.DcGatewayIp in project netvirt by opendaylight.
the class VpnInstanceListener method getDcGatewayTunnelInterfaceNameList.
private List<String> getDcGatewayTunnelInterfaceNameList() {
List<String> tunnelInterfaceNameList = new ArrayList<>();
InstanceIdentifier<DcGatewayIpList> dcGatewayIpListInstanceIdentifier = InstanceIdentifier.create(DcGatewayIpList.class);
Optional<DcGatewayIpList> dcGatewayIpListOptional = VpnUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, dcGatewayIpListInstanceIdentifier);
if (!dcGatewayIpListOptional.isPresent()) {
LOG.info("No DC gateways configured.");
return tunnelInterfaceNameList;
}
List<DcGatewayIp> dcGatewayIps = dcGatewayIpListOptional.get().getDcGatewayIp();
InstanceIdentifier<ExternalTunnelList> externalTunnelListId = InstanceIdentifier.create(ExternalTunnelList.class);
Optional<ExternalTunnelList> externalTunnelListOptional = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, externalTunnelListId);
if (externalTunnelListOptional.isPresent()) {
List<ExternalTunnel> externalTunnels = externalTunnelListOptional.get().getExternalTunnel();
List<String> externalTunnelIpList = new ArrayList<>();
for (ExternalTunnel externalTunnel : externalTunnels) {
externalTunnelIpList.add(externalTunnel.getDestinationDevice());
}
List<String> dcGatewayIpList = new ArrayList<>();
for (DcGatewayIp dcGatewayIp : dcGatewayIps) {
dcGatewayIpList.add(dcGatewayIp.getIpAddress().getIpv4Address().toString());
}
// Find all externalTunnelIps present in dcGateWayIpList
List<String> externalTunnelIpsInDcGatewayIpList = new ArrayList<>();
for (String externalTunnelIp : externalTunnelIpList) {
for (String dcGateWayIp : dcGatewayIpList) {
if (externalTunnelIp.contentEquals(dcGateWayIp)) {
externalTunnelIpsInDcGatewayIpList.add(externalTunnelIp);
}
}
}
for (String externalTunnelIpsInDcGatewayIp : externalTunnelIpsInDcGatewayIpList) {
for (ExternalTunnel externalTunnel : externalTunnels) {
if (externalTunnel.getDestinationDevice().contentEquals(externalTunnelIpsInDcGatewayIp)) {
tunnelInterfaceNameList.add(externalTunnel.getTunnelInterfaceName());
}
}
}
}
return tunnelInterfaceNameList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.dc.gateway.ip.list.DcGatewayIp in project genius by opendaylight.
the class ItmManagerRpcService method removeExternalTunnelEndpoint.
@Override
public Future<RpcResult<Void>> removeExternalTunnelEndpoint(RemoveExternalTunnelEndpointInput input) {
// Ignore the Futures for now
final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
Collection<DPNTEPsInfo> meshedDpnList = dpnTEPsInfoCache.getAllPresent();
ItmExternalTunnelDeleteWorker.deleteTunnels(dataBroker, meshedDpnList, input.getDestinationIp(), input.getTunnelType());
InstanceIdentifier<DcGatewayIp> extPath = InstanceIdentifier.builder(DcGatewayIpList.class).child(DcGatewayIp.class, new DcGatewayIpKey(input.getDestinationIp())).build();
WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
transaction.delete(LogicalDatastoreType.CONFIGURATION, extPath);
ListenableFuture<Void> futureCheck = transaction.submit();
Futures.addCallback(futureCheck, new FutureCallback<Void>() {
@Override
public void onSuccess(Void voidInstance) {
result.set(RpcResultBuilder.<Void>success().build());
}
@Override
public void onFailure(Throwable error) {
String msg = "Unable to delete DcGatewayIp " + input.getDestinationIp() + " in datastore and tunnel type " + input.getTunnelType();
LOG.error("Unable to delete DcGatewayIp {} in datastore and tunnel type {}", input.getDestinationIp(), input.getTunnelType());
result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, error).build());
}
});
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.dc.gateway.ip.list.DcGatewayIp in project genius by opendaylight.
the class ItmUtils method getDcGatewayIpList.
public static List<DcGatewayIp> getDcGatewayIpList(DataBroker broker) {
InstanceIdentifier<DcGatewayIpList> dcGatewayIpListid = InstanceIdentifier.builder(DcGatewayIpList.class).build();
Optional<DcGatewayIpList> dcGatewayIpListConfig = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, dcGatewayIpListid, broker);
if (dcGatewayIpListConfig.isPresent()) {
DcGatewayIpList containerList = dcGatewayIpListConfig.get();
if (containerList != null) {
return containerList.getDcGatewayIp();
}
}
return null;
}
Aggregations