Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 1 | /* |
Daniel Park | 3a06c52 | 2016-01-28 20:51:12 +0900 | [diff] [blame] | 2 | * Copyright 2015 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; |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 21 | import static com.google.common.base.Preconditions.checkNotNull; |
| 22 | |
| 23 | /** |
| 24 | * Contains OpenstackPort Information. |
| 25 | */ |
Daniel Park | 3a06c52 | 2016-01-28 20:51:12 +0900 | [diff] [blame] | 26 | public class OpenstackPortInfo { |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 27 | private final Ip4Address hostIp; |
sangho | 3623cb6 | 2016-01-15 22:06:38 +0900 | [diff] [blame] | 28 | private final MacAddress hostMac; |
Daniel Park | 3a06c52 | 2016-01-28 20:51:12 +0900 | [diff] [blame] | 29 | private final DeviceId deviceId; |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 30 | private final long vni; |
Daniel Park | 3a06c52 | 2016-01-28 20:51:12 +0900 | [diff] [blame] | 31 | private final Ip4Address gatewayIP; |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 32 | |
Daniel Park | 3a06c52 | 2016-01-28 20:51:12 +0900 | [diff] [blame] | 33 | public OpenstackPortInfo(Ip4Address hostIp, MacAddress hostMac, DeviceId deviceId, long vni, Ip4Address gatewayIP) { |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 34 | this.hostIp = hostIp; |
sangho | 3623cb6 | 2016-01-15 22:06:38 +0900 | [diff] [blame] | 35 | this.hostMac = hostMac; |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 36 | this.deviceId = deviceId; |
| 37 | this.vni = vni; |
Daniel Park | 3a06c52 | 2016-01-28 20:51:12 +0900 | [diff] [blame] | 38 | this.gatewayIP = gatewayIP; |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | public Ip4Address ip() { |
| 42 | return hostIp; |
| 43 | } |
| 44 | |
sangho | 3623cb6 | 2016-01-15 22:06:38 +0900 | [diff] [blame] | 45 | public MacAddress mac() { |
| 46 | return hostMac; |
| 47 | } |
| 48 | |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 49 | public DeviceId deviceId() { |
| 50 | return deviceId; |
| 51 | } |
| 52 | |
| 53 | public long vni() { |
| 54 | return vni; |
| 55 | } |
| 56 | |
Daniel Park | 3a06c52 | 2016-01-28 20:51:12 +0900 | [diff] [blame] | 57 | public Ip4Address gatewayIP() { |
| 58 | return gatewayIP; |
| 59 | } |
| 60 | |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 61 | public static OpenstackPortInfo.Builder builder() { |
| 62 | return new Builder(); |
| 63 | } |
| 64 | |
| 65 | public static final class Builder { |
| 66 | private Ip4Address hostIp; |
sangho | 3623cb6 | 2016-01-15 22:06:38 +0900 | [diff] [blame] | 67 | private MacAddress hostMac; |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 68 | private DeviceId deviceId; |
| 69 | private long vni; |
Daniel Park | 3a06c52 | 2016-01-28 20:51:12 +0900 | [diff] [blame] | 70 | private Ip4Address gatewayIP; |
| 71 | |
| 72 | public Builder setGatewayIP(Ip4Address gatewayIP) { |
| 73 | this.gatewayIP = checkNotNull(gatewayIP, "gatewayIP cannot be null"); |
| 74 | return this; |
| 75 | } |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 76 | |
| 77 | public Builder setHostIp(Ip4Address hostIp) { |
| 78 | this.hostIp = checkNotNull(hostIp, "hostIp cannot be null"); |
| 79 | return this; |
| 80 | } |
| 81 | |
sangho | 3623cb6 | 2016-01-15 22:06:38 +0900 | [diff] [blame] | 82 | public Builder setHostMac(MacAddress hostMac) { |
| 83 | this.hostMac = checkNotNull(hostMac, "hostMac cannot be bull"); |
| 84 | return this; |
| 85 | } |
| 86 | |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 87 | public Builder setDeviceId(DeviceId deviceId) { |
| 88 | this.deviceId = checkNotNull(deviceId, "deviceId cannot be null"); |
| 89 | return this; |
| 90 | } |
| 91 | |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 92 | public Builder setVni(long vni) { |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 93 | this.vni = checkNotNull(vni, "vni cannot be null"); |
| 94 | return this; |
| 95 | } |
| 96 | public OpenstackPortInfo build() { |
| 97 | return new OpenstackPortInfo(this); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | private OpenstackPortInfo(Builder builder) { |
| 102 | hostIp = builder.hostIp; |
sangho | 3623cb6 | 2016-01-15 22:06:38 +0900 | [diff] [blame] | 103 | hostMac = builder.hostMac; |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 104 | deviceId = builder.deviceId; |
| 105 | vni = builder.vni; |
Daniel Park | 3a06c52 | 2016-01-28 20:51:12 +0900 | [diff] [blame] | 106 | gatewayIP = builder.gatewayIP; |
Daniel Park | 5df6518 | 2016-01-09 00:12:03 +0900 | [diff] [blame] | 107 | } |
| 108 | } |