mirror of https://github.com/apache/cloudstack.git
simplify setCpuUsed
- variables inlined - cpu utilization is not cast to float from double Signed-off-by: Laszlo Hornyak <laszlo.hornyak@gmail.com> Signed-off-by: Min Chen <min.chen@citrix.com>
This commit is contained in:
parent
d3237e75b2
commit
cb3a3da75d
|
|
@ -166,14 +166,10 @@ public class UserVmJoinDaoImpl extends GenericDaoBase<UserVmJoinVO, Long> implem
|
|||
userVmResponse.setKeyPairName(userVm.getKeypairName());
|
||||
|
||||
if (details.contains(VMDetails.all) || details.contains(VMDetails.stats)) {
|
||||
DecimalFormat decimalFormat = new DecimalFormat("#.##");
|
||||
// stats calculation
|
||||
String cpuUsed = null;
|
||||
VmStats vmStats = ApiDBUtils.getVmStatistics(userVm.getId());
|
||||
if (vmStats != null) {
|
||||
float cpuUtil = (float) vmStats.getCPUUtilization();
|
||||
cpuUsed = decimalFormat.format(cpuUtil) + "%";
|
||||
userVmResponse.setCpuUsed(cpuUsed);
|
||||
userVmResponse.setCpuUsed(new DecimalFormat("#.##").format(vmStats.getCPUUtilization()) + "%");
|
||||
|
||||
userVmResponse.setNetworkKbsRead((long) vmStats.getNetworkReadKBs());
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue