Search in sources :

Example 1 with ItmRpcService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService in project netvirt by opendaylight.

the class HwvtepPhysicalSwitchListener method updated.

/**
 * Upon update checks if the tunnels Ip was null earlier and it got newly added.
 * In that case simply call add.
 * If not then check if Tunnel Ip has been updated from an old value to new value.
 * If yes. delete old ITM tunnels of odl Tunnel Ipand add new ITM tunnels with new Tunnel
 * IP then call added ().
 *
 * @param identifier iid
 * @param phySwitchBefore ps Node before update
 * @param phySwitchAfter ps Node after update
 */
@Override
protected void updated(InstanceIdentifier<PhysicalSwitchAugmentation> identifier, PhysicalSwitchAugmentation phySwitchBefore, PhysicalSwitchAugmentation phySwitchAfter) {
    NodeId nodeId = getNodeId(identifier);
    LOG.trace("Received PhysicalSwitch Update Event for node {}: PhysicalSwitch Before: {}, " + "PhysicalSwitch After: {}", nodeId.getValue(), phySwitchBefore, phySwitchAfter);
    String psName = getPsName(identifier);
    if (psName == null) {
        LOG.error("Could not find the physical switch name for node {}", nodeId.getValue());
        return;
    }
    L2GatewayDevice existingDevice = l2GatewayCache.get(psName);
    LOG.info("Received physical switch {} update event for node {}", psName, nodeId.getValue());
    InstanceIdentifier<Node> globalNodeIid = getManagedByNodeIid(identifier);
    if (DEVICE_NOT_CACHED_OR_PARENT_CONNECTED.test(existingDevice, globalNodeIid)) {
        if (TUNNEL_IP_AVAILABLE.test(phySwitchAfter)) {
            added(identifier, phySwitchAfter);
        }
    } else {
        if (!Objects.equals(phySwitchAfter.getTunnelIps(), phySwitchBefore.getTunnelIps()) && TUNNEL_IP_CHANGED.test(phySwitchAfter, existingDevice)) {
            final String hwvtepId = existingDevice.getHwvtepNodeId();
            elanClusterUtils.runOnlyInOwnerNode(existingDevice.getDeviceName(), "handling Physical Switch add create itm tunnels ", () -> {
                LOG.info("Deleting itm tunnels for device {}", existingDevice.getDeviceName());
                L2GatewayUtils.deleteItmTunnels(itmRpcService, hwvtepId, existingDevice.getDeviceName(), existingDevice.getTunnelIp());
                // TODO remove these sleeps
                Thread.sleep(10000L);
                LOG.info("Creating itm tunnels for device {}", existingDevice.getDeviceName());
                ElanL2GatewayUtils.createItmTunnels(dataBroker, itmRpcService, hwvtepId, psName, phySwitchAfter.getTunnelIps().get(0).getTunnelIpsKey());
                return Collections.emptyList();
            });
            try {
                // TODO remove the sleep by using better itm api to detect finish of prev op
                Thread.sleep(20000L);
            } catch (InterruptedException e) {
                LOG.error("Interrupted ");
            }
            existingDevice.setTunnelIps(new HashSet<>());
            added(identifier, phySwitchAfter);
        }
    }
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 2 with ItmRpcService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService in project netvirt by opendaylight.

the class ElanL2GatewayUtils method createItmTunnels.

public static void createItmTunnels(DataBroker dataBroker, ItmRpcService itmRpcService, String hwvtepId, String psName, IpAddress tunnelIp) {
    AddL2GwDeviceInputBuilder builder = new AddL2GwDeviceInputBuilder();
    builder.setTopologyId(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID.getValue());
    builder.setNodeId(HwvtepSouthboundUtils.createManagedNodeId(new NodeId(hwvtepId), psName).getValue());
    builder.setIpAddress(tunnelIp);
    try {
        deleteStaleTunnelsOfHwvtepInITM(dataBroker, itmRpcService, hwvtepId, psName, tunnelIp);
        Future<RpcResult<Void>> result = itmRpcService.addL2GwDevice(builder.build());
        RpcResult<Void> rpcResult = result.get();
        if (rpcResult.isSuccessful()) {
            LOG.info("Created ITM tunnels for {}", hwvtepId);
        } else {
            LOG.error("Failed to create ITM Tunnels: {}", rpcResult.getErrors());
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("RPC to create ITM tunnels failed", e);
    }
}
Also used : AddL2GwDeviceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddL2GwDeviceInputBuilder) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ExecutionException(java.util.concurrent.ExecutionException)

Example 3 with ItmRpcService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService in project netvirt by opendaylight.

the class L2gwServiceProvider method provisionItmAndL2gwConnection.

@Override
public void provisionItmAndL2gwConnection(L2GatewayDevice l2GwDevice, String psName, String hwvtepNodeId, IpAddress tunnelIpAddr) {
    elanClusterUtils.runOnlyInOwnerNode(hwvtepNodeId, "Handling Physical Switch add create itm tunnels ", () -> {
        ElanL2GatewayUtils.createItmTunnels(dataBroker, itmRpcService, hwvtepNodeId, psName, tunnelIpAddr);
        return Collections.emptyList();
    });
    List<L2gatewayConnection> l2GwConns = L2GatewayConnectionUtils.getAssociatedL2GwConnections(dataBroker, l2GwDevice.getL2GatewayIds());
    LOG.debug("L2GatewayConnections associated for {} physical switch", psName);
    for (L2gatewayConnection l2GwConn : l2GwConns) {
        LOG.trace("L2GatewayConnection {} changes executed on physical switch {}", l2GwConn.getL2gatewayId(), psName);
        l2GatewayConnectionUtils.addL2GatewayConnection(l2GwConn, psName);
    }
}
Also used : L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection)

Example 4 with ItmRpcService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService in project netvirt by opendaylight.

the class ElanServiceTestModule method configureBindings.

@Override
protected void configureBindings() {
    DataBroker dataBroker = DataBrokerTestModule.dataBroker();
    bind(EntityOwnershipService.class).toInstance(Mockito.mock(EntityOwnershipService.class));
    bind(INeutronVpnManager.class).toInstance(Mockito.mock(NeutronvpnManagerImpl.class));
    IVpnManager ivpnManager = Mockito.mock(VpnManagerTestImpl.class, CALLS_REAL_METHODS);
    bind(IMdsalApiManager.class).toInstance(new MDSALManager(dataBroker, Mockito.mock(PacketProcessingService.class)));
    // Bindings for external services to "real" implementations
    bind(LockManagerService.class).to(LockManagerServiceImpl.class);
    bind(ElanConfig.class).toInstance(new ElanConfigBuilder().setIntBridgeGenMac(true).setTempSmacLearnTimeout(10).build());
    // Bindings of all listeners (which are not directly referenced in the code)
    // This is required to be explicit here, because these are referenced neither from src/main nor src/test
    // and we, intentionally, don't use "classpath scanning for auto-discovery"
    // so this list must kept, manually, in line with the rc/main/resources/org/opendaylight/blueprint/*.xml
    // and target/generated-resources/org/opendaylight/blueprint/autowire.xml
    // bind(ElanGroupListener.class);
    // TODO complete this list!!! after Gerrit which adds @Inject to all listeners
    // Bindings to test infra (fakes & mocks)
    TestInterfaceManager obj = TestInterfaceManager.newInstance(dataBroker);
    ItmRpcService itmRpcService = new ItmRpcTestImpl();
    bind(DataBroker.class).toInstance(dataBroker);
    bind(DataBroker.class).annotatedWith(OsgiService.class).toInstance(dataBroker);
    bind(IdManagerService.class).toInstance(Mockito.mock(IdHelper.class, CALLS_REAL_METHODS));
    bind(IInterfaceManager.class).toInstance(obj);
    bind(TestInterfaceManager.class).toInstance(obj);
    InterfaceMetaUtils interfaceMetaUtils = new InterfaceMetaUtils(dataBroker, Mockito.mock(IdHelper.class, CALLS_REAL_METHODS), Mockito.mock(BatchingUtils.class));
    InterfaceManagerCommonUtils interfaceManagerCommonUtils = new InterfaceManagerCommonUtils(dataBroker, new MDSALManager(dataBroker, Mockito.mock(PacketProcessingService.class)), Mockito.mock(IdHelper.class, CALLS_REAL_METHODS), interfaceMetaUtils, Mockito.mock(BatchingUtils.class));
    bind(OdlInterfaceRpcService.class).toInstance(ElanEgressActionsHelper.newInstance(interfaceManagerCommonUtils));
    SingleTransactionDataBroker singleTransactionDataBroker = new SingleTransactionDataBroker(dataBroker);
    bind(SingleTransactionDataBroker.class).toInstance(singleTransactionDataBroker);
    IBgpManager ibgpManager = BgpManagerTestImpl.newInstance(singleTransactionDataBroker);
    bind(ItmRpcService.class).toInstance(itmRpcService);
    bind(ItmRpcTestImpl.class).toInstance((ItmRpcTestImpl) itmRpcService);
    bind(DataImportBootReady.class).annotatedWith(OsgiService.class).toInstance(new DataImportBootReady() {
    });
    bind(DiagStatusService.class).toInstance(Mockito.mock(DiagStatusService.class));
    bind(IVpnManager.class).toInstance(ivpnManager);
    bind(IBgpManager.class).toInstance(ibgpManager);
    bind(DataImportBootReady.class).toInstance(new DataImportBootReady() {
    });
    bind(IElanService.class).to(ElanServiceProvider.class);
    MdsalUtils mdsalUtils = new MdsalUtils(dataBroker);
    bind(MdsalUtils.class).toInstance(mdsalUtils);
    bind(SouthboundUtils.class).toInstance(new SouthboundUtils(mdsalUtils));
}
Also used : SouthboundUtils(org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) TestInterfaceManager(org.opendaylight.genius.testutils.TestInterfaceManager) LockManagerService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockManagerService) IdHelper(org.opendaylight.netvirt.elanmanager.tests.utils.IdHelper) IElanService(org.opendaylight.netvirt.elanmanager.api.IElanService) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) NeutronvpnManagerImpl(org.opendaylight.netvirt.neutronvpn.NeutronvpnManagerImpl) InterfaceMetaUtils(org.opendaylight.genius.interfacemanager.commons.InterfaceMetaUtils) InterfaceManagerCommonUtils(org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils) MdsalUtils(org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils) OdlInterfaceRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService) IVpnManager(org.opendaylight.netvirt.vpnmanager.api.IVpnManager) BatchingUtils(org.opendaylight.genius.interfacemanager.renderer.ovs.utilities.BatchingUtils) IdManagerService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService) ElanConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.config.rev150710.ElanConfig) INeutronVpnManager(org.opendaylight.netvirt.neutronvpn.interfaces.INeutronVpnManager) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) OsgiService(org.ops4j.pax.cdi.api.OsgiService) MDSALManager(org.opendaylight.genius.mdsalutil.internal.MDSALManager) ItmRpcTestImpl(org.opendaylight.genius.testutils.itm.ItmRpcTestImpl) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) ElanConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.config.rev150710.ElanConfigBuilder) ItmRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService) EntityOwnershipService(org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService) DataImportBootReady(org.opendaylight.daexim.DataImportBootReady) DiagStatusService(org.opendaylight.infrautils.diagstatus.DiagStatusService) IBgpManager(org.opendaylight.netvirt.bgpmanager.api.IBgpManager)

Example 5 with ItmRpcService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService in project netvirt by opendaylight.

the class L2GatewayUtils method createItmTunnels.

protected static void createItmTunnels(ItmRpcService itmRpcService, String hwvtepId, String psName, IpAddress tunnelIp) {
    AddL2GwDeviceInputBuilder builder = new AddL2GwDeviceInputBuilder();
    builder.setTopologyId(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID.getValue());
    builder.setNodeId(HwvtepSouthboundUtils.createManagedNodeId(new NodeId(hwvtepId), psName).getValue());
    builder.setIpAddress(tunnelIp);
    try {
        Future<RpcResult<Void>> result = itmRpcService.addL2GwDevice(builder.build());
        RpcResult<Void> rpcResult = result.get();
        if (rpcResult.isSuccessful()) {
            LOG.info("Created ITM tunnels for {}", hwvtepId);
        } else {
            LOG.error("Failed to create ITM Tunnels: {}", rpcResult.getErrors());
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("RPC to create ITM tunnels failed", e);
    }
}
Also used : AddL2GwDeviceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddL2GwDeviceInputBuilder) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)6 ExecutionException (java.util.concurrent.ExecutionException)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)2 AddL2GwDeviceInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddL2GwDeviceInputBuilder)2 DeleteL2GwDeviceInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.DeleteL2GwDeviceInputBuilder)2 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)1 DataImportBootReady (org.opendaylight.daexim.DataImportBootReady)1 SingleTransactionDataBroker (org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker)1 InterfaceManagerCommonUtils (org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils)1 InterfaceMetaUtils (org.opendaylight.genius.interfacemanager.commons.InterfaceMetaUtils)1 IInterfaceManager (org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager)1 BatchingUtils (org.opendaylight.genius.interfacemanager.renderer.ovs.utilities.BatchingUtils)1 IMdsalApiManager (org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager)1 MDSALManager (org.opendaylight.genius.mdsalutil.internal.MDSALManager)1 TestInterfaceManager (org.opendaylight.genius.testutils.TestInterfaceManager)1 ItmRpcTestImpl (org.opendaylight.genius.testutils.itm.ItmRpcTestImpl)1 DiagStatusService (org.opendaylight.infrautils.diagstatus.DiagStatusService)1 EntityOwnershipService (org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService)1 IBgpManager (org.opendaylight.netvirt.bgpmanager.api.IBgpManager)1