Bug 1516497

Summary: [v2v] Single VM or multiple VMs transform failed with error "Source provider must be of type Vmware", "nil"]
Product: Red Hat CloudForms Management Engine Reporter: Nisim Simsolo <nsimsolo>
Component: ProvidersAssignee: Shmuel Melamud <smelamud>
Status: CLOSED CURRENTRELEASE QA Contact: Nisim Simsolo <nsimsolo>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 5.9.0CC: cpelland, dagur, gblomqui, gmccullo, jfrey, jhardy, lsmola, michal.skrivanek, mkanoor, nsimsolo, obarenbo, smelamud, tfitzger, ykaul
Target Milestone: GAKeywords: TestBlocker, TestOnly
Target Release: 5.10.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: rhv:v2v
Fixed In Version: 5.10.0.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1530773 (view as bug list) Environment:
Last Closed: 2018-06-21 20:43:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: RHEVM Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1491182, 1530773    
Attachments:
Description Flags
evm.log none

Description Nisim Simsolo 2017-11-22 18:39:41 UTC
Description of problem:
Trying to import VMs from Compute -> infrastructure -> providers -> VMware -> VMs -> check VM -> lifecycle -> transform tagged VMs to RHV failed with the next CFME UI error:
"VM Import Error: [EVM] VM [11fedora23_block] Step [Launch] Status [Error submitting VM Import to RHV] Message [Submitting VM Import to RHV]"

which 11fedora23_block is actually RHV VM and not VMware, and it's not the VM checked before the transform dialog.

And the next errors observed in evm.log:
[----] I, [2017-11-22T13:25:12.037644 #52151:c47138]  INFO -- : MIQ(MiqQueue#m_callback) Message id: [11425], Invoking Callback with args: ["Finished", "error", "Source provid
er must be of type Vmware", "nil"]
[----] I, [2017-11-22T13:25:12.039526 #52151:c47138]  INFO -- : MIQ(MiqTask#update_status) Task: [105] [Finished] [Error] [Source provider must be of type Vmware]
[----] I, [2017-11-22T13:25:12.527242 #60858:10d6ca8]  INFO -- : MIQ(ManageIQ::Providers::Redhat::InfraManager#with_provider_connection) Connecting through ManageIQ::Providers
::Redhat::InfraManager: [nsimsolo41]
[----] E, [2017-11-22T13:25:14.212637 #52159:c47138] ERROR -- : Q-task_id([automation_task_10]) MIQ(MiqAeEngine.deliver) Error delivering {"Vm::vm"=>2, "name"=>"CFME_RHEL7", "
provider_id"=>"1", "cluster_id"=>"1", "storage_id"=>"6", "sparse"=>"f", "drivers_iso"=>""} for object [AutomationTask.10] with state [] to Automate: 

The problematic VM "1fedora23_block" has no tags assigned to it or any special configuration.
This issue occurs on any of VMware VMs selected to be transformed and can be imported from RHV Webadmin.

Version-Release number of selected component (if applicable):
cfme-5.9.0.10-1.el7cf.x86_64
ovirt-engine-4.1.8-0.1.el7
vdsm-4.19.38-1.el7ev.x86_64
libvirt-client-3.2.0-14.el7_4.3.x86_64
qemu-kvm-rhev-2.9.0-16.el7_4.8.x86_64
virt-v2v-1.36.3-6.el7_4.3.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Browse CFME UI -> Compute -> infrastructure -> providers -> VMware -> VMs -> check VM or some VMs -> lifecycle -> transform tagged VMs to RHV, enter details and start transform
2.
3.

Actual results:
CFME UI shows error message on a VM which is not related to the import.
evm.log error: "Source provider must be of type Vmware"

Expected results:
VM transform should not fail.

Additional info:
evm.log attached.

Comment 2 Nisim Simsolo 2017-11-22 18:44:40 UTC
Created attachment 1357740 [details]
evm.log

Comment 5 Ladislav Smola 2017-11-23 14:11:39 UTC
Hilda, could this also be duplicate of? https://bugzilla.redhat.com/show_bug.cgi?id=1514334

Comment 9 Michal Skrivanek 2017-11-30 12:28:51 UTC
[----] I, [2017-11-22T11:30:11.000282 #63741:c47138]  INFO -- : MIQ(EmsRefresh.save_vms_inventory) EMS: [nsimsolo41], id: [1] Duplicate unique values found: ["423c483c-7ef7-1ad8-f56d-2283e40d6624", "423c7623-0a4f-65fc-bcaf-254d3d0e7c10"]
looks suspicious, the other id is of a different vm.

Comment 20 mkanoor 2017-12-15 20:02:22 UTC
We need to differentiate between single vm import and mass vm import using tags

When doing a single vm the target should be the VM object.

When doing mass import the target has to be the EMS object.

Thie code
https://github.com/ManageIQ/manageiq-ui-classic/blob/d4f2be2fdbd1a82dc232223c60593327c5f9abbd/app/controllers/mixins/actions/vm_actions/transform.rb#L7

Doesn't differentiate between EMS and VM when running the mass import the URL is
http://localhost:3000/ems_infra/10000000000001?display=vms

The id here is for the EMS and not for VM. the above mentioned code doesn't check if the ID is for VM or EMS and assumes that the object is the VM. That code was written with the assumption that when doing mass import there won't be an ID field.

The error mentioned in this ticket happens because we are using the EMS object and assuming its a VM.

The code needs to be fixed in PR https://github.com/ManageIQ/manageiq-ui-classic/pull/3073

So that it can properly set the target

Comment 21 Yaniv Kaul 2017-12-18 08:26:36 UTC
(In reply to mkanoor from comment #20)
> We need to differentiate between single vm import and mass vm import using
> tags
> 
> When doing a single vm the target should be the VM object.
> 
> When doing mass import the target has to be the EMS object.
> 
> Thie code
> https://github.com/ManageIQ/manageiq-ui-classic/blob/
> d4f2be2fdbd1a82dc232223c60593327c5f9abbd/app/controllers/mixins/actions/
> vm_actions/transform.rb#L7
> 
> Doesn't differentiate between EMS and VM when running the mass import the
> URL is
> http://localhost:3000/ems_infra/10000000000001?display=vms
> 
> The id here is for the EMS and not for VM. the above mentioned code doesn't
> check if the ID is for VM or EMS and assumes that the object is the VM. That
> code was written with the assumption that when doing mass import there won't
> be an ID field.
> 
> The error mentioned in this ticket happens because we are using the EMS
> object and assuming its a VM.
> 
> The code needs to be fixed in PR
> https://github.com/ManageIQ/manageiq-ui-classic/pull/3073
> 
> So that it can properly set the target

Shmuel, do you have everything you need to make progress here?

Comment 22 CFME Bot 2017-12-21 11:11:48 UTC
New commit detected on ManageIQ/manageiq-ui-classic/master:
https://github.com/ManageIQ/manageiq-ui-classic/commit/dbfc5ba17e01422fc6462591540dfb2f3e507fe0

commit dbfc5ba17e01422fc6462591540dfb2f3e507fe0
Author:     Shmuel Melamud <smelamud>
AuthorDate: Thu Dec 14 23:41:01 2017 +0200
Commit:     Shmuel Melamud <smelamud>
CommitDate: Wed Dec 20 01:38:11 2017 +0200

    Target for mass VM transformation dialog
    
    Created a separate vm_transform_mass action to handle VM Transform
    button clicks in on Providers page and on Compute > Infrastructure >
    Virtual Machines page. This action interprets the ID passed to it as
    provider ID, while regular vm_transform action interprets it as VM ID.
    If provider ID is not passed, the Redhat provider EMS object is used as
    target.
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1514939
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1516497

 .../application_controller/ci_processing.rb        |  3 ++
 app/controllers/application_controller/explorer.rb |  1 +
 .../actions/provider_actions/mass_transform.rb     | 56 ++++++++++++++++++++++
 .../mixins/actions/vm_actions/transform.rb         | 24 ++++------
 app/controllers/vm_infra_controller.rb             | 23 ---------
 .../application_helper/toolbar/vm_infras_center.rb |  2 +-
 spec/controllers/ems_infra_controller_spec.rb      |  6 +--
 spec/controllers/vm_infra_controller_spec.rb       |  8 ----
 8 files changed, 72 insertions(+), 51 deletions(-)
 create mode 100644 app/controllers/mixins/actions/provider_actions/mass_transform.rb