Search in sources :

Example 6 with ItmConfig

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();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) SubnetUtils(org.apache.commons.net.util.SubnetUtils) ExternalTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList) ExternalTunnelKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelKey) ExternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel) TunnelOptions(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptions) TunnelEndPoints(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)

Example 7 with ItmConfig

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);
}
Also used : TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) ItmConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig) ItmConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfigBuilder) Test(org.junit.Test)

Example 8 with ItmConfig

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;
}
Also used : TepCommandHelper(org.opendaylight.genius.itm.cli.TepCommandHelper) ItmConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig) ItmConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfigBuilder) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) TepsInNotHostedTransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)

Example 9 with ItmConfig

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());
}
Also used : TepCommandHelper(org.opendaylight.genius.itm.cli.TepCommandHelper) ItmConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig) ItmConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfigBuilder) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) TepsInNotHostedTransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone) Test(org.junit.Test)

Example 10 with ItmConfig

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());
}
Also used : TepCommandHelper(org.opendaylight.genius.itm.cli.TepCommandHelper) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) ItmConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig) ItmConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfigBuilder) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) TepsInNotHostedTransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone) Test(org.junit.Test)

Aggregations

ItmConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig)6 ItmConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfigBuilder)6 ArrayList (java.util.ArrayList)5 TepCommandHelper (org.opendaylight.genius.itm.cli.TepCommandHelper)5 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)5 Test (org.junit.Test)4 DPNTEPsInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)4 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)3 ItmTepAddWorker (org.opendaylight.genius.itm.confighelpers.ItmTepAddWorker)3 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)3 TepsInNotHostedTransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)3 BigInteger (java.math.BigInteger)2 TepException (org.opendaylight.genius.itm.cli.TepException)2 HwVtep (org.opendaylight.genius.itm.confighelpers.HwVtep)2 ItmTepRemoveWorker (org.opendaylight.genius.itm.confighelpers.ItmTepRemoveWorker)2 TunnelOptions (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptions)2 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)2 SubnetUtils (org.apache.commons.net.util.SubnetUtils)1 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1