Search in sources :

Example 16 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 ElanDpnInterfacesListener method add.

@Override
protected void add(InstanceIdentifier<DpnInterfaces> identifier, final DpnInterfaces dpnInterfaces) {
    final String elanName = getElanName(identifier);
    BigInteger addDpnId = dpnInterfaces.getDpId();
    LOG.debug("ELAN interfaces {} added on DPN {} for Elan {}", dpnInterfaces.getInterfaces(), addDpnId, elanName);
    Optional<ElanServiceChainState> elanServiceChainState = ElanServiceChainUtils.getElanServiceChainState(broker, elanName);
    if (elanServiceChainState.isPresent()) {
        List<ElanToPseudoPortData> elanToPseudoPortDataList = elanServiceChainState.get().getElanToPseudoPortData();
        for (ElanToPseudoPortData elanToPseudoPortData : elanToPseudoPortDataList) {
            Long scfTag = elanToPseudoPortData.getScfTag();
            Long elanLportTag = elanToPseudoPortData.getElanLportTag();
            if (elanLportTag != null && scfTag != null) {
                short tableId = NwConstants.SCF_DOWN_SUB_FILTER_TCP_BASED_TABLE;
                handleUpdate(addDpnId, elanName, tableId, elanLportTag.intValue(), /*21 bit*/
                scfTag, NwConstants.ADD_FLOW);
            } else {
                LOG.debug("Could not find lportTag for ELAN={}", elanName);
            }
        }
    }
}
Also used : BigInteger(java.math.BigInteger) ElanToPseudoPortData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.elan.to.pseudo.port.data.list.ElanToPseudoPortData) ElanServiceChainState(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.ElanServiceChainState)

Example 17 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 EtreeInterfaceGet method doExecute.

@Override
protected Object doExecute() {
    LOG.debug("Executing Get EtreeInterface command for the corresponding Etree Instance {}", etreeName);
    if (etreeName != null) {
        ElanInstance elanInstance = elanProvider.getElanInstance(etreeName);
        if (elanInstance == null || elanInstance.getAugmentation(EtreeInstance.class) == null) {
            session.getConsole().println("Etree instance doesn't exist or isn't configured as etree: " + etreeName);
            return null;
        }
        List<String> elanInterfaces = elanProvider.getElanInterfaces(etreeName);
        if (elanInterfaces == null) {
            session.getConsole().println("No Etree Interfaces present for ELan Instance:" + etreeName);
            return null;
        }
        session.getConsole().println(getEtreeInterfaceHeaderOutput());
        displayInterfaces(elanInstance, elanInterfaces);
    } else {
        List<ElanInstance> elanInstances = elanProvider.getElanInstances();
        if (!elanInstances.isEmpty()) {
            session.getConsole().println(getEtreeInterfaceHeaderOutput());
            for (ElanInstance elanInstance : elanInstances) {
                List<String> elanInterfaces = elanProvider.getElanInterfaces(elanInstance.getElanInstanceName());
                displayInterfaces(elanInstance, elanInterfaces);
                session.getConsole().println("\n");
            }
        }
    }
    return null;
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)

Example 18 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 ElanInterfaceGet method doExecute.

@Override
protected Object doExecute() {
    LOG.debug("Executing Get ElanInterface command for the corresponding Elan Instance for {}", elanName);
    if (elanName != null) {
        ElanInstance elanInstance = elanProvider.getElanInstance(elanName);
        List<String> elanInterfaces = elanProvider.getElanInterfaces(elanName);
        if (elanInterfaces == null) {
            session.getConsole().println("No Elan Interfaces present for ELan Instance:" + elanName);
            return null;
        }
        session.getConsole().println(getElanInterfaceHeaderOutput());
        displayInterfaces(elanInstance, elanInterfaces);
    } else {
        List<ElanInstance> elanInstances = elanProvider.getElanInstances();
        if (!elanInstances.isEmpty()) {
            session.getConsole().println(getElanInterfaceHeaderOutput());
            for (ElanInstance elanInstance : elanInstances) {
                List<String> elanInterfaces = elanProvider.getElanInterfaces(elanInstance.getElanInstanceName());
                displayInterfaces(elanInstance, elanInterfaces);
                session.getConsole().println("\n");
            }
        }
    }
    return null;
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)

Example 19 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 addSubnetToVpn.

protected void addSubnetToVpn(@Nullable final Uuid vpnId, Uuid subnet, @Nullable final Uuid internetVpnId) {
    LOG.debug("addSubnetToVpn: Adding subnet {} to vpn {}", subnet.getValue(), vpnId != null ? vpnId.getValue() : internetVpnId.getValue());
    Subnetmap sn = updateSubnetNode(subnet, null, vpnId, internetVpnId);
    if (sn == null) {
        LOG.error("addSubnetToVpn: subnetmap is null, cannot add subnet {} to VPN {}", subnet.getValue(), vpnId != null ? vpnId.getValue() : internetVpnId.getValue());
        return;
    }
    if (vpnId != null) {
        VpnMap vpnMap = neutronvpnUtils.getVpnMap(vpnId);
        if (vpnMap == null) {
            LOG.error("addSubnetToVpn: No vpnMap for vpnId {}," + " cannot add subnet {} to VPN", vpnId.getValue(), subnet.getValue());
            return;
        }
        final VpnInstance vpnInstance = VpnHelper.getVpnInstance(dataBroker, vpnId.getValue());
        LOG.debug("addSubnetToVpn: VpnInstance {}", vpnInstance.toString());
        if (isVpnOfTypeL2(vpnInstance)) {
            neutronEvpnUtils.updateElanAndVpn(vpnInstance, sn.getNetworkId().getValue(), NeutronEvpnUtils.Operation.ADD);
        }
    }
    if (internetVpnId != null) {
        VpnMap vpnMap = neutronvpnUtils.getVpnMap(internetVpnId);
        if (vpnMap == null) {
            LOG.error("addSubnetToVpn: No vpnMap for InternetVpnId {}, cannot add " + "subnet {} to VPN", internetVpnId.getValue(), subnet.getValue());
            return;
        }
    }
    final Uuid internetId = internetVpnId;
    // Check if there are ports on this subnet and add corresponding vpn-interfaces
    List<Uuid> portList = sn.getPortList();
    if (portList != null) {
        for (final Uuid portId : portList) {
            String vpnInfName = portId.getValue();
            VpnInterface vpnIface = VpnHelper.getVpnInterface(dataBroker, vpnInfName);
            Port port = neutronvpnUtils.getNeutronPort(portId);
            if (port == null) {
                LOG.error("addSubnetToVpn: Cannot proceed with addSubnetToVpn for port {} in subnet {} " + "since port is absent in Neutron config DS", portId.getValue(), subnet.getValue());
                continue;
            }
            final Boolean isRouterInterface = port.getDeviceOwner().equals(NeutronConstants.DEVICE_OWNER_ROUTER_INF) ? true : false;
            jobCoordinator.enqueueJob("PORT-" + portId.getValue(), () -> singletonList(managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(wrtConfigTxn -> {
                Adjacencies portAdj = createPortIpAdjacencies(port, isRouterInterface, wrtConfigTxn, sn, vpnIface);
                if (vpnIface == null) {
                    LOG.trace("addSubnetToVpn: create new VpnInterface for Port {}", vpnInfName);
                    Set<Uuid> listVpn = new HashSet<Uuid>();
                    if (vpnId != null) {
                        listVpn.add(vpnId);
                    }
                    if (internetId != null) {
                        listVpn.add(internetId);
                    }
                    writeVpnInterfaceToDs(listVpn, vpnInfName, portAdj, isRouterInterface, wrtConfigTxn);
                    if (sn.getRouterId() != null) {
                        addToNeutronRouterInterfacesMap(sn.getRouterId(), portId.getValue());
                    }
                } else {
                    LOG.trace("update VpnInterface for Port {} with adj {}", vpnInfName, portAdj);
                    if (vpnId != null) {
                        updateVpnInterfaceWithAdjacencies(vpnId, vpnInfName, portAdj, wrtConfigTxn);
                    }
                    if (internetId != null) {
                        updateVpnInterfaceWithAdjacencies(internetId, vpnInfName, portAdj, wrtConfigTxn);
                    }
                }
            })));
        }
    }
}
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) 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) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) Adjacencies(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.Adjacencies) HashSet(java.util.HashSet)

Example 20 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 updateVpnForSubnet.

private Subnetmap updateVpnForSubnet(Uuid oldVpnId, Uuid newVpnId, Uuid subnet, boolean isBeingAssociated) {
    LOG.debug("Moving subnet {} from oldVpn {} to newVpn {} ", subnet.getValue(), oldVpnId.getValue(), newVpnId.getValue());
    Uuid networkUuid = neutronvpnUtils.getSubnetmap(subnet).getNetworkId();
    Network network = neutronvpnUtils.getNeutronNetwork(networkUuid);
    boolean netIsExternal = NeutronvpnUtils.getIsExternal(network);
    Uuid vpnExtUuid = netIsExternal ? null : neutronvpnUtils.getInternetvpnUuidBoundToSubnetRouter(subnet);
    Subnetmap sn = updateSubnetNode(subnet, null, newVpnId, vpnExtUuid);
    if (sn == null) {
        LOG.error("Updating subnet {} with newVpn {} failed", subnet.getValue(), newVpnId.getValue());
        return sn;
    }
    // CAUTION:  Please DONOT make the router interface VPN Movement as an asynchronous commit again !
    try {
        WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
        updateVpnInterface(newVpnId, oldVpnId, neutronvpnUtils.getNeutronPort(sn.getRouterInterfacePortId()), isBeingAssociated, true, wrtConfigTxn);
        wrtConfigTxn.submit().checkedGet();
    } catch (TransactionCommitFailedException e) {
        LOG.error("Failed to update router interface {} in subnet {} from oldVpnId {} to newVpnId {}, returning", sn.getRouterInterfacePortId().getValue(), subnet.getValue(), oldVpnId, newVpnId);
        return sn;
    }
    // Check for ports on this subnet and update association of
    // corresponding vpn-interfaces to external vpn
    List<Uuid> portList = sn.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<>();
                updateVpnInterface(newVpnId, oldVpnId, neutronvpnUtils.getNeutronPort(port), isBeingAssociated, false, wrtConfigTxn);
                futures.add(wrtConfigTxn.submit());
                return futures;
            });
        }
    }
    return sn;
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) 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) ArrayList(java.util.ArrayList) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

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