blob: e480ee27761f591b26b3a3d81422d9b406bdc710 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska83e090e2014-10-22 14:25:35 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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
Thomas Vachuska83e090e2014-10-22 14:25:35 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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.
Thomas Vachuska83e090e2014-10-22 14:25:35 -070015 */
Brian O'Connorb876bf12014-10-02 14:59:37 -070016package org.onlab.onos.net.intent;
17
toma1d16b62014-10-02 23:45:11 -070018import com.google.common.base.MoreObjects;
Thomas Vachuskaedc944c2014-11-04 15:42:25 -080019import com.google.common.collect.ImmutableList;
Thomas Vachuskae0f804a2014-10-27 23:40:48 -070020import org.onlab.onos.core.ApplicationId;
Brian O'Connorb876bf12014-10-02 14:59:37 -070021import org.onlab.onos.net.ConnectPoint;
Thomas Vachuskaedc944c2014-11-04 15:42:25 -080022import org.onlab.onos.net.Link;
Brian O'Connorb876bf12014-10-02 14:59:37 -070023import org.onlab.onos.net.flow.TrafficSelector;
24import org.onlab.onos.net.flow.TrafficTreatment;
Thomas Vachuskaedc944c2014-11-04 15:42:25 -080025import org.onlab.onos.net.intent.constraint.LinkTypeConstraint;
26
27import java.util.List;
Brian O'Connorb876bf12014-10-02 14:59:37 -070028
toma1d16b62014-10-02 23:45:11 -070029import static com.google.common.base.Preconditions.checkNotNull;
Brian O'Connorb876bf12014-10-02 14:59:37 -070030
31/**
32 * Abstraction of point-to-point connectivity.
33 */
34public class PointToPointIntent extends ConnectivityIntent {
35
tom85258ee2014-10-07 00:10:02 -070036 private final ConnectPoint ingressPoint;
37 private final ConnectPoint egressPoint;
Brian O'Connorb876bf12014-10-02 14:59:37 -070038
39 /**
40 * Creates a new point-to-point intent with the supplied ingress/egress
Thomas Vachuskaedc944c2014-11-04 15:42:25 -080041 * ports and with built-in link type constraint to avoid optical links.
Brian O'Connorb876bf12014-10-02 14:59:37 -070042 *
Thomas Vachuskac96058a2014-10-20 23:00:16 -070043 * @param appId application identifier
tom85258ee2014-10-07 00:10:02 -070044 * @param selector traffic selector
45 * @param treatment treatment
46 * @param ingressPoint ingress port
47 * @param egressPoint egress port
48 * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null.
Brian O'Connorb876bf12014-10-02 14:59:37 -070049 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070050 public PointToPointIntent(ApplicationId appId, TrafficSelector selector,
toma1d16b62014-10-02 23:45:11 -070051 TrafficTreatment treatment,
tom85258ee2014-10-07 00:10:02 -070052 ConnectPoint ingressPoint,
53 ConnectPoint egressPoint) {
Thomas Vachuskaedc944c2014-11-04 15:42:25 -080054 this(appId, selector, treatment, ingressPoint, egressPoint,
55 ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL)));
56 }
57
58 /**
59 * Creates a new point-to-point intent with the supplied ingress/egress
60 * ports and constraints.
61 *
62 * @param appId application identifier
63 * @param selector traffic selector
64 * @param treatment treatment
65 * @param ingressPoint ingress port
66 * @param egressPoint egress port
67 * @param constraints optional list of constraints
68 * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null.
69 */
70 public PointToPointIntent(ApplicationId appId, TrafficSelector selector,
71 TrafficTreatment treatment,
72 ConnectPoint ingressPoint,
73 ConnectPoint egressPoint,
74 List<Constraint> constraints) {
75 super(id(PointToPointIntent.class, selector, treatment,
76 ingressPoint, egressPoint, constraints),
77 appId, null, selector, treatment, constraints);
tom85258ee2014-10-07 00:10:02 -070078 this.ingressPoint = checkNotNull(ingressPoint);
79 this.egressPoint = checkNotNull(egressPoint);
Brian O'Connorb876bf12014-10-02 14:59:37 -070080 }
81
82 /**
83 * Constructor for serializer.
84 */
85 protected PointToPointIntent() {
86 super();
tom85258ee2014-10-07 00:10:02 -070087 this.ingressPoint = null;
88 this.egressPoint = null;
Brian O'Connorb876bf12014-10-02 14:59:37 -070089 }
90
91 /**
92 * Returns the port on which the ingress traffic should be connected to
93 * the egress.
94 *
95 * @return ingress port
96 */
tom85258ee2014-10-07 00:10:02 -070097 public ConnectPoint ingressPoint() {
98 return ingressPoint;
Brian O'Connorb876bf12014-10-02 14:59:37 -070099 }
100
101 /**
102 * Returns the port on which the traffic should egress.
103 *
104 * @return egress port
105 */
tom85258ee2014-10-07 00:10:02 -0700106 public ConnectPoint egressPoint() {
107 return egressPoint;
Brian O'Connorb876bf12014-10-02 14:59:37 -0700108 }
109
110 @Override
Brian O'Connorb876bf12014-10-02 14:59:37 -0700111 public String toString() {
112 return MoreObjects.toStringHelper(getClass())
tom85258ee2014-10-07 00:10:02 -0700113 .add("id", id())
Thomas Vachuskae291c842014-10-21 02:52:38 -0700114 .add("appId", appId())
115 .add("selector", selector())
116 .add("treatment", treatment())
117 .add("ingress", ingressPoint)
118 .add("egress", egressPoint)
Thomas Vachuskaedc944c2014-11-04 15:42:25 -0800119 .add("constraints", constraints())
Brian O'Connorb876bf12014-10-02 14:59:37 -0700120 .toString();
121 }
122
123}