Ashok Kumar M
Ashok Kumar M

Reputation: 1

Is there any way to calculate vm snaphot size in vmware vsphere by using PyVmomi SDK?

I am trying to determine the size of a VM snapshot using the PyVmomi library in Python, but the size I obtain differs from the actual VM snapshot size shown in the vSphere client. How can I resolve this issue?

This is my code,

def get_snapshot_size(snapshot):
    total_size = 0
    for file in snapshot.vm.layoutEx.file:
        if 'snapshot' in file.type.lower() or file.type == 'snapshotData':
            total_size += file.size
            size_gb = (float(total_size) / 1024 / 1024 / 1024)
    return size_gb

Help me to solve this problem!

Upvotes: 0

Views: 111

Answers (0)

Related Questions