Skip to content

Commit 31a3b87

Browse files
Alena ProkharchykAlena Prokharchyk
authored andcommitted
bug 13864: for elastic IP address return the purpose (staticNat or Lb) in listPublicIpAddresses api response
Reviewed-by: Frank
1 parent 4d27f3c commit 31a3b87

4 files changed

Lines changed: 23 additions & 5 deletions

File tree

api/src/com/cloud/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ public class ApiConstants {
331331
public static final String IS_STATIC_NAT = "isstaticnat";
332332
public static final String SORT_BY = "sortby";
333333
public static final String CHANGE_CIDR = "changecidr";
334+
public static final String PURPOSE = "purpose";
334335

335336
public enum HostDetails {
336337
all, capacity, events, stats, min;

api/src/com/cloud/api/response/IPAddressResponse.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
9393
private String state;
9494

9595
@SerializedName(ApiConstants.PHYSICAL_NETWORK_ID) @Param(description="the physical network this belongs to")
96-
private IdentityProxy physicalNetworkId = new IdentityProxy("physical_network");
96+
private IdentityProxy physicalNetworkId = new IdentityProxy("physical_network");
97+
98+
@SerializedName(ApiConstants.PURPOSE) @Param(description="purpose of the IP address. In Acton this value is not null for Elastic IPs only, and can have either StaticNat or LB value")
99+
private String purpose;
97100

98101
/*
99102
@SerializedName(ApiConstants.JOB_ID) @Param(description="shows the current pending asynchronous job ID. This tag is not returned if no current pending jobs are acting on the volume")
@@ -207,11 +210,11 @@ public void setPhysicalNetworkId(long physicalNetworkId) {
207210
this.physicalNetworkId.setValue(physicalNetworkId);
208211
}
209212

210-
public long getphysicalNetworkId() {
211-
return physicalNetworkId.getValue();
212-
}
213-
214213
public void setIsElastic(Boolean isElastic) {
215214
this.isElastic = isElastic;
216215
}
216+
217+
public void setPurpose(String purpose) {
218+
this.purpose = purpose;
219+
}
217220
}

api/src/com/cloud/network/IpAddress.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ enum State {
4444
Releasing, // The IP address is being released for other network elements and is not ready for allocation.
4545
Free // The IP address is ready to be allocated.
4646
}
47+
48+
enum Purpose {
49+
StaticNat,
50+
Lb
51+
}
4752

4853
long getDataCenterId();
4954

server/src/com/cloud/api/ApiResponseHelper.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,15 @@ public IPAddressResponse createIPAddressResponse(IpAddress ipAddress) {
759759
ipResponse.setVlanId(ipAddress.getVlanId());
760760
ipResponse.setVlanName(ApiDBUtils.findVlanById(ipAddress.getVlanId()).getVlanTag());
761761
}
762+
763+
if (ipAddress.getElastic()) {
764+
if (ipAddress.isOneToOneNat()) {
765+
ipResponse.setPurpose(IpAddress.Purpose.StaticNat.toString());
766+
} else {
767+
ipResponse.setPurpose(IpAddress.Purpose.Lb.toString());
768+
}
769+
}
770+
762771
ipResponse.setObjectName("ipaddress");
763772
return ipResponse;
764773
}

0 commit comments

Comments
 (0)