blob: b40b8650c19fe4aee4bc283aef1d4f521d1460d9 [file] [log] [blame]
Daniel Park5df65182016-01-09 00:12:03 +09001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present 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
Daniel Park5df65182016-01-09 00:12:03 +090022import static com.google.common.base.Preconditions.checkNotNull;
23
24/**
25 * Contains OpenstackPort Information.
26 */
Hyunsun Moonb974fca2016-06-30 21:20:39 -070027// TODO remove this
Daniel Park81a61a12016-02-26 08:24:44 +090028public final class OpenstackPortInfo {
Daniel Park5df65182016-01-09 00:12:03 +090029 private final Ip4Address hostIp;
sangho3623cb62016-01-15 22:06:38 +090030 private final MacAddress hostMac;
Daniel Park3a06c522016-01-28 20:51:12 +090031 private final DeviceId deviceId;
Daniel Park5df65182016-01-09 00:12:03 +090032 private final long vni;
Daniel Park3a06c522016-01-28 20:51:12 +090033 private final Ip4Address gatewayIP;
Daniel Park81a61a12016-02-26 08:24:44 +090034 private final String networkId;
Daniel Park5df65182016-01-09 00:12:03 +090035
sangho90088532016-02-25 18:06:12 +090036 /**
37 * Returns OpenstackPortInfo reference.
38 *
39 * @param hostIp host IP address
40 * @param hostMac host MAC address
41 * @param deviceId device ID
42 * @param vni tunnel ID
43 * @param gatewayIP gateway IP address
Ray Milkey21c3ebe2016-03-08 10:49:16 -080044 * @param networkId network identifier
sangho90088532016-02-25 18:06:12 +090045 */
46 public OpenstackPortInfo(Ip4Address hostIp, MacAddress hostMac, DeviceId deviceId, long vni,
Hyunsun Moonb974fca2016-06-30 21:20:39 -070047 Ip4Address gatewayIP, String networkId) {
Daniel Park5df65182016-01-09 00:12:03 +090048 this.hostIp = hostIp;
sangho3623cb62016-01-15 22:06:38 +090049 this.hostMac = hostMac;
Daniel Park5df65182016-01-09 00:12:03 +090050 this.deviceId = deviceId;
51 this.vni = vni;
Daniel Park3a06c522016-01-28 20:51:12 +090052 this.gatewayIP = gatewayIP;
Daniel Park81a61a12016-02-26 08:24:44 +090053 this.networkId = networkId;
Daniel Park5df65182016-01-09 00:12:03 +090054 }
55
sangho90088532016-02-25 18:06:12 +090056 /**
57 * Returns IP address of the port.
58 *
59 * @return IP address
60 */
Daniel Park5df65182016-01-09 00:12:03 +090061 public Ip4Address ip() {
62 return hostIp;
63 }
64
sangho90088532016-02-25 18:06:12 +090065 /**
66 * Returns MAC address of the port.
67 *
68 * @return MAC address
69 */
sangho3623cb62016-01-15 22:06:38 +090070 public MacAddress mac() {
71 return hostMac;
72 }
73
sangho90088532016-02-25 18:06:12 +090074 /**
75 * Returns device ID.
76 *
77 * @return device ID
78 */
Daniel Park5df65182016-01-09 00:12:03 +090079 public DeviceId deviceId() {
80 return deviceId;
81 }
82
sangho90088532016-02-25 18:06:12 +090083 /**
84 * Returns tunnel ID.
85 *
86 * @return tunnel ID
87 */
Daniel Park5df65182016-01-09 00:12:03 +090088 public long vni() {
89 return vni;
90 }
91
sangho90088532016-02-25 18:06:12 +090092 /**
93 * Returns gateway IP address.
94 *
95 * @return gateway IP address
96 */
Daniel Park3a06c522016-01-28 20:51:12 +090097 public Ip4Address gatewayIP() {
98 return gatewayIP;
99 }
100
sangho90088532016-02-25 18:06:12 +0900101 /**
Daniel Park81a61a12016-02-26 08:24:44 +0900102 * Returns network ID.
103 *
104 * @return network ID
105 */
106 public String networkId() {
107 return networkId;
108 }
109
110 /**
sangho90088532016-02-25 18:06:12 +0900111 * Returns the builder of the OpenstackPortInfo.
112 *
113 * @return OpenstackPortInfo builder reference
114 */
Daniel Park5df65182016-01-09 00:12:03 +0900115 public static OpenstackPortInfo.Builder builder() {
116 return new Builder();
117 }
118
sangho90088532016-02-25 18:06:12 +0900119 /**
120 * Represents the OpenstackPortInfo Builder.
121 *
122 */
Daniel Park5df65182016-01-09 00:12:03 +0900123 public static final class Builder {
124 private Ip4Address hostIp;
sangho3623cb62016-01-15 22:06:38 +0900125 private MacAddress hostMac;
Daniel Park5df65182016-01-09 00:12:03 +0900126 private DeviceId deviceId;
127 private long vni;
Daniel Park3a06c522016-01-28 20:51:12 +0900128 private Ip4Address gatewayIP;
Daniel Park81a61a12016-02-26 08:24:44 +0900129 private String networkId;
Daniel Park3a06c522016-01-28 20:51:12 +0900130
sangho90088532016-02-25 18:06:12 +0900131 /**
132 * Sets the IP address of the port.
133 *
Daniel Park81a61a12016-02-26 08:24:44 +0900134 * @param gatewayIP gateway IP
sangho90088532016-02-25 18:06:12 +0900135 * @return Builder reference
136 */
Daniel Park3a06c522016-01-28 20:51:12 +0900137 public Builder setGatewayIP(Ip4Address gatewayIP) {
138 this.gatewayIP = checkNotNull(gatewayIP, "gatewayIP cannot be null");
139 return this;
140 }
Daniel Park5df65182016-01-09 00:12:03 +0900141
sangho90088532016-02-25 18:06:12 +0900142 /**
Daniel Park81a61a12016-02-26 08:24:44 +0900143 * Sets the network ID.
144 *
145 * @param networkId network id
146 * @return Builder reference
147 */
148 public Builder setNetworkId(String networkId) {
149 this.networkId = checkNotNull(networkId, "networkId cannot be null");
150 return this;
151 }
152
153 /**
sangho90088532016-02-25 18:06:12 +0900154 * Sets the host IP address of the port.
155 *
156 * @param hostIp host IP address
157 * @return Builder reference
158 */
Daniel Park5df65182016-01-09 00:12:03 +0900159 public Builder setHostIp(Ip4Address hostIp) {
160 this.hostIp = checkNotNull(hostIp, "hostIp cannot be null");
161 return this;
162 }
163
sangho90088532016-02-25 18:06:12 +0900164 /**
165 * Sets the host MAC address of the port.
166 *
167 * @param hostMac host MAC address
168 * @return Builder reference
169 */
sangho3623cb62016-01-15 22:06:38 +0900170 public Builder setHostMac(MacAddress hostMac) {
171 this.hostMac = checkNotNull(hostMac, "hostMac cannot be bull");
172 return this;
173 }
174
sangho90088532016-02-25 18:06:12 +0900175 /**
176 * Sets the device ID.
177 *
178 * @param deviceId device ID
179 * @return Builder reference
180 */
Daniel Park5df65182016-01-09 00:12:03 +0900181 public Builder setDeviceId(DeviceId deviceId) {
182 this.deviceId = checkNotNull(deviceId, "deviceId cannot be null");
183 return this;
184 }
185
sangho90088532016-02-25 18:06:12 +0900186 /**
187 * Sets the tunnel ID.
188 *
189 * @param vni tunnel ID
190 * @return Builder reference
191 */
Jonathan Hart51539b82015-10-29 09:53:04 -0700192 public Builder setVni(long vni) {
Daniel Park5df65182016-01-09 00:12:03 +0900193 this.vni = checkNotNull(vni, "vni cannot be null");
194 return this;
195 }
sangho90088532016-02-25 18:06:12 +0900196
197 /**
sangho90088532016-02-25 18:06:12 +0900198 * Builds the OpenstackPortInfo reference.
199 *
200 * @return OpenstackPortInfo reference
201 */
Daniel Park5df65182016-01-09 00:12:03 +0900202 public OpenstackPortInfo build() {
Hyunsun Moonb974fca2016-06-30 21:20:39 -0700203 return new OpenstackPortInfo(hostIp, hostMac, deviceId, vni, gatewayIP, networkId);
Daniel Park5df65182016-01-09 00:12:03 +0900204 }
205 }
Daniel Park5df65182016-01-09 00:12:03 +0900206}