use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.DcGatewayIpList in project netvirt by opendaylight.
the class EvpnUtils method getDcGatewayIpList.
public Optional<DcGatewayIpList> getDcGatewayIpList() {
InstanceIdentifier<DcGatewayIpList> dcGatewayIpListInstanceIdentifier = getDcGatewayIpListIdentifier();
DcGatewayIpList dcGatewayIpListConfig = null;
try {
dcGatewayIpListConfig = elanUtils.read2(LogicalDatastoreType.CONFIGURATION, dcGatewayIpListInstanceIdentifier).orNull();
} catch (ReadFailedException e) {
LOG.error("getDcGatewayTunnelInterfaceNameList: unable to read DcGatewayTunnelList, exception ", e);
}
return Optional.fromNullable(dcGatewayIpListConfig);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.DcGatewayIpList in project netvirt by opendaylight.
the class TunnelInterfaceStateListener method getDcGwIps.
private List<String> getDcGwIps() {
InstanceIdentifier<DcGatewayIpList> dcGatewayIpListid = InstanceIdentifier.builder(DcGatewayIpList.class).build();
DcGatewayIpList dcGatewayIpListConfig = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, dcGatewayIpListid).orNull();
if (dcGatewayIpListConfig == null) {
return Collections.EMPTY_LIST;
}
return dcGatewayIpListConfig.getDcGatewayIp().stream().filter(dcGwIp -> dcGwIp.getTunnnelType().equals(TunnelTypeMplsOverGre.class)).map(dcGwIp -> String.valueOf(dcGwIp.getIpAddress().getValue())).sorted().collect(toList());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.DcGatewayIpList 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.DcGatewayIpList 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.DcGatewayIpList 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