-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathNicProfile.java
More file actions
374 lines (304 loc) · 8.89 KB
/
NicProfile.java
File metadata and controls
374 lines (304 loc) · 8.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.vm;
import java.io.Serializable;
import java.net.URI;
import org.apache.cloudstack.api.InternalIdentity;
import com.cloud.network.Network;
import com.cloud.network.Networks.AddressFormat;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
import com.cloud.vm.Nic.ReservationStrategy;
public class NicProfile implements InternalIdentity, Serializable {
private static final long serialVersionUID = 4997005771736090304L;
long id;
long networkId;
BroadcastDomainType broadcastType;
Mode mode;
long vmId;
String gateway;
AddressFormat format;
TrafficType trafficType;
String ip4Address;
String ip6Address;
String ip6Gateway;
String ip6Cidr;
String macAddress;
URI isolationUri;
String netmask;
URI broadcastUri;
ReservationStrategy strategy;
String reservationId;
boolean defaultNic;
Integer deviceId;
String dns1;
String dns2;
String ip6Dns1;
String ip6Dns2;
Integer networkRate;
boolean isSecurityGroupEnabled;
String name;
String requestedIpv4;
String requestedIpv6;
String uuid;
public String getDns1() {
return dns1;
}
public String getName() {
return name;
}
public String getDns2() {
return dns2;
}
public void setDns1(String dns1) {
this.dns1 = dns1;
}
public void setDns2(String dns2) {
this.dns2 = dns2;
}
public boolean isDefaultNic() {
return defaultNic;
}
public String getNetmask() {
return netmask;
}
public void setNetmask(String netmask) {
this.netmask = netmask;
}
public void setBroadcastUri(URI broadcastUri) {
this.broadcastUri = broadcastUri;
}
public URI getBroadCastUri() {
return broadcastUri;
}
public void setIsolationUri(URI isolationUri) {
this.isolationUri = isolationUri;
}
public URI getIsolationUri() {
return isolationUri;
}
public void setStrategy(ReservationStrategy strategy) {
this.strategy = strategy;
}
public BroadcastDomainType getType() {
return broadcastType;
}
public void setBroadcastType(BroadcastDomainType broadcastType) {
this.broadcastType = broadcastType;
}
public void setMode(Mode mode) {
this.mode = mode;
}
public void setDeviceId(int deviceId) {
this.deviceId = deviceId;
}
public void setDefaultNic(boolean defaultNic) {
this.defaultNic = defaultNic;
}
public Integer getDeviceId() {
return deviceId;
}
public void setGateway(String gateway) {
this.gateway = gateway;
}
public void setFormat(AddressFormat format) {
this.format = format;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public void setTrafficType(TrafficType trafficType) {
this.trafficType = trafficType;
}
public void setIp6Address(String ip6Address) {
this.ip6Address = ip6Address;
}
public Mode getMode() {
return mode;
}
public long getNetworkId() {
return networkId;
}
public long getVirtualMachineId() {
return vmId;
}
@Override
public long getId() {
return id;
}
public BroadcastDomainType getBroadcastType() {
return broadcastType;
}
public void setMacAddress(String macAddress) {
this.macAddress = macAddress;
}
public long getVmId() {
return vmId;
}
public String getGateway() {
return gateway;
}
public AddressFormat getFormat() {
return format;
}
public TrafficType getTrafficType() {
return trafficType;
}
public String getIp4Address() {
return ip4Address;
}
public String getIp6Address() {
return ip6Address;
}
public String getMacAddress() {
return macAddress;
}
public void setIp4Address(String ip4Address) {
this.ip4Address = ip4Address;
}
public Integer getNetworkRate() {
return networkRate;
}
public ReservationStrategy getStrategy() {
return strategy;
}
public String getUuid() {
return uuid;
}
public NicProfile(Nic nic, Network network, URI broadcastUri, URI isolationUri, Integer networkRate, boolean isSecurityGroupEnabled, String name) {
id = nic.getId();
networkId = network.getId();
gateway = nic.getGateway();
mode = network.getMode();
broadcastType = network.getBroadcastDomainType();
trafficType = network.getTrafficType();
ip4Address = nic.getIp4Address();
format = nic.getAddressFormat();
ip6Address = nic.getIp6Address();
macAddress = nic.getMacAddress();
reservationId = nic.getReservationId();
strategy = nic.getReservationStrategy();
deviceId = nic.getDeviceId();
defaultNic = nic.isDefaultNic();
this.broadcastUri = broadcastUri;
this.isolationUri = isolationUri;
netmask = nic.getNetmask();
this.isSecurityGroupEnabled = isSecurityGroupEnabled;
vmId = nic.getInstanceId();
this.name = name;
ip6Cidr = nic.getIp6Cidr();
ip6Gateway = nic.getIp6Gateway();
uuid = nic.getUuid();
if (networkRate != null) {
this.networkRate = networkRate;
}
}
public NicProfile(ReservationStrategy strategy, String ip4Address, String macAddress, String gateway, String netmask) {
format = AddressFormat.Ip4;
this.ip4Address = ip4Address;
this.macAddress = macAddress;
this.gateway = gateway;
this.netmask = netmask;
this.strategy = strategy;
}
public NicProfile(String requestedIpv4, String requestedIpv6) {
this.requestedIpv4 = requestedIpv4;
this.requestedIpv6 = requestedIpv6;
}
public NicProfile() {
}
public ReservationStrategy getReservationStrategy() {
return strategy;
}
public String getReservationId() {
return reservationId;
}
public void setReservationId(String reservationId) {
this.reservationId = reservationId;
}
public boolean isSecurityGroupEnabled() {
return isSecurityGroupEnabled;
}
public void setSecurityGroupEnabled(boolean enabled) {
isSecurityGroupEnabled = enabled;
}
public String getRequestedIpv4() {
return requestedIpv4;
}
public void deallocate() {
gateway = null;
mode = null;
format = null;
broadcastType = null;
trafficType = null;
ip4Address = null;
ip6Address = null;
macAddress = null;
reservationId = null;
strategy = null;
deviceId = null;
broadcastUri = null;
isolationUri = null;
netmask = null;
dns1 = null;
dns2 = null;
}
@Override
public String toString() {
return new StringBuilder("NicProfile[").append(id)
.append("-")
.append(vmId)
.append("-")
.append(reservationId)
.append("-")
.append(ip4Address)
.append("-")
.append(broadcastUri)
.toString();
}
public String getIp6Gateway() {
return ip6Gateway;
}
public void setIp6Gateway(String ip6Gateway) {
this.ip6Gateway = ip6Gateway;
}
public String getIp6Cidr() {
return ip6Cidr;
}
public void setIp6Cidr(String ip6Cidr) {
this.ip6Cidr = ip6Cidr;
}
public String getRequestedIpv6() {
return requestedIpv6;
}
public void setRequestedIpv6(String requestedIpv6) {
this.requestedIpv6 = requestedIpv6;
}
public String getIp6Dns1() {
return ip6Dns1;
}
public void setIp6Dns1(String ip6Dns1) {
this.ip6Dns1 = ip6Dns1;
}
public String getIp6Dns2() {
return ip6Dns2;
}
public void setIp6Dns2(String ip6Dns2) {
this.ip6Dns2 = ip6Dns2;
}
}