blob: 7006b6841ed4e0fd783b12be4ef7d2748cf6c609 [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
18import java.util.Collection;
weibitf32383b2014-10-22 10:17:31 -070019
Brian O'Connorabafb502014-12-02 22:26:20 -080020import org.onosproject.core.ApplicationId;
21import org.onosproject.net.ConnectPoint;
22import org.onosproject.net.Link;
23import org.onosproject.net.NetworkResource;
24import org.onosproject.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'Connor520c0522014-11-23 23:50:47 -080040 super(appId, ImmutableSet.<NetworkResource>copyOf(path.links()));
Brian O'Connor086724e2014-10-23 15:47:32 -070041 this.src = src;
42 this.dst = dst;
weibitf32383b2014-10-22 10:17:31 -070043 this.path = path;
44 }
45
weibit9e622ac2014-10-23 13:45:44 -070046 protected OpticalPathIntent() {
Brian O'Connor086724e2014-10-23 15:47:32 -070047 this.src = null;
48 this.dst = null;
weibitf32383b2014-10-22 10:17:31 -070049 this.path = null;
50 }
51
Brian O'Connor086724e2014-10-23 15:47:32 -070052 public ConnectPoint src() {
53 return src;
54 }
55
56 public ConnectPoint dst() {
57 return dst;
58 }
59
weibitf32383b2014-10-22 10:17:31 -070060 public Path path() {
61 return path;
62 }
weibitf32383b2014-10-22 10:17:31 -070063
weibitf32383b2014-10-22 10:17:31 -070064 @Override
weibit7e583462014-10-23 10:14:05 -070065 public boolean isInstallable() {
weibitf32383b2014-10-22 10:17:31 -070066 return true;
67 }
68
69 @Override
weibitf32383b2014-10-22 10:17:31 -070070 public String toString() {
71 return MoreObjects.toStringHelper(getClass())
72 .add("id", id())
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}