Bug 1410920

Summary: Setting relationship data for generic objects in automate does not work
Product: Red Hat CloudForms Management Engine Reporter: Satoe Imaishi <simaishi>
Component: AutomateAssignee: Lucy Fu <lufu>
Status: CLOSED CURRENTRELEASE QA Contact: Milan Falešník <mfalesni>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 5.7.0CC: jhardy, mfalesni, mkanoor, obarenbo, tfitzger
Target Milestone: GAKeywords: TestOnly, ZStream
Target Release: 5.8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 5.8.0.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1411357 (view as bug list) Environment:
Last Closed: 2017-06-12 16:20:10 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1411357    
Attachments:
Description Flags
Test domain none

Description Satoe Imaishi 2017-01-06 20:53:36 UTC
From PR: https://github.com/ManageIQ/manageiq/pull/11811

Generic Object relationships are defined and implemented for AR objects.
Generic Object methods are defined as for AR objects and implemented in automate model.

Converting the object into AR model object when calling the generic object methods from automate as these methods are defined as AR model methods.

Converting the object into service model object when returning the generic object method results back to automate.


ManageIQ issue: https://github.com/ManageIQ/manageiq/issues/11728

The following script fails to add the service to the services relationship for a generic object.

go_class = $evm.vmdb(:generic_object_definition).find_by(:name => "LoadBalancer")
load_balancer = go_class.create_object(:name => "Test Load Balancer")

service = $evm.vmdb(:service).first
load_balancer.services = [service]

Comment 3 Milan Falešník 2017-01-27 09:37:11 UTC
Created attachment 1245071 [details]
Test domain

Use the attached domain to test this bug:

1) Import end enable the domain
2) Have at least one service created (Generic is enough)
3) Run rails console and create the object definition:
GenericObjectDefinition.create(
  :name => "LoadBalancer", 
  :properties => {
    :attributes   => {:location => "string"},
    :associations => {:vms => "Vm", :services => "Service"},
  }
)
4) Run tail -fn0 log/automation.log | egrep 'ERROR|XYZ'
5) Simulate Request/GOTest with method execution

In the tail'ed log:
There should be no ERROR lines related to the execution.
There should be these two lines:
<AEMethod gotest> XYZ go object: #<MiqAeServiceGenericObject ....something...>
<AEMethod gotest> XYZ load balancer got service: #<MiqAeServiceService:....something....>
If there is "XYZ load balancer got service: nil", then this bug was reproduced.

thx @lfu

Comment 4 Milan Falešník 2017-03-03 14:46:57 UTC
Verified in 5.8.0.3 using the steps in comment 3