Bug 1933238

Summary: Allow migration of vms in between the clusters using ansible
Product: Red Hat Enterprise Virtualization Manager Reporter: Marian Jankular <mjankula>
Component: ovirt-ansible-collectionAssignee: Martin Necas <mnecas>
Status: CLOSED ERRATA QA Contact: Guilherme Santos <gdeolive>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.4.3CC: ahadas, gdeolive, mavital, michal.skrivanek, mperina, pagranat
Target Milestone: ovirt-4.4.6   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ovirt-ansible-collection-1.5.0 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-06-01 13:23:43 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Marian Jankular 2021-02-26 08:47:38 UTC
Description of problem:
[RFE] allow migration of vms in between the cluster via rest api

Version-Release number of selected component (if applicable):
4.4.3

How reproducible:
everytime

Steps to Reproduce:
1. try to migrate vm from cluster A to cluster B with restapi
2.
3.

Actual results:
ansible all -c localhost -m ovirt_vm -a "name=test cluster=cl2 name=test state=running migrate=true"

Vm is called test and it should be migrated to cluster cl2.

The message is
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ovirtsdk4.Error: Fault reason is "Operation Failed". Fault detail is "[Cannot update a VM in this status. Try stopping the VM first.]". HTTP response code is 409.
localhost | FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": false,
    "msg": "Fault reason is \"Operation Failed\". Fault detail is \"[Cannot update a VM in this status. Try stopping the VM first.]\". HTTP response code is 409."

Expected results:
vm will be migrated to the the different cluster 

Additional info:

Comment 7 Martin Necas 2021-03-18 15:46:11 UTC
Hi,
create a patch on the ansible collection which adds the capability to migrate between clusters.

Comment 10 Guilherme Santos 2021-05-05 13:39:06 UTC
Failed on:
ovirt-engine-4.4.6.6-0.10.el8ev.noarch
ovirt-ansible-collection-1.4.2-1.el8ev.noarch

Steps:
1. Have 2 hosts in two different clusters and a vm running in one of them
2. # ansible localhost -c localhost -m ovirt.ovirt.ovirt_vm -a "name=vm_1 cluster=cl_2 state=running migrate=true auth='url=https://<engine-fqdn>/ovirt-engine/api username=admin@internal password=<pass> insecure=true'" -v
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ovirtsdk4.Error: Fault reason is "Operation Failed". Fault detail is "[Cannot update a VM in this status. Try stopping the VM first.]". HTTP response code is 409.
localhost | FAILED! => {
    "changed": false,
    "msg": "Fault reason is \"Operation Failed\". Fault detail is \"[Cannot update a VM in this status. Try stopping the VM first.]\". HTTP response code is 409."
}

Results:
Fails on ansible (also tried with setting force_migrate as true), but it succeeds on API (also tried)

Comment 11 Michal Skrivanek 2021-05-11 07:07:37 UTC
logs?

Comment 12 Martin Necas 2021-05-12 12:11:57 UTC
Please specify also host and retry it.

Comment 13 Guilherme Santos 2021-05-17 18:35:52 UTC
Verified as it works when specifying the host.
Open another bug (BZ1961353) though as imho I think it should work also not specifying the host (when the VM is running, if the VM is stopped, the host don't need to be specified)

Comment 17 errata-xmlrpc 2021-06-01 13:23:43 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: RHV Engine and Host Common Packages security update [ovirt-4.4.6]), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2021:2180

Comment 18 meital avital 2022-08-14 13:50:26 UTC
Due to QE capacity, we are not going to cover this issue in our automation