use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project lispflowmapping by opendaylight.
the class SubnetDataProcessorTest method createTest.
/**
* Tests {@link SubnetDataProcessor#create} method.
*/
@Test
public void createTest() throws ExecutionException, InterruptedException {
final MappingAuthkey mappingAuthkey = new MappingAuthkeyBuilder().setKeyString(UUID_STRING).setKeyType(1).build();
final AddKeyInput addKeyInput = new AddKeyInputBuilder().setEid(EID).setMappingAuthkey(mappingAuthkey).build();
commonStubbing();
Mockito.when(odlMappingserviceServiceMock.addKey(addKeyInput)).thenReturn(future);
subnetDataProcessor.create(subnet);
assertEquals(true, rpcResult.isSuccessful());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project lispflowmapping by opendaylight.
the class SubnetDataProcessorTest method deleteTest.
/**
* Tests {@link SubnetDataProcessor#delete} method.
*/
@Test
public void deleteTest() throws ExecutionException, InterruptedException {
final RemoveKeyInput removeKeyInput = new RemoveKeyInputBuilder().setEid(EID).build();
commonStubbing();
Mockito.when(odlMappingserviceServiceMock.removeKey(removeKeyInput)).thenReturn(future);
subnetDataProcessor.delete(subnet);
assertEquals(true, rpcResult.isSuccessful());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project lispflowmapping by opendaylight.
the class PortDataProcessor method delete.
@Override
public void delete(Port port) {
// TODO if port ips existed in MapServer, delete them. Else, log error.
LOG.info("Neutron Port Deleted: Port name: " + port.getName() + " Port Fixed IP: " + (port.getFixedIps() != null ? port.getFixedIps().get(0) : "No Fixed IP assigned"));
LOG.debug("Neutron Port Deleted : " + port.toString());
List<FixedIps> fixedIPs = port.getFixedIps();
if (fixedIPs != null && fixedIPs.size() > 0) {
Eid eidAddress;
for (FixedIps ip : fixedIPs) {
// TODO Add check/support for IPv6.
// Get subnet for this port, based on v4 or v6 decide address
// iana code.
eidAddress = LispAddressUtil.asIpv4PrefixEid(ip.getIpAddress().getIpv4Address().getValue() + "/32");
lispNeutronService.getMappingDbService().removeMapping(LispUtil.buildRemoveMappingInput(eidAddress));
LOG.info("Neutron Port mapping deleted from lisp: " + " Port Fixed IP: " + ip + "Port host IP: ");
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project lispflowmapping by opendaylight.
the class SubnetDataProcessor method create.
/**
* Method adds the newly created subnet as an EID prefix to the
* MappingService. The subnet's network UUID is used as the key for this EID
* prefix.
*/
@Override
public void create(Subnet subnet) {
// TODO update for multi-tenancy
LOG.info("Neutron Subnet Created request : Subnet name: " + subnet.getName() + " Subnet Cidr: " + subnet.getCidr());
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 AddKeyInput addKeyInput = LispUtil.buildAddKeyInput(eid, subnet.getUuid().getValue());
final Future<RpcResult<Void>> result = lfmdb.addKey(addKeyInput);
final Boolean isSuccessful = result.get().isSuccessful();
if (isSuccessful) {
LOG.debug("Neutron Subnet Added to MapServer : Subnet name: " + subnet.getName() + " EID Prefix: " + subnet.getCidr() + " Key: " + subnet.getUuid());
}
LOG.info("Neutron Subnet Created request : Subnet name: " + subnet.getName() + " Subnet Cidr: " + subnet.getCidr());
} catch (InterruptedException | ExecutionException e) {
LOG.error("Adding new subnet to lisp service 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.Subnet in project genius by opendaylight.
the class TransportZoneListener method createDPNTepInfo.
private List<DPNTEPsInfo> createDPNTepInfo(TransportZone transportZone) {
Map<BigInteger, List<TunnelEndPoints>> mapDPNToTunnelEndpt = new ConcurrentHashMap<>();
List<DPNTEPsInfo> dpnTepInfo = new ArrayList<>();
List<TzMembership> zones = ItmUtils.createTransportZoneMembership(transportZone.getZoneName());
Class<? extends TunnelTypeBase> tunnelType = transportZone.getTunnelType();
LOG.trace("Transport Zone_name: {}", transportZone.getZoneName());
List<Subnets> subnetsList = transportZone.getSubnets();
if (subnetsList != null) {
for (Subnets subnet : subnetsList) {
IpPrefix ipPrefix = subnet.getPrefix();
IpAddress gatewayIP = subnet.getGatewayIp();
int vlanID = subnet.getVlanId();
LOG.trace("IpPrefix: {}, gatewayIP: {}, vlanID: {} ", ipPrefix, gatewayIP, vlanID);
List<Vteps> vtepsList = subnet.getVteps();
if (vtepsList != null && !vtepsList.isEmpty()) {
for (Vteps vteps : vtepsList) {
BigInteger dpnID = vteps.getDpnId();
String port = vteps.getPortname();
IpAddress ipAddress = vteps.getIpAddress();
boolean useOfTunnel = ItmUtils.falseIfNull(vteps.isOptionOfTunnel());
String tos = vteps.getOptionTunnelTos();
if (tos == null) {
tos = itmConfig.getDefaultTunnelTos();
}
LOG.trace("DpnID: {}, port: {}, ipAddress: {}", dpnID, port, ipAddress);
TunnelEndPoints tunnelEndPoints = ItmUtils.createTunnelEndPoints(dpnID, ipAddress, port, useOfTunnel, vlanID, ipPrefix, gatewayIP, zones, tunnelType, tos);
List<TunnelEndPoints> tunnelEndPointsList = mapDPNToTunnelEndpt.get(dpnID);
if (tunnelEndPointsList != null) {
LOG.trace("Existing DPN info list in the Map: {} ", dpnID);
tunnelEndPointsList.add(tunnelEndPoints);
} else {
LOG.trace("Adding new DPN info list to the Map: {} ", dpnID);
tunnelEndPointsList = new ArrayList<>();
tunnelEndPointsList.add(tunnelEndPoints);
mapDPNToTunnelEndpt.put(dpnID, tunnelEndPointsList);
}
}
}
}
}
if (!mapDPNToTunnelEndpt.isEmpty()) {
LOG.trace("List of dpns in the Map: {} ", mapDPNToTunnelEndpt.keySet());
for (Entry<BigInteger, List<TunnelEndPoints>> entry : mapDPNToTunnelEndpt.entrySet()) {
DPNTEPsInfo newDpnTepsInfo = ItmUtils.createDPNTepInfo(entry.getKey(), entry.getValue());
dpnTepInfo.add(newDpnTepsInfo);
}
}
return dpnTepInfo;
}
Aggregations