use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets in project lispflowmapping by opendaylight.
the class SubnetDataProcessor method delete.
/**
* Method removes the EID prefix and key associated with the deleted subnet
* from Lisp mapping service.
*/
@Override
public void delete(Subnet subnet) {
LOG.info("Neutron Subnet Deleted Request : Subnet name: " + subnet.getName() + " Subnet Cidr: " + subnet.getCidr() + "Key: " + subnet.getUuid());
LOG.debug("Lisp Neutron Subnet: " + subnet.toString());
// Determine the IANA code for the subnet IP version
// Default is set to IPv4 for neutron subnets
final Eid eid = LispAddressUtil.asIpv4PrefixEid(String.valueOf(subnet.getCidr().getValue()));
try {
final OdlMappingserviceService lfmdb = lispNeutronService.getMappingDbService();
if (lfmdb == null) {
LOG.debug("lfmdb is null!!!");
return;
}
final RemoveKeyInput removeKeyInput = LispUtil.buildRemoveKeyInput(eid);
final Future<RpcResult<Void>> result = lfmdb.removeKey(removeKeyInput);
final Boolean isSuccessful = result.get().isSuccessful();
if (isSuccessful) {
LOG.debug("Neutron Subnet Deleted from MapServer : Subnet name: " + subnet.getName() + " Eid Prefix: " + subnet.getCidr() + " Key: " + subnet.getUuid());
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Deleting subnet's EID prefix from mapping service failed + Subnet: " + subnet.toString() + "Error: " + ExceptionUtils.getStackTrace(e));
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets in project genius by opendaylight.
the class ItmTepInstanceRecoveryHandler method extractDPNTepsInfo.
private DPNTEPsInfo extractDPNTepsInfo(String entityId) {
String[] params = entityId.split(":");
if (params.length < 2) {
LOG.error("Not enough arguments..Exiting...");
return null;
} else if (params.length > 2) {
LOG.info("Ignoring extra parameter and proceeding...");
}
// ToDo:- Need to add more validations
this.tzName = params[0];
String ipAddress = params[1];
transportZone = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
if (transportZone == null) {
LOG.error("Transportzone name {} is not valid.", tzName);
return null;
}
for (Subnets sub : transportZone.getSubnets()) {
if (sub.getVteps() == null || sub.getVteps().isEmpty()) {
LOG.error("Transport Zone {} subnet {} has no vteps", transportZone.getZoneName(), sub.getPrefix());
}
for (Vteps vtep : sub.getVteps()) {
if (ipAddress.equals(String.valueOf(vtep.getIpAddress().getValue()))) {
List<TzMembership> zones = ItmUtils.createTransportZoneMembership(tzName);
LOG.trace("Transportzone {} found match for tep {} to be recovered", transportZone.getZoneName(), ipAddress);
// OfTunnels is false byDefault
TunnelEndPoints tunnelEndPoints = ItmUtils.createTunnelEndPoints(vtep.getDpnId(), IpAddressBuilder.getDefaultInstance(ipAddress), vtep.getPortname(), false, sub.getVlanId(), sub.getPrefix(), sub.getGatewayIp(), zones, transportZone.getTunnelType(), itmConfig.getDefaultTunnelTos());
List<TunnelEndPoints> teps = new ArrayList<>();
teps.add(tunnelEndPoints);
return ItmUtils.createDPNTepInfo(vtep.getDpnId(), teps);
}
}
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets in project genius by opendaylight.
the class ItmManagerRpcService method deleteL2GwMlagDevice.
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
public Future<RpcResult<Void>> deleteL2GwMlagDevice(DeleteL2GwMlagDeviceInput input) {
final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
try {
final IpAddress hwIp = input.getIpAddress();
final List<String> nodeId = input.getNodeId();
InstanceIdentifier<TransportZones> containerPath = InstanceIdentifier.create(TransportZones.class);
Optional<TransportZones> transportZonesOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, containerPath, dataBroker);
if (transportZonesOptional.isPresent()) {
TransportZones tzones = transportZonesOptional.get();
if (tzones.getTransportZone() == null || tzones.getTransportZone().isEmpty()) {
LOG.error("No teps configured");
result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, "No teps Configured").build());
return result;
}
String transportZone = tzones.getTransportZone().get(0).getZoneName();
if (tzones.getTransportZone().get(0).getSubnets() == null || tzones.getTransportZone().get(0).getSubnets().isEmpty()) {
result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, "No subnets Configured").build());
return result;
}
SubnetsKey subnetsKey = tzones.getTransportZone().get(0).getSubnets().get(0).getKey();
DeviceVtepsKey deviceVtepKey = new DeviceVtepsKey(hwIp, nodeId.get(0));
InstanceIdentifier<DeviceVteps> path = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(transportZone)).child(Subnets.class, subnetsKey).child(DeviceVteps.class, deviceVtepKey).build();
WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
// TO DO: add retry if it fails
transaction.delete(LogicalDatastoreType.CONFIGURATION, path);
DeviceVtepsKey deviceVtepKey2 = new DeviceVtepsKey(hwIp, nodeId.get(1));
InstanceIdentifier<DeviceVteps> path2 = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(transportZone)).child(Subnets.class, subnetsKey).child(DeviceVteps.class, deviceVtepKey2).build();
// TO DO: add retry if it fails
transaction.delete(LogicalDatastoreType.CONFIGURATION, path2);
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 = String.format("Unable to write HwVtep %s to datastore", nodeId);
LOG.error("Unable to write HwVtep {}, {} to datastore", nodeId, hwIp);
result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, error).build());
}
});
}
return result;
} catch (Exception e) {
RpcResultBuilder<java.lang.Void> resultBuilder = RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, "Deleting l2 Gateway to DS Failed", e);
return Futures.immediateFuture(resultBuilder.build());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets in project genius by opendaylight.
the class ItmManagerRpcService method deleteL2GwDevice.
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
public Future<RpcResult<java.lang.Void>> deleteL2GwDevice(DeleteL2GwDeviceInput input) {
final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
boolean foundVxlanTzone = false;
try {
final IpAddress hwIp = input.getIpAddress();
final String nodeId = input.getNodeId();
InstanceIdentifier<TransportZones> containerPath = InstanceIdentifier.create(TransportZones.class);
Optional<TransportZones> transportZonesOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, containerPath, dataBroker);
if (transportZonesOptional.isPresent()) {
TransportZones transportZones = transportZonesOptional.get();
if (transportZones.getTransportZone() == null || transportZones.getTransportZone().isEmpty()) {
LOG.error("No teps configured");
result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, "No teps Configured").build());
return result;
}
for (TransportZone tzone : transportZones.getTransportZone()) {
if (!tzone.getTunnelType().equals(TunnelTypeVxlan.class)) {
continue;
}
foundVxlanTzone = true;
String transportZone = tzone.getZoneName();
if (tzone.getSubnets() == null || tzone.getSubnets().isEmpty()) {
result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, "No subnets Configured").build());
return result;
}
SubnetsKey subnetsKey = tzone.getSubnets().get(0).getKey();
DeviceVtepsKey deviceVtepKey = new DeviceVtepsKey(hwIp, nodeId);
InstanceIdentifier<DeviceVteps> path = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(transportZone)).child(Subnets.class, subnetsKey).child(DeviceVteps.class, deviceVtepKey).build();
WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
// TO DO: add retry if it fails
transaction.delete(LogicalDatastoreType.CONFIGURATION, path);
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 = String.format("Unable to delete HwVtep %s from datastore", nodeId);
LOG.error("Unable to delete HwVtep {}, {} from datastore", nodeId, hwIp);
result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, error).build());
}
});
}
} else {
result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, "No TransportZones configured").build());
return result;
}
if (!foundVxlanTzone) {
result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, "No VxLan TransportZones configured").build());
}
return result;
} catch (Exception e) {
RpcResultBuilder<java.lang.Void> resultBuilder = RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, "Deleting l2 Gateway to DS Failed", e);
return Futures.immediateFuture(resultBuilder.build());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets in project genius by opendaylight.
the class ItmManagerRpcService method getTunnelEndPointByDpnIdFromTranPortZone.
private Map<BigInteger, ComputesBuilder> getTunnelEndPointByDpnIdFromTranPortZone(Collection<BigInteger> dpnIds) throws ReadFailedException {
TransportZones transportZones = singleTransactionDataBroker.syncRead(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(TransportZones.class).build());
if (transportZones.getTransportZone() == null || transportZones.getTransportZone().isEmpty()) {
throw new IllegalStateException("Failed to find transport zones in config datastore");
}
Map<BigInteger, ComputesBuilder> result = new HashMap<>();
for (TransportZone transportZone : transportZones.getTransportZone()) {
if (transportZone.getSubnets() == null || transportZone.getSubnets().isEmpty()) {
LOG.debug("Transport Zone {} has no subnets", transportZone.getZoneName());
continue;
}
for (Subnets sub : transportZone.getSubnets()) {
if (sub.getVteps() == null || sub.getVteps().isEmpty()) {
LOG.debug("Transport Zone {} subnet {} has no vteps configured", transportZone.getZoneName(), sub.getPrefix());
continue;
}
for (Vteps vtep : sub.getVteps()) {
if (dpnIds.contains(vtep.getDpnId())) {
result.putIfAbsent(vtep.getDpnId(), new ComputesBuilder().setZoneName(transportZone.getZoneName()).setPrefix(sub.getPrefix()).setDpnId(vtep.getDpnId()).setPortName(vtep.getPortname()).setNodeId(getNodeId(vtep.getDpnId())).setTepIp(Collections.singletonList(vtep.getIpAddress())));
}
}
}
}
for (BigInteger dpnId : dpnIds) {
if (!result.containsKey(dpnId)) {
throw new IllegalStateException("Failed to find dpn id " + dpnId + " in transport zone");
}
}
return result;
}
Aggregations