blob: 92017f1e0e6001ff91b71ace02949acac6499fc0 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
weibitf32383b2014-10-22 10:17:31 -070016package org.onlab.onos.net.intent;
17
18import java.util.Collection;
weibitf32383b2014-10-22 10:17:31 -070019
Thomas Vachuskae0f804a2014-10-27 23:40:48 -070020import org.onlab.onos.core.ApplicationId;
weibitf32383b2014-10-22 10:17:31 -070021import org.onlab.onos.net.ConnectPoint;
22import org.onlab.onos.net.Link;
Brian O'Connor4908d602014-10-23 15:58:20 -070023import org.onlab.onos.net.NetworkResource;
weibitf32383b2014-10-22 10:17:31 -070024import org.onlab.onos.net.Path;
weibitf32383b2014-10-22 10:17:31 -070025
26import com.google.common.base.MoreObjects;
Brian O'Connor4908d602014-10-23 15:58:20 -070027import com.google.common.collect.ImmutableSet;
weibitf32383b2014-10-22 10:17:31 -070028
Brian O'Connor4908d602014-10-23 15:58:20 -070029public class OpticalPathIntent extends Intent {
Brian O'Connor086724e2014-10-23 15:47:32 -070030
31 private final ConnectPoint src;
32 private final ConnectPoint dst;
weibitf32383b2014-10-22 10:17:31 -070033 private final Path path;
Brian O'Connor086724e2014-10-23 15:47:32 -070034
weibitf32383b2014-10-22 10:17:31 -070035
weibit7e583462014-10-23 10:14:05 -070036 public OpticalPathIntent(ApplicationId appId,
37 ConnectPoint src,
38 ConnectPoint dst,
weibit7e583462014-10-23 10:14:05 -070039 Path path) {
Brian O'Connor086724e2014-10-23 15:47:32 -070040 super(id(OpticalPathIntent.class, src, dst),
Brian O'Connor4908d602014-10-23 15:58:20 -070041 appId,
42 ImmutableSet.<NetworkResource>copyOf(path.links()));
Brian O'Connor086724e2014-10-23 15:47:32 -070043 this.src = src;
44 this.dst = dst;
weibitf32383b2014-10-22 10:17:31 -070045 this.path = path;
46 }
47
weibit9e622ac2014-10-23 13:45:44 -070048 protected OpticalPathIntent() {
Brian O'Connor086724e2014-10-23 15:47:32 -070049 this.src = null;
50 this.dst = null;
weibitf32383b2014-10-22 10:17:31 -070051 this.path = null;
52 }
53
Brian O'Connor086724e2014-10-23 15:47:32 -070054 public ConnectPoint src() {
55 return src;
56 }
57
58 public ConnectPoint dst() {
59 return dst;
60 }
61
weibitf32383b2014-10-22 10:17:31 -070062 public Path path() {
63 return path;
64 }
weibitf32383b2014-10-22 10:17:31 -070065
weibitf32383b2014-10-22 10:17:31 -070066 @Override
weibit7e583462014-10-23 10:14:05 -070067 public boolean isInstallable() {
weibitf32383b2014-10-22 10:17:31 -070068 return true;
69 }
70
71 @Override
weibitf32383b2014-10-22 10:17:31 -070072 public String toString() {
73 return MoreObjects.toStringHelper(getClass())
74 .add("id", id())
Brian O'Connor086724e2014-10-23 15:47:32 -070075 .add("ingressPort", src)
76 .add("egressPort", dst)
weibitf32383b2014-10-22 10:17:31 -070077 .add("path", path)
78 .toString();
79 }
80
weibitf32383b2014-10-22 10:17:31 -070081 public Collection<Link> requiredLinks() {
82 return path.links();
83 }
84}