blob: 1b6250e02546aee8a8491515fd16883449e56401 [file] [log] [blame]
Daniel Park5df65182016-01-09 00:12:03 +09001/*
2 * Copyright 2014-2015 Open Networking Laboratory
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 */
Jian Li7f256f52016-01-24 15:08:05 -080016package org.onosproject.openstackswitching.impl;
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;
21
22import static com.google.common.base.Preconditions.checkNotNull;
23
24/**
25 * Contains OpenstackPort Information.
26 */
27public final class OpenstackPortInfo {
28
29 private final Ip4Address hostIp;
30 private final DeviceId deviceId;
sangho3623cb62016-01-15 22:06:38 +090031 private final MacAddress hostMac;
Daniel Park5df65182016-01-09 00:12:03 +090032 private final long vni;
33
sangho3623cb62016-01-15 22:06:38 +090034 public OpenstackPortInfo(Ip4Address hostIp, MacAddress hostMac, DeviceId deviceId,
Daniel Park5df65182016-01-09 00:12:03 +090035 long vni) {
36 this.hostIp = hostIp;
sangho3623cb62016-01-15 22:06:38 +090037 this.hostMac = hostMac;
Daniel Park5df65182016-01-09 00:12:03 +090038 this.deviceId = deviceId;
39 this.vni = vni;
40 }
41
42 public Ip4Address ip() {
43 return hostIp;
44 }
45
sangho3623cb62016-01-15 22:06:38 +090046 public MacAddress mac() {
47 return hostMac;
48 }
49
Daniel Park5df65182016-01-09 00:12:03 +090050 public DeviceId deviceId() {
51 return deviceId;
52 }
53
54 public long vni() {
55 return vni;
56 }
57
58 public static OpenstackPortInfo.Builder builder() {
59 return new Builder();
60 }
61
62 public static final class Builder {
63 private Ip4Address hostIp;
sangho3623cb62016-01-15 22:06:38 +090064 private MacAddress hostMac;
Daniel Park5df65182016-01-09 00:12:03 +090065 private DeviceId deviceId;
66 private long vni;
67
68 public Builder setHostIp(Ip4Address hostIp) {
69 this.hostIp = checkNotNull(hostIp, "hostIp cannot be null");
70 return this;
71 }
72
sangho3623cb62016-01-15 22:06:38 +090073 public Builder setHostMac(MacAddress hostMac) {
74 this.hostMac = checkNotNull(hostMac, "hostMac cannot be bull");
75 return this;
76 }
77
Daniel Park5df65182016-01-09 00:12:03 +090078 public Builder setDeviceId(DeviceId deviceId) {
79 this.deviceId = checkNotNull(deviceId, "deviceId cannot be null");
80 return this;
81 }
82
Jonathan Hart51539b82015-10-29 09:53:04 -070083 public Builder setVni(long vni) {
Daniel Park5df65182016-01-09 00:12:03 +090084 this.vni = checkNotNull(vni, "vni cannot be null");
85 return this;
86 }
87 public OpenstackPortInfo build() {
88 return new OpenstackPortInfo(this);
89 }
90 }
91
92 private OpenstackPortInfo(Builder builder) {
93 hostIp = builder.hostIp;
sangho3623cb62016-01-15 22:06:38 +090094 hostMac = builder.hostMac;
Daniel Park5df65182016-01-09 00:12:03 +090095 deviceId = builder.deviceId;
96 vni = builder.vni;
97 }
98}