use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces in project netvirt by opendaylight.
the class VpnServiceElanDpnInterfacesListener method update.
@Override
protected void update(InstanceIdentifier<DpnInterfaces> identifier, DpnInterfaces original, DpnInterfaces update) {
LOG.info("received Dpninterfaces update event for dpn {}", update.getDpId());
BigInteger dpnId = update.getDpId();
String elanInstanceName = identifier.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
ElanInstance elanInstance = VpnUtil.getElanInstanceByName(dataBroker, elanInstanceName);
String vpnName = VpnUtil.getVpnNameFromElanIntanceName(dataBroker, elanInstanceName);
if (vpnName == null) {
return;
}
String primaryRd = VpnUtil.getPrimaryRd(dataBroker, vpnName);
if (elanInstance != null && !elanInstance.isExternal() && VpnUtil.isVlan(elanInstance)) {
jobCoordinator.enqueueJob(elanInstance.getElanInstanceName(), () -> {
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeConfigTxn -> {
List<String> addedInterfaces = getUpdatedInterfaceList(update.getInterfaces(), original.getInterfaces());
for (String addedInterface : addedInterfaces) {
if (interfaceManager.isExternalInterface(addedInterface)) {
InstanceIdentifier<VpnToDpnList> id = VpnUtil.getVpnToDpnListIdentifier(primaryRd, dpnId);
Optional<VpnToDpnList> dpnInVpn = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
if (!dpnInVpn.isPresent() || (dpnInVpn.get().getVpnInterfaces() != null && dpnInVpn.get().getVpnInterfaces().size() != 1)) {
return;
}
if (!VpnUtil.shouldPopulateFibForVlan(dataBroker, vpnName, elanInstanceName, dpnId, interfaceManager)) {
return;
}
long vpnId = VpnUtil.getVpnId(dataBroker, vpnName);
fibManager.populateFibOnNewDpn(dpnId, vpnId, primaryRd, null);
break;
}
}
List<String> deletedInterfaces = getUpdatedInterfaceList(original.getInterfaces(), update.getInterfaces());
if (!deletedInterfaces.isEmpty()) {
String routerPortUuid = VpnUtil.getRouterPordIdFromElanInstance(dataBroker, elanInstanceName);
if (update.getInterfaces().size() == 2 && update.getInterfaces().contains(routerPortUuid)) {
VpnUtil.removeRouterPortFromElanForVlanInDpn(vpnName, dpnId, dataBroker);
}
}
}));
});
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces in project netvirt by opendaylight.
the class DhcpServiceUtils method getDpnsForElan.
@Nonnull
public static List<BigInteger> getDpnsForElan(String elanInstanceName, DataBroker broker) {
List<BigInteger> elanDpns = new LinkedList<>();
InstanceIdentifier<ElanDpnInterfacesList> elanDpnInstanceIdentifier = InstanceIdentifier.builder(ElanDpnInterfaces.class).child(ElanDpnInterfacesList.class, new ElanDpnInterfacesListKey(elanInstanceName)).build();
Optional<ElanDpnInterfacesList> elanDpnOptional = MDSALUtil.read(broker, LogicalDatastoreType.OPERATIONAL, elanDpnInstanceIdentifier);
if (elanDpnOptional.isPresent()) {
List<DpnInterfaces> dpns = elanDpnOptional.get().getDpnInterfaces();
for (DpnInterfaces dpnInterfaces : dpns) {
elanDpns.add(dpnInterfaces.getDpId());
}
}
return elanDpns;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces in project netvirt by opendaylight.
the class ElanDpnInterfacesListener method add.
@Override
protected void add(InstanceIdentifier<DpnInterfaces> identifier, DpnInterfaces dpnInterfaces) {
LOG.debug("received Dpninterfaces add event for dpn {}", dpnInterfaces.getDpId());
BigInteger dpnId = dpnInterfaces.getDpId();
String elanInstanceName = identifier.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
// on br-int patch port for this DPN
if (elanInstance != null && !elanInstance.isExternal() && ElanUtils.isVlan(elanInstance)) {
jobCoordinator.enqueueJob(dpnId.toString(), () -> {
LOG.debug("creating vlan member intf for elan {}, dpn {}", elanInstance.getPhysicalNetworkName(), dpnId);
elanService.createExternalElanNetwork(elanInstance, dpnId);
return Collections.emptyList();
});
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces in project netvirt by opendaylight.
the class ElanDpnInterfacesListener method update.
@Override
protected void update(InstanceIdentifier<DpnInterfaces> identifier, DpnInterfaces original, DpnInterfaces update) {
LOG.debug("received Dpninterfaces update event for dpn {}", update.getDpId());
BigInteger dpnId = update.getDpId();
String elanInstanceName = identifier.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
if (elanInstance != null && !elanInstance.isExternal() && ElanUtils.isVlan(elanInstance)) {
List<String> interfaces = update.getInterfaces();
// trigger deletion for vlan provider intf on the DPN for the vlan provider network
if (interfaces.size() == 1 && interfaceManager.isExternalInterface(interfaces.get(0))) {
LOG.debug("deleting vlan prv intf for elan {}, dpn {}", elanInstanceName, dpnId);
jobCoordinator.enqueueJob(dpnId.toString(), () -> {
elanService.deleteExternalElanNetwork(elanInstance, dpnId);
return Collections.emptyList();
});
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces in project netvirt by opendaylight.
the class ElanDpnToTransportZoneListener method remove.
@Override
protected void remove(InstanceIdentifier<DpnInterfaces> key, DpnInterfaces dataObjectModification) {
LOG.debug("Elan dpn {} delete detected, deleting transport zones", dataObjectModification.getDpId());
BigInteger dpId = dataObjectModification.getDpId();
String elanInstanceName = key.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
if (!ElanUtils.isVxlanNetworkOrVxlanSegment(elanInstanceCache.get(elanInstanceName).orNull())) {
LOG.debug("ElanInstance {} is not vxlan network, nothing to do", elanInstanceName);
return;
}
LOG.debug("Deleting tz for elanInstance {} dpId {}", elanInstanceName, dpId);
transportZoneNotificationUtil.deleteTransportZone(elanInstanceName, dpId);
}
Aggregations