blob: 0099ea9adb224aa59c62e6668001ad8bcc91d791 [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;
Daniel Park5df65182016-01-09 00:12:03 +090021import static com.google.common.base.Preconditions.checkNotNull;
22
23/**
24 * Contains OpenstackPort Information.
25 */
Daniel Park3a06c522016-01-28 20:51:12 +090026public class OpenstackPortInfo {
Daniel Park5df65182016-01-09 00:12:03 +090027 private final Ip4Address hostIp;
sangho3623cb62016-01-15 22:06:38 +090028 private final MacAddress hostMac;
Daniel Park3a06c522016-01-28 20:51:12 +090029 private final DeviceId deviceId;
Daniel Park5df65182016-01-09 00:12:03 +090030 private final long vni;
Daniel Park3a06c522016-01-28 20:51:12 +090031 private final Ip4Address gatewayIP;
Daniel Park5df65182016-01-09 00:12:03 +090032
Daniel Park3a06c522016-01-28 20:51:12 +090033 public OpenstackPortInfo(Ip4Address hostIp, MacAddress hostMac, DeviceId deviceId, long vni, Ip4Address gatewayIP) {
Daniel Park5df65182016-01-09 00:12:03 +090034 this.hostIp = hostIp;
sangho3623cb62016-01-15 22:06:38 +090035 this.hostMac = hostMac;
Daniel Park5df65182016-01-09 00:12:03 +090036 this.deviceId = deviceId;
37 this.vni = vni;
Daniel Park3a06c522016-01-28 20:51:12 +090038 this.gatewayIP = gatewayIP;
Daniel Park5df65182016-01-09 00:12:03 +090039 }
40
41 public Ip4Address ip() {
42 return hostIp;
43 }
44
sangho3623cb62016-01-15 22:06:38 +090045 public MacAddress mac() {
46 return hostMac;
47 }
48
Daniel Park5df65182016-01-09 00:12:03 +090049 public DeviceId deviceId() {
50 return deviceId;
51 }
52
53 public long vni() {
54 return vni;
55 }
56
Daniel Park3a06c522016-01-28 20:51:12 +090057 public Ip4Address gatewayIP() {
58 return gatewayIP;
59 }
60
Daniel Park5df65182016-01-09 00:12:03 +090061 public static OpenstackPortInfo.Builder builder() {
62 return new Builder();
63 }
64
65 public static final class Builder {
66 private Ip4Address hostIp;
sangho3623cb62016-01-15 22:06:38 +090067 private MacAddress hostMac;
Daniel Park5df65182016-01-09 00:12:03 +090068 private DeviceId deviceId;
69 private long vni;
Daniel Park3a06c522016-01-28 20:51:12 +090070 private Ip4Address gatewayIP;
71
72 public Builder setGatewayIP(Ip4Address gatewayIP) {
73 this.gatewayIP = checkNotNull(gatewayIP, "gatewayIP cannot be null");
74 return this;
75 }
Daniel Park5df65182016-01-09 00:12:03 +090076
77 public Builder setHostIp(Ip4Address hostIp) {
78 this.hostIp = checkNotNull(hostIp, "hostIp cannot be null");
79 return this;
80 }
81
sangho3623cb62016-01-15 22:06:38 +090082 public Builder setHostMac(MacAddress hostMac) {
83 this.hostMac = checkNotNull(hostMac, "hostMac cannot be bull");
84 return this;
85 }
86
Daniel Park5df65182016-01-09 00:12:03 +090087 public Builder setDeviceId(DeviceId deviceId) {
88 this.deviceId = checkNotNull(deviceId, "deviceId cannot be null");
89 return this;
90 }
91
Jonathan Hart51539b82015-10-29 09:53:04 -070092 public Builder setVni(long vni) {
Daniel Park5df65182016-01-09 00:12:03 +090093 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;
sangho3623cb62016-01-15 22:06:38 +0900103 hostMac = builder.hostMac;
Daniel Park5df65182016-01-09 00:12:03 +0900104 deviceId = builder.deviceId;
105 vni = builder.vni;
Daniel Park3a06c522016-01-28 20:51:12 +0900106 gatewayIP = builder.gatewayIP;
Daniel Park5df65182016-01-09 00:12:03 +0900107 }
108}