ovirt-ansible-collection
ovirt-ansible-collection copied to clipboard
ovirt_vm OVA import failing with "ovirtsdk4.NotFoundError: HTTP response code is 404."
SUMMARY
I have a playbook, that should import multiple OVAs through ovirt_vm. but on import using url as per docs "ova:///path/to/image.ova" I run into the aforementioned error. This feature seems rarely used as I cannot find examples on it, just other people having similar issues, without solutions...
I used this expample from the docs and adopted it to my needs:
- name: Import external ova VM
ovirt.ovirt.ovirt_vm:
cluster: mycluster
name: myvm
host: myhost
timeout: 1800
poll_interval: 30
kvm:
name: myvm
url: ova:///path/myvm.ova
storage_domain: mystorage
COMPONENT NAME
ovirt.ovirt.ovirt_vm module
STEPS TO REPRODUCE
Place the OVA on the hypervisor in a locally mounted NFS share, do the authentication against the api and run the below snippet. I did set a couple of parameters (cluster_name, vm_name, rhv_host (my hypervisor to import on), etc).
The variable "ova_to_use" has the full path to the OVA file on the hypervisor and the "SDName" holds the human readable name of the SD.
- name: Start the import
ovirt.ovirt.ovirt_vm:
auth: "{{ ovirt_auth }}"
cluster: "{{ cluster_name }}"
name: "{{ vm_name }}"
host: "{{ rhv_host }}"
timeout: "{{ all_timeout }}"
poll_interval: "{{ poll_interval }}"
state: present
clone: yes
kvm:
name: "{{ vm_name }}"
url: "ova://{{ ova_to_use }}"
storage_domain: "{{ SDName }}"
EXPECTED RESULTS
Starting OVA import
ACTUAL RESULTS
{
"module_args": {
"cluster": "RHV",
"name": "myVM.local",
"host": "hypervisor.local",
"timeout": 7200,
"poll_interval": 30,
"state": "present",
"clone": true,
"kvm": {
"name": "myVM.local",
"url": "ova:///mnt/ovas/myVM.local_2022-08-01T04:04:37Z.ova",
"storage_domain": "DATA"
},
"wait": true,
"fetch_nested": false,
"nested_attributes": [],
"disk_format": "cow",
"disks": [],
"vnic_profile_mappings": [],
"cluster_mappings": [],
"role_mappings": [],
"affinity_group_mappings": [],
"affinity_label_mappings": [],
"lun_mappings": [],
"domain_mappings": [],
"force": false,
"nics": [],
"cloud_init_nics": [],
"cloud_init_persist": false,
"kernel_params_persist": false,
"clone_permissions": false,
"numa_nodes": [],
"id": null,
"allow_partial_import": null,
"template": null,
"template_version": null,
"use_latest_template_version": null,
"storage_domain": null,
"memory": null,
"memory_guaranteed": null,
"memory_max": null,
"cpu_sockets": null,
"cpu_cores": null,
"cpu_shares": null,
"cpu_threads": null,
"type": null,
"operating_system": null,
"cd_iso": null,
"boot_devices": null,
"reassign_bad_macs": null,
"boot_menu": null,
"bios_type": null,
"serial_console": null,
"usb_support": null,
"sso": null,
"quota_id": null,
"high_availability": null,
"high_availability_priority": null,
"lease": null,
"stateless": null,
"delete_protected": null,
"custom_emulated_machine": null,
"cloud_init": null,
"sysprep": null,
"kernel_path": null,
"initrd_path": null,
"kernel_params": null,
"instance_type": null,
"description": null,
"comment": null,
"timezone": null,
"serial_policy": null,
"serial_policy_value": null,
"vmware": null,
"xen": null,
"cpu_mode": null,
"placement_policy": null,
"placement_policy_hosts": null,
"custom_compatibility_version": null,
"ticket": null,
"cpu_pinning": null,
"soundcard_enabled": null,
"smartcard_enabled": null,
"io_threads": null,
"ballooning_enabled": null,
"rng_device": null,
"numa_tune_mode": null,
"custom_properties": null,
"watchdog": null,
"host_devices": null,
"graphical_console": null,
"exclusive": null,
"export_domain": null,
"export_ova": null,
"force_migrate": null,
"migrate": null,
"next_run": null,
"snapshot_name": null,
"snapshot_vm": null
}
} => {
"exception": "Traceback (most recent call last):
File \"/tmp/ansible_ovirt.ovirt.ovirt_vm_payload_jlaakugn/ansible_ovirt.ovirt.ovirt_vm_payload.zip/ansible_collections/ovirt/ovirt/plugins/modules/ovirt_vm.py\", line 2613, in main
File \"/tmp/ansible_ovirt.ovirt.ovirt_vm_payload_jlaakugn/ansible_ovirt.ovirt.ovirt_vm_payload.zip/ansible_collections/ovirt/ovirt/plugins/modules/ovirt_vm.py\", line 2401, in import_vm
File \"/usr/local/lib64/python3.8/site-packages/ovirtsdk4/services.py\", line 10524, in add
return self._internal_add(import_, headers, query, wait)
File \"/usr/local/lib64/python3.8/site-packages/ovirtsdk4/service.py\", line 232, in _internal_add
return future.wait() if wait else future
File \"/usr/local/lib64/python3.8/site-packages/ovirtsdk4/service.py\", line 55, in wait
return self._code(response)
File \"/usr/local/lib64/python3.8/site-packages/ovirtsdk4/service.py\", line 229, in callback
self._check_fault(response)
File \"/usr/local/lib64/python3.8/site-packages/ovirtsdk4/service.py\", line 130, in _check_fault
body = self._internal_read_body(response)
File \"/usr/local/lib64/python3.8/site-packages/ovirtsdk4/service.py\", line 312, in _internal_read_body
self._raise_error(response)
File \"/usr/local/lib64/python3.8/site-packages/ovirtsdk4/service.py\", line 118, in _raise_error
raise error
ovirtsdk4.NotFoundError: HTTP response code is 404.
",
"msg": "HTTP response code is 404.",
"_ansible_no_log": false,
"changed": false
}
Hi, what did not come to my mind is: Could it be possible, that my manager is not up to date enough to have the needed api endpoint?
I have an update for you.
When checking the httpd logs on the manager I can see this when executing my playbook: ´´´ ==> httpd/ssl_access_log <== <IP> - - [07/Sep/2022:17:56:59 +0200] "POST /ovirt-engine/api/externalvmimports HTTP/1.1" 404 - ´´´
When I access the same API URL through e.g. the RESTClient extension for Firefox I get this in the logs using the "OPTIONS" method:
==> httpd/ssl_access_log <==
<IP> - - [07/Sep/2022:18:13:52 +0200] "OPTIONS /ovirt-engine/api/externalvmimports HTTP/1.1" 200 13
or this when I use the "POST" method:
==> httpd/ssl_access_log <==
<IP> - - [07/Sep/2022:18:17:49 +0200] "POST /ovirt-engine/api/externalvmimports HTTP/1.1" 415 -
FYI: In both cases I am not send sending data with the request.
And the ovirt-engine/server.log shows this exception:
2022-09-07 17:56:59,210+02 ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (default task-6897) RESTEASY002010: Failed to execute: javax.ws.rs.WebApplicationException: HTTP 404 Not Found
at org.ovirt.engine.api.restapi-jaxrs//org.ovirt.engine.api.restapi.resource.BaseBackendResource.handleError(BaseBackendResource.java:236)
at org.ovirt.engine.api.restapi-jaxrs//org.ovirt.engine.api.restapi.resource.BackendResource.getEntity(BackendResource.java:119)
at org.ovirt.engine.api.restapi-jaxrs//org.ovirt.engine.api.restapi.resource.BackendResource.getEntity(BackendResource.java:99)
at org.ovirt.engine.api.restapi-jaxrs//org.ovirt.engine.api.restapi.resource.BackendExternalVmImportsResource.getStorageDomainId(BackendExternalVmImportsResource.java:131)
at org.ovirt.engine.api.restapi-jaxrs//org.ovirt.engine.api.restapi.resource.BackendExternalVmImportsResource.buildImportParameters(BackendExternalVmImportsResource.java:70)
at org.ovirt.engine.api.restapi-jaxrs//org.ovirt.engine.api.restapi.resource.BackendExternalVmImportsResource.add(BackendExternalVmImportsResource.java:39)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at [email protected]//org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:138)
at [email protected]//org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:546)
at [email protected]//org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:435)
at [email protected]//org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$0(ResourceMethodInvoker.java:396)
at [email protected]//org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358)
at [email protected]//org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:398)
at [email protected]//org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:365)
at [email protected]//org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:150)
at [email protected]//org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:104)
at [email protected]//org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:440)
at [email protected]//org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:229)
at [email protected]//org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:135)
at [email protected]//org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358)
at [email protected]//org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:138)
at [email protected]//org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:215)
at [email protected]//org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:245)
at [email protected]//org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:61)
at [email protected]//org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
at [email protected]//javax.servlet.http.HttpServlet.service(HttpServlet.java:590)
at [email protected]//io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
at [email protected]//io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:81)
at [email protected]//io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at [email protected]//io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
at [email protected]//io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at [email protected]//io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68)
at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:257)
at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.dispatchToPath(ServletInitialHandler.java:182)
at [email protected]//io.undertow.servlet.spec.RequestDispatcherImpl.forwardImpl(RequestDispatcherImpl.java:225)
at [email protected]//io.undertow.servlet.spec.RequestDispatcherImpl.forwardImplSetup(RequestDispatcherImpl.java:147)
at [email protected]//io.undertow.servlet.spec.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:110)
at org.ovirt.engine.api.restapi-jaxrs//org.ovirt.engine.api.restapi.invocation.VersionFilter.doFilter(VersionFilter.java:167)
at org.ovirt.engine.api.restapi-jaxrs//org.ovirt.engine.api.restapi.invocation.VersionFilter.doFilter(VersionFilter.java:87)
at [email protected]//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:69)
at [email protected]//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.ovirt.engine.api.restapi-jaxrs//org.ovirt.engine.api.restapi.invocation.CurrentFilter.doFilter(CurrentFilter.java:106)
at org.ovirt.engine.api.restapi-jaxrs//org.ovirt.engine.api.restapi.invocation.CurrentFilter.doFilter(CurrentFilter.java:61)
at [email protected]//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:69)
at [email protected]//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.ovirt.engine.core.aaa//org.ovirt.engine.core.aaa.filters.RestApiSessionMgmtFilter.doFilter(RestApiSessionMgmtFilter.java:78)
at [email protected]//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:69)
at [email protected]//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.ovirt.engine.core.aaa//org.ovirt.engine.core.aaa.filters.EnforceAuthFilter.doFilter(EnforceAuthFilter.java:42)
at [email protected]//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:69)
at [email protected]//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.ovirt.engine.core.aaa//org.ovirt.engine.core.aaa.filters.SsoRestApiNegotiationFilter.doFilter(SsoRestApiNegotiationFilter.java:85)
at [email protected]//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:69)
at [email protected]//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.ovirt.engine.core.aaa//org.ovirt.engine.core.aaa.filters.SsoRestApiAuthFilter.doFilter(SsoRestApiAuthFilter.java:46)
at [email protected]//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:69)
at [email protected]//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.ovirt.engine.core.aaa//org.ovirt.engine.core.aaa.filters.SessionValidationFilter.doFilter(SessionValidationFilter.java:59)
at [email protected]//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:69)
at [email protected]//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.ovirt.engine.core.aaa//org.ovirt.engine.core.aaa.filters.RestApiSessionValidationFilter.doFilter(RestApiSessionValidationFilter.java:35)
at [email protected]//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:69)
at [email protected]//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.ovirt.engine.api.restapi-jaxrs//org.ovirt.engine.api.restapi.security.CSRFProtectionFilter.doFilter(CSRFProtectionFilter.java:100)
at org.ovirt.engine.api.restapi-jaxrs//org.ovirt.engine.api.restapi.security.CSRFProtectionFilter.doFilter(CSRFProtectionFilter.java:91)
at [email protected]//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:69)
at [email protected]//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.ovirt.engine.core.utils//org.ovirt.engine.core.utils.servlet.CORSSupportFilter.doFilter(CORSSupportFilter.java:272)
at [email protected]//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:69)
at [email protected]//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at [email protected]//io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
at [email protected]//io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at [email protected]//io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
at [email protected]//io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at [email protected]//org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at [email protected]//io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68)
at [email protected]//io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:117)
at [email protected]//io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at [email protected]//io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:53)
at [email protected]//io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at [email protected]//io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at [email protected]//io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:59)
at [email protected]//io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
at [email protected]//io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
at [email protected]//io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
at [email protected]//io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at [email protected]//org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at [email protected]//io.undertow.servlet.handlers.SendErrorPageHandler.handleRequest(SendErrorPageHandler.java:52)
at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:275)
at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:79)
at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:134)
at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:131)
at [email protected]//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
at [email protected]//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at [email protected]//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1551)
at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1551)
at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1551)
at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:255)
at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:79)
at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:100)
at [email protected]//io.undertow.server.Connectors.executeRootHandler(Connectors.java:387)
at [email protected]//io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:852)
at [email protected]//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at [email protected]//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at [email protected]//org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282)
at java.base/java.lang.Thread.run(Thread.java:829)
So I am still not sure where this 404 comes from.
Can you elaborate on how to use the module to import OVAs? E.g. where - in relation to the playbook execution - does the OVA need to be located on?
Thanks, Jens
Hi, Has anyone managed to resolve this bug? I'm having the same problem. I noticed that if I create the vm name "vm_name01" in the engine the error no longer occurs but the OVA is not imported. I think something is missing in ovirt_vm -> name: vm_name01 as it should create the name to import the OVA but does not create it before running kvm... name test
- name: "Export external ova VM" ovirt.ovirt.ovirt_vm: auth: "{{ ovirt_auth }}" cluster: "{{ cluster }}" name: vm_name01 host: "{{ host }}" timeout: 1800 poll_interval: 30 kvm: name: test url: ova:///ova/test.ova storage_domain: "{{ storage_domain }}"
I found the problem.