Updated Branches: refs/heads/4.2 2f308cc98 -> 982c5fffb
CLOUDSTACK-5228: [API] [EIP/ELB enabled Zone] Need to display EIP address as "Public IP Address" for system VMs In system VM response object return EIP as public IP in case of basic zone with EIP service. Conflicts: server/src/com/cloud/api/ApiResponseHelper.java Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/982c5fff Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/982c5fff Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/982c5fff Branch: refs/heads/4.2 Commit: 982c5fffbfe7e0af37ee061f6ab4a4b76869ade4 Parents: 2f308cc Author: Murali Reddy <murali.re...@citrix.com> Authored: Tue Dec 4 14:56:58 2012 +0530 Committer: Murali Reddy <muralimmre...@gmail.com> Committed: Thu Nov 21 15:29:17 2013 +0530 ---------------------------------------------------------------------- server/src/com/cloud/api/ApiResponseHelper.java | 21 ++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/982c5fff/server/src/com/cloud/api/ApiResponseHelper.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index b5d2de6..68770e5 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -1149,12 +1149,29 @@ public class ApiResponseHelper implements ResponseGenerator { vmResponse.setLinkLocalIp(singleNicProfile.getIp4Address()); vmResponse.setLinkLocalMacAddress(singleNicProfile.getMacAddress()); vmResponse.setLinkLocalNetmask(singleNicProfile.getNetmask()); - } else if (network.getTrafficType() == TrafficType.Public || network.getTrafficType() == TrafficType.Guest) { - /*In basic zone, public ip has TrafficType.Guest*/ + } else if (network.getTrafficType() == TrafficType.Public) { vmResponse.setPublicIp(singleNicProfile.getIp4Address()); vmResponse.setPublicMacAddress(singleNicProfile.getMacAddress()); vmResponse.setPublicNetmask(singleNicProfile.getNetmask()); vmResponse.setGateway(singleNicProfile.getGateway()); + } else if (network.getTrafficType() == TrafficType.Guest) { + /* + * In basic zone, public ip has TrafficType.Guest in case EIP service is not enabled. + * When EIP service is enabled in the basic zone, system VM by default get the public + * IP allocated for EIP. So return the guest/public IP accordingly. + * */ + NetworkOffering networkOffering = ApiDBUtils.findNetworkOfferingById(network.getNetworkOfferingId()); + if (networkOffering.getElasticIp()) { + IpAddress ip = ApiDBUtils.findIpByAssociatedVmId(vm.getId()); + if (ip != null) { + vmResponse.setPublicIp(ip.getAddress().addr()); + } + } else { + vmResponse.setPublicIp(singleNicProfile.getIp4Address()); + vmResponse.setPublicMacAddress(singleNicProfile.getMacAddress()); + vmResponse.setPublicNetmask(singleNicProfile.getNetmask()); + vmResponse.setGateway(singleNicProfile.getGateway()); + } } } }