use of org.onosproject.incubator.net.tunnel.DefaultTunnel in project onos by opennetworkinglab.
the class DistributedTunnelStore method handleCreateOrUpdateTunnel.
private TunnelId handleCreateOrUpdateTunnel(Tunnel tunnel, State state) {
// tunnelIdAsKeyStore.
if (tunnel.tunnelId() != null && !"".equals(tunnel.tunnelId().toString())) {
Tunnel old = tunnelIdAsKeyStore.get(tunnel.tunnelId());
if (old == null) {
log.info("This tunnel[" + tunnel.tunnelId() + "] is not available.");
return tunnel.tunnelId();
}
DefaultAnnotations oldAnno = (DefaultAnnotations) old.annotations();
SparseAnnotations newAnno = (SparseAnnotations) tunnel.annotations();
State newTunnelState = (state != null) ? state : old.state();
Tunnel newT = new DefaultTunnel(old.providerId(), old.src(), old.dst(), old.type(), newTunnelState, old.groupId(), old.tunnelId(), old.tunnelName(), old.path(), old.resource(), DefaultAnnotations.merge(oldAnno, newAnno));
tunnelIdAsKeyStore.put(tunnel.tunnelId(), newT);
TunnelEvent event = new TunnelEvent(TunnelEvent.Type.TUNNEL_UPDATED, tunnel);
notifyDelegate(event);
return tunnel.tunnelId();
} else {
TunnelId tunnelId = TunnelId.valueOf(String.valueOf(idGenerator.getNewId()));
State tunnelState = (state != null) ? state : tunnel.state();
Tunnel newT = new DefaultTunnel(tunnel.providerId(), tunnel.src(), tunnel.dst(), tunnel.type(), tunnelState, tunnel.groupId(), tunnelId, tunnel.tunnelName(), tunnel.path(), tunnel.resource(), tunnel.annotations());
tunnelIdAsKeyStore.put(tunnelId, newT);
TunnelEvent event = new TunnelEvent(TunnelEvent.Type.TUNNEL_ADDED, tunnel);
notifyDelegate(event);
return tunnelId;
}
}
use of org.onosproject.incubator.net.tunnel.DefaultTunnel in project onos by opennetworkinglab.
the class TunnelManager method borrowTunnel.
@Override
public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, Type type, Annotations... annotations) {
Collection<Tunnel> tunnels = store.borrowTunnel(consumerId, src, dst, type, annotations);
if (tunnels == null || tunnels.isEmpty()) {
Tunnel tunnel = new DefaultTunnel(null, src, dst, type, null, null, null, null, annotations);
Set<ProviderId> ids = getProviders();
for (ProviderId providerId : ids) {
TunnelProvider provider = getProvider(providerId);
provider.setupTunnel(tunnel, null);
}
}
return tunnels;
}
use of org.onosproject.incubator.net.tunnel.DefaultTunnel in project onos by opennetworkinglab.
the class TunnelManager method borrowTunnel.
@Override
public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, Annotations... annotations) {
Collection<Tunnel> tunnels = store.borrowTunnel(consumerId, src, dst, annotations);
if (tunnels == null || tunnels.isEmpty()) {
Tunnel tunnel = new DefaultTunnel(null, src, dst, null, null, null, null, null, annotations);
Set<ProviderId> ids = getProviders();
for (ProviderId providerId : ids) {
TunnelProvider provider = getProvider(providerId);
provider.setupTunnel(tunnel, null);
}
}
return tunnels;
}
Aggregations