Skip to content

Commit d489dea

Browse files
committed
Fix str conversion
1 parent dd35b7a commit d489dea

File tree

1 file changed

+3
-1
lines changed
  • plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux

1 file changed

+3
-1
lines changed

plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ protected static long getCpuSpeed(final NodeInfo nodeInfo) {
9292
cpuInfoMaxFreqFileName), e);
9393
String command = "lscpu | grep -i 'Model name' | head -n 1 | egrep -o '[[:digit:]].[[:digit:]]+GHz' | sed 's/GHz//g'";
9494
String result = Script.runSimpleBashScript(command);
95-
return Long.parseLong(result) * 1000;
95+
long speed = (long) (Float.parseFloat(result) * 1000);
96+
LOGGER.info(String.format("Got [%d] speed from lscpu", speed));
97+
return speed;
9698
} catch (NullPointerException | NumberFormatException ex) {
9799
LOGGER.error(String.format("Unable to retrieve the CPU speed from file [%s] and lscpu. Using the value [%s] provided by the Libvirt.", cpuInfoMaxFreqFileName, nodeInfo.mhz), ex);
98100
return nodeInfo.mhz;

0 commit comments

Comments
 (0)