blob: 544d762a8f8232f9303d74ff023b877963897d7c [file] [log] [blame]
Daniel Park5df65182016-01-09 00:12:03 +09001/*
Daniel Park3a06c522016-01-28 20:51:12 +09002 * Copyright 2015 Open Networking Laboratory
Daniel Park5df65182016-01-09 00:12:03 +09003 *
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 */
sangho0c2a3da2016-02-16 13:39:07 +090016package org.onosproject.openstacknetworking;
Daniel Park5df65182016-01-09 00:12:03 +090017
18import org.onlab.packet.Ip4Address;
sangho3623cb62016-01-15 22:06:38 +090019import org.onlab.packet.MacAddress;
Daniel Park5df65182016-01-09 00:12:03 +090020import org.onosproject.net.DeviceId;
sangho90088532016-02-25 18:06:12 +090021
22import java.util.Collection;
23import java.util.Collections;
24
Daniel Park5df65182016-01-09 00:12:03 +090025import static com.google.common.base.Preconditions.checkNotNull;
26
27/**
28 * Contains OpenstackPort Information.
29 */
Daniel Park81a61a12016-02-26 08:24:44 +090030public final class OpenstackPortInfo {
Daniel Park5df65182016-01-09 00:12:03 +090031 private final Ip4Address hostIp;
sangho3623cb62016-01-15 22:06:38 +090032 private final MacAddress hostMac;
Daniel Park3a06c522016-01-28 20:51:12 +090033 private final DeviceId deviceId;
Daniel Park5df65182016-01-09 00:12:03 +090034 private final long vni;
Daniel Park3a06c522016-01-28 20:51:12 +090035 private final Ip4Address gatewayIP;
Daniel Park81a61a12016-02-26 08:24:44 +090036 private final String networkId;
sangho90088532016-02-25 18:06:12 +090037 private final Collection<String> securityGroups;
Daniel Park5df65182016-01-09 00:12:03 +090038
sangho90088532016-02-25 18:06:12 +090039 /**
40 * Returns OpenstackPortInfo reference.
41 *
42 * @param hostIp host IP address
43 * @param hostMac host MAC address
44 * @param deviceId device ID
45 * @param vni tunnel ID
46 * @param gatewayIP gateway IP address
Ray Milkey21c3ebe2016-03-08 10:49:16 -080047 * @param networkId network identifier
sangho90088532016-02-25 18:06:12 +090048 * @param securityGroups security group list
49 */
50 public OpenstackPortInfo(Ip4Address hostIp, MacAddress hostMac, DeviceId deviceId, long vni,
Daniel Park81a61a12016-02-26 08:24:44 +090051 Ip4Address gatewayIP, String networkId, Collection<String> securityGroups) {
Daniel Park5df65182016-01-09 00:12:03 +090052 this.hostIp = hostIp;
sangho3623cb62016-01-15 22:06:38 +090053 this.hostMac = hostMac;
Daniel Park5df65182016-01-09 00:12:03 +090054 this.deviceId = deviceId;
55 this.vni = vni;
Daniel Park3a06c522016-01-28 20:51:12 +090056 this.gatewayIP = gatewayIP;
Daniel Park81a61a12016-02-26 08:24:44 +090057 this.networkId = networkId;
sangho90088532016-02-25 18:06:12 +090058 this.securityGroups = securityGroups;
Daniel Park5df65182016-01-09 00:12:03 +090059 }
60
sangho90088532016-02-25 18:06:12 +090061 /**
62 * Returns IP address of the port.
63 *
64 * @return IP address
65 */
Daniel Park5df65182016-01-09 00:12:03 +090066 public Ip4Address ip() {
67 return hostIp;
68 }
69
sangho90088532016-02-25 18:06:12 +090070 /**
71 * Returns MAC address of the port.
72 *
73 * @return MAC address
74 */
sangho3623cb62016-01-15 22:06:38 +090075 public MacAddress mac() {
76 return hostMac;
77 }
78
sangho90088532016-02-25 18:06:12 +090079 /**
80 * Returns device ID.
81 *
82 * @return device ID
83 */
Daniel Park5df65182016-01-09 00:12:03 +090084 public DeviceId deviceId() {
85 return deviceId;
86 }
87
sangho90088532016-02-25 18:06:12 +090088 /**
89 * Returns tunnel ID.
90 *
91 * @return tunnel ID
92 */
Daniel Park5df65182016-01-09 00:12:03 +090093 public long vni() {
94 return vni;
95 }
96
sangho90088532016-02-25 18:06:12 +090097 /**
98 * Returns gateway IP address.
99 *
100 * @return gateway IP address
101 */
Daniel Park3a06c522016-01-28 20:51:12 +0900102 public Ip4Address gatewayIP() {
103 return gatewayIP;
104 }
105
sangho90088532016-02-25 18:06:12 +0900106 /**
Daniel Park81a61a12016-02-26 08:24:44 +0900107 * Returns network ID.
108 *
109 * @return network ID
110 */
111 public String networkId() {
112 return networkId;
113 }
114
115 /**
sangho90088532016-02-25 18:06:12 +0900116 * Returns Security Group ID list.
117 *
118 * @return list of Security Group ID
119 */
120 public Collection<String> securityGroups() {
121 return Collections.unmodifiableCollection(securityGroups);
122 }
123
124 /**
125 * Returns the builder of the OpenstackPortInfo.
126 *
127 * @return OpenstackPortInfo builder reference
128 */
Daniel Park5df65182016-01-09 00:12:03 +0900129 public static OpenstackPortInfo.Builder builder() {
130 return new Builder();
131 }
132
sangho90088532016-02-25 18:06:12 +0900133 /**
134 * Represents the OpenstackPortInfo Builder.
135 *
136 */
Daniel Park5df65182016-01-09 00:12:03 +0900137 public static final class Builder {
138 private Ip4Address hostIp;
sangho3623cb62016-01-15 22:06:38 +0900139 private MacAddress hostMac;
Daniel Park5df65182016-01-09 00:12:03 +0900140 private DeviceId deviceId;
141 private long vni;
Daniel Park3a06c522016-01-28 20:51:12 +0900142 private Ip4Address gatewayIP;
sangho90088532016-02-25 18:06:12 +0900143 private Collection<String> securityGroups;
Daniel Park81a61a12016-02-26 08:24:44 +0900144 private String networkId;
Daniel Park3a06c522016-01-28 20:51:12 +0900145
sangho90088532016-02-25 18:06:12 +0900146 /**
147 * Sets the IP address of the port.
148 *
Daniel Park81a61a12016-02-26 08:24:44 +0900149 * @param gatewayIP gateway IP
sangho90088532016-02-25 18:06:12 +0900150 * @return Builder reference
151 */
Daniel Park3a06c522016-01-28 20:51:12 +0900152 public Builder setGatewayIP(Ip4Address gatewayIP) {
153 this.gatewayIP = checkNotNull(gatewayIP, "gatewayIP cannot be null");
154 return this;
155 }
Daniel Park5df65182016-01-09 00:12:03 +0900156
sangho90088532016-02-25 18:06:12 +0900157 /**
Daniel Park81a61a12016-02-26 08:24:44 +0900158 * Sets the network ID.
159 *
160 * @param networkId network id
161 * @return Builder reference
162 */
163 public Builder setNetworkId(String networkId) {
164 this.networkId = checkNotNull(networkId, "networkId cannot be null");
165 return this;
166 }
167
168 /**
sangho90088532016-02-25 18:06:12 +0900169 * Sets the host IP address of the port.
170 *
171 * @param hostIp host IP address
172 * @return Builder reference
173 */
Daniel Park5df65182016-01-09 00:12:03 +0900174 public Builder setHostIp(Ip4Address hostIp) {
175 this.hostIp = checkNotNull(hostIp, "hostIp cannot be null");
176 return this;
177 }
178
sangho90088532016-02-25 18:06:12 +0900179 /**
180 * Sets the host MAC address of the port.
181 *
182 * @param hostMac host MAC address
183 * @return Builder reference
184 */
sangho3623cb62016-01-15 22:06:38 +0900185 public Builder setHostMac(MacAddress hostMac) {
186 this.hostMac = checkNotNull(hostMac, "hostMac cannot be bull");
187 return this;
188 }
189
sangho90088532016-02-25 18:06:12 +0900190 /**
191 * Sets the device ID.
192 *
193 * @param deviceId device ID
194 * @return Builder reference
195 */
Daniel Park5df65182016-01-09 00:12:03 +0900196 public Builder setDeviceId(DeviceId deviceId) {
197 this.deviceId = checkNotNull(deviceId, "deviceId cannot be null");
198 return this;
199 }
200
sangho90088532016-02-25 18:06:12 +0900201 /**
202 * Sets the tunnel ID.
203 *
204 * @param vni tunnel ID
205 * @return Builder reference
206 */
Jonathan Hart51539b82015-10-29 09:53:04 -0700207 public Builder setVni(long vni) {
Daniel Park5df65182016-01-09 00:12:03 +0900208 this.vni = checkNotNull(vni, "vni cannot be null");
209 return this;
210 }
sangho90088532016-02-25 18:06:12 +0900211
212 /**
213 * Sets the security group ID list.
214 *
215 * @param securityGroups security group ID list
216 * @return Builder reference
217 */
218 public Builder setSecurityGroups(Collection<String> securityGroups) {
219 this.securityGroups = securityGroups;
220 return this;
221 }
222
223 /**
224 * Builds the OpenstackPortInfo reference.
225 *
226 * @return OpenstackPortInfo reference
227 */
Daniel Park5df65182016-01-09 00:12:03 +0900228 public OpenstackPortInfo build() {
Daniel Park81a61a12016-02-26 08:24:44 +0900229 return new OpenstackPortInfo(hostIp, hostMac, deviceId, vni, gatewayIP, networkId, securityGroups);
Daniel Park5df65182016-01-09 00:12:03 +0900230 }
231 }
Daniel Park5df65182016-01-09 00:12:03 +0900232}