blob: 72e3bdcdb3eeac7109f898a675b161062ded02bd [file] [log] [blame]
wei wei89ddc322015-03-22 16:29:04 -05001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
wei wei89ddc322015-03-22 16:29:04 -05003 *
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 */
Thomas Vachuskabf916ea2015-05-20 18:24:34 -070016package org.onosproject.incubator.net.tunnel;
wei wei89ddc322015-03-22 16:29:04 -050017
Brian O'Connor2bed5ce2015-06-25 15:10:28 -040018import com.google.common.annotations.Beta;
Yi Tsengfa394de2017-02-01 11:26:40 -080019import org.onosproject.core.GroupId;
wei wei89ddc322015-03-22 16:29:04 -050020import org.onosproject.net.AbstractDescription;
Satish Kd70e9572016-04-28 13:58:51 +053021import org.onosproject.net.NetworkResource;
samuel7a5691a2015-05-23 00:36:32 +080022import org.onosproject.net.Path;
wei wei89ddc322015-03-22 16:29:04 -050023import org.onosproject.net.SparseAnnotations;
jcc4a20a5f2015-04-30 15:43:39 +080024import org.onosproject.net.provider.ProviderId;
25
26import com.google.common.base.MoreObjects;
wei wei89ddc322015-03-22 16:29:04 -050027
28/**
29 * Default implementation of immutable tunnel description entity.
30 */
Brian O'Connor2bed5ce2015-06-25 15:10:28 -040031@Beta
wei wei89ddc322015-03-22 16:29:04 -050032public class DefaultTunnelDescription extends AbstractDescription
33 implements TunnelDescription {
34
jcc4a20a5f2015-04-30 15:43:39 +080035 private final TunnelId tunnelId;
36 private final TunnelEndPoint src;
37 private final TunnelEndPoint dst;
wei wei89ddc322015-03-22 16:29:04 -050038 private final Tunnel.Type type;
Yi Tsengfa394de2017-02-01 11:26:40 -080039 private final GroupId groupId; // represent for a group flow table
jcc4a20a5f2015-04-30 15:43:39 +080040 // which a tunnel match up
41 // tunnel producer
42 private final ProviderId producerName; // tunnel producer name
43 private final TunnelName tunnelName; // name of a tunnel
samuel7a5691a2015-05-23 00:36:32 +080044 private final Path path;
Satish Kd70e9572016-04-28 13:58:51 +053045 private final NetworkResource networkRes;
wei wei89ddc322015-03-22 16:29:04 -050046
47 /**
48 * Creates a tunnel description using the supplied information.
49 *
jcc4a20a5f2015-04-30 15:43:39 +080050 * @param id TunnelId
51 * @param src TunnelPoint source
52 * @param dst TunnelPoint destination
53 * @param type tunnel type
54 * @param groupId groupId
55 * @param producerName tunnel producer
56 * @param tunnelName tunnel name
samuel7a5691a2015-05-23 00:36:32 +080057 * @param path the path of tunnel
wei wei89ddc322015-03-22 16:29:04 -050058 * @param annotations optional key/value annotations
59 */
jcc4a20a5f2015-04-30 15:43:39 +080060 public DefaultTunnelDescription(TunnelId id, TunnelEndPoint src,
61 TunnelEndPoint dst, Tunnel.Type type,
Yi Tsengfa394de2017-02-01 11:26:40 -080062 GroupId groupId,
jcc4a20a5f2015-04-30 15:43:39 +080063 ProviderId producerName,
64 TunnelName tunnelName,
samuel7a5691a2015-05-23 00:36:32 +080065 Path path,
jcc4a20a5f2015-04-30 15:43:39 +080066 SparseAnnotations... annotations) {
wei wei89ddc322015-03-22 16:29:04 -050067 super(annotations);
68 this.tunnelId = id;
69 this.src = src;
70 this.dst = dst;
71 this.type = type;
jcc4a20a5f2015-04-30 15:43:39 +080072 this.groupId = groupId;
73 this.producerName = producerName;
74 this.tunnelName = tunnelName;
samuel7a5691a2015-05-23 00:36:32 +080075 this.path = path;
Satish Kd70e9572016-04-28 13:58:51 +053076 this.networkRes = null;
77 }
78
79 /**
80 * Creates a tunnel description using the supplied information.
81 *
82 * @param id TunnelId
83 * @param src TunnelPoint source
84 * @param dst TunnelPoint destination
85 * @param type tunnel type
86 * @param groupId groupId
87 * @param producerName tunnel producer
88 * @param tunnelName tunnel name
89 * @param path the path of tunnel
90 * @param networkRes network resource of tunnel
91 * @param annotations optional key/value annotations
92 */
93 public DefaultTunnelDescription(TunnelId id, TunnelEndPoint src,
94 TunnelEndPoint dst, Tunnel.Type type,
Yi Tsengfa394de2017-02-01 11:26:40 -080095 GroupId groupId,
Satish Kd70e9572016-04-28 13:58:51 +053096 ProviderId producerName,
97 TunnelName tunnelName,
98 Path path,
99 NetworkResource networkRes,
100 SparseAnnotations... annotations) {
101 super(annotations);
102 this.tunnelId = id;
103 this.src = src;
104 this.dst = dst;
105 this.type = type;
106 this.groupId = groupId;
107 this.producerName = producerName;
108 this.tunnelName = tunnelName;
109 this.path = path;
110 this.networkRes = networkRes;
wei wei89ddc322015-03-22 16:29:04 -0500111 }
112
113 @Override
114 public TunnelId id() {
115 return tunnelId;
116 }
117
118 @Override
jcc4a20a5f2015-04-30 15:43:39 +0800119 public TunnelEndPoint src() {
wei wei89ddc322015-03-22 16:29:04 -0500120 return src;
121 }
122
123 @Override
jcc4a20a5f2015-04-30 15:43:39 +0800124 public TunnelEndPoint dst() {
wei wei89ddc322015-03-22 16:29:04 -0500125 return dst;
126 }
127
128 @Override
129 public Tunnel.Type type() {
130 return type;
131 }
132
133 @Override
Yi Tsengfa394de2017-02-01 11:26:40 -0800134 public GroupId groupId() {
jcc4a20a5f2015-04-30 15:43:39 +0800135 return groupId;
136 }
137
138 @Override
139 public ProviderId producerName() {
140 return producerName;
141 }
142
143 @Override
144 public TunnelName tunnelName() {
145 return tunnelName;
wei wei89ddc322015-03-22 16:29:04 -0500146 }
147
samuel7a5691a2015-05-23 00:36:32 +0800148
149 @Override
150 public Path path() {
151 return path;
152 }
153
wei wei89ddc322015-03-22 16:29:04 -0500154 @Override
Satish Kd70e9572016-04-28 13:58:51 +0530155 public NetworkResource resource() {
156 return networkRes;
157 }
158
159 @Override
wei wei89ddc322015-03-22 16:29:04 -0500160 public String toString() {
161 return MoreObjects.toStringHelper(this)
162 .add("tunnelId", id())
163 .add("src", src())
164 .add("dst", dst())
165 .add("type", type())
jcc4a20a5f2015-04-30 15:43:39 +0800166 .add("tunnelName", tunnelName())
167 .add("producerName", producerName())
168 .add("groupId", groupId())
samuel7a5691a2015-05-23 00:36:32 +0800169 .add("path", path)
Satish Kd70e9572016-04-28 13:58:51 +0530170 .add("resource", networkRes)
wei wei89ddc322015-03-22 16:29:04 -0500171 .toString();
172 }
wei wei89ddc322015-03-22 16:29:04 -0500173}