CLOUDSTACK-1868. GetVmStatsCommand throws NullPointerException with VMWare.

This commit is contained in:
Likitha Shetty 2013-11-21 09:35:10 +05:30
parent 278ef81a83
commit 273c912bb6

View File

@ -6526,6 +6526,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
for(int i=0; i<values.size(); ++i) { for(int i=0; i<values.size(); ++i) {
List<PerfSampleInfo> infos = ((PerfEntityMetric)values.get(i)).getSampleInfo(); List<PerfSampleInfo> infos = ((PerfEntityMetric)values.get(i)).getSampleInfo();
if (infos != null && infos.size() > 0) {
int endMs = infos.get(infos.size()-1).getTimestamp().getSecond() * 1000 + infos.get(infos.size()-1).getTimestamp().getMillisecond(); int endMs = infos.get(infos.size()-1).getTimestamp().getSecond() * 1000 + infos.get(infos.size()-1).getTimestamp().getMillisecond();
int beginMs = infos.get(0).getTimestamp().getSecond() * 1000 + infos.get(0).getTimestamp().getMillisecond(); int beginMs = infos.get(0).getTimestamp().getSecond() * 1000 + infos.get(0).getTimestamp().getMillisecond();
sampleDuration = (endMs - beginMs) /1000; sampleDuration = (endMs - beginMs) /1000;
@ -6544,6 +6545,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
} }
} }
} }
}
vmResponseMap.put(name, new VmStatsEntry(Integer.parseInt(maxCpuUsage), networkReadKBs, networkWriteKBs, Integer.parseInt(numberCPUs), "vm")); vmResponseMap.put(name, new VmStatsEntry(Integer.parseInt(maxCpuUsage), networkReadKBs, networkWriteKBs, Integer.parseInt(numberCPUs), "vm"));
} }
} }