use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project lispflowmapping by opendaylight.
the class MappingSystem method handleAddMappingNotifications.
private void handleAddMappingNotifications(MappingOrigin origin, Eid key, MappingData mappingData, MappingRecord oldMapping, MappingRecord newMapping, MappingChange changeType) {
// account policy as well
if (origin != MappingOrigin.Southbound || MappingRecordUtil.mappingChanged(oldMapping, newMapping)) {
notifyChange(key, mappingData.getRecord(), changeType);
Eid dstKey = key;
// for the checks that we do afterwards
if (key.getAddress() instanceof SourceDestKey) {
dstKey = SourceDestKeyHelper.getDstBinary(key);
}
// If the old mapping had a different EID than what was just added, notify those subscribers too
if (oldMapping != null && !oldMapping.getEid().equals(key) && !oldMapping.getEid().equals(dstKey)) {
notifyChange(oldMapping.getEid(), oldMapping, changeType);
}
// subscribers too
if (newMapping != null && !newMapping.getEid().equals(key) && !newMapping.getEid().equals(dstKey)) {
notifyChange(newMapping.getEid(), newMapping, changeType);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project lispflowmapping by opendaylight.
the class MapServer method handleMapRegister.
@SuppressWarnings("unchecked")
public void handleMapRegister(MapRegister mapRegister) {
boolean mappingUpdated = false;
boolean merge = ConfigIni.getInstance().mappingMergeIsSet() && mapRegister.isMergeEnabled();
MappingRecord oldMapping;
if (merge) {
if (!mapRegister.isXtrSiteIdPresent() || mapRegister.getXtrId() == null) {
LOG.error("Merge bit is set in Map-Register, but xTR-ID is not present. Will not merge.");
merge = false;
} else if (Arrays.equals(mapRegister.getXtrId().getValue(), ALL_ZEROES_XTR_ID)) {
LOG.warn("Merge bit is set in Map-Register, but xTR-ID is all zeroes.");
}
}
for (MappingRecordItem record : mapRegister.getMappingRecordItem()) {
MappingRecord mapping = record.getMappingRecord();
Eid eid = mapping.getEid();
MappingData mappingData = new MappingData(mapping, System.currentTimeMillis());
mappingData.setMergeEnabled(merge);
mappingData.setXtrId(mapRegister.getXtrId());
oldMapping = getMappingRecord(mapService.getMapping(MappingOrigin.Southbound, eid));
mapService.addMapping(MappingOrigin.Southbound, eid, getSiteId(mapRegister), mappingData);
if (merge) {
MappingRecord newMapping = getMappingRecord(mapService.getMapping(MappingOrigin.Southbound, eid));
if (MappingRecordUtil.mappingChanged(oldMapping, newMapping)) {
// If there is a SB mapping change with merge on, Map-Notify will be sent to ALL xTRs, not jus the
// one registering (merging is done in the MappingSystem code)
mappingUpdated = true;
}
}
}
if (BooleanUtils.isTrue(mapRegister.isWantMapNotify())) {
LOG.trace("MapRegister wants MapNotify");
MapNotifyBuilder builder = new MapNotifyBuilder();
List<TransportAddress> rlocs = null;
if (merge) {
Set<IpAddressBinary> notifyRlocs = new HashSet<IpAddressBinary>();
List<MappingRecordItem> mergedMappings = new ArrayList<MappingRecordItem>();
for (MappingRecordItem record : mapRegister.getMappingRecordItem()) {
MappingRecord mapping = record.getMappingRecord();
MappingRecord currentRecord = getMappingRecord(mapService.getMapping(MappingOrigin.Southbound, mapping.getEid()));
mergedMappings.add(new MappingRecordItemBuilder().setMappingRecord(currentRecord).build());
Set<IpAddressBinary> sourceRlocs = (Set<IpAddressBinary>) mapService.getData(MappingOrigin.Southbound, mapping.getEid(), SubKeys.SRC_RLOCS);
if (sourceRlocs != null) {
notifyRlocs.addAll(sourceRlocs);
}
}
MapNotifyBuilderHelper.setFromMapRegisterAndMappingRecordItems(builder, mapRegister, mergedMappings);
// send map-notify to merge group only when mapping record is changed
if (mappingUpdated) {
rlocs = getTransportAddresses(notifyRlocs);
}
} else {
MapNotifyBuilderHelper.setFromMapRegister(builder, mapRegister);
}
List<MappingRecordItem> mappings = builder.getMappingRecordItem();
if (mappings != null && mappings.get(0) != null && mappings.get(0).getMappingRecord() != null && mappings.get(0).getMappingRecord().getEid() != null) {
MappingAuthkey authkey = mapService.getAuthenticationKey(mappings.get(0).getMappingRecord().getEid());
if (authkey != null) {
builder.setAuthenticationData(LispAuthenticationUtil.createAuthenticationData(builder.build(), authkey.getKeyString()));
}
}
notifyHandler.handleMapNotify(builder.build(), rlocs);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project netvirt by opendaylight.
the class AclInterfaceStateListener method remove.
@Override
public void remove(InstanceIdentifier<Interface> key, Interface deleted) {
if (!L2vlan.class.equals(deleted.getType())) {
return;
}
String interfaceId = deleted.getName();
AclInterface aclInterface = aclInterfaceCache.remove(interfaceId);
if (AclServiceUtils.isOfInterest(aclInterface)) {
List<Uuid> aclList = aclInterface.getSecurityGroups();
if (aclClusterUtil.isEntityOwner()) {
LOG.debug("On remove event, notify ACL service manager to remove ACL from interface: {}", aclInterface);
aclServiceManger.notify(aclInterface, null, Action.UNBIND);
aclServiceManger.notify(aclInterface, null, Action.REMOVE);
if (aclList != null) {
aclServiceUtils.deleteAclPortsLookup(aclInterface, aclList, aclInterface.getAllowedAddressPairs());
}
}
if (aclList != null) {
for (Uuid acl : aclList) {
jobCoordinator.enqueueJob(acl.getValue(), () -> {
aclDataUtil.removeAclInterfaceMap(acl, aclInterface);
return Collections.emptyList();
});
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project netvirt by opendaylight.
the class AclElanInterfaceListener method add.
@Override
public void add(InstanceIdentifier<ElanInterface> key, ElanInterface elanInterface) {
String interfaceId = elanInterface.getName();
AclInterface aclInterface = aclInterfaceCache.updateIfPresent(interfaceId, (prevAclInterface, builder) -> {
if (prevAclInterface.getElanId() == null) {
ElanInstance elanInfo = AclServiceUtils.getElanInstanceByName(elanInterface.getElanInstanceName(), dataBroker);
if (elanInfo != null) {
builder.elanId(elanInfo.getElanTag().toJava());
}
return true;
}
return false;
});
if (aclInterface == null) {
LOG.debug("On Add event, ignore if AclInterface was not found in cache or was not updated");
return;
}
if (aclInterface.getDpId() != null && aclClusterUtil.isEntityOwner()) {
// Notify ADD flows, if InterfaceStateListener has processed before ELAN-ID getting populated
LOG.debug("On add event, notify ACL service manager to BIND/ADD ACL for interface: {}", aclInterface);
aclServiceManager.notify(aclInterface, null, Action.BIND);
aclServiceManager.notify(aclInterface, null, Action.ADD);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project netvirt by opendaylight.
the class AclInterfaceListener method update.
@Override
public void update(@Nullable InstanceIdentifier<Interface> key, Interface portBefore, Interface portAfter) {
if (portBefore.augmentation(ParentRefs.class) == null && portAfter.augmentation(ParentRefs.class) != null) {
LOG.trace("Ignoring event for update in ParentRefs for {} ", portAfter.getName());
return;
}
LOG.trace("Received AclInterface update event, portBefore={}, portAfter={}", portBefore, portAfter);
InterfaceAcl aclInPortAfter = portAfter.augmentation(InterfaceAcl.class);
InterfaceAcl aclInPortBefore = portBefore.augmentation(InterfaceAcl.class);
String interfaceId = portAfter.getName();
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface interfaceState = AclServiceUtils.getInterfaceStateFromOperDS(dataBroker, interfaceId);
AclInterface aclInterfaceBefore = aclInterfaceCache.get(interfaceId);
if (aclInterfaceBefore == null || isPortSecurityEnabledNow(aclInPortBefore, aclInPortAfter)) {
// Updating cache now as it might have not updated when
// port-security-enable=false
aclInterfaceBefore = addOrUpdateAclInterfaceCache(interfaceId, aclInPortBefore, true, interfaceState);
}
if (AclServiceUtils.isOfInterest(aclInPortAfter) || AclServiceUtils.isOfInterest(aclInPortBefore)) {
List<Uuid> sgsBefore = null;
if (aclInPortBefore != null) {
sgsBefore = aclInPortBefore.getSecurityGroups();
}
boolean isSgChanged = isSecurityGroupsChanged(sgsBefore, aclInPortAfter.getSecurityGroups());
AclInterface aclInterfaceAfter = addOrUpdateAclInterfaceCache(interfaceId, aclInPortAfter, isSgChanged, interfaceState);
updateCacheWithAddedAcls(aclInterfaceBefore, aclInterfaceAfter);
if (aclClusterUtil.isEntityOwner()) {
// Handle bind/unbind service irrespective of interface state (up/down)
boolean isPortSecurityEnable = aclInterfaceAfter.isPortSecurityEnabled();
boolean isPortSecurityEnableBefore = aclInterfaceBefore.isPortSecurityEnabled();
// if port security enable is changed and is disabled, unbind ACL service
if (isPortSecurityEnableBefore != isPortSecurityEnable && !isPortSecurityEnable) {
LOG.debug("Notify unbind ACL service for interface={}, isPortSecurityEnable={}", interfaceId, isPortSecurityEnable);
aclServiceManager.notify(aclInterfaceAfter, null, Action.UNBIND);
}
if (interfaceState != null && org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Up.equals(interfaceState.getOperStatus())) {
// if port security enable is changed and is enabled, bind ACL service
if (isPortSecurityEnableBefore != isPortSecurityEnable && isPortSecurityEnable) {
LOG.debug("Notify bind ACL service for interface={}, isPortSecurityEnable={}", interfaceId, isPortSecurityEnable);
aclServiceManager.notify(aclInterfaceAfter, null, Action.BIND);
}
LOG.debug("On update event, notify ACL service manager to update ACL for interface: {}", interfaceId);
// handle add for AclPortsLookup before processing update
aclServiceUtils.addAclPortsLookupForInterfaceUpdate(aclInterfaceBefore, aclInterfaceAfter);
aclServiceManager.notify(aclInterfaceAfter, aclInterfaceBefore, AclServiceManager.Action.UPDATE);
// handle delete for AclPortsLookup after processing update
aclServiceUtils.deleteAclPortsLookupForInterfaceUpdate(aclInterfaceBefore, aclInterfaceAfter);
}
}
updateCacheWithAclChange(aclInterfaceBefore, aclInterfaceAfter);
}
}
Aggregations