Search in sources :

Example 1 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 setupEntriesForElanInterface.

List<ListenableFuture<Void>> setupEntriesForElanInterface(ElanInstance elanInstance, ElanInterface elanInterface, InterfaceInfo interfaceInfo, boolean isFirstInterfaceInDpn) throws ElanException {
    String elanInstanceName = elanInstance.getElanInstanceName();
    String interfaceName = elanInterface.getName();
    WriteTransaction tx = broker.newWriteOnlyTransaction();
    BigInteger dpId = interfaceInfo.getDpId();
    WriteTransaction writeFlowGroupTx = broker.newWriteOnlyTransaction();
    installEntriesForElanInterface(elanInstance, elanInterface, interfaceInfo, isFirstInterfaceInDpn, tx, writeFlowGroupTx);
    List<StaticMacEntries> staticMacEntriesList = elanInterface.getStaticMacEntries();
    List<PhysAddress> staticMacAddresses = Lists.newArrayList();
    boolean isInterfaceOperational = isOperational(interfaceInfo);
    if (ElanUtils.isNotEmpty(staticMacEntriesList)) {
        for (StaticMacEntries staticMacEntry : staticMacEntriesList) {
            InstanceIdentifier<MacEntry> macId = getMacEntryOperationalDataPath(elanInstanceName, staticMacEntry.getMacAddress());
            Optional<MacEntry> existingMacEntry = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, macId);
            if (existingMacEntry.isPresent()) {
                elanForwardingEntriesHandler.updateElanInterfaceForwardingTablesList(elanInstanceName, interfaceName, existingMacEntry.get().getInterface(), existingMacEntry.get(), tx);
            } else {
                elanForwardingEntriesHandler.addElanInterfaceForwardingTableList(elanInstanceName, interfaceName, staticMacEntry, tx);
            }
            if (isInterfaceOperational) {
                // Setting SMAC, DMAC, UDMAC in this DPN and also in other
                // DPNs
                String macAddress = staticMacEntry.getMacAddress().getValue();
                LOG.info("programming smac and dmacs for {} on source and other DPNs for elan {} and interface {}", macAddress, elanInstanceName, interfaceName);
                elanUtils.setupMacFlows(elanInstance, interfaceInfo, ElanConstants.STATIC_MAC_TIMEOUT, staticMacEntry.getMacAddress().getValue(), true, writeFlowGroupTx);
            }
        }
        if (isInterfaceOperational) {
            // on purpose.
            for (StaticMacEntries staticMacEntry : staticMacEntriesList) {
                staticMacAddresses.add(staticMacEntry.getMacAddress());
            }
            elanL2GatewayUtils.scheduleAddDpnMacInExtDevices(elanInstance.getElanInstanceName(), dpId, staticMacAddresses);
        }
    }
    List<ListenableFuture<Void>> futures = new ArrayList<>();
    futures.add(ElanUtils.waitForTransactionToComplete(tx));
    futures.add(ElanUtils.waitForTransactionToComplete(writeFlowGroupTx));
    if (isInterfaceOperational && !interfaceManager.isExternalInterface(interfaceName)) {
        // At this point, the interface is operational and D/SMAC flows have been configured, mark the port active
        try {
            Port neutronPort = neutronVpnManager.getNeutronPort(interfaceName);
            if (neutronPort != null) {
                NeutronUtils.updatePortStatus(interfaceName, NeutronUtils.PORT_STATUS_ACTIVE, broker);
            }
        } catch (IllegalArgumentException ex) {
            LOG.trace("Interface: {} is not part of Neutron Network", interfaceName);
        }
    }
    return futures;
}
Also used : ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) ArrayList(java.util.ArrayList) StaticMacEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries) BigInteger(java.math.BigInteger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 2 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 L2GwValidateCli method verifyL2GatewayConnections.

private void verifyL2GatewayConnections() {
    boolean isValid = true;
    for (L2gatewayConnection l2gatewayConnection : l2gatewayConnections) {
        L2gateway l2gateway = uuidToL2Gateway.get(l2gatewayConnection.getL2gatewayId());
        String logicalSwitchName = l2gatewayConnection.getNetworkId().getValue();
        List<Devices> devices = l2gateway.getDevices();
        for (Devices device : devices) {
            L2GatewayDevice l2GatewayDevice = l2GatewayCache.get(device.getDeviceName());
            isValid = verifyL2GatewayDevice(l2gateway, device, l2GatewayDevice);
            if (!isValid) {
                continue;
            }
            NodeId nodeId = new NodeId(l2GatewayDevice.getHwvtepNodeId());
            InstanceIdentifier<Node> nodeIid = topoIid.child(Node.class, new NodeKey(nodeId));
            isValid = verfiyLogicalSwitch(logicalSwitchName, nodeIid);
            if (isValid) {
                isValid = verifyMcastMac(logicalSwitchName, nodeIid);
                verifyVlanBindings(nodeIid, logicalSwitchName, device, l2gatewayConnection.getSegmentId());
                L2GatewayDevice elanL2gatewayDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(logicalSwitchName, nodeId.getValue());
                if (elanL2gatewayDevice == null) {
                    pw.println("Failed elan l2gateway device not found for network " + logicalSwitchName + " and device " + device.getDeviceName() + " " + l2GatewayDevice.getHwvtepNodeId() + " l2gw connection id " + l2gatewayConnection.getUuid());
                }
            }
        }
    }
}
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) L2gateway(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway) Devices(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection)

Example 3 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 ElanInstanceListener method remove.

@Override
protected void remove(final InstanceIdentifier<ElanInstance> identifier, final ElanInstance del) {
    elanClusterUtils.runOnlyInOwnerNode(del.getElanInstanceName(), "delete Elan instance", () -> {
        LOG.info("Elan instance {} deleted from Configuration tree ", del);
        List<L2gatewayConnection> connections = L2GatewayConnectionUtils.getL2GwConnectionsByElanName(this.broker, del.getElanInstanceName());
        if (connections.isEmpty()) {
            return Collections.emptyList();
        }
        ListenableFuture<Void> future = txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
            for (L2gatewayConnection connection : connections) {
                InstanceIdentifier<L2gatewayConnection> iid = InstanceIdentifier.create(Neutron.class).child(L2gatewayConnections.class).child(L2gatewayConnection.class, connection.getKey());
                tx.delete(LogicalDatastoreType.CONFIGURATION, iid);
            }
        });
        ListenableFutures.addErrorLogging(future, LOG, "Failed to delete associate L2 gateway connection while deleting network");
        return Collections.singletonList(future);
    });
}
Also used : L2gatewayConnections(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.L2gatewayConnections) L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection)

Example 4 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 ElanServiceProvider method handleExternalElanNetwork.

private void handleExternalElanNetwork(ElanInstance elanInstance, boolean update, BiFunction<ElanInstance, String, Void> function) {
    String elanInstanceName = elanInstance.getElanInstanceName();
    if (elanInstance.getPhysicalNetworkName() == null) {
        LOG.trace("No physical network attached to {}", elanInstanceName);
        return;
    }
    List<Node> nodes = southboundUtils.getOvsdbNodes();
    if (nodes == null || nodes.isEmpty()) {
        LOG.trace("No OVS nodes found while creating external network for ELAN {}", elanInstance.getElanInstanceName());
        return;
    }
    for (Node node : nodes) {
        if (bridgeMgr.isIntegrationBridge(node)) {
            if (update && !elanInstance.isExternal()) {
                DpnInterfaces dpnInterfaces = elanUtils.getElanInterfaceInfoByElanDpn(elanInstanceName, bridgeMgr.getDatapathId(node));
                if (dpnInterfaces == null || dpnInterfaces.getInterfaces().isEmpty()) {
                    continue;
                }
            }
            String interfaceName = bridgeMgr.getProviderInterfaceName(node, elanInstance.getPhysicalNetworkName());
            function.apply(elanInstance, interfaceName);
        }
    }
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces)

Example 5 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 VpnElanInterfaceChangeListener method add.

@Override
protected void add(InstanceIdentifier<ElanInterface> key, ElanInterface elanInterface) {
    String interfaceName = elanInterface.getName();
    if (!elanService.isExternalInterface(interfaceName)) {
        LOG.debug("add: Interface {} is not external. Ignoring", interfaceName);
        return;
    }
    Uuid networkId;
    try {
        networkId = new Uuid(elanInterface.getElanInstanceName());
    } catch (IllegalArgumentException e) {
        LOG.debug("add: ELAN instance {} for interface {} is not Uuid", elanInterface.getElanInstanceName(), elanInterface.getName());
        return;
    }
    Uuid vpnId = VpnUtil.getExternalNetworkVpnId(broker, networkId);
    if (vpnId == null) {
        LOG.debug("add: Network {} is not external or vpn-id missing. Ignoring interface {} on elan {}", networkId.getValue(), elanInterface.getName(), elanInterface.getElanInstanceName());
        return;
    }
    VpnInstanceNames vpnInstance = VpnHelper.getVpnInterfaceVpnInstanceNames(vpnId.getValue(), AssociatedSubnetType.V4AndV6Subnets);
    List<VpnInstanceNames> listVpn = new ArrayList<>();
    listVpn.add(vpnInstance);
    VpnInterface vpnInterface = new VpnInterfaceBuilder().setKey(new VpnInterfaceKey(interfaceName)).setVpnInstanceNames(listVpn).setScheduledForRemove(Boolean.FALSE).build();
    InstanceIdentifier<VpnInterface> vpnInterfaceIdentifier = VpnUtil.getVpnInterfaceIdentifier(interfaceName);
    VpnUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, vpnInterfaceIdentifier, vpnInterface);
    LOG.info("add: Added VPN interface {} with VPN-id {} elanInstance {}", interfaceName, vpnId.getValue(), elanInterface.getElanInstanceName());
}
Also used : VpnInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceBuilder) VpnInterfaceKey(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceKey) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) VpnInstanceNames(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames) VpnInterface(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface) ArrayList(java.util.ArrayList)

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