Search in sources :

Example 61 with Interfaces

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces in project netvirt by opendaylight.

the class NeutronvpnManager method updateVpnInternetForSubnet.

protected void updateVpnInternetForSubnet(Subnetmap sm, Uuid vpn, boolean isBeingAssociated) {
    LOG.debug("updateVpnInternetForSubnet: {} subnet {} with BGPVPN Internet {} ", isBeingAssociated ? "associating" : "dissociating", sm.getSubnetIp(), vpn.getValue());
    Uuid internalVpnId = sm.getVpnId();
    if (internalVpnId == null) {
        LOG.error("updateVpnInternetForSubnet: can not find Internal or BGPVPN Id for subnet {}, bailing out", sm.getId().getValue());
        return;
    }
    if (isBeingAssociated) {
        updateSubnetNode(sm.getId(), null, sm.getVpnId(), vpn);
    } else {
        updateSubnetNode(sm.getId(), null, sm.getVpnId(), null);
    }
    jobCoordinator.enqueueJob("VPN-" + vpn.getValue(), () -> singletonList(managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(wrtConfigTxn -> {
        if (isBeingAssociated) {
            updateVpnInterface(vpn, null, neutronvpnUtils.getNeutronPort(sm.getRouterInterfacePortId()), true, true, wrtConfigTxn);
        } else {
            removeVpnFromVpnInterface(vpn, neutronvpnUtils.getNeutronPort(sm.getRouterInterfacePortId()), wrtConfigTxn, sm);
        }
    })));
    // Check for ports on this subnet and update association of
    // corresponding vpn-interfaces to internet vpn
    List<Uuid> portList = sm.getPortList();
    if (portList != null) {
        for (Uuid port : portList) {
            LOG.debug("Updating vpn-interface for port {} isBeingAssociated {}", port.getValue(), isBeingAssociated);
            jobCoordinator.enqueueJob("PORT-" + port.getValue(), () -> {
                WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
                List<ListenableFuture<Void>> futures = new ArrayList<>();
                if (isBeingAssociated) {
                    updateVpnInterface(vpn, null, neutronvpnUtils.getNeutronPort(port), isBeingAssociated, false, wrtConfigTxn);
                } else {
                    removeVpnFromVpnInterface(vpn, neutronvpnUtils.getNeutronPort(port), wrtConfigTxn, sm);
                }
                futures.add(wrtConfigTxn.submit());
                return futures;
            });
        }
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Example 62 with Interfaces

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces in project netvirt by opendaylight.

the class NeutronvpnManager method removeSubnetFromVpn.

protected void removeSubnetFromVpn(final Uuid vpnId, Uuid subnet, Uuid internetVpnId) {
    Preconditions.checkArgument(vpnId != null || internetVpnId != null, "removeSubnetFromVpn: at least one VPN must be not null");
    LOG.debug("Removing subnet {} from vpn {}/{}", subnet.getValue(), vpnId, internetVpnId);
    Subnetmap sn = neutronvpnUtils.getSubnetmap(subnet);
    if (sn == null) {
        LOG.error("removeSubnetFromVpn: Subnetmap for subnet {} not found", subnet.getValue());
        return;
    }
    VpnMap vpnMap = null;
    VpnInstance vpnInstance = null;
    if (vpnId != null) {
        vpnMap = neutronvpnUtils.getVpnMap(vpnId);
        if (vpnMap == null) {
            LOG.error("No vpnMap for vpnId {}, cannot remove subnet {} from VPN", vpnId.getValue(), subnet.getValue());
            return;
        }
        vpnInstance = VpnHelper.getVpnInstance(dataBroker, vpnId.getValue());
    }
    if (internetVpnId == null) {
        internetVpnId = sn.getInternetVpnId();
    }
    if (internetVpnId != null) {
        vpnMap = neutronvpnUtils.getVpnMap(internetVpnId);
        if (vpnMap == null) {
            LOG.error("No vpnMap for vpnId {}, cannot remove subnet {}" + " from Internet VPN", internetVpnId.getValue(), subnet.getValue());
            return;
        }
    }
    if (vpnInstance != null && isVpnOfTypeL2(vpnInstance)) {
        neutronEvpnUtils.updateElanAndVpn(vpnInstance, sn.getNetworkId().getValue(), NeutronEvpnUtils.Operation.DELETE);
    }
    boolean subnetVpnAssociation = false;
    if (vpnId != null && sn.getVpnId() != null && sn.getVpnId().getValue().equals(vpnId.getValue())) {
        subnetVpnAssociation = true;
    } else if (internetVpnId != null && sn.getInternetVpnId() != null && sn.getInternetVpnId().getValue().matches(internetVpnId.getValue())) {
        subnetVpnAssociation = true;
    }
    if (subnetVpnAssociation == false) {
        LOG.error("Removing subnet : Subnetmap is not in VPN {}/{}, owns {} and {}", vpnId, internetVpnId, sn.getVpnId(), sn.getInternetVpnId());
        return;
    }
    // Check if there are ports on this subnet; remove corresponding vpn-interfaces
    List<Uuid> portList = sn.getPortList();
    final Uuid internetId = internetVpnId;
    if (portList != null) {
        for (final Uuid portId : portList) {
            LOG.debug("withdrawing subnet IP {} from vpn-interface {}", sn.getSubnetIp(), portId.getValue());
            final Port port = neutronvpnUtils.getNeutronPort(portId);
            jobCoordinator.enqueueJob("PORT-" + portId.getValue(), () -> {
                WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
                List<ListenableFuture<Void>> futures = new ArrayList<>();
                if (port != null) {
                    withdrawPortIpFromVpnIface(vpnId, internetId, port, sn, wrtConfigTxn);
                } else {
                    LOG.warn("Cannot proceed with withdrawPortIpFromVpnIface for port {} in subnet {} since " + "port is absent in Neutron config DS", portId.getValue(), subnet.getValue());
                }
                futures.add(wrtConfigTxn.submit());
                return futures;
            });
        }
    }
    // update subnet-vpn association
    removeFromSubnetNode(subnet, null, null, vpnId, null);
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) VpnMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMap) VpnInstance(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) ArrayList(java.util.ArrayList) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Example 63 with Interfaces

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces in project netvirt by opendaylight.

the class NeutronNetworkChangeListener method add.

@Override
protected void add(InstanceIdentifier<Network> identifier, Network input) {
    LOG.trace("Adding Network : key: {}, value={}", identifier, input);
    String networkId = input.getUuid().getValue();
    if (!NeutronvpnUtils.isNetworkTypeSupported(input)) {
        LOG.error("Neutronvpn doesn't support the provider type for given network {}", networkId);
        return;
    }
    Class<? extends NetworkTypeBase> networkType = input.getAugmentation(NetworkProviderExtension.class).getNetworkType();
    if (NeutronvpnUtils.isVlanOrVxlanNetwork(networkType) && NeutronUtils.getSegmentationIdFromNeutronNetwork(input, networkType) == null) {
        LOG.error("Segmentation ID is null for configured provider network {} of type {}. Abandoning any further " + "processing for the network", input.getUuid().getValue(), networkType);
        return;
    }
    neutronvpnUtils.addToNetworkCache(input);
    // Create ELAN instance for this network
    ElanInstance elanInstance = createElanInstance(input);
    if (NeutronvpnUtils.getIsExternal(input)) {
        // Create ELAN interface and IETF interfaces for the physical network
        elanService.createExternalElanNetwork(elanInstance);
        ProviderTypes providerNwType = NeutronvpnUtils.getProviderNetworkType(input);
        if (providerNwType == null) {
            LOG.error("Unable to get Network Provider Type for network {}", networkId);
            return;
        }
        LOG.trace("External Network Provider Type for network {} is {}", networkId, providerNwType.getName());
        nvpnNatManager.addExternalNetwork(input);
        if (NeutronvpnUtils.isFlatOrVlanNetwork(input)) {
            nvpnManager.createL3InternalVpn(input.getUuid(), null, null, null, null, null, null, null);
            nvpnManager.createExternalVpnInterfaces(input.getUuid());
        }
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ProviderTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes) NetworkProviderExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.NetworkProviderExtension)

Example 64 with Interfaces

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces in project netvirt by opendaylight.

the class NeutronPortChangeListener method handleNeutronPortDeleted.

private void handleNeutronPortDeleted(final Port port) {
    final String portName = port.getUuid().getValue();
    final Uuid portId = port.getUuid();
    final List<FixedIps> portIpsList = port.getFixedIps();
    jobCoordinator.enqueueJob("PORT- " + portName, () -> {
        WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
        List<ListenableFuture<Void>> futures = new ArrayList<>();
        if (!(NeutronUtils.isPortVnicTypeNormal(port) || isPortTypeSwitchdev(port))) {
            for (FixedIps ip : portIpsList) {
                // remove direct port from subnetMaps config DS
                nvpnManager.removePortsFromSubnetmapNode(ip.getSubnetId(), null, portId);
            }
            LOG.info("Port {} is not a normal and not a direct with switchdev VNIC type ;" + "Skipping OF Port interfaces removal", portName);
            return futures;
        }
        Uuid vpnId = null;
        Set<Uuid> routerIds = new HashSet<>();
        Uuid internetVpnId = null;
        for (FixedIps ip : portIpsList) {
            Subnetmap subnetMap = nvpnManager.removePortsFromSubnetmapNode(ip.getSubnetId(), portId, null);
            if (subnetMap == null) {
                continue;
            }
            if (subnetMap.getVpnId() != null) {
                // can't use NeutronvpnUtils.getVpnForNetwork to optimise here, because it gives BGPVPN id
                // obtained subnetMaps belongs to one network => vpnId must be the same for each port Ip
                vpnId = subnetMap.getVpnId();
            }
            if (subnetMap.getRouterId() != null) {
                routerIds.add(subnetMap.getRouterId());
            }
            internetVpnId = subnetMap.getInternetVpnId();
        }
        if (vpnId != null || internetVpnId != null) {
            // remove vpn-interface for this neutron port
            LOG.debug("removing VPN Interface for port {}", portName);
            if (!routerIds.isEmpty()) {
                for (Uuid routerId : routerIds) {
                    nvpnManager.removeFromNeutronRouterInterfacesMap(routerId, portName);
                }
            }
            nvpnManager.deleteVpnInterface(portName, null, /* vpn-id */
            wrtConfigTxn);
        }
        // Remove of-port interface for this neutron port
        // ELAN interface is also implicitly deleted as part of this operation
        LOG.debug("Of-port-interface removal for port {}", portName);
        deleteOfPortInterface(port, wrtConfigTxn);
        // dissociate fixedIP from floatingIP if associated
        nvpnManager.dissociatefixedIPFromFloatingIP(port.getUuid().getValue());
        futures.add(wrtConfigTxn.submit());
        return futures;
    });
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) HashSet(java.util.HashSet)

Example 65 with Interfaces

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces in project netvirt by opendaylight.

the class NeutronRouterChangeListener method remove.

@Override
protected void remove(InstanceIdentifier<Router> identifier, Router input) {
    LOG.trace("Removing router : key: {}, value={}", identifier, input);
    Uuid routerId = input.getUuid();
    /*External Router and networks is handled before deleting the internal VPN, as there is dependency
        on vpn operational data to release Lport tag in case of L3VPN over VxLAN*/
    if (input.getExternalGatewayInfo() != null) {
        Uuid extNetId = input.getExternalGatewayInfo().getExternalNetworkId();
        List<ExternalFixedIps> externalFixedIps = input.getExternalGatewayInfo().getExternalFixedIps();
        nvpnNatManager.removeExternalNetworkFromRouter(extNetId, input, externalFixedIps);
    }
    // NOTE: Pass an empty routerSubnetIds list, as router interfaces
    // will be removed from VPN by invocations from NeutronPortChangeListener
    List<Uuid> routerSubnetIds = new ArrayList<>();
    nvpnManager.handleNeutronRouterDeleted(routerId, routerSubnetIds);
    neutronvpnUtils.removeFromRouterCache(input);
}
Also used : ExternalFixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.external_gateway_info.ExternalFixedIps) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)26 BigInteger (java.math.BigInteger)24 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)23 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)14 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)10 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)9 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)7 HashSet (java.util.HashSet)7 ExecutionException (java.util.concurrent.ExecutionException)7 HashMap (java.util.HashMap)4 List (java.util.List)4 Test (org.junit.Test)4 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)4 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)4 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)4 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)4 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)4 RouterPorts (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts)4 Ports (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports)4 InternalToExternalPortMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap)4