Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Sample: Get snapshot's creator name #744

Open
EshginGuluzade opened this issue Jan 19, 2024 · 0 comments
Open

New Sample: Get snapshot's creator name #744

EshginGuluzade opened this issue Jan 19, 2024 · 0 comments

Comments

@EshginGuluzade
Copy link

EshginGuluzade commented Jan 19, 2024

Is your feature request related to a problem? Please describe.

Hi,
It looks like vSphere doesn't inherently store the information about who created a specific snapshot. This information is typically not directly available in the vSphere API.

This code snippet gives attributes and methods of the snapshot:

cluster_name_prefix = "my-cluster"
content = service_instance.RetrieveContent()
vm_list = []
for datacenter in content.rootFolder.childEntity:
    for cluster in datacenter.hostFolder.childEntity:
        if cluster.name.startswith(cluster_name_prefix):
            for host in cluster.host:
                for vm in host.vm:
                    vm_list.append(vm)

for vm in vm_list:
        if vm.name == "my-vm":
                snapshot = vm.snapshot.rootSnapshotList[0]
                print(f"Attributes and Methods of the Snapshot for VM my-vm:")
                print(dir(snapshot))

Disconnect(service_instance)

here is the output:

Attributes and Methods of the Snapshot for VM my-vm:
['Array', '_GetPropertyInfo', '_GetPropertyList', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_propInfo', '_propList', '_version', '_wsdlName', 'backupManifest', 'childSnapshotList', 'createTime', 'description', 'dynamicProperty', 'dynamicType', 'id', 'name', 'quiesced', 'replaySupported', 'snapshot', 'state', 'vm']

I can easily get snapshot id, name, state, createtime, description but not creator name.

Does anybody know any way to achieve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant