Search in sources :

Example 6 with DpnToInterface

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface in project netvirt by opendaylight.

the class UnderlayNetworkDpnListener method update.

@Override
protected void update(InstanceIdentifier<DpnToInterface> key, DpnToInterface origDpnToInterface, DpnToInterface updatedDpnToInterface) {
    String underlayNetwork = key.firstKeyOf(UnderlayNetwork.class).getNetworkName();
    BigInteger dpId = updatedDpnToInterface.getDpId();
    LOG.info("DPN {} updated to underlay network {} with tunnels {}", dpId, underlayNetwork, updatedDpnToInterface.getTunnelInterface());
    List<PolicyProfile> profiles = policyServiceUtil.getUnderlayNetworkPolicyProfiles(underlayNetwork);
    if (profiles == null || profiles.isEmpty()) {
        LOG.debug("No policy profiles found for underlay network {}", underlayNetwork);
        return;
    }
    List<TunnelInterface> origTunnelInterfaces = origDpnToInterface.getTunnelInterface();
    if (origTunnelInterfaces == null) {
        origTunnelInterfaces = Collections.emptyList();
    }
    List<TunnelInterface> updatedTunnelInterfaces = updatedDpnToInterface.getTunnelInterface();
    if (updatedTunnelInterfaces == null) {
        updatedTunnelInterfaces = Collections.emptyList();
    }
    List<TunnelInterface> removedTunnelInterfaces = new ArrayList<>(origTunnelInterfaces);
    removedTunnelInterfaces.removeAll(updatedTunnelInterfaces);
    List<TunnelInterface> addedTunnelInterfaces = new ArrayList<>(updatedTunnelInterfaces);
    addedTunnelInterfaces.removeAll(origTunnelInterfaces);
    populatePolicyGroupBucketsToDpn(underlayNetwork, profiles, removedTunnelInterfaces, dpId, NwConstants.DEL_FLOW);
    populatePolicyGroupsToDpn(profiles, addedTunnelInterfaces, dpId, NwConstants.ADD_FLOW);
    populatePolicyGroupBucketsToDpn(underlayNetwork, profiles, addedTunnelInterfaces, dpId, NwConstants.ADD_FLOW);
}
Also used : UnderlayNetwork(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.UnderlayNetwork) PolicyProfile(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.PolicyProfile) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) TunnelInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterface)

Example 7 with DpnToInterface

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface in project netvirt by opendaylight.

the class PolicyRouteGroupProgrammer method programPolicyClassifierGroupBuckets.

public void programPolicyClassifierGroupBuckets(String policyClassifier, List<String> underlayNetworks, int addOrRemove) {
    if (underlayNetworks == null) {
        return;
    }
    coordinator.enqueueJob(policyClassifier, () -> {
        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
        for (int idx = 0; idx < underlayNetworks.size(); idx++) {
            final int bucketId = idx;
            String underlayNetwork = underlayNetworks.get(idx);
            List<DpnToInterface> dpnToInterfaceList = policyServiceUtil.getUnderlayNetworkDpnToInterfaces(underlayNetwork);
            dpnToInterfaceList.forEach(dpnToInterface -> {
                BigInteger dpId = dpnToInterface.getDpId();
                List<TunnelInterface> tunnelInterfaces = dpnToInterface.getTunnelInterface();
                programPolicyClassifierGroupBuckets(policyClassifier, tunnelInterfaces, dpId, bucketId, addOrRemove, tx);
            });
        }
        return Collections.singletonList(tx.submit());
    });
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DpnToInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.DpnToInterface) BigInteger(java.math.BigInteger) TunnelInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterface)

Example 8 with DpnToInterface

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface in project genius by opendaylight.

the class InterfaceManagerCommonUtils method getAllInterfaces.

public List<InterfaceNameEntry> getAllInterfaces(BigInteger dpnId) {
    DpnToInterfaceKey dpnToInterfaceKey = new DpnToInterfaceKey(dpnId);
    InstanceIdentifier<DpnToInterface> dpninterfaceListId = InstanceIdentifier.builder(DpnToInterfaceList.class).child(DpnToInterface.class, dpnToInterfaceKey).build();
    Optional<DpnToInterface> interfaceList = IfmUtil.read(LogicalDatastoreType.OPERATIONAL, dpninterfaceListId, dataBroker);
    if (interfaceList.isPresent()) {
        return interfaceList.get().getInterfaceNameEntry();
    }
    return null;
}
Also used : DpnToInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface) DpnToInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterfaceKey)

Example 9 with DpnToInterface

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface in project genius by opendaylight.

the class InterfaceManagerServiceImpl method getDpnInterfaceList.

@Override
public ListenableFuture<GetDpnInterfaceListOutput> getDpnInterfaceList(GetDpnInterfaceListInput input) {
    BigInteger dpnid = input.getDpid();
    InstanceIdentifier<DpnToInterface> id = InstanceIdentifier.builder(DpnToInterfaceList.class).child(DpnToInterface.class, new DpnToInterfaceKey(dpnid)).build();
    Optional<DpnToInterface> entry = IfmUtil.read(LogicalDatastoreType.OPERATIONAL, id, dataBroker);
    if (!entry.isPresent()) {
        LOG.warn("Could not find Operational DpnToInterface info for DPN {}. Returning empty list", dpnid);
        return buildEmptyInterfaceListResult();
    }
    List<InterfaceNameEntry> interfaceNameEntries = entry.get().getInterfaceNameEntry();
    if (interfaceNameEntries == null || interfaceNameEntries.isEmpty()) {
        LOG.debug("No Interface list found in Operational for DPN {}", dpnid);
        return buildEmptyInterfaceListResult();
    }
    List<Interfaces> interfaceList = new ArrayList<>();
    interfaceNameEntries.forEach((interfaceNameEntry) -> {
        InterfacesBuilder intf = new InterfacesBuilder().setInterfaceName(interfaceNameEntry.getInterfaceName()).setInterfaceType(interfaceNameEntry.getInterfaceType());
        interfaceList.add(intf.build());
    });
    // TODO as above, simplify the success case later, as we have the failure case below
    return Futures.immediateFuture(new GetDpnInterfaceListOutputBuilder().setInterfaces(interfaceList).build());
}
Also used : Interfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.get.dpn._interface.list.output.Interfaces) InterfaceNameEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntry) GetDpnInterfaceListOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListOutputBuilder) DpnToInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface) DpnToInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterfaceKey) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) InterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.get.dpn._interface.list.output.InterfacesBuilder)

Aggregations

BigInteger (java.math.BigInteger)5 TunnelInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterface)5 DpnToInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface)3 DpnToInterfaceKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterfaceKey)3 UnderlayNetwork (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.UnderlayNetwork)3 DpnToInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.DpnToInterface)3 PolicyProfile (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.PolicyProfile)3 ArrayList (java.util.ArrayList)2 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)2 InterfaceNameEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntry)2 DpnToInterfaceList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.DpnToInterfaceList)1 InterfaceNameEntryKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntryKey)1 GetDpnInterfaceListOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListOutputBuilder)1 Interfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.get.dpn._interface.list.output.Interfaces)1 InterfacesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.get.dpn._interface.list.output.InterfacesBuilder)1 DpnToInterfaceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.DpnToInterfaceBuilder)1