// FIXME: Kubevirt currently have only kubevirt_vmi_vcpu_seconds, which is total CPU time,
// so we are setting it here only as system time, which is wrong.
private VdsmVm appendStatistics(VdsmVm vm, V1VirtualMachineInstance vmi) {
        VmStatistics statistics = new VmStatistics();
        statistics.setId(vm.getId());
        DateTime creationTimestampDate = vmi.getMetadata().getCreationTimestamp();
        if (creationTimestampDate != null) {
            DateTime now = DateTime.now();
            Seconds seconds = Seconds.secondsBetween(creationTimestampDate, now);
            statistics.setElapsedTime((double) seconds.getSeconds());
        }
        PrometheusClient promClient = getPrometheusClient();
        if (promClient != null) {
            // FIXME: Kubevirt currently have only kubevirt_vmi_vcpu_seconds, which is total CPU time,
            // so we are setting it here only as system time, which is wrong.
            statistics.setCpuSys(
                    promClient.getVmiCpuUsage(vmi.getMetadata().getName(), vmi.getMetadata().getNamespace())
            );
        }
        return vm.setVmStatistics(statistics)
                .setDiskStatistics(Collections.emptyList())
                .setVmJobs(Collections.emptyList());
    }
PrometheusClient promClient = getPrometheusClient();
if (promClient != null) {
// FIXME: Kubevirt currently have only kubevirt_vmi_vcpu_seconds, which is total CPU time,
// so we are setting it here only as system time, which is wrong.
statistics.setCpuSys(
promClient.getVmiCpuUsage(vmi.getMetadata().getName(), vmi.getMetadata().getNamespace())
VmStatistics statistics = new VmStatistics();
statistics.setId(vm.getId());
DateTime creationTimestampDate = vmi.getMetadata().getCreationTimestamp();
if (creationTimestampDate != null) {
DateTime now = DateTime.now();
Seconds seconds = Seconds.secondsBetween(creationTimestampDate, now);
statistics.setElapsedTime((double) seconds.getSeconds());
}
PrometheusClient promClient = getPrometheusClient();
if (promClient != null) {
// FIXME: Kubevirt currently have only kubevirt_vmi_vcpu_seconds, which is total CPU time,
// so we are setting it here only as system time, which is wrong.
statistics.setCpuSys(
promClient.getVmiCpuUsage(vmi.getMetadata().getName(), vmi.getMetadata().getNamespace())
);
}
return vm.setVmStatistics(statistics)
.setDiskStatistics(Collections.emptyList())
.setVmJobs(Collections.emptyList());
}
private VdsmVm appendStatistics(VdsmVm vm, V1VirtualMachineInstance vmi) {
VmStatistics statistics = new VmStatistics();
statistics.setId(vm.getId());
DateTime creationTimestampDate = vmi.getMetadata().getCreationTimestamp();
if (creationTimestampDate != null) {
DateTime now = DateTime.now();
Seconds seconds = Seconds.secondsBetween(creationTimestampDate, now);
statistics.setElapsedTime((double) seconds.getSeconds());
}
PrometheusClient promClient = getPrometheusClient();
if (promClient != null) {
// FIXME: Kubevirt currently have only kubevirt_vmi_vcpu_seconds, which is total CPU time,
// so we are setting it here only as system time, which is wrong.
statistics.setCpuSys(
promClient.getVmiCpuUsage(vmi.getMetadata().getName(), vmi.getMetadata().getNamespace())
);
}
return vm.setVmStatistics(statistics)
.setDiskStatistics(Collections.emptyList())
.setVmJobs(Collections.emptyList());
}