use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig in project genius by opendaylight.
the class ItmExternalTunnelAddWorker method buildTunnelsToExternalEndPoint.
public List<ListenableFuture<Void>> buildTunnelsToExternalEndPoint(Collection<DPNTEPsInfo> cfgDpnList, IpAddress extIp, Class<? extends TunnelTypeBase> tunType) {
if (null != cfgDpnList) {
WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
for (DPNTEPsInfo teps : cfgDpnList) {
// CHECK -- Assumption -- Only one End Point / Dpn for GRE/Vxlan Tunnels
TunnelEndPoints firstEndPt = teps.getTunnelEndPoints().get(0);
String interfaceName = firstEndPt.getInterfaceName();
String tunTypeStr = tunType.getName();
String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(interfaceName, new String(firstEndPt.getIpAddress().getValue()), new String(extIp.getValue()), tunTypeStr);
char[] subnetMaskArray = firstEndPt.getSubnetMask().getValue();
boolean useOfTunnel = ItmUtils.falseIfNull(firstEndPt.isOptionOfTunnel());
List<TunnelOptions> tunOptions = ItmUtils.buildTunnelOptions(firstEndPt, itmConfig);
String subnetMaskStr = String.valueOf(subnetMaskArray);
SubnetUtils utils = new SubnetUtils(subnetMaskStr);
String dcGwyIpStr = String.valueOf(extIp.getValue());
IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
IpAddress gwyIpAddress = utils.getInfo().isInRange(dcGwyIpStr) ? gatewayIpObj : firstEndPt.getGwIpAddress();
LOG.debug(" Creating Trunk Interface with parameters trunk I/f Name - {}, parent I/f name - {}," + " source IP - {}, DC Gateway IP - {} gateway IP - {}", trunkInterfaceName, interfaceName, firstEndPt.getIpAddress(), extIp, gwyIpAddress);
Interface iface = ItmUtils.buildTunnelInterface(teps.getDPNID(), trunkInterfaceName, String.format("%s %s", ItmUtils.convertTunnelTypetoString(tunType), "Trunk Interface"), true, tunType, firstEndPt.getIpAddress(), extIp, gwyIpAddress, firstEndPt.getVLANID(), false, false, ITMConstants.DEFAULT_MONITOR_PROTOCOL, null, useOfTunnel, tunOptions);
LOG.debug(" Trunk Interface builder - {} ", iface);
InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkInterfaceName);
LOG.debug(" Trunk Interface Identifier - {} ", trunkIdentifier);
LOG.trace(" Writing Trunk Interface to Config DS {}, {} ", trunkIdentifier, iface);
transaction.merge(LogicalDatastoreType.CONFIGURATION, trunkIdentifier, iface, true);
// update external_tunnel_list ds
InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(String.valueOf(extIp.getValue()), teps.getDPNID().toString(), tunType));
ExternalTunnel tnl = ItmUtils.buildExternalTunnel(teps.getDPNID().toString(), String.valueOf(extIp.getValue()), tunType, trunkInterfaceName);
transaction.merge(LogicalDatastoreType.CONFIGURATION, path, tnl, true);
}
return Collections.singletonList(transaction.submit());
}
return Collections.emptyList();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig in project genius by opendaylight.
the class ItmTepAutoConfigTest method defTzEnabledFalseConfigTest.
@Test
public void defTzEnabledFalseConfigTest() throws Exception {
InstanceIdentifier<ItmConfig> iid = InstanceIdentifier.create(ItmConfig.class);
// set def-tz-enabled flag to false
ItmConfig itmConfigObj = new ItmConfigBuilder().setDefTzEnabled(false).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, false);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig in project genius by opendaylight.
the class ItmTepAutoConfigTest method processDefTzOnItmConfig.
// Common method created for code-reuse
private InstanceIdentifier<TransportZone> processDefTzOnItmConfig(boolean defTzEnabledFlag, String defTzTunnelType) throws Exception {
ItmConfig itmConfigObj = null;
if (defTzTunnelType != null) {
// set def-tz-enabled flag and def-tz-tunnel-type
itmConfigObj = new ItmConfigBuilder().setDefTzEnabled(defTzEnabledFlag).setDefTzTunnelType(defTzTunnelType).build();
} else {
// set def-tz-enabled flag only
itmConfigObj = new ItmConfigBuilder().setDefTzEnabled(defTzEnabledFlag).build();
}
// Create TepCommandHelper object which creates/deletes default-TZ based
// on def-tz-enabled flag
TepCommandHelper tepCmdHelper = new TepCommandHelper(dataBroker, itmConfigObj);
tepCmdHelper.start();
InstanceIdentifier<TransportZone> tzonePath = ItmTepAutoConfigTestUtil.getTzIid(ITMConstants.DEFAULT_TRANSPORT_ZONE);
return tzonePath;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig in project genius by opendaylight.
the class ItmTepAutoConfigTest method defTzDeletionTest.
@Test
public void defTzDeletionTest() throws Exception {
// create default-TZ first by setting def-tz-enabled flag to true
ItmConfig itmConfigObj = new ItmConfigBuilder().setDefTzEnabled(true).setDefTzTunnelType(ITMConstants.TUNNEL_TYPE_GRE).build();
TepCommandHelper tepCmdHelper = new TepCommandHelper(dataBroker, itmConfigObj);
tepCmdHelper.start();
// Create TepCommandHelper object which creates/deletes default-TZ based on def-tz-enabled flag
InstanceIdentifier<TransportZone> tzonePath = ItmTepAutoConfigTestUtil.getTzIid(ITMConstants.DEFAULT_TRANSPORT_ZONE);
Assert.assertNotNull(tzonePath);
assertEqualBeans(ExpectedDefTransportZoneObjects.newDefTzWithGreTunnelType(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get());
// now delete default-TZ first by setting def-tz-enabled flag to false
itmConfigObj = new ItmConfigBuilder().setDefTzEnabled(false).build();
// Create TepCommandHelper object which creates/deletes default-TZ based on def-tz-enabled flag
tepCmdHelper = new TepCommandHelper(dataBroker, itmConfigObj);
tepCmdHelper.start();
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).get());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig in project genius by opendaylight.
the class ItmTepAutoConfigTest method testAddDeleteTepForDefTz.
@Test
public void testAddDeleteTepForDefTz() throws Exception {
// create default-TZ first by setting def-tz-enabled flag to true
ItmConfig itmConfigObj = new ItmConfigBuilder().setDefTzEnabled(true).setDefTzTunnelType(ITMConstants.TUNNEL_TYPE_VXLAN).build();
TepCommandHelper tepCmdHelper = new TepCommandHelper(dataBroker, itmConfigObj);
tepCmdHelper.start();
InstanceIdentifier<TransportZone> tzonePath = ItmTepAutoConfigTestUtil.getTzIid(ITMConstants.DEFAULT_TRANSPORT_ZONE);
Assert.assertNotNull(tzonePath);
IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
// add TEP into default-TZ
CheckedFuture<Void, TransactionCommitFailedException> futures = ItmTepAutoConfigTestUtil.addTep(ItmTestConstants.DEF_TZ_TEP_IP, ItmTestConstants.DEF_BR_DPID, ITMConstants.DEFAULT_TRANSPORT_ZONE, false, dataBroker);
futures.get();
InstanceIdentifier<Vteps> vtepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj, ITMConstants.DEFAULT_TRANSPORT_ZONE, ItmTestConstants.INT_DEF_BR_DPID, ITMConstants.DUMMY_PORT);
Assert.assertNotNull(vtepPath);
// check TEP is added into default-TZ
assertEqualBeans(ExpectedDefTransportZoneObjects.newDefTzWithTep(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get());
// remove tep from default-TZ
futures = ItmTepAutoConfigTestUtil.deleteTep(ItmTestConstants.DEF_TZ_TEP_IP, ItmTestConstants.DEF_BR_DPID, ITMConstants.DEFAULT_TRANSPORT_ZONE, dataBroker);
futures.get();
// check TEP is deleted from default-TZ
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, vtepPath).get());
}
Aggregations