Pysphere获取当前快照名称

时间:2015-09-08 07:58:46

标签: python vsphere pysphere

有人知道如何使用pyshpere api获取当前快照名称吗? https://code.google.com/p/pysphere/wiki/GettingStarted#List_snapshots

1 个答案:

答案 0 :(得分:0)

    # This ignores the certificate warning
    default_context = ssl._create_default_https_context
    ssl._create_default_https_context = ssl._create_unverified_context

    # Connect to the VMware instance
    server_instance = pysphere.VIServer();
    server_instance.connect(ipaddress,username,password)

    # Create a VM object of which details are required
    vm = server_instance.get_vm_by_name(vmname)

    # This gets the status of the VM.
    print vm.get_status()

    # This gets the current snapshot name.
    print vm.get_current_snapshot_name()

参考基本库总是一个好主意。这是pysphere的链接。 http://nullege.com/codes/show/src@p@y@pysphere-HEAD@pysphere@init.py/173/pysphere.vi_mor.MORTypes

祝你好运!