use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.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());
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.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());
}
Aggregations