Search in sources :

Example 6 with Network

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp_allocation_pool.rev161214.dhcp_allocation_pool.Network in project netvirt by opendaylight.

the class SubnetRoutePacketInHandler method handleInternalVpnSubnetRoutePacket.

private void handleInternalVpnSubnetRoutePacket(BigInteger metadata, byte[] dstIp, String srcIpStr, String dstIpStr, int destinationAddress, String vpnIdVpnInstanceName, long elanTag) throws InterruptedException, ExecutionException, UnknownHostException {
    String vmVpnInterfaceName = VpnUtil.getVpnInterfaceName(odlInterfaceRpcService, metadata);
    if (isTunnel(vmVpnInterfaceName)) {
        handlePacketFromTunnelToExternalNetwork(vpnIdVpnInstanceName, srcIpStr, dstIp, elanTag);
    }
    VpnInterface vmVpnInterface = VpnUtil.getVpnInterface(dataBroker, vmVpnInterfaceName);
    if (vmVpnInterface == null) {
        LOG.error("Vpn interface {} doesn't exist.", vmVpnInterfaceName);
        VpnManagerCounters.subnet_route_packet_failed.inc();
        return;
    }
    if (VpnHelper.doesVpnInterfaceBelongToVpnInstance(vpnIdVpnInstanceName, vmVpnInterface.getVpnInstanceNames()) && !VpnUtil.isBgpVpnInternet(dataBroker, vpnIdVpnInstanceName)) {
        LOG.trace("Unknown IP is in internal network");
        handlePacketToInternalNetwork(dstIp, dstIpStr, destinationAddress, elanTag);
    } else {
        LOG.trace("Unknown IP is in external network");
        String vpnName = VpnUtil.getInternetVpnFromVpnInstanceList(dataBroker, vmVpnInterface.getVpnInstanceNames());
        if (vpnName != null) {
            handlePacketToExternalNetwork(new Uuid(vpnIdVpnInstanceName), vpnName, dstIp, elanTag);
        } else {
            vpnName = VpnHelper.getFirstVpnNameFromVpnInterface(vmVpnInterface);
            LOG.trace("Unknown IP is in external network, but internet VPN not found." + " fallback to first VPN");
            handlePacketToExternalNetwork(new Uuid(vpnIdVpnInstanceName), vpnName, dstIp, elanTag);
        }
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) VpnInterface(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface)

Example 7 with Network

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp_allocation_pool.rev161214.dhcp_allocation_pool.Network in project netvirt by opendaylight.

the class SubnetmapChangeListener method add.

@Override
protected void add(InstanceIdentifier<Subnetmap> identifier, Subnetmap subnetmap) {
    LOG.debug("SubnetmapChangeListener add subnetmap method - key: {}, value: {}", identifier, subnetmap);
    Uuid subnetId = subnetmap.getId();
    Network network = VpnUtil.getNeutronNetwork(dataBroker, subnetmap.getNetworkId());
    if (network == null) {
        LOG.error("SubnetMapChangeListener:add: network was not found for subnetId {}", subnetId.getValue());
        return;
    }
    if (VpnUtil.getIsExternal(network)) {
        LOG.debug("SubnetmapListener:add: provider subnetwork {} is handling in " + "ExternalSubnetVpnInstanceListener", subnetId.getValue());
        return;
    }
    String elanInstanceName = subnetmap.getNetworkId().getValue();
    long elanTag = getElanTag(elanInstanceName);
    if (elanTag == 0L) {
        LOG.error("SubnetMapChangeListener:add: unable to fetch elantag from ElanInstance {} for subnet {}", elanInstanceName, subnetId.getValue());
        return;
    }
    if (subnetmap.getVpnId() != null) {
        boolean isBgpVpn = !subnetmap.getVpnId().equals(subnetmap.getRouterId());
        LOG.info("SubnetMapChangeListener:add: subnetmap {} with elanTag {} to VPN {}", subnetmap, elanTag, subnetmap.getVpnId());
        vpnSubnetRouteHandler.onSubnetAddedToVpn(subnetmap, isBgpVpn, elanTag);
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Network(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)

Example 8 with Network

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp_allocation_pool.rev161214.dhcp_allocation_pool.Network in project netvirt by opendaylight.

the class NetvirtProviderTest method getLogicalInterfacesFromNeutronNetwork.

@Test
public void getLogicalInterfacesFromNeutronNetwork() {
    // Network doesnt exist
    NeutronNetworkBuilder nwBuilder = new NeutronNetworkBuilder();
    nwBuilder.setNetworkUuid(NW_UUID_NOEXIST_STR);
    List<String> interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
    assertTrue(interfaces.isEmpty());
    // Network exists, subnet list empty
    createNetworkMap(NW_UUID_STR);
    nwBuilder = new NeutronNetworkBuilder();
    nwBuilder.setNetworkUuid(NW_UUID_STR);
    interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
    assertTrue(interfaces.isEmpty());
    // Network exists, subnet does not exist
    createNetworkMap(NW_UUID_STR, SUBNET_UUID_STR, false, EMPTY_STR);
    nwBuilder = new NeutronNetworkBuilder();
    nwBuilder.setNetworkUuid(NW_UUID_STR);
    interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
    assertTrue(interfaces.isEmpty());
    // Network exists, subnet exists, no ports
    createNetworkMap(NW_UUID_STR, SUBNET_UUID_STR, true, EMPTY_STR);
    nwBuilder = new NeutronNetworkBuilder();
    nwBuilder.setNetworkUuid(NW_UUID_STR);
    interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
    assertTrue(interfaces.isEmpty());
    // Network exists, subnet exists, port exists
    createNetworkMap(NW_UUID_STR, SUBNET_UUID_STR, true, PORT_UUID_STR);
    nwBuilder = new NeutronNetworkBuilder();
    nwBuilder.setNetworkUuid(NW_UUID_STR);
    interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
    assertFalse(interfaces.isEmpty());
}
Also used : NeutronNetworkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NeutronNetworkBuilder) Test(org.junit.Test) ConstantSchemaAbstractDataBrokerTest(org.opendaylight.controller.md.sal.binding.test.ConstantSchemaAbstractDataBrokerTest)

Example 9 with Network

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp_allocation_pool.rev161214.dhcp_allocation_pool.Network in project netvirt by opendaylight.

the class ExternalNetworkGroupInstaller method installExtNetGroupEntries.

public void installExtNetGroupEntries(Uuid networkId, BigInteger dpnId) {
    if (networkId == null) {
        return;
    }
    List<Uuid> subnetIds = NatUtil.getSubnetIdsFromNetworkId(broker, networkId);
    if (subnetIds.isEmpty()) {
        LOG.error("installExtNetGroupEntries : No subnet ids associated network id {}", networkId.getValue());
        return;
    }
    for (Uuid subnetId : subnetIds) {
        String macAddress = NatUtil.getSubnetGwMac(broker, subnetId, networkId.getValue());
        installExtNetGroupEntry(networkId, subnetId, dpnId, macAddress);
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)

Example 10 with Network

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp_allocation_pool.rev161214.dhcp_allocation_pool.Network in project netvirt by opendaylight.

the class ExternalNetworksChangeListener method update.

@Override
protected void update(InstanceIdentifier<Networks> identifier, Networks original, Networks update) {
    // Check for VPN disassociation
    Uuid originalVpn = original.getVpnid();
    Uuid updatedVpn = update.getVpnid();
    coordinator.enqueueJob(NatConstants.NAT_DJC_PREFIX + update.getKey(), () -> {
        WriteTransaction writeFlowInvTx = dataBroker.newWriteOnlyTransaction();
        List<ListenableFuture<Void>> futures = new ArrayList<>();
        if (originalVpn == null && updatedVpn != null) {
            // external network is dis-associated from L3VPN instance
            associateExternalNetworkWithVPN(update, writeFlowInvTx);
        } else if (originalVpn != null && updatedVpn == null) {
            // external network is associated with vpn
            disassociateExternalNetworkFromVPN(update, originalVpn.getValue());
            // Remove the SNAT entries
            removeSnatEntries(original, original.getId(), writeFlowInvTx);
        }
        futures.add(NatUtil.waitForTransactionToComplete(writeFlowInvTx));
        return futures;
    }, NatConstants.NAT_DJC_MAX_RETRIES);
}
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)

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