Bug 1301717

Summary: Missing instance processing in Automate engine doesn't preserve the instance name that was missing
Product: Red Hat CloudForms Management Engine Reporter: mkanoor
Component: AutomateAssignee: mkanoor
Status: CLOSED ERRATA QA Contact: Milan Falešník <mfalesni>
Severity: low Docs Contact:
Priority: unspecified    
Version: 5.5.0CC: dajohnso, jhardy, mkanoor, obarenbo, tfitzger
Target Milestone: GA   
Target Release: 5.6.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 5.6.0.0 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-06-29 15:33:17 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:

Description mkanoor 2016-01-25 19:30:34 UTC
Description of problem:
In Automate Models a .missing instance can be used to provide default behaviors when an instance is missing. Automate models support substitutions from user defined attributes, we don't have an attribute that stores the name of the original instance. One use case we have for this we have to always have a method instance to accompany a method script, we can't have one instance (.missing) that can point to the method scripts. If we can store the missing instance as an attribute it can be used to locate the correct method.

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


How reproducible:
New feature

Steps to Reproduce:
1. In a namespace (NS1) add a new class (classA) add a schema to it to have a method field (mfield)
2. Add a .missing instance, set the value in the method field (mfield) to ${#_missing_instance}
3. Add multiple methods in the class (classA), test1, test2, test3, please note you are only adding method scripts but no instances.
4. Create a new class (classB) and add a schema to it to have a relation ship field (rel)
5. Create an instance in ClassB (call_any_method) and set the relationship field (rel) to NS1/ClassA/test1, this points to a non existent instance, we will pick up the .missing instance and run the method test1.

Actual results:
New feature

Expected results:
A single missing instance can call methods without having a 1-1 relationship between method instance and method scripts.

Additional info:
This feature is typically handy in Automate State machine, today users end up using the on_entry field to directly call the method without having an instance. The state machine states can only point to relationships they can't directly point to a method. This feature allows them to use the .missing instance and not provide one instance for every method.

Comment 3 CFME Bot 2016-01-29 14:26:07 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/de3fbad2eedbb6cfd52d3adff480059d762570c5

commit de3fbad2eedbb6cfd52d3adff480059d762570c5
Author:     Madhu Kanoor <mkanoor>
AuthorDate: Mon Jan 25 15:23:15 2016 -0500
Commit:     Madhu Kanoor <mkanoor>
CommitDate: Mon Jan 25 17:43:10 2016 -0500

    Add _missing_instance attribute
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1301717
    
    If the .missing instance is being used for an instance, preserve
    the original name in an attribute called _missing_instance in the
    MiqAeObject.
    This attribute can be used in substitution.

 lib/miq_automation_engine/engine/miq_ae_object.rb    |  1 +
 spec/lib/miq_automation_engine/miq_ae_engine_spec.rb | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

Comment 4 Shveta 2016-02-01 21:31:31 UTC
Assigning to add test case

Comment 5 Milan Falešník 2016-04-18 15:36:42 UTC
Verified in 5.6.0.2-beta2. I did not go the long way for verification, I just tried to call a method using .missing and _missing_instance expansion and it worked.

Comment 7 errata-xmlrpc 2016-06-29 15:33:17 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, 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/RHBA-2016:1348