Bug 1693378

Summary: ServiceTemplateTransformationPlanRequest fails with explicit resource type
Product: Red Hat CloudForms Management Engine Reporter: Fabien Dupont <fdupont>
Component: V2VAssignee: Fabien Dupont <fdupont>
Status: CLOSED CURRENTRELEASE QA Contact: Yadnyawalk Tale <ytale>
Severity: high Docs Contact: Red Hat CloudForms Documentation <cloudforms-docs>
Priority: high    
Version: 5.10.2CC: bthurber, jprause, simaishi, ytale
Target Milestone: GAKeywords: TestOnly, ZStream
Target Release: 5.11.0   
Hardware: All   
OS: All   
Whiteboard: v2v
Fixed In Version: 5.11.0.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1696447 (view as bug list) Environment:
Last Closed: 2019-12-13 15:09:26 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: V2V Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1683443, 1696447    

Description Fabien Dupont 2019-03-27 17:01:35 UTC
Description of problem:
When starting a migration it fails as the request is denied. And the request is denied because no conversion host is associated to the destination  ext_management_system. Below is an example of the failing relationship:

```
irb(main):029:0> ConversionHost.first.ext_management_system.conversion_hosts
  ConversionHost Load (0.3ms)  SELECT  "conversion_hosts".* FROM "conversion_hosts" ORDER BY "conversion_hosts"."id" ASC LIMIT $1  [["LIMIT", 1]]
  ConversionHost Inst Including Associations (0.1ms - 1rows)
  ManageIQ::Providers::Openstack::CloudManager::Vm Load (0.5ms)  SELECT  "vms".* FROM "vms" WHERE "vms"."template" = $1 AND "vms"."type" IN ('ManageIQ::Providers::Openstack::CloudManager::Vm') AND "vms"."id" = $2 LIMIT $3  [["template", "f"], ["id", 162], ["LIMIT", 1]]
  ManageIQ::Providers::Openstack::CloudManager::Vm Inst Including Associations (0.3ms - 1rows)
  ExtManagementSystem Load (0.3ms)  SELECT  "ext_management_systems".* FROM "ext_management_systems" WHERE "ext_management_systems"."id" = $1 LIMIT $2  [["id", 6], ["LIMIT", 1]]
  ExtManagementSystem Inst Including Associations (0.3ms - 1rows)
  ConversionHost Load (0.4ms)  SELECT "conversion_hosts".* FROM "conversion_hosts" INNER JOIN "hosts" ON "conversion_hosts"."resource_id" = "hosts"."id" WHERE "hosts"."ems_id" = $1 AND "conversion_hosts"."resource_type" = $2  [["ems_id", 6], ["resource_type", "Host"]]
  ConversionHost Inst Including Associations (0.0ms - 0rows)
  ConversionHost Load (0.6ms)  SELECT "conversion_hosts".* FROM "conversion_hosts" INNER JOIN "vms" ON "conversion_hosts"."resource_id" = "vms"."id" WHERE "vms"."type" IN ('Vm', 'ManageIQ::Providers::CloudManager::Vm', 'ManageIQ::Providers::InfraManager::Vm', 'VmServer', 'ManageIQ::Providers::Amazon::CloudManager::Vm', 'ManageIQ::Providers::Azure::CloudManager::Vm', 'ManageIQ::Providers::Google::CloudManager::Vm', 'ManageIQ::Providers::Openstack::CloudManager::Vm', 'ManageIQ::Providers::Vmware::CloudManager::Vm', 'VmXen', 'ManageIQ::Providers::Kubevirt::InfraManager::Vm', 'ManageIQ::Providers::Redhat::InfraManager::Vm', 'ManageIQ::Providers::Microsoft::InfraManager::Vm', 'ManageIQ::Providers::Vmware::InfraManager::Vm') AND "vms"."template" = $1 AND "vms"."ems_id" = $2 AND "conversion_hosts"."resource_type" = $3  [["template", "f"], ["ems_id", 6], ["resource_type", "VmOrTemplate"]]
  ConversionHost Inst Including Associations (0.0ms - 0rows)
=> []
```

Actually, the conversion_hosts table contains `ManageIQ::Providers::Openstack::CloudManager::Vm` for the resource type of the existing conversion host.

The impact is that no migration will work.


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


How reproducible: 100%


Steps to Reproduce:
1. Create a conversion host from API:

curl -sk -u admin:smartvm http://localhost:3000/api/conversion_hosts -X POST -d '{"action": "create", "resource": {"resource_type": "ManageIQ::Providers::Openstack::CloudManager::Vm", "resource_id": 162, "vmware_vddk_package_url": "http://file.example.com/vddk/VMware-vix-disklib-stable.tar.gz", "conversion_host_ssh_private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIE...", "address": "192.168.0.10"}}'

2. Try to list the conversion host of the provider

irb> ConversionHost.first.ext_management_system.conversion_hosts


Actual results: returns an empty array


Expected results: returns the created conversion host

Comment 2 Fabien Dupont 2019-03-27 17:03:49 UTC
Github Issue: https://bugzilla.redhat.com/show_bug.cgi?id=1693378

Comment 3 Fabien Dupont 2019-03-29 06:21:28 UTC
Issue closed. Moving to POST

Comment 5 Fabien Dupont 2019-04-02 15:02:45 UTC
Conversion host base class - https://github.com/ManageIQ/manageiq/pull/18604

Comment 7 Yadnyawalk Tale 2019-06-14 13:38:08 UTC
Verified on: 5.11.0.8.20190611155126_01e077e

irb(main):004:0> ConversionHost.first.ext_management_system.conversion_hosts
=> [#<ConversionHost id: 5, name: "env-rhv43-01.cfme2.lab.eng.rdu2.redhat.com", address: nil, type: nil, resource_type: "Host", resource_id: 1, version: nil, max_concurrent_tasks: nil, vddk_transport_supported: false, ssh_transport_supported: true, created_at: "2019-06-14 12:43:34", updated_at: "2019-06-14 12:43:34", concurrent_transformation_limit: nil, cpu_limit: nil, memory_limit: nil, network_limit: nil, blockio_limit: nil>]