use of org.onosproject.openstackvtap.api.OpenstackVtap.Type in project onos by opennetworkinglab.
the class OpenstackVtapManager method updateHostbyType.
/**
* Updates device list of vtaps with respect to the host changes.
*
* @param newHost new host instance
* @param oldHost old host instance
*/
private void updateHostbyType(Type type, Host newHost, Host oldHost) {
getVtaps(type).forEach(vtap -> {
IpPrefix prefix = (type == Type.VTAP_TX) ? vtap.vtapCriterion().srcIpPrefix() : vtap.vtapCriterion().dstIpPrefix();
int hostDiff = hostCompareIp(newHost, oldHost, prefix);
if (hostDiff < 0) {
oldHost.locations().stream().map(HostLocation::deviceId).forEach(deviceId -> store.removeDeviceFromVtap(vtap.id(), type, deviceId));
} else if (hostDiff > 0) {
newHost.locations().stream().map(HostLocation::deviceId).filter(deviceId -> Objects.nonNull(osNodeService.node(deviceId))).forEach(deviceId -> store.addDeviceToVtap(vtap.id(), type, deviceId));
}
});
}
Aggregations