Skip to content

Commit 4e09079

Browse files
committed
Update the Logical Router NatRules to be compatible with the NVP 3.x.x
platform Use the Gson adapters to serialize/deserialize the NatRules Switch the NiciraNvpApi to a single gson Object with the proper adapters Fix missing order setting for static nat rules and portforwarding rules Return an error when a port range is passed in a portforwarding rule The serializer is not required Fix a bug where an ip address could be released even if it was still in use for SourceNat Throw a json parse exception when the type is unknown to the adapter
1 parent 83f84ad commit 4e09079

9 files changed

Lines changed: 493 additions & 500 deletions

File tree

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package com.cloud.network.nicira;
2+
3+
public class DestinationNatRule extends NatRule {
4+
private String toDestinationIpAddress;
5+
private Integer toDestinationPort;
6+
7+
public DestinationNatRule() {
8+
setType("DestinationNatRule");
9+
}
10+
11+
public String getToDestinationIpAddress() {
12+
return toDestinationIpAddress;
13+
}
14+
15+
16+
public void setToDestinationIpAddress(String toDestinationIpAddress) {
17+
this.toDestinationIpAddress = toDestinationIpAddress;
18+
}
19+
20+
21+
public Integer getToDestinationPort() {
22+
return toDestinationPort;
23+
}
24+
25+
26+
public void setToDestinationPort(Integer toDestinationPort) {
27+
this.toDestinationPort = toDestinationPort;
28+
}
29+
30+
@Override
31+
public int hashCode() {
32+
final int prime = 31;
33+
int result = super.hashCode();
34+
result = prime
35+
* result
36+
+ ((toDestinationIpAddress == null) ? 0
37+
: toDestinationIpAddress.hashCode());
38+
result = prime
39+
* result
40+
+ ((toDestinationPort == null) ? 0 : toDestinationPort
41+
.hashCode());
42+
return result;
43+
}
44+
45+
@Override
46+
public boolean equals(Object obj) {
47+
if (this == obj)
48+
return true;
49+
if (!super.equals(obj))
50+
return false;
51+
if (getClass() != obj.getClass())
52+
return false;
53+
DestinationNatRule other = (DestinationNatRule) obj;
54+
if (toDestinationIpAddress == null) {
55+
if (other.toDestinationIpAddress != null)
56+
return false;
57+
} else if (!toDestinationIpAddress.equals(other.toDestinationIpAddress))
58+
return false;
59+
if (toDestinationPort == null) {
60+
if (other.toDestinationPort != null)
61+
return false;
62+
} else if (!toDestinationPort.equals(other.toDestinationPort))
63+
return false;
64+
return true;
65+
}
66+
67+
@Override
68+
public boolean equalsIgnoreUuid(Object obj) {
69+
if (this == obj)
70+
return true;
71+
if (!super.equalsIgnoreUuid(obj))
72+
return false;
73+
if (getClass() != obj.getClass())
74+
return false;
75+
DestinationNatRule other = (DestinationNatRule) obj;
76+
if (toDestinationIpAddress == null) {
77+
if (other.toDestinationIpAddress != null)
78+
return false;
79+
} else if (!toDestinationIpAddress.equals(other.toDestinationIpAddress))
80+
return false;
81+
if (toDestinationPort == null) {
82+
if (other.toDestinationPort != null)
83+
return false;
84+
} else if (!toDestinationPort.equals(other.toDestinationPort))
85+
return false;
86+
return true;
87+
}
88+
89+
}

‎plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Match.java‎

Lines changed: 20 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,9 @@
2222
public class Match {
2323
private Integer protocol;
2424
private String source_ip_addresses;
25-
private Boolean source_ip_addresses_not;
2625
private String destination_ip_addresses;
27-
private Boolean destination_ip_addresses_not;
28-
private Integer source_port_min;
29-
private Integer source_port_max;
30-
private Boolean source_port_not;
31-
private Integer destination_port_min;
32-
private Integer destination_port_max;
33-
private Boolean destination_port_not;
26+
private Integer source_port;
27+
private Integer destination_port;
3428
private String ethertype = "IPv4";
3529

3630
public Integer getProtocol() {
@@ -41,54 +35,22 @@ public void setProtocol(Integer protocol) {
4135
this.protocol = protocol;
4236
}
4337

44-
public Integer getSourcePortMin() {
45-
return source_port_min;
38+
public Integer getSourcePort() {
39+
return source_port;
4640
}
4741

48-
public void setSourcePortMin(Integer source_port_min) {
49-
this.source_port_min = source_port_min;
42+
public void setSourcePort(Integer source_port) {
43+
this.source_port = source_port;
5044
}
51-
52-
public Integer getSourcePortMax() {
53-
return source_port_max;
54-
}
55-
56-
public void setSourcePortMax(Integer source_port_max) {
57-
this.source_port_max = source_port_max;
58-
}
59-
60-
public Boolean isSourcePortNot() {
61-
return source_port_not;
62-
}
63-
64-
public void setSourcePortNot(Boolean source_port_not) {
65-
this.source_port_not = source_port_not;
66-
}
67-
68-
public Integer getDestinationPortMin() {
69-
return destination_port_min;
70-
}
71-
72-
public void setDestinationPortMin(Integer destination_port_min) {
73-
this.destination_port_min = destination_port_min;
74-
}
75-
76-
public Integer getDestinationPortMax() {
77-
return destination_port_max;
45+
46+
public Integer getDestinationPort() {
47+
return destination_port;
7848
}
7949

80-
public void setDestinationPortMax(Integer destination_port_max) {
81-
this.destination_port_max = destination_port_max;
50+
public void setDestinationPort(Integer destination_port) {
51+
this.destination_port = destination_port;
8252
}
83-
84-
public Boolean isDestinationPortNot() {
85-
return destination_port_not;
86-
}
87-
88-
public void setDestinationPortNot(Boolean destination_port_not) {
89-
this.destination_port_not = destination_port_not;
90-
}
91-
53+
9254
public String getEthertype() {
9355
return ethertype;
9456
}
@@ -105,14 +67,6 @@ public void setSourceIpAddresses(String source_ip_addresses) {
10567
this.source_ip_addresses = source_ip_addresses;
10668
}
10769

108-
public boolean isSourceIpAddressesNot() {
109-
return source_ip_addresses_not;
110-
}
111-
112-
public void setSourceIpAddresses_not(boolean source_ip_addresses_not) {
113-
this.source_ip_addresses_not = source_ip_addresses_not;
114-
}
115-
11670
public String getDestinationIpAddresses() {
11771
return destination_ip_addresses;
11872
}
@@ -121,14 +75,6 @@ public void setDestinationIpAddresses(String destination_ip_addresses) {
12175
this.destination_ip_addresses = destination_ip_addresses;
12276
}
12377

124-
public Boolean isDestinationIpAddressesNot() {
125-
return destination_ip_addresses_not;
126-
}
127-
128-
public void setDestinationIpAddressesNot(Boolean destination_ip_addresses_not) {
129-
this.destination_ip_addresses_not = destination_ip_addresses_not;
130-
}
131-
13278
@Override
13379
public int hashCode() {
13480
final int prime = 31;
@@ -139,19 +85,7 @@ public int hashCode() {
13985
: destination_ip_addresses.hashCode());
14086
result = prime
14187
* result
142-
+ ((destination_ip_addresses_not == null) ? 0
143-
: destination_ip_addresses_not.hashCode());
144-
result = prime
145-
* result
146-
+ ((destination_port_max == null) ? 0 : destination_port_max
147-
.hashCode());
148-
result = prime
149-
* result
150-
+ ((destination_port_min == null) ? 0 : destination_port_min
151-
.hashCode());
152-
result = prime
153-
* result
154-
+ ((destination_port_not == null) ? 0 : destination_port_not
88+
+ ((destination_port == null) ? 0 : destination_port
15589
.hashCode());
15690
result = prime * result
15791
+ ((ethertype == null) ? 0 : ethertype.hashCode());
@@ -161,16 +95,8 @@ public int hashCode() {
16195
* result
16296
+ ((source_ip_addresses == null) ? 0 : source_ip_addresses
16397
.hashCode());
164-
result = prime
165-
* result
166-
+ ((source_ip_addresses_not == null) ? 0
167-
: source_ip_addresses_not.hashCode());
168-
result = prime * result
169-
+ ((source_port_max == null) ? 0 : source_port_max.hashCode());
170-
result = prime * result
171-
+ ((source_port_min == null) ? 0 : source_port_min.hashCode());
17298
result = prime * result
173-
+ ((source_port_not == null) ? 0 : source_port_not.hashCode());
99+
+ ((source_port == null) ? 0 : source_port.hashCode());
174100
return result;
175101
}
176102

@@ -189,26 +115,10 @@ public boolean equals(Object obj) {
189115
} else if (!destination_ip_addresses
190116
.equals(other.destination_ip_addresses))
191117
return false;
192-
if (destination_ip_addresses_not == null) {
193-
if (other.destination_ip_addresses_not != null)
118+
if (destination_port == null) {
119+
if (other.destination_port != null)
194120
return false;
195-
} else if (!destination_ip_addresses_not
196-
.equals(other.destination_ip_addresses_not))
197-
return false;
198-
if (destination_port_max == null) {
199-
if (other.destination_port_max != null)
200-
return false;
201-
} else if (!destination_port_max.equals(other.destination_port_max))
202-
return false;
203-
if (destination_port_min == null) {
204-
if (other.destination_port_min != null)
205-
return false;
206-
} else if (!destination_port_min.equals(other.destination_port_min))
207-
return false;
208-
if (destination_port_not == null) {
209-
if (other.destination_port_not != null)
210-
return false;
211-
} else if (!destination_port_not.equals(other.destination_port_not))
121+
} else if (!destination_port.equals(other.destination_port))
212122
return false;
213123
if (ethertype == null) {
214124
if (other.ethertype != null)
@@ -225,26 +135,10 @@ public boolean equals(Object obj) {
225135
return false;
226136
} else if (!source_ip_addresses.equals(other.source_ip_addresses))
227137
return false;
228-
if (source_ip_addresses_not == null) {
229-
if (other.source_ip_addresses_not != null)
230-
return false;
231-
} else if (!source_ip_addresses_not
232-
.equals(other.source_ip_addresses_not))
233-
return false;
234-
if (source_port_max == null) {
235-
if (other.source_port_max != null)
236-
return false;
237-
} else if (!source_port_max.equals(other.source_port_max))
238-
return false;
239-
if (source_port_min == null) {
240-
if (other.source_port_min != null)
241-
return false;
242-
} else if (!source_port_min.equals(other.source_port_min))
243-
return false;
244-
if (source_port_not == null) {
245-
if (other.source_port_not != null)
138+
if (source_port == null) {
139+
if (other.source_port != null)
246140
return false;
247-
} else if (!source_port_not.equals(other.source_port_not))
141+
} else if (!source_port.equals(other.source_port))
248142
return false;
249143
return true;
250144
}

0 commit comments

Comments
 (0)