CS-16962: [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
This commit is contained in:
Murali Reddy 2012-12-04 14:56:58 +05:30 committed by Murali Reddy
parent 8c6840e489
commit 899e9f0d60
1 changed files with 19 additions and 2 deletions

View File

@ -1186,12 +1186,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());
}
}
}
}