Closed laidbackware closed 1 year ago
This doesn't work because the vsphere-automation-sdk-python uses JSON-RPC internal protocol to invoke the vCenter APIs (which also have REST rendering), while the govmomi vcsim only supports vCenter SOAP and REST APIs (but not the JSON-RPC protocol).
Per my previous comment.
Describe the bug
The govcsim is capable simulating Rest API requests, but the creation of he client fails with a HTTP 404 error. The PyVmomi implementation in the client works without issue, but the rest API client generates an exception with the a 404 error.
When querying the govcsim using govc I am able to work with rest only objects such as tags, meaning that the govcsim fully implements authentication using the rest API.
I'm building a collection of vSphere with Tanzu Ansible modules that will be published via
vmware-tanzu-labs
, but will not be able to do any Github Actions integration tests without the ability to use govcsim - without significant infrastructure automation and resources.Reproduction steps
docker run -p 9090:9090 --name vcsim --rm --detach vmware/vcsim -l :9090
session = requests.Session() session.verify = False client = create_vsphere_client( server="localhost:9090", username="user", password="pass", session=session )
Traceback (most recent call last): File "/home/matt/workspace/projects/ansible-for-vsphere-with-tanzu/tst.py", line 6, in
client = create_vsphere_client(
File "/home/matt/.local/lib/python3.10/site-packages/vmware/vapi/vsphere/client.py", line 173, in create_vsphere_client
return VsphereClient(session=session, server=server, username=username,
File "/home/matt/.local/lib/python3.10/site-packages/vmware/vapi/vsphere/client.py", line 116, in init
session_id = session_svc.create()
File "/home/matt/.local/lib/python3.10/site-packages/com/vmware/cis_client.py", line 201, in create
return self._invoke('create', None)
File "/home/matt/.local/lib/python3.10/site-packages/vmware/vapi/bindings/stub.py", line 345, in _invoke
return self._api_interface.native_invoke(ctx, _method_name, kwargs)
File "/home/matt/.local/lib/python3.10/site-packages/vmware/vapi/bindings/stub.py", line 266, in native_invoke
method_result = self.invoke(ctx, method_id, data_val)
File "/home/matt/.local/lib/python3.10/site-packages/vmware/vapi/bindings/stub.py", line 199, in invoke
return self._api_provider.invoke(self._iface_id.get_name(),
File "/home/matt/.local/lib/python3.10/site-packages/vmware/vapi/security/client/security_context_filter.py", line 101, in invoke
method_result = ApiProviderFilter.invoke(
File "/home/matt/.local/lib/python3.10/site-packages/vmware/vapi/provider/filter.py", line 75, in invoke
method_result = self.next_provider.invoke(
File "/home/matt/.local/lib/python3.10/site-packages/vmware/vapi/protocol/client/msg/json_connector.py", line 79, in invoke
response = self._do_request(VAPI_INVOKE, ctx, params)
File "/home/matt/.local/lib/python3.10/site-packages/vmware/vapi/protocol/client/msg/json_connector.py", line 127, in _do_request
http_response.data.raise_for_status()
File "/home/matt/.local/lib/python3.10/site-packages/requests/models.py", line 960, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://localhost:9090/api/