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

vcsim: Unable to list virtual machine's snapshot #968

Closed
Akasurde opened this issue Dec 16, 2017 · 2 comments
Closed

vcsim: Unable to list virtual machine's snapshot #968

Akasurde opened this issue Dec 16, 2017 · 2 comments

Comments

@Akasurde
Copy link
Contributor

I am unable to list the snapshots of VM, when no snapshot exists for given VM.

Here is reproducer -

from pyVim.connect import SmartConnect, Disconnect
import ssl
import atexit
from pyVmomi import vim

def connect():
    context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
    context.verify_mode = ssl.CERT_NONE

    si = SmartConnect(host='0.0.0.0', user='user', pwd='pass', port=443, sslContext=context)
    atexit.register(Disconnect, si)
    content = si.RetrieveContent()
    return content

def get_obj(content, vimtype, name):
    """
    Return an object by name, if name is None the
    first found object is returned
    """
    obj = None
    container = content.viewManager.CreateContainerView(
        content.rootFolder, vimtype, True)
    for c in container.view:
        if name:
            if c.name == name:
                obj = c
                break
        else:
            obj = c
            break

    container.Destroy()
    return obj

content = connect()

vm = get_obj(content, [vim.VirtualMachine], 'DC0_H0_VM0')
print(vm.snapshot)

I get traceback like -

python snapshot.py
Traceback (most recent call last):
  File "snapshot.py", line 7, in <module>
    print(vm.snapshot)
  File "/Volumes/data/src/ansible/venv4/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 574, in __call__
    return self.f(*args, **kwargs)
  File "/Volumes/data/src/ansible/venv4/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 394, in _InvokeAccessor
    return self._stub.InvokeAccessor(self, info)
  File "/Volumes/data/src/ansible/venv4/lib/python2.7/site-packages/pyVmomi/StubAdapterAccessorImpl.py", line 43, in InvokeAccessor
    objectContent = result.objects[0]
IndexError: list index out of range

govcsim trace =

Request: <?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body><RetrievePropertiesEx xmlns="urn:vim25"><_this type="PropertyCollector">propertyCollector</_this><specSet><propSet><type>VirtualMachine</type><all>false</all><pathSet>name</pathSet></propSet><objectSet><obj type="VirtualMachine">vm-68</obj><skip>false</skip></objectSet></specSet><options><maxObjects>1</maxObjects></options></RetrievePropertiesEx></soapenv:Body>
</soapenv:Envelope>
Response: <?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><RetrievePropertiesExResponse xmlns="urn:vim25"><returnval><objects><obj type="VirtualMachine">vm-68</obj><propSet><name>name</name><val xmlns:XMLSchema-instance="http://www.w3.org/2001/XMLSchema-instance" XMLSchema-instance:type="xsd:string">DC0_H0_VM0</val></propSet></objects></returnval></RetrievePropertiesExResponse></soapenv:Body></soapenv:Envelope>
@anfernee
Copy link
Contributor

it seems the PropertyCollector didn't return the result. looking into it.

@anfernee anfernee self-assigned this Dec 19, 2017
anfernee pushed a commit to anfernee/govmomi that referenced this issue Dec 20, 2017
Initialize VM fields with the correct structs, so PropertyCollector can
find and retrieve it for clients.

Fix vmware#968
@Akasurde
Copy link
Contributor Author

@anfernee Thanks for this fix. This is working but "RenameSnapshot" API fails -

Request: <?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body><RenameSnapshot xmlns="urn:vim25"><_this type="VirtualMachineSnapshot">snapshot-90</_this><name>snap_c</name></RenameSnapshot></soapenv:Body>
</soapenv:Envelope>
2017/12/20 19:46:31 VirtualMachineSnapshot:snapshot-90 does not implement: RenameSnapshot
Response: <?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><soapenv:Fault><faultcode>ServerFaultCode</faultcode><faultstring>VirtualMachineSnapshot:snapshot-90 does not implement: RenameSnapshot</faultstring><detail><Fault xmlns:XMLSchema-instance="http://www.w3.org/2001/XMLSchema-instance" XMLSchema-instance:type="MethodNotFound"><receiver type="VirtualMachineSnapshot">snapshot-90</receiver><method>RenameSnapshot</method></Fault></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>

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

3 participants