Search in sources :

Example 91 with Network

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network in project netvirt by opendaylight.

the class VpnManagerImpl method addArpResponderFlowsToExternalNetworkIps.

@Override
public void addArpResponderFlowsToExternalNetworkIps(String id, Collection<String> fixedIps, String macAddress, BigInteger dpnId, Uuid extNetworkId, WriteTransaction writeTx) {
    if (dpnId == null || BigInteger.ZERO.equals(dpnId)) {
        LOG.warn("Failed to install arp responder flows for router {}. DPN id is missing.", id);
        return;
    }
    String extInterfaceName = elanService.getExternalElanInterface(extNetworkId.getValue(), dpnId);
    if (extInterfaceName != null) {
        doAddArpResponderFlowsToExternalNetworkIps(id, fixedIps, macAddress, dpnId, extNetworkId, writeTx, extInterfaceName);
        return;
    }
    LOG.warn("Failed to install responder flows for {}. No external interface found for DPN id {}", id, dpnId);
    if (!upgradeState.isUpgradeInProgress()) {
        return;
    }
    // The following through the end of the function deals with an upgrade scenario where the neutron configuration
    // is restored before the OVS switches reconnect. In such a case, the elan-dpn-interfaces entries will be
    // missing from the operational data store. In order to mitigate this we use DataTreeEventCallbackRegistrar
    // to wait for the exact operational md-sal object we need to contain the external interface we need.
    LOG.info("Upgrade in process, waiting for an external interface to appear on dpn {} for elan {}", dpnId, extNetworkId.getValue());
    InstanceIdentifier<DpnInterfaces> dpnInterfacesIid = elanService.getElanDpnInterfaceOperationalDataPath(extNetworkId.getValue(), dpnId);
    eventCallbacks.onAddOrUpdate(LogicalDatastoreType.OPERATIONAL, dpnInterfacesIid, (unused, alsoUnused) -> {
        LOG.info("Reattempting write of arp responder for external interfaces for external network {}", extNetworkId);
        DpnInterfaces dpnInterfaces = elanService.getElanInterfaceInfoByElanDpn(extNetworkId.getValue(), dpnId);
        if (dpnInterfaces == null) {
            LOG.error("Could not retrieve DpnInterfaces for {}, {}", extNetworkId.getValue(), dpnId);
            return DataTreeEventCallbackRegistrar.NextAction.UNREGISTER;
        }
        String extIfc = null;
        for (String dpnInterface : dpnInterfaces.getInterfaces()) {
            if (interfaceManager.isExternalInterface(dpnInterface)) {
                extIfc = dpnInterface;
                break;
            }
        }
        if (extIfc == null) {
            if (upgradeState.isUpgradeInProgress()) {
                LOG.info("External interface not found yet in elan {} on dpn {}, keep waiting", extNetworkId.getValue(), dpnInterfaces);
                return DataTreeEventCallbackRegistrar.NextAction.CALL_AGAIN;
            } else {
                return DataTreeEventCallbackRegistrar.NextAction.UNREGISTER;
            }
        }
        final String extIfcFinal = extIfc;
        ListenableFuture<Void> listenableFuture = txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
            doAddArpResponderFlowsToExternalNetworkIps(id, fixedIps, macAddress, dpnId, extNetworkId, tx, extIfcFinal);
        });
        ListenableFutures.addErrorLogging(listenableFuture, LOG, "Error while configuring arp responder for ext. interface");
        return DataTreeEventCallbackRegistrar.NextAction.UNREGISTER;
    });
}
Also used : DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces)

Example 92 with Network

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network in project netvirt by opendaylight.

the class ElanDpnInterfacesListener method update.

@Override
protected void update(InstanceIdentifier<DpnInterfaces> identifier, DpnInterfaces original, DpnInterfaces update) {
    LOG.debug("received Dpninterfaces update event for dpn {}", update.getDpId());
    BigInteger dpnId = update.getDpId();
    String elanInstanceName = identifier.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
    ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
    if (elanInstance != null && !elanInstance.isExternal() && ElanUtils.isVlan(elanInstance)) {
        List<String> interfaces = update.getInterfaces();
        // trigger deletion for vlan provider intf on the DPN for the vlan provider network
        if (interfaces.size() == 1 && interfaceManager.isExternalInterface(interfaces.get(0))) {
            LOG.debug("deleting vlan prv intf for elan {}, dpn {}", elanInstanceName, dpnId);
            jobCoordinator.enqueueJob(dpnId.toString(), () -> {
                elanService.deleteExternalElanNetwork(elanInstance, dpnId);
                return Collections.emptyList();
            });
        }
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) BigInteger(java.math.BigInteger)

Example 93 with Network

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network in project netvirt by opendaylight.

the class ElanDpnToTransportZoneListener method remove.

@Override
protected void remove(InstanceIdentifier<DpnInterfaces> key, DpnInterfaces dataObjectModification) {
    LOG.debug("Elan dpn {} delete detected, deleting transport zones", dataObjectModification.getDpId());
    BigInteger dpId = dataObjectModification.getDpId();
    String elanInstanceName = key.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
    if (!ElanUtils.isVxlanNetworkOrVxlanSegment(elanInstanceCache.get(elanInstanceName).orNull())) {
        LOG.debug("ElanInstance {} is not vxlan network, nothing to do", elanInstanceName);
        return;
    }
    LOG.debug("Deleting tz for elanInstance {} dpId {}", elanInstanceName, dpId);
    transportZoneNotificationUtil.deleteTransportZone(elanInstanceName, dpId);
}
Also used : ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) BigInteger(java.math.BigInteger)

Example 94 with Network

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network in project netvirt by opendaylight.

the class NetworkL2gwDeviceInfoCli method doExecute.

@Override
protected Object doExecute() {
    List<Node> nodes = new ArrayList<>();
    Set<String> networks = new HashSet<>();
    if (nodeId == null) {
        Optional<Topology> topologyOptional = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, createHwvtepTopologyInstanceIdentifier());
        if (topologyOptional.isPresent()) {
            nodes = topologyOptional.get().getNode();
        }
    } else {
        Optional<Node> nodeOptional = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, createInstanceIdentifier(new NodeId(new Uri(nodeId))));
        if (nodeOptional.isPresent()) {
            nodes.add(nodeOptional.get());
        }
    }
    if (elanName == null) {
        // get all elan instance
        // get all device node id
        // print result
        Optional<ElanInstances> elanInstancesOptional = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(ElanInstances.class).build());
        if (elanInstancesOptional.isPresent()) {
            List<ElanInstance> elans = elanInstancesOptional.get().getElanInstance();
            if (elans != null) {
                for (ElanInstance elan : elans) {
                    networks.add(elan.getElanInstanceName());
                }
            }
        }
    } else {
        networks.add(elanName);
    }
    for (Node node : nodes) {
        if (node.getNodeId().getValue().contains("physicalswitch")) {
            continue;
        }
        Node hwvtepConfigNode = HwvtepUtils.getHwVtepNode(dataBroker, LogicalDatastoreType.CONFIGURATION, node.getNodeId());
        Node hwvtepOpPsNode = getPSnode(node, LogicalDatastoreType.OPERATIONAL);
        Node hwvtepConfigPsNode = null;
        if (hwvtepOpPsNode != null) {
            hwvtepConfigPsNode = HwvtepUtils.getHwVtepNode(dataBroker, LogicalDatastoreType.CONFIGURATION, hwvtepOpPsNode.getNodeId());
            opPSNodes.put(node.getNodeId(), hwvtepOpPsNode);
        }
        opNodes.put(node.getNodeId(), node);
        configNodes.put(node.getNodeId(), hwvtepConfigNode);
        if (hwvtepConfigPsNode != null) {
            configPSNodes.put(node.getNodeId(), hwvtepConfigPsNode);
        }
    }
    for (String network : networks) {
        session.getConsole().println("Network info for " + network);
        for (Node node : nodes) {
            if (node.getNodeId().getValue().contains("physicalswitch")) {
                continue;
            }
            session.getConsole().println("Printing for node " + node.getNodeId().getValue());
            process(node.getNodeId(), network);
        }
    }
    return null;
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ArrayList(java.util.ArrayList) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) ElanInstances(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) HashSet(java.util.HashSet)

Example 95 with Network

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network in project netvirt by opendaylight.

the class ElanInterfaceManager method remove.

@Override
protected void remove(InstanceIdentifier<ElanInterface> identifier, ElanInterface del) {
    String interfaceName = del.getName();
    ElanInstance elanInfo = elanInstanceCache.get(del.getElanInstanceName()).orNull();
    /*
         * Handling in case the elan instance is deleted.If the Elan instance is
         * deleted, there is no need to explicitly delete the elan interfaces
         */
    if (elanInfo == null) {
        return;
    }
    InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
    if (interfaceInfo == null && elanInfo.isExternal()) {
        // In deleting external network, the underlying ietf Inteface might have been removed
        // from the config DS prior to deleting the ELAN interface. We try to get the InterfaceInfo
        // from Operational DS instead
        interfaceInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(interfaceName);
    }
    String elanInstanceName = elanInfo.getElanInstanceName();
    InterfaceRemoveWorkerOnElan configWorker = new InterfaceRemoveWorkerOnElan(elanInstanceName, elanInfo, interfaceName, interfaceInfo, this);
    jobCoordinator.enqueueJob(elanInstanceName, configWorker, ElanConstants.JOB_MAX_RETRIES);
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)93 ArrayList (java.util.ArrayList)46 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)33 BigInteger (java.math.BigInteger)31 Network (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)31 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)26 ProviderTypes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes)19 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)19 Port (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)19 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)17 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)15 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)12 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)11 ExecutionException (java.util.concurrent.ExecutionException)10 ExternalNetworks (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalNetworks)10 Networks (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.Networks)10 QosPolicy (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicy)10 Routers (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers)9 HashSet (java.util.HashSet)8 Nonnull (javax.annotation.Nonnull)8