From 596d55d48190affa1886551fc2383dca2a61cf06 Mon Sep 17 00:00:00 2001 From: catborise Date: Thu, 31 Dec 2020 11:30:33 +0300 Subject: [PATCH] fix uuid and name changes and update them on db correctly. (#404) --- computes/utils.py | 2 ++ instances/utils.py | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/computes/utils.py b/computes/utils.py index 351c5ff..05feb03 100644 --- a/computes/utils.py +++ b/computes/utils.py @@ -4,8 +4,10 @@ from instances.models import Instance def refresh_instance_database(compute): domains = compute.proxy.wvm.listAllDomains() domain_names = [d.name() for d in domains] + domain_uuids = [d.UUIDString() for d in domains] # Delete instances that're not on host from DB Instance.objects.filter(compute=compute).exclude(name__in=domain_names).delete() + Instance.objects.filter(compute=compute).exclude(uuid__in=domain_uuids).delete() # Create instances that're on host but not in DB names = Instance.objects.filter(compute=compute).values_list('name', flat=True) for domain in domains: diff --git a/instances/utils.py b/instances/utils.py index 365ade7..5cc72a7 100644 --- a/instances/utils.py +++ b/instances/utils.py @@ -169,17 +169,15 @@ def refr(compute): if compute.status is True: domains = compute.proxy.wvm.listAllDomains() domain_names = [d.name() for d in domains] + domain_uuids = [d.UUIDString() for d in domains] # Delete instances that're not on host Instance.objects.filter(compute=compute).exclude(name__in=domain_names).delete() + Instance.objects.filter(compute=compute).exclude(uuid__in=domain_uuids).delete() # Create instances that're not in DB names = Instance.objects.filter(compute=compute).values_list('name', flat=True) - uuids = Instance.objects.filter(compute=compute).values_list('uuid', flat=True) for domain in domains: if domain.name() not in names: Instance(compute=compute, name=domain.name(), uuid=domain.UUIDString()).save() - continue - if domain.UUIDString() not in uuids: - Instance(compute=compute, name=domain.name(), uuid=domain.UUIDString()).save() def get_dhcp_mac_address(vname):