Bug 1539752

Summary: [RFE] Naming Runs Before Parsed Dialog: Dialog Options missing via prov.get_tags or prov.get_option
Product: Red Hat CloudForms Management Engine Reporter: Satoe Imaishi <simaishi>
Component: AutomateAssignee: Greg McCullough <gmccullo>
Status: CLOSED ERRATA QA Contact: Shveta <sshveta>
Severity: high Docs Contact:
Priority: high    
Version: 5.7.0CC: brant.evans, cpelland, jcutter, jhardy, mkanoor, obarenbo, simaishi, tfitzger
Target Milestone: GAKeywords: FutureFeature, ZStream
Target Release: 5.8.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 5.8.3.3 Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: 1455002 Environment:
Last Closed: 2018-02-28 13:13:50 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: CFME Core Target Upstream Version:
Embargoed:
Bug Depends On: 1455002    
Bug Blocks:    
Attachments:
Description Flags
Test method none

Comment 2 CFME Bot 2018-01-29 18:16:45 UTC
New commit detected on ManageIQ/manageiq/fine:
https://github.com/ManageIQ/manageiq/commit/2896f2ccba8b43c03e504459bbc8fa1722c1060d

commit 2896f2ccba8b43c03e504459bbc8fa1722c1060d
Author:     Chris Arcand <chrisarcand.github.com>
AuthorDate: Fri Oct 20 10:15:54 2017 -0500
Commit:     Satoe Imaishi <simaishi>
CommitDate: Mon Jan 29 13:02:53 2018 -0500

    Merge pull request #16237 from gmcculloug/remove_legacy_provision_naming
    
    Remove legacy naming code from provisioning
    (cherry picked from commit 8636cc7006ff16d7d85e518121c637558afd7f01)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1539752

 app/models/miq_provision/naming.rb  | 32 +++++++++-----------------------
 config/brakeman.ignore              | 20 --------------------
 db/fixtures/miq_provision_naming.rb | 28 ----------------------------
 spec/models/miq_provision_spec.rb   | 15 +++++++++++++--
 spec/models/miq_request_spec.rb     |  9 +++++++++
 5 files changed, 31 insertions(+), 73 deletions(-)
 delete mode 100644 db/fixtures/miq_provision_naming.rb

Comment 3 CFME Bot 2018-01-29 18:16:51 UTC
New commit detected on ManageIQ/manageiq/fine:
https://github.com/ManageIQ/manageiq/commit/97a67036c90689c9cbde3813dce16eb09a6502f7

commit 97a67036c90689c9cbde3813dce16eb09a6502f7
Author:     Brandon Dunne <brandondunne>
AuthorDate: Fri Jan 26 17:23:11 2018 -0500
Commit:     Satoe Imaishi <simaishi>
CommitDate: Mon Jan 29 13:04:18 2018 -0500

    Merge pull request #16897 from gmcculloug/provision_vm_name
    
    Refactor VM naming method in provisioning task to support call from automate
    (cherry picked from commit ee6cb2d7ffab0853db0376aa5b4d31e20410c5b8)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1539752

 app/models/miq_provision.rb          | 15 +++++++++-----
 app/models/miq_provision/automate.rb | 14 +++++++++++++
 app/models/miq_provision/naming.rb   |  8 +-------
 app/models/miq_provision_request.rb  |  6 +++++-
 spec/models/miq_provision_spec.rb    | 39 ++++++++++++++++++++++++++++++++----
 5 files changed, 65 insertions(+), 17 deletions(-)

Comment 4 CFME Bot 2018-01-29 18:16:56 UTC
New commit detected on ManageIQ/manageiq/fine:
https://github.com/ManageIQ/manageiq/commit/a7097c99a319aa1f768f04806d49221cbcb9b559

commit a7097c99a319aa1f768f04806d49221cbcb9b559
Author:     Oleg Barenboim <chessbyte>
AuthorDate: Sat Jan 27 09:40:54 2018 -0500
Commit:     Satoe Imaishi <simaishi>
CommitDate: Mon Jan 29 13:04:58 2018 -0500

    Merge pull request #153 from gmcculloug/miq_provision_update_vm_name
    
    Support calling update_vm_name for miq_provision service models
    (cherry picked from commit cf31df0a593f2f650169101fd4569e7ce7bd3c60)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1539752

 lib/miq_automation_engine/service_models/miq_ae_service_miq_provision.rb | 1 +
 1 file changed, 1 insertion(+)

Comment 5 Shveta 2018-02-01 22:48:12 UTC
Created attachment 1389797 [details]
Test method

Attached is the method used for testing . 
Import the attached method and order a service .

Currently the service provision fails .
Discussed this with Tina .

Comment 6 Tina Fitzgerald 2018-02-02 14:40:28 UTC
The code changes made for this ticket enables a user to manually call the VM naming from an Automate method.  This method would be used in a scenario where VM provisioning is called by Service provisioning, when a Service dialog overrides a VM name. 
The VM state machine instance would need to be modified to add a call to the new method in preprovisioning, or an existing Automate preprovision method can be modified to add the call to update_vm_name. 

My test method:
------------------------------------------------------------------------ 
prov = $evm.root['miq_provision']
$evm.log('info', "testing new name changes")
$evm.log('info', "vm name before: <#{prov.options[:vm_target_name]}> ")

test_vm_name = "test_new_name_here"
prov.update_vm_name("#{test_vm_name}$n{3}",:update_request => false)

$evm.log('info', "vm name after: <#{prov.options[:vm_target_name]}> ")
------------------------------------------------------------------------ 


Example Method Call: (only 1 argument is required)
prov.update_vm_name("#{test_vm_name}$n{3}")

Example Method Call: (optional 2 argument provided)
(default = :update_request = true)
prov.update_vm_name("#{test_vm_name}$n{3}",:update_request => false)

The failure occurs when this method is called from a Service provisioning when update_request = true.(Either by not specifying the 2 argument or by specifying 2nd arg: (:update_request => true)
   
prov.update_vm_name("#{test_vm_name}$n{3}")

Shows this error in the evm.log:
[----] E, [2018-02-01T15:37:54.539589 #8315:3ef508] ERROR -- : Q-task_id([miq_provision_78]) MiqAeServiceModelBase.ar_method raised: <NoMethodError>: <undefined method `update_description_from_tasks' for #<ServiceTemplateProvisionRequest:0x000000013d1bd8>
Did you mean?  updated_on_before_type_cast>
[----] E, [2018-02-01T15:37:54.539743 #8315:3ef508] ERROR -- : Q-task_id([miq_provision_78]) /opt/rh/cfme-gemset/gems/activemodel-5.0.3/lib/active_model/attribute_methods.rb:433:in `method_missing'
/var/www/miq/vmdb/app/models/miq_provision.rb:69:in `update_vm_name'

Comment 7 CFME Bot 2018-02-05 17:26:22 UTC
New commit detected on ManageIQ/manageiq/fine:
https://github.com/ManageIQ/manageiq/commit/c36d65447228c50432391bf37548c4ae18168140

commit c36d65447228c50432391bf37548c4ae18168140
Author:     Brandon Dunne <brandondunne>
AuthorDate: Mon Feb 5 11:20:16 2018 -0500
Commit:     Satoe Imaishi <simaishi>
CommitDate: Mon Feb 5 12:16:14 2018 -0500

    Merge pull request #16949 from gmcculloug/provision_vm_update_name_service
    
    Follow up to update_vm_name for Service template provisioning
    (cherry picked from commit cdb1271d6d4f51d0f55253676f9170b2f7a1bbd0)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1539752

 app/models/miq_provision.rb       |  2 +-
 spec/models/miq_provision_spec.rb | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

Comment 8 Shveta 2018-02-22 19:24:55 UTC
Fixed in 5.8.3.4.20180221165627_8efa813

Comment 11 errata-xmlrpc 2018-02-28 13:13:50 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/RHSA-2018:0374