blob: 6804c86e6c1019f702e615d930063331b0021997 [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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.intent;
weibitf32383b2014-10-22 10:17:31 -070017
Jonathan Hart23b5a762015-01-26 14:47:33 -080018import com.google.common.base.MoreObjects;
19import com.google.common.collect.ImmutableSet;
Brian O'Connorabafb502014-12-02 22:26:20 -080020import org.onosproject.core.ApplicationId;
21import org.onosproject.net.ConnectPoint;
22import org.onosproject.net.Link;
Brian O'Connorabafb502014-12-02 22:26:20 -080023import org.onosproject.net.Path;
weibitf32383b2014-10-22 10:17:31 -070024
Jonathan Hart23b5a762015-01-26 14:47:33 -080025import java.util.Collection;
weibitf32383b2014-10-22 10:17:31 -070026
Ray Milkeybd4f0112015-03-02 17:07:09 -080027public final class OpticalPathIntent extends Intent {
Brian O'Connor086724e2014-10-23 15:47:32 -070028
29 private final ConnectPoint src;
30 private final ConnectPoint dst;
weibitf32383b2014-10-22 10:17:31 -070031 private final Path path;
Brian O'Connor086724e2014-10-23 15:47:32 -070032
weibitf32383b2014-10-22 10:17:31 -070033
weibit7e583462014-10-23 10:14:05 -070034 public OpticalPathIntent(ApplicationId appId,
35 ConnectPoint src,
36 ConnectPoint dst,
weibit7e583462014-10-23 10:14:05 -070037 Path path) {
Sho SHIMIZU2c255db2014-12-09 15:49:15 -080038 super(appId, ImmutableSet.copyOf(path.links()));
Brian O'Connor086724e2014-10-23 15:47:32 -070039 this.src = src;
40 this.dst = dst;
weibitf32383b2014-10-22 10:17:31 -070041 this.path = path;
42 }
43
weibit9e622ac2014-10-23 13:45:44 -070044 protected OpticalPathIntent() {
Brian O'Connor086724e2014-10-23 15:47:32 -070045 this.src = null;
46 this.dst = null;
weibitf32383b2014-10-22 10:17:31 -070047 this.path = null;
48 }
49
Brian O'Connor086724e2014-10-23 15:47:32 -070050 public ConnectPoint src() {
51 return src;
52 }
53
54 public ConnectPoint dst() {
55 return dst;
56 }
57
weibitf32383b2014-10-22 10:17:31 -070058 public Path path() {
59 return path;
60 }
weibitf32383b2014-10-22 10:17:31 -070061
weibitf32383b2014-10-22 10:17:31 -070062 @Override
weibit7e583462014-10-23 10:14:05 -070063 public boolean isInstallable() {
weibitf32383b2014-10-22 10:17:31 -070064 return true;
65 }
66
67 @Override
weibitf32383b2014-10-22 10:17:31 -070068 public String toString() {
69 return MoreObjects.toStringHelper(getClass())
70 .add("id", id())
Jonathan Hart23b5a762015-01-26 14:47:33 -080071 .add("appId", appId())
72 .add("resources", resources())
Brian O'Connor086724e2014-10-23 15:47:32 -070073 .add("ingressPort", src)
74 .add("egressPort", dst)
weibitf32383b2014-10-22 10:17:31 -070075 .add("path", path)
76 .toString();
77 }
78
Praseed Balakrishnan00dd1f92014-11-19 17:12:36 -080079
weibitf32383b2014-10-22 10:17:31 -070080 public Collection<Link> requiredLinks() {
81 return path.links();
82 }
83}