blob: feb05f9ee7a02bc998d7ec5896b48fddf0a9e465 [file] [log] [blame]
Kyuhwi Choi5d7c9982016-01-20 13:55:55 +09001/*
2 * Copyright 2016 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 */
16package org.onosproject.openstackrouting;
17
18import org.onlab.packet.Ip4Address;
19
20/**
21 * An Openstack Neutron Floating IP Model.
22 */
23public final class OpenstackFloatingIP {
24
25 public enum FloatingIPStatus {
26 UP,
27 DOWN,
28 ACTIVE,
29 }
30
31 private String tenantId;
32 private String networkId;
33 private Ip4Address fixedIpAddress;
34 private String portId;
35 private String routerId;
36 private String id;
37 private Ip4Address floatingIpAddress;
38 private FloatingIPStatus status;
39
40 private OpenstackFloatingIP(FloatingIPStatus status, String id, String tenantId,
41 String networkId, Ip4Address fixedIpAddress, String portId,
42 String routerId, Ip4Address floatingIpAddress) {
43 this.status = status;
44 this.id = id;
45 this.tenantId = tenantId;
46 this.networkId = networkId;
47 this.fixedIpAddress = fixedIpAddress;
48 this.portId = portId;
49 this.routerId = routerId;
50 this.floatingIpAddress = floatingIpAddress;
51 }
52
53 /**
54 * Returns floating ip status.
55 *
56 * @return floating ip status
57 */
58 public FloatingIPStatus status() {
59 return status;
60 }
61
62 /**
63 * Returns floating ip`s ID.
64 *
65 * @return floating ip`s ID
66 */
67 public String id() {
68 return id;
69 }
70
71 /**
72 * Returns tenant ID.
73 *
74 * @return tenant ID
75 */
76 public String tenantId() {
77 return tenantId;
78 }
79
80 /**
81 * Returns network ID.
82 *
83 * @return network ID
84 */
85 public String networkId() {
86 return networkId;
87 }
88
89 /**
90 * Returns fixed IP Address.
91 *
92 * @return fixed IP Address
93 */
94 public Ip4Address fixedIpAddress() {
95 return fixedIpAddress;
96 }
97
98 /**
99 * Returns port ID.
100 *
101 * @return port ID
102 */
103 public String portId() {
104 return portId;
105 }
106
107 /**
108 * Returns router ID.
109 *
110 * @return router ID
111 */
112 public String routerId() {
113 return routerId;
114 }
115
116 /**
117 * Returns floating IP address.
118 *
119 * @return Floating IP address
120 */
121 public Ip4Address floatingIpAddress() {
122 return floatingIpAddress;
123 }
124
125 /**
126 * An Openstack Floating IP Builder class.
127 */
128 public static final class Builder {
129 private String tenantId;
130 private String networkId;
131 private Ip4Address fixedIpAddress;
132 private String portId;
133 private String routerId;
134 private String id;
135 private Ip4Address floatingIpAddress;
136 private FloatingIPStatus status;
137
138 /**
139 * Sets tenant ID.
140 *
141 * @param tenantId tenant ID
142 * @return Builder object
143 */
144 public Builder tenantId(String tenantId) {
145 this.tenantId = tenantId;
146 return this;
147 }
148
149 /**
150 * Sets floating IP status.
151 *
152 * @param status Floating IP status
153 * @return Builder object
154 */
155 public Builder status(FloatingIPStatus status) {
156 this.status = status;
157 return this;
158 }
159
160 /**
161 * Sets Floating IP`s ID.
162 *
163 * @param id Floating IP`s ID
164 * @return Builder object
165 */
166 public Builder id(String id) {
167 this.id = id;
168 return this;
169 }
170
171 /**
172 * Sets network ID.
173 *
174 * @param networkId Network ID
175 * @return Builder object
176 */
177 public Builder networkId(String networkId) {
178 this.networkId = networkId;
179 return this;
180 }
181
182 /**
183 * Sets fixed IP address.
184 *
185 * @param fixedIpAddress Fixed IP address
186 * @return Builder object
187 */
188 public Builder fixedIpAddress(Ip4Address fixedIpAddress) {
189 this.fixedIpAddress = fixedIpAddress;
190 return this;
191 }
192
193 /**
194 * Sets port ID.
195 *
196 * @param portId port ID
197 * @return Builder object
198 */
199 public Builder portId(String portId) {
200 this.portId = portId;
201 return this;
202 }
203
204 /**
205 * Sets router ID.
206 *
207 * @param routerId router ID
208 * @return Builder object
209 */
210 public Builder routerId(String routerId) {
211 this.routerId = routerId;
212 return this;
213 }
214
215 /**
216 * Sets floating IP address.
217 *
218 * @param floatingIpAddress Floating IP address
219 * @return Builder object
220 */
221 public Builder floatingIpAddress(Ip4Address floatingIpAddress) {
222 this.floatingIpAddress = floatingIpAddress;
223 return this;
224 }
225
226 /**
227 * Builds an OpenstackFloatingIP object.
228 *
229 * @return OpenstackFloatingIP object
230 */
231 public OpenstackFloatingIP build() {
232 return new OpenstackFloatingIP(status, id, tenantId, networkId,
233 fixedIpAddress, portId, routerId, floatingIpAddress);
234
235 }
236 }
237}