use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig in project genius by opendaylight.
the class VtepConfigSchemaListener method addVteps.
/**
* Adds the vteps.
*
* @param schema
* the schema
* @param vtepIpPool
* the vtep ip pool
*/
private void addVteps(VtepConfigSchema schema, VtepIpPool vtepIpPool) {
if (schema.getDpnIds() == null || schema.getDpnIds().isEmpty()) {
LOG.debug("DPN list is empty, skipping addVteps for schema: {}", schema);
return;
}
String subnetCidr = ItmUtils.getSubnetCidrAsString(schema.getSubnet());
if (vtepIpPool == null) {
LOG.error("VTEP config pool not found for subnetCidr {}. Failed to add VTEPs for schema {}", subnetCidr, schema);
return;
}
TepCommandHelper tepCommandHelper = new TepCommandHelper(this.dataBroker, itmConfig);
// Check this later
String tunType;
Class<? extends TunnelTypeBase> tunnelType = schema.getTunnelType();
if (tunnelType.equals(TunnelTypeVxlan.class)) {
tunType = ITMConstants.TUNNEL_TYPE_VXLAN;
} else {
tunType = ITMConstants.TUNNEL_TYPE_GRE;
}
tepCommandHelper.configureTunnelType(schema.getTransportZoneName(), StringUtils.upperCase(tunType));
List<IpAddress> availableIps = vtepIpPool.getAvailableIpaddress();
List<IpAddress> newlyAllocatedIps = new ArrayList<>();
List<BigInteger> skippedDpnIds = new ArrayList<>();
String gatewayIp = handleGatewayIp(schema.getGatewayIp());
for (BigInteger dpnId : ItmUtils.getDpnIdList(schema.getDpnIds())) {
IpAddress ipAddress = getAnAvailableIP(availableIps);
if (ipAddress == null) {
skippedDpnIds.add(dpnId);
continue;
}
try {
tepCommandHelper.createLocalCache(dpnId, schema.getPortName(), schema.getVlanId(), String.valueOf(ipAddress.getValue()), subnetCidr, gatewayIp, schema.getTransportZoneName(), null);
} catch (TepException e) {
LOG.error("create local cache Failed", e);
}
newlyAllocatedIps.add(ipAddress);
}
if (!skippedDpnIds.isEmpty()) {
LOG.error("No available IP addresses in the VTEP config pool {}, skipping VTEP configurations for DPN's {}", subnetCidr, skippedDpnIds);
}
if (!newlyAllocatedIps.isEmpty()) {
LOG.debug("Delete OnCommit and buildTeps in NewlyAddedDpns");
tepCommandHelper.deleteOnCommit();
tepCommandHelper.buildTeps();
allocateIpAddresses(newlyAllocatedIps, vtepIpPool, subnetCidr);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig in project genius by opendaylight.
the class VtepConfigSchemaListener method deleteVteps.
/**
* Delete vteps.
*
* @param schema
* the schema
* @param lstDpnIdsToBeDeleted
* the dpn ids list to be deleted
*/
private void deleteVteps(VtepConfigSchema schema, List<BigInteger> lstDpnIdsToBeDeleted) {
TepCommandHelper tepCommandHelper = new TepCommandHelper(this.dataBroker, itmConfig);
List<IpAddress> freeIps = new ArrayList<>();
String subnetCidr = ItmUtils.getSubnetCidrAsString(schema.getSubnet());
String gatewayIp = handleGatewayIp(schema.getGatewayIp());
for (BigInteger dpnId : lstDpnIdsToBeDeleted) {
VtepsKey vtepkey = new VtepsKey(dpnId, schema.getPortName());
InstanceIdentifier<Vteps> vpath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(schema.getTransportZoneName())).child(Subnets.class, new SubnetsKey(schema.getSubnet())).child(Vteps.class, vtepkey).build();
Vteps vtep;
Optional<Vteps> vtepOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, vpath, dataBroker);
if (vtepOptional.isPresent()) {
vtep = vtepOptional.get();
} else {
LOG.warn("VTEP doesn't exist for DPN [{}] and port [{}].", dpnId, schema.getPortName());
continue;
}
IpAddress ipAddress = vtep.getIpAddress();
try {
tepCommandHelper.deleteVtep(dpnId, vtep.getPortname(), schema.getVlanId(), String.valueOf(ipAddress.getValue()), subnetCidr, gatewayIp, schema.getTransportZoneName(), null);
} catch (TepException e) {
LOG.error("delete Vtep Failed", e);
}
freeIps.add(ipAddress);
}
LOG.debug("Delete OnCommit in NewlyAddedDpns");
tepCommandHelper.deleteOnCommit();
deAllocateIpAddresses(freeIps, subnetCidr);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig in project genius by opendaylight.
the class ItmTepAutoConfigTest method defTzEnabledTrueConfigTest.
@Test
public void defTzEnabledTrueConfigTest() throws Exception {
InstanceIdentifier<ItmConfig> iid = InstanceIdentifier.create(ItmConfig.class);
// set def-tz-enabled flag to true
ItmConfig itmConfigObj = new ItmConfigBuilder().setDefTzEnabled(true).build();
// write into config DS
CheckedFuture<Void, TransactionCommitFailedException> futures = ItmTepAutoConfigTestUtil.writeItmConfig(iid, itmConfigObj, dataBroker);
futures.get();
// read from config DS
boolean defTzEnabled = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, iid).get().isDefTzEnabled();
Assert.assertEquals(defTzEnabled, true);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig in project genius by opendaylight.
the class ItmUtils method buildTunnelOptions.
public static List<TunnelOptions> buildTunnelOptions(TunnelEndPoints tep, ItmConfig itmConfig) {
List<TunnelOptions> tunOptions = new ArrayList<>();
String tos = tep.getOptionTunnelTos();
if (tos == null) {
tos = itmConfig.getDefaultTunnelTos();
}
/* populate tos option only if its not default value of 0 */
if (tos != null && !tos.equals("0")) {
TunnelOptionsBuilder optionsBuilder = new TunnelOptionsBuilder();
optionsBuilder.setKey(new TunnelOptionsKey("tos"));
optionsBuilder.setTunnelOption("tos");
optionsBuilder.setValue(tos);
tunOptions.add(optionsBuilder.build());
}
if (tep.getTunnelType() == TunnelTypeVxlan.class && itmConfig.isGpeExtensionEnabled()) {
TunnelOptionsBuilder optionsBuilder = new TunnelOptionsBuilder();
optionsBuilder.setKey(new TunnelOptionsKey("exts"));
optionsBuilder.setTunnelOption("exts");
optionsBuilder.setValue("gpe");
tunOptions.add(optionsBuilder.build());
}
return tunOptions.isEmpty() ? null : tunOptions;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig in project genius by opendaylight.
the class ItmTestModule method configureBindings.
@Override
protected void configureBindings() {
// Bindings for services from this project
bind(ItmRpcService.class).to(ItmManagerRpcService.class);
bind(ItmProvider.class);
ItmConfig itmConfigObj = new ItmConfigBuilder().setDefTzEnabled(true).setDefTzTunnelType(ITMConstants.TUNNEL_TYPE_VXLAN).setGpeExtensionEnabled(false).build();
bind(ItmConfig.class).toInstance(itmConfigObj);
IfmConfig interfaceConfig = new IfmConfigBuilder().setItmDirectTunnels(false).build();
bind(IfmConfig.class).toInstance(interfaceConfig);
bind(TunnelMonitorIntervalListener.class);
bind(TransportZoneListener.class);
bind(OvsdbNodeListener.class);
bind(InterfaceStateListener.class);
bind(VtepConfigSchemaListener.class);
bind(TunnelMonitorChangeListener.class);
bind(ItmTunnelEventListener.class);
// Bindings for external services to "real" implementations
bind(EntityOwnershipService.class).toInstance(mock(EntityOwnershipService.class));
bind(IdManagerService.class).to(IdManager.class);
bind(LockManagerService.class).to(LockManagerServiceImpl.class);
DataBroker dataBroker = DataBrokerTestModule.dataBroker();
bind(DataBroker.class).toInstance(dataBroker);
bind(DataBroker.class).annotatedWith(OsgiService.class).toInstance(dataBroker);
bind(InterfaceManagerService.class).to(InterfaceManagerServiceImpl.class);
bind(IInterfaceManager.class).to(InterfacemgrProvider.class);
bind(ServiceRecoveryRegistry.class).toInstance(mock(ServiceRecoveryRegistry.class));
// Bindings to test infra (fakes & mocks)
TestIMdsalApiManager mdsalManager = TestIMdsalApiManager.newInstance();
bind(IMdsalApiManager.class).toInstance(mdsalManager);
bind(TestIMdsalApiManager.class).toInstance(mdsalManager);
bind(DataImportBootReady.class).annotatedWith(OsgiService.class).toInstance(new DataImportBootReady() {
});
bind(DiagStatusService.class).toInstance(mock(DiagStatusService.class));
}
Aggregations