diff --git a/igvm/hypervisor.py b/igvm/hypervisor.py index 9959e322..8f20c36f 100644 --- a/igvm/hypervisor.py +++ b/igvm/hypervisor.py @@ -6,7 +6,8 @@ import logging import math from contextlib import contextmanager -from time import sleep, time +from time import sleep +from datetime import datetime from xml.etree import ElementTree from igvm.vm import VM @@ -1149,9 +1150,12 @@ def log_migration(self, vm: VM, operator: str) -> None: :param operator: plus for migration to HV, minus for migration from HV """ - cpu_usage_vm = self.estimate_vm_cpu_usage(vm) - timestamp = int(time()) - log_entry = '{} {}{}'.format(timestamp, operator, round(cpu_usage_vm)) + cpu_usage_vm = round(self.estimate_vm_cpu_usage(vm)) + if cpu_usage_vm == 0: + return + + timestamp = datetime.now().isoformat() + log_entry = '{} {}{}'.format(timestamp, operator, cpu_usage_vm) self.dataset_obj['igvm_migration_log'].add(log_entry) self.dataset_obj.commit() diff --git a/igvm/settings.py b/igvm/settings.py index 642a7786..e3f6ef69 100644 --- a/igvm/settings.py +++ b/igvm/settings.py @@ -125,7 +125,6 @@ 'igvm_migration_log', 'intern_ip', 'iops_avg', - 'igvm_migration_log', 'libvirt_memory_total_gib', 'libvirt_memory_used_gib', 'libvirt_pool_total_gib', diff --git a/tests/test_integration.py b/tests/test_integration.py index e54146b7..0418d083 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -518,7 +518,7 @@ def test_igvm_migration_log(self, performance_value, mock_time): src_hv = self.vm.hypervisor.dataset_obj['hostname'] cpu_usage_vm_src = self.vm.hypervisor.estimate_vm_cpu_usage(self.vm) - timestamp = 1234567890 + timestamp = 1234567890000 vm_migrate( VM_HOSTNAME,