Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 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 | */ |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 16 | package org.onosproject.openstacknetworking; |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 17 | |
| 18 | import org.onlab.packet.Ip4Address; |
sangho | 3623cb6 | 2016-01-15 22:06:38 +0900 | [diff] [blame] | 19 | import org.onlab.packet.MacAddress; |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 20 | import org.onosproject.net.DeviceId; |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 21 | |
| 22 | import java.util.Collection; |
| 23 | import java.util.Collections; |
| 24 | |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 25 | import static com.google.common.base.Preconditions.checkNotNull; |
| 26 | |
| 27 | /** |
| 28 | * Contains OpenstackPort Information. |
| 29 | */ |
Daniel Park | 81a61a1 | 2016-02-26 08:24:44 +0900 | [diff] [blame] | 30 | public final class OpenstackPortInfo { |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 31 | private final Ip4Address hostIp; |
sangho | 3623cb6 | 2016-01-15 22:06:38 +0900 | [diff] [blame] | 32 | private final MacAddress hostMac; |
Daniel Park | 3a06c52 | 2016-01-28 20:51:12 +0900 | [diff] [blame] | 33 | private final DeviceId deviceId; |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 34 | private final long vni; |
Daniel Park | 3a06c52 | 2016-01-28 20:51:12 +0900 | [diff] [blame] | 35 | private final Ip4Address gatewayIP; |
Daniel Park | 81a61a1 | 2016-02-26 08:24:44 +0900 | [diff] [blame] | 36 | private final String networkId; |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 37 | private final Collection<String> securityGroups; |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 38 | |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 39 | /** |
| 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 Milkey | 21c3ebe | 2016-03-08 10:49:16 -0800 | [diff] [blame] | 47 | * @param networkId network identifier |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 48 | * @param securityGroups security group list |
| 49 | */ |
| 50 | public OpenstackPortInfo(Ip4Address hostIp, MacAddress hostMac, DeviceId deviceId, long vni, |
Daniel Park | 81a61a1 | 2016-02-26 08:24:44 +0900 | [diff] [blame] | 51 | Ip4Address gatewayIP, String networkId, Collection<String> securityGroups) { |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 52 | this.hostIp = hostIp; |
sangho | 3623cb6 | 2016-01-15 22:06:38 +0900 | [diff] [blame] | 53 | this.hostMac = hostMac; |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 54 | this.deviceId = deviceId; |
| 55 | this.vni = vni; |
Daniel Park | 3a06c52 | 2016-01-28 20:51:12 +0900 | [diff] [blame] | 56 | this.gatewayIP = gatewayIP; |
Daniel Park | 81a61a1 | 2016-02-26 08:24:44 +0900 | [diff] [blame] | 57 | this.networkId = networkId; |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 58 | this.securityGroups = securityGroups; |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 59 | } |
| 60 | |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 61 | /** |
| 62 | * Returns IP address of the port. |
| 63 | * |
| 64 | * @return IP address |
| 65 | */ |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 66 | public Ip4Address ip() { |
| 67 | return hostIp; |
| 68 | } |
| 69 | |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 70 | /** |
| 71 | * Returns MAC address of the port. |
| 72 | * |
| 73 | * @return MAC address |
| 74 | */ |
sangho | 3623cb6 | 2016-01-15 22:06:38 +0900 | [diff] [blame] | 75 | public MacAddress mac() { |
| 76 | return hostMac; |
| 77 | } |
| 78 | |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 79 | /** |
| 80 | * Returns device ID. |
| 81 | * |
| 82 | * @return device ID |
| 83 | */ |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 84 | public DeviceId deviceId() { |
| 85 | return deviceId; |
| 86 | } |
| 87 | |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 88 | /** |
| 89 | * Returns tunnel ID. |
| 90 | * |
| 91 | * @return tunnel ID |
| 92 | */ |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 93 | public long vni() { |
| 94 | return vni; |
| 95 | } |
| 96 | |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 97 | /** |
| 98 | * Returns gateway IP address. |
| 99 | * |
| 100 | * @return gateway IP address |
| 101 | */ |
Daniel Park | 3a06c52 | 2016-01-28 20:51:12 +0900 | [diff] [blame] | 102 | public Ip4Address gatewayIP() { |
| 103 | return gatewayIP; |
| 104 | } |
| 105 | |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 106 | /** |
Daniel Park | 81a61a1 | 2016-02-26 08:24:44 +0900 | [diff] [blame] | 107 | * Returns network ID. |
| 108 | * |
| 109 | * @return network ID |
| 110 | */ |
| 111 | public String networkId() { |
| 112 | return networkId; |
| 113 | } |
| 114 | |
| 115 | /** |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 116 | * 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 Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 129 | public static OpenstackPortInfo.Builder builder() { |
| 130 | return new Builder(); |
| 131 | } |
| 132 | |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 133 | /** |
| 134 | * Represents the OpenstackPortInfo Builder. |
| 135 | * |
| 136 | */ |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 137 | public static final class Builder { |
| 138 | private Ip4Address hostIp; |
sangho | 3623cb6 | 2016-01-15 22:06:38 +0900 | [diff] [blame] | 139 | private MacAddress hostMac; |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 140 | private DeviceId deviceId; |
| 141 | private long vni; |
Daniel Park | 3a06c52 | 2016-01-28 20:51:12 +0900 | [diff] [blame] | 142 | private Ip4Address gatewayIP; |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 143 | private Collection<String> securityGroups; |
Daniel Park | 81a61a1 | 2016-02-26 08:24:44 +0900 | [diff] [blame] | 144 | private String networkId; |
Daniel Park | 3a06c52 | 2016-01-28 20:51:12 +0900 | [diff] [blame] | 145 | |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 146 | /** |
| 147 | * Sets the IP address of the port. |
| 148 | * |
Daniel Park | 81a61a1 | 2016-02-26 08:24:44 +0900 | [diff] [blame] | 149 | * @param gatewayIP gateway IP |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 150 | * @return Builder reference |
| 151 | */ |
Daniel Park | 3a06c52 | 2016-01-28 20:51:12 +0900 | [diff] [blame] | 152 | public Builder setGatewayIP(Ip4Address gatewayIP) { |
| 153 | this.gatewayIP = checkNotNull(gatewayIP, "gatewayIP cannot be null"); |
| 154 | return this; |
| 155 | } |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 156 | |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 157 | /** |
Daniel Park | 81a61a1 | 2016-02-26 08:24:44 +0900 | [diff] [blame] | 158 | * 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 | /** |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 169 | * Sets the host IP address of the port. |
| 170 | * |
| 171 | * @param hostIp host IP address |
| 172 | * @return Builder reference |
| 173 | */ |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 174 | public Builder setHostIp(Ip4Address hostIp) { |
| 175 | this.hostIp = checkNotNull(hostIp, "hostIp cannot be null"); |
| 176 | return this; |
| 177 | } |
| 178 | |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 179 | /** |
| 180 | * Sets the host MAC address of the port. |
| 181 | * |
| 182 | * @param hostMac host MAC address |
| 183 | * @return Builder reference |
| 184 | */ |
sangho | 3623cb6 | 2016-01-15 22:06:38 +0900 | [diff] [blame] | 185 | public Builder setHostMac(MacAddress hostMac) { |
| 186 | this.hostMac = checkNotNull(hostMac, "hostMac cannot be bull"); |
| 187 | return this; |
| 188 | } |
| 189 | |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 190 | /** |
| 191 | * Sets the device ID. |
| 192 | * |
| 193 | * @param deviceId device ID |
| 194 | * @return Builder reference |
| 195 | */ |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 196 | public Builder setDeviceId(DeviceId deviceId) { |
| 197 | this.deviceId = checkNotNull(deviceId, "deviceId cannot be null"); |
| 198 | return this; |
| 199 | } |
| 200 | |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 201 | /** |
| 202 | * Sets the tunnel ID. |
| 203 | * |
| 204 | * @param vni tunnel ID |
| 205 | * @return Builder reference |
| 206 | */ |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 207 | public Builder setVni(long vni) { |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 208 | this.vni = checkNotNull(vni, "vni cannot be null"); |
| 209 | return this; |
| 210 | } |
sangho | 9008853 | 2016-02-25 18:06:12 +0900 | [diff] [blame] | 211 | |
| 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 Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 228 | public OpenstackPortInfo build() { |
Daniel Park | 81a61a1 | 2016-02-26 08:24:44 +0900 | [diff] [blame] | 229 | return new OpenstackPortInfo(hostIp, hostMac, deviceId, vni, gatewayIP, networkId, securityGroups); |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 230 | } |
| 231 | } |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 232 | } |