[GH-ISSUE #661] views.py ( instance ) #504

Open
opened 2026-02-27 16:39:29 +03:00 by kerem · 1 comment
Owner

Originally created by @marukochanstella on GitHub (May 26, 2018).
Original GitHub issue: https://github.com/retspen/webvirtmgr/issues/661

try:
     conn = wvmInstances(compute.hostname,
                        compute.login,
                        compute.password,
                        compute.type)
     get_instances = conn.get_instances()
 except libvirtError as err:
    errors.append(err)

for instance in get_instances:
    try:
        inst = Instance.objects.get(compute_id=host_id, name=instance)
        uuid = inst.uuid
    except Instance.DoesNotExist:
        uuid = conn.get_uuid(instance)
        inst = Instance(compute_id=host_id, name=instance, uuid=uuid)
        inst.save()
    instances.append({'name': instance,
                      'status': conn.get_instance_status(instance),
                      'uuid': uuid,
                      'memory': conn.get_instance_memory(instance),
                      'vcpu': conn.get_instance_vcpu(instance),
                      'has_managed_save_image': conn.get_instance_managed_save_image(instance)})

@retspen .... Can you explain it for me ??? Please !!! :((

Originally created by @marukochanstella on GitHub (May 26, 2018). Original GitHub issue: https://github.com/retspen/webvirtmgr/issues/661 try: conn = wvmInstances(compute.hostname, compute.login, compute.password, compute.type) get_instances = conn.get_instances() except libvirtError as err: errors.append(err) for instance in get_instances: try: inst = Instance.objects.get(compute_id=host_id, name=instance) uuid = inst.uuid except Instance.DoesNotExist: uuid = conn.get_uuid(instance) inst = Instance(compute_id=host_id, name=instance, uuid=uuid) inst.save() instances.append({'name': instance, 'status': conn.get_instance_status(instance), 'uuid': uuid, 'memory': conn.get_instance_memory(instance), 'vcpu': conn.get_instance_vcpu(instance), 'has_managed_save_image': conn.get_instance_managed_save_image(instance)}) @retspen .... Can you explain it for me ??? Please !!! :((
Author
Owner

@catborise commented on GitHub (Jun 20, 2018):

@marukochanstella hi, it gets list of vm domains from libvirt with specified hostname. Then it gets list of vm domains from internal database for specified host. then it check if there is any new domains. if there is a new domain it adds to database. after that it gets info of domain to show.

sum:

  1. get instance list from libvirt
  2. add them to database if it is not already in database
  3. add instances info's to a list to show.
<!-- gh-comment-id:398632308 --> @catborise commented on GitHub (Jun 20, 2018): @marukochanstella hi, it gets list of vm domains from libvirt with specified hostname. Then it gets list of vm domains from internal database for specified host. then it check if there is any new domains. if there is a new domain it adds to database. after that it gets info of domain to show. sum: 1. get instance list from libvirt 2. add them to database if it is not already in database 3. add instances info's to a list to show.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/webvirtmgr#504
No description provided.