Search in sources :

Example 46 with CONFIGURATION

use of org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION in project netvirt by opendaylight.

the class NeutronTrunkChangeListener method createSubPortInterface.

private void createSubPortInterface(Trunk trunk, SubPorts subPort) {
    if (!NetworkTypeVlan.class.equals(subPort.getSegmentationType())) {
        LOG.warn("SegmentationType other than VLAN not supported for Trunk:SubPorts");
        return;
    }
    String portName = subPort.getPortId().getValue();
    String parentName = trunk.getPortId().getValue();
    InstanceIdentifier<Interface> interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(portName);
    // Should we use parentName?
    jobCoordinator.enqueueJob("PORT- " + portName, () -> {
        /*
            *  Build Port-to-Subport details first, irrespective of port being available or not.
            */
        PortIdToSubportBuilder portIdToSubportBuilder = new PortIdToSubportBuilder();
        Uuid subPortUuid = subPort.getPortId();
        portIdToSubportBuilder.withKey(new PortIdToSubportKey(subPortUuid)).setPortId(subPortUuid).setTrunkPortId(trunk.getPortId()).setVlanId(subPort.getSegmentationId());
        List<ListenableFuture<?>> futures = new ArrayList<>();
        futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
            tx.merge(NeutronvpnUtils.buildPortIdSubportMappingIdentifier(subPortUuid), portIdToSubportBuilder.build());
            LOG.trace("Creating PortIdSubportMapping for port{}", portName);
        }));
        Interface iface = ifMgr.getInterfaceInfoFromConfigDataStore(portName);
        if (iface == null) {
            /*
                 * Trunk creation requires NeutronPort to be present, by this time interface
                 * should've been created. In controller restart use case Interface would already be present.
                 * Clustering consideration:
                 *      This being same shard as NeutronPort, interface creation will be triggered on the same
                 *      node as this one. Use of DSJC helps ensure the order.
                 */
            LOG.warn("Interface not present for Trunk SubPort: {}", subPort);
            return futures;
        }
        InterfaceBuilder interfaceBuilder = new InterfaceBuilder();
        IfL2vlan ifL2vlan = new IfL2vlanBuilder().setL2vlanMode(IfL2vlan.L2vlanMode.TrunkMember).setVlanId(new VlanId(subPort.getSegmentationId().intValue())).build();
        ParentRefs parentRefs = new ParentRefsBuilder().setParentInterface(parentName).build();
        SplitHorizon splitHorizon = new SplitHorizonBuilder().setOverrideSplitHorizonProtection(true).build();
        interfaceBuilder.setName(portName).setType(L2vlan.class).addAugmentation(ifL2vlan).addAugmentation(parentRefs).addAugmentation(splitHorizon);
        Interface newIface = interfaceBuilder.build();
        /*
             * Interface is already created for parent NeutronPort. We're updating parent refs
             * and VLAN Information
             */
        ListenableFuture<?> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, txn -> txn.merge(interfaceIdentifier, newIface));
        LoggingFutures.addErrorLogging(future, LOG, "createSubPortInterface: Failed for portName {}, parentName {}", portName, parentName);
        futures.add(future);
        return futures;
    });
}
Also used : CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) SplitHorizon(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.SplitHorizon) LoggerFactory(org.slf4j.LoggerFactory) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) NetworkTypeVlan(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeVlan) Trunk(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk) Singleton(javax.inject.Singleton) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan) Neutron(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron) IfL2vlanBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder) ArrayList(java.util.ArrayList) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) SplitHorizonBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.SplitHorizonBuilder) Map(java.util.Map) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) SubPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunk.attributes.SubPorts) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) Trunks(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.Trunks) Logger(org.slf4j.Logger) PortIdToSubportKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.port.id.subport.data.PortIdToSubportKey) AbstractAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) Objects(java.util.Objects) List(java.util.List) ParentRefsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.L2vlan) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Preconditions(com.google.common.base.Preconditions) VlanId(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId) SubPortsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunk.attributes.SubPortsKey) Collections(java.util.Collections) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) PortIdToSubportBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.port.id.subport.data.PortIdToSubportBuilder) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan) L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.L2vlan) SplitHorizonBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.SplitHorizonBuilder) ArrayList(java.util.ArrayList) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) IfL2vlanBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder) ParentRefsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) PortIdToSubportBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.port.id.subport.data.PortIdToSubportBuilder) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) NetworkTypeVlan(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeVlan) PortIdToSubportKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.port.id.subport.data.PortIdToSubportKey) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) VlanId(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId) SplitHorizon(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.SplitHorizon) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 47 with CONFIGURATION

use of org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION in project netvirt by opendaylight.

the class NeutronTrunkChangeListener method deleteSubPortInterface.

private void deleteSubPortInterface(SubPorts subPort) {
    String portName = subPort.getPortId().getValue();
    InstanceIdentifier<Interface> interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(subPort.getPortId().getValue());
    jobCoordinator.enqueueJob("PORT- " + portName, () -> {
        Interface iface = ifMgr.getInterfaceInfoFromConfigDataStore(portName);
        List<ListenableFuture<?>> futures = new ArrayList<>();
        if (iface == null) {
            LOG.warn("Interface not present for SubPort {}", subPort);
            return futures;
        }
        /*
             * We'll reset interface back to way it was? Can IFM handle parentRef delete?
             */
        InterfaceBuilder interfaceBuilder = new InterfaceBuilder(iface);
        // Reset augmentations
        interfaceBuilder.removeAugmentation(IfL2vlan.class).removeAugmentation(ParentRefs.class).removeAugmentation(SplitHorizon.class);
        IfL2vlan ifL2vlan = new IfL2vlanBuilder().setL2vlanMode(IfL2vlan.L2vlanMode.Trunk).build();
        interfaceBuilder.addAugmentation(ifL2vlan);
        Interface newIface = interfaceBuilder.build();
        /*
             * There is no means to do an update to remove elements from a node.
             * Our solution is to get existing iface, remove parentRef and VlanId,
             * and do a put to replace existing entry. This works out better as put
             * has better performance than merge.
             * Only drawback is any in-flight changes might be lost, but that is a corner case
             * and this being subport delete path, don't expect any significant changes to
             * corresponding Neutron Port. Deletion of NeutronPort should follow soon enough.
             */
        futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
            tx.put(interfaceIdentifier, newIface);
            LOG.trace("Resetting trunk member interface {}", newIface);
        }));
        futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
            tx.delete(NeutronvpnUtils.buildPortIdSubportMappingIdentifier(subPort.getPortId()));
            LOG.trace("Deleting PortIdSubportMapping for portName {}", portName);
        }));
        return futures;
    });
}
Also used : CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) SplitHorizon(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.SplitHorizon) LoggerFactory(org.slf4j.LoggerFactory) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) NetworkTypeVlan(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeVlan) Trunk(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk) Singleton(javax.inject.Singleton) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan) Neutron(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron) IfL2vlanBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder) ArrayList(java.util.ArrayList) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) SplitHorizonBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.SplitHorizonBuilder) Map(java.util.Map) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) SubPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunk.attributes.SubPorts) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) Trunks(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.Trunks) Logger(org.slf4j.Logger) PortIdToSubportKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.port.id.subport.data.PortIdToSubportKey) AbstractAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) Objects(java.util.Objects) List(java.util.List) ParentRefsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.L2vlan) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Preconditions(com.google.common.base.Preconditions) VlanId(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId) SubPortsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunk.attributes.SubPortsKey) Collections(java.util.Collections) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) PortIdToSubportBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.port.id.subport.data.PortIdToSubportBuilder) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) IfL2vlanBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 48 with CONFIGURATION

use of org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION in project netvirt by opendaylight.

the class InterVpnLinkListener method remove.

@Override
public void remove(InstanceIdentifier<InterVpnLink> identifier, InterVpnLink del) {
    LOG.debug("Reacting to InterVpnLink {} removal", del.getName());
    // Remove learnt routes
    // Remove entries in the LPortDispatcher table
    // Remove the corresponding entries in InterVpnLinkState
    // For each endpoint, remove all routes that have been learnt by intervpnLink
    String vpn1Uuid = del.getFirstEndpoint().getVpnUuid().getValue();
    String rd1 = vpnUtil.getVpnRd(vpn1Uuid);
    LOG.debug("Removing leaked routes in VPN {}  rd={}", vpn1Uuid, rd1);
    vpnUtil.removeVrfEntriesByOrigin(rd1, RouteOrigin.INTERVPN);
    List<VrfEntry> vrfEntriesSecondEndpoint = vpnUtil.findVrfEntriesByNexthop(rd1, del.getSecondEndpoint().getIpAddress().getValue());
    String vpn2Uuid = del.getSecondEndpoint().getVpnUuid().getValue();
    String rd2 = vpnUtil.getVpnRd(vpn2Uuid);
    LOG.debug("Removing leaked routes in VPN {}  rd={}", vpn2Uuid, rd2);
    vpnUtil.removeVrfEntriesByOrigin(rd2, RouteOrigin.INTERVPN);
    List<VrfEntry> vrfEntriesFirstEndpoint = vpnUtil.findVrfEntriesByNexthop(rd2, del.getFirstEndpoint().getIpAddress().getValue());
    Optional<InterVpnLinkState> optIVpnLinkState = interVpnLinkUtil.getInterVpnLinkState(del.getName());
    if (optIVpnLinkState.isPresent()) {
        InterVpnLinkState interVpnLinkState = optIVpnLinkState.get();
        boolean isVpnFirstEndPoint = true;
        if (interVpnLinkState.getFirstEndpointState() != null) {
            Long firstEndpointLportTag = interVpnLinkState.getFirstEndpointState().getLportTag().toJava();
            removeVpnLinkEndpointFlows(del, vpn2Uuid, rd1, interVpnLinkState.getSecondEndpointState().getDpId(), firstEndpointLportTag.intValue(), del.getFirstEndpoint().getIpAddress().getValue(), vrfEntriesSecondEndpoint, isVpnFirstEndPoint);
        } else {
            LOG.info("Could not get first endpoint state attributes for InterVpnLink {}", del.getName());
        }
        isVpnFirstEndPoint = false;
        if (interVpnLinkState.getSecondEndpointState() != null) {
            Long secondEndpointLportTag = interVpnLinkState.getSecondEndpointState().getLportTag().toJava();
            removeVpnLinkEndpointFlows(del, vpn1Uuid, rd2, interVpnLinkState.getFirstEndpointState().getDpId(), secondEndpointLportTag.intValue(), del.getSecondEndpoint().getIpAddress().getValue(), vrfEntriesFirstEndpoint, isVpnFirstEndPoint);
        } else {
            LOG.info("Could not get second endpoint state attributes for InterVpnLink {}", del.getName());
        }
    }
    vpnUtil.removeVrfEntries(rd1, vrfEntriesSecondEndpoint);
    vpnUtil.removeVrfEntries(rd2, vrfEntriesFirstEndpoint);
    vpnUtil.withdrawRoutes(rd1, vrfEntriesSecondEndpoint);
    vpnUtil.withdrawRoutes(rd2, vrfEntriesFirstEndpoint);
    // Release idManager with LPortTag associated to endpoints
    LOG.debug("Releasing InterVpnLink {} endpoints LportTags", del.getName());
    InterVpnLinkKey key = del.key();
    Uuid firstEndpointVpnUuid = del.getFirstEndpoint().getVpnUuid();
    Uuid secondEndpointVpnUuid = del.getSecondEndpoint().getVpnUuid();
    releaseVpnLinkLPortTag(key.getName() + firstEndpointVpnUuid.getValue());
    releaseVpnLinkLPortTag(key.getName() + secondEndpointVpnUuid.getValue());
    // Routes with nextHop pointing to an end-point of the inter-vpn-link are populated into FIB table.
    // The action in that case is a nx_resubmit to LPortDispatcher table. This is done in FibManager.
    // At this point. we need to check if is there any entry in FIB table pointing to LPortDispatcher table.
    // Remove it in that case.
    // Removing the InterVpnLinkState
    InstanceIdentifier<InterVpnLinkState> interVpnLinkStateIid = InterVpnLinkUtil.getInterVpnLinkStateIid(del.getName());
    LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.delete(interVpnLinkStateIid)), LOG, "Error deleting inter-VPN link state {}", interVpnLinkStateIid);
}
Also used : CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) IFibManager(org.opendaylight.netvirt.fibmanager.api.IFibManager) VpnUtil(org.opendaylight.netvirt.vpnmanager.VpnUtil) InterVpnLinkCleanedCheckerTask(org.opendaylight.netvirt.vpnmanager.intervpnlink.tasks.InterVpnLinkCleanedCheckerTask) InterVpnLink(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLink) LoggerFactory(org.slf4j.LoggerFactory) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) InterVpnLinkRemoverTask(org.opendaylight.netvirt.vpnmanager.intervpnlink.tasks.InterVpnLinkRemoverTask) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) PreDestroy(javax.annotation.PreDestroy) Future(java.util.concurrent.Future) InterVpnLinkCache(org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkCache) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) IBgpManager(org.opendaylight.netvirt.bgpmanager.api.IBgpManager) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) IVpnLinkService(org.opendaylight.netvirt.vpnmanager.api.intervpnlink.IVpnLinkService) InterVpnLinkCreationErrorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinkCreationErrorBuilder) SecondEndpointState(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.states.inter.vpn.link.state.SecondEndpointState) ReleaseIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInput) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) FirstEndpointStateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.states.inter.vpn.link.state.FirstEndpointStateBuilder) List(java.util.List) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) InterVpnLinkCreationErrorMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.creation.error.InterVpnLinkCreationErrorMessageBuilder) Optional(java.util.Optional) InterVpnLinkStateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.states.InterVpnLinkStateBuilder) InterVpnLinkKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLinkKey) AllocateIdOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput) InterVpnLinks(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinks) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) SecondEndpointStateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.states.inter.vpn.link.state.SecondEndpointStateBuilder) Uint64(org.opendaylight.yangtools.yang.common.Uint64) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) Singleton(javax.inject.Singleton) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) InterVpnLinkCreationErrorMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.creation.error.InterVpnLinkCreationErrorMessage) Inject(javax.inject.Inject) InterVpnLinkDataComposite(org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkDataComposite) VpnConstants(org.opendaylight.netvirt.vpnmanager.VpnConstants) Objects.requireNonNull(java.util.Objects.requireNonNull) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) VpnOpDataSyncer(org.opendaylight.netvirt.vpnmanager.VpnOpDataSyncer) InterVpnLinkCreationError(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinkCreationError) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Logger(org.slf4j.Logger) InterVpnLinkCreatorTask(org.opendaylight.netvirt.vpnmanager.intervpnlink.tasks.InterVpnLinkCreatorTask) InterVpnLinkState(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.states.InterVpnLinkState) RouteOrigin(org.opendaylight.netvirt.fibmanager.api.RouteOrigin) AbstractAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) VpnFootprintService(org.opendaylight.netvirt.vpnmanager.VpnFootprintService) ReleaseIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInputBuilder) IdManagerService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService) FutureCallback(com.google.common.util.concurrent.FutureCallback) ExecutionException(java.util.concurrent.ExecutionException) Futures(com.google.common.util.concurrent.Futures) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) NotificationPublishService(org.opendaylight.mdsal.binding.api.NotificationPublishService) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) FirstEndpointState(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.states.inter.vpn.link.state.FirstEndpointState) Collections(java.util.Collections) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) InterVpnLinkKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLinkKey) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) InterVpnLinkState(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.states.InterVpnLinkState)

Example 49 with CONFIGURATION

use of org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION in project netvirt by opendaylight.

the class QosAlertManager method writeConfigDataStore.

private void writeConfigDataStore(boolean qosAlertEnabled, short dropPacketThreshold, int alertPollInterval) {
    InstanceIdentifier<QosalertConfig> path = InstanceIdentifier.builder(QosalertConfig.class).build();
    QosalertConfig qosAlertConfig = new QosalertConfigBuilder().setQosDropPacketThreshold(dropPacketThreshold).setQosAlertEnabled(qosAlertEnabled).setQosAlertPollInterval(alertPollInterval).build();
    LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.mergeParentStructurePut(path, qosAlertConfig)), LOG, "Error writing to the config data store");
}
Also used : CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) JsonObject(com.google.gson.JsonObject) QosalertConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.qosalert.config.rev170301.QosalertConfig) Uint64(org.opendaylight.yangtools.yang.common.Uint64) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) LoggerFactory(org.slf4j.LoggerFactory) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) CommandSession(org.apache.felix.service.command.CommandSession) Singleton(javax.inject.Singleton) Supplier(java.util.function.Supplier) GsonBuilder(com.google.gson.GsonBuilder) ConcurrentMap(java.util.concurrent.ConcurrentMap) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) Future(java.util.concurrent.Future) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Gson(com.google.gson.Gson) Map(java.util.Map) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) GetNodeConnectorStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInputBuilder) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) Logger(org.slf4j.Logger) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) IfmConstants(org.opendaylight.genius.interfacemanager.globals.IfmConstants) ExecutionException(java.util.concurrent.ExecutionException) OpendaylightDirectStatisticsService(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.OpendaylightDirectStatisticsService) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap) JsonArray(com.google.gson.JsonArray) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) Entry(java.util.Map.Entry) PostConstruct(javax.annotation.PostConstruct) GetNodeConnectorStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput) QosalertConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.qosalert.config.rev170301.QosalertConfigBuilder) NodeConnectorStatisticsAndPortNumberMapKey(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapKey) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) QosalertConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.qosalert.config.rev170301.QosalertConfig) QosalertConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.qosalert.config.rev170301.QosalertConfigBuilder)

Example 50 with CONFIGURATION

use of org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION in project netvirt by opendaylight.

the class InterfaceStateChangeListener method add.

@Override
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public void add(InstanceIdentifier<Interface> identifier, Interface intrf) {
    try {
        if (L2vlan.class.equals(intrf.getType())) {
            LOG.info("VPN Interface add event - intfName {} from InterfaceStateChangeListener", intrf.getName());
            jobCoordinator.enqueueJob("VPNINTERFACE-" + intrf.getName(), () -> {
                List<ListenableFuture<?>> futures = new ArrayList<>(3);
                futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, writeInvTxn -> {
                    // map of prefix and vpn name used, as entry in prefix-to-interface datastore
                    // is prerequisite for refresh Fib to avoid race condition leading to missing remote next hop
                    // in bucket actions on bgp-vpn delete
                    Map<String, Set<String>> mapOfRdAndPrefixesForRefreshFib = new HashMap<>();
                    ListenableFuture<?> configFuture = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, writeConfigTxn -> {
                        ListenableFuture<?> operFuture = txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, writeOperTxn -> {
                            final String interfaceName = intrf.getName();
                            LOG.info("Detected interface add event for interface {}", interfaceName);
                            final VpnInterface vpnIf = vpnUtil.getConfiguredVpnInterface(interfaceName);
                            if (vpnIf != null) {
                                for (VpnInstanceNames vpnInterfaceVpnInstance : vpnIf.nonnullVpnInstanceNames().values()) {
                                    String vpnName = vpnInterfaceVpnInstance.getVpnName();
                                    String primaryRd = vpnUtil.getPrimaryRd(vpnName);
                                    if (!vpnInterfaceManager.isVpnInstanceReady(vpnName)) {
                                        LOG.info("VPN Interface add event - intfName {} onto vpnName {} " + "running oper-driven, VpnInstance not ready, holding" + " on", vpnIf.getName(), vpnName);
                                    } else if (vpnUtil.isVpnPendingDelete(primaryRd)) {
                                        LOG.error("add: Ignoring addition of vpnInterface {}, as" + " vpnInstance {} with primaryRd {} is already marked for" + " deletion", interfaceName, vpnName, primaryRd);
                                    } else {
                                        Uint64 intfDpnId = Uint64.ZERO;
                                        try {
                                            intfDpnId = InterfaceUtils.getDpIdFromInterface(intrf);
                                        } catch (Exception e) {
                                            LOG.error("Unable to retrieve dpnId for interface {}. " + "Process vpn interface add failed", intrf.getName(), e);
                                            return;
                                        }
                                        LOG.error("InterfaceStateChangeListener- Processing ifState" + " {} add event with dpnId {}", intrf.getName(), intfDpnId);
                                        final Uint64 dpnId = intfDpnId;
                                        final int ifIndex = intrf.getIfIndex();
                                        LOG.info("VPN Interface add event - intfName {} onto vpnName {}" + " running oper-driven", vpnIf.getName(), vpnName);
                                        Set<String> prefixes = new HashSet<>();
                                        vpnInterfaceManager.processVpnInterfaceUp(dpnId, vpnIf, primaryRd, ifIndex, false, writeConfigTxn, writeOperTxn, writeInvTxn, intrf, vpnName, prefixes);
                                        mapOfRdAndPrefixesForRefreshFib.put(primaryRd, prefixes);
                                    }
                                }
                            }
                        });
                        futures.add(operFuture);
                        // Synchronous submit of operTxn
                        operFuture.get();
                    });
                    Futures.addCallback(configFuture, new VpnInterfaceCallBackHandler(mapOfRdAndPrefixesForRefreshFib), MoreExecutors.directExecutor());
                    futures.add(configFuture);
                    // TODO: Allow immediateFailedFuture from writeCfgTxn to cancel writeInvTxn as well.
                    Futures.addCallback(configFuture, new PostVpnInterfaceThreadWorker(intrf.getName(), true, "Operational"), MoreExecutors.directExecutor());
                }));
                return futures;
            });
        }
    } catch (Exception e) {
        LOG.error("Exception caught in Interface {} Operational State Up event", intrf.getName(), e);
    }
}
Also used : CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) IFibManager(org.opendaylight.netvirt.fibmanager.api.IFibManager) VpnInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.VpnInterface) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) InterfacesState(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency) Uint64(org.opendaylight.yangtools.yang.common.Uint64) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) LoggerFactory(org.slf4j.LoggerFactory) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) HashBasedTable(com.google.common.collect.HashBasedTable) HashMap(java.util.HashMap) Singleton(javax.inject.Singleton) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) InterfaceUtils(org.opendaylight.netvirt.vpnmanager.api.InterfaceUtils) Map(java.util.Map) AdjacencyKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyKey) Logger(org.slf4j.Logger) OperStatus(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus) AbstractAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) Set(java.util.Set) VpnInstanceNames(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.vpn._interface.VpnInstanceNames) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) Adjacencies(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.Adjacencies) FutureCallback(com.google.common.util.concurrent.FutureCallback) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.L2vlan) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Optional(java.util.Optional) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort) Table(com.google.common.collect.Table) OPERATIONAL(org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) ArrayList(java.util.ArrayList) VpnInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.VpnInterface) VpnInstanceNames(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.vpn._interface.VpnInstanceNames) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) HashMap(java.util.HashMap) Map(java.util.Map) Uint64(org.opendaylight.yangtools.yang.common.Uint64) HashSet(java.util.HashSet)

Aggregations

DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)83 CONFIGURATION (org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION)83 Logger (org.slf4j.Logger)82 LoggerFactory (org.slf4j.LoggerFactory)82 ManagedNewTransactionRunner (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner)81 ManagedNewTransactionRunnerImpl (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl)81 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)80 Inject (javax.inject.Inject)75 Singleton (javax.inject.Singleton)75 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)72 ArrayList (java.util.ArrayList)66 Collections (java.util.Collections)66 List (java.util.List)66 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)61 ExecutionException (java.util.concurrent.ExecutionException)60 Optional (java.util.Optional)57 LoggingFutures (org.opendaylight.infrautils.utils.concurrent.LoggingFutures)56 JobCoordinator (org.opendaylight.infrautils.jobcoordinator.JobCoordinator)53 NwConstants (org.opendaylight.genius.mdsalutil.NwConstants)51 PreDestroy (javax.annotation.PreDestroy)50