Bug 1687061

Summary: Custom Button on the VM/Instance not able to get $evm.root["vm"]
Product: Red Hat CloudForms Management Engine Reporter: Ahmed El-Rayess <aelrayes>
Component: UI - ServiceAssignee: Martin Hradil <mhradil>
Status: CLOSED CURRENTRELEASE QA Contact: Nikhil Dhandre <ndhandre>
Severity: high Docs Contact: Red Hat CloudForms Documentation <cloudforms-docs>
Priority: high    
Version: 5.10.1CC: aelrayes, bmidwood, dmetzger, jprause, lavenel, mshriver, nansari, ndhandre, obarenbo, simaishi, smallamp, tfitzger, wfitzger
Target Milestone: GAKeywords: TestOnly, ZStream
Target Release: 5.11.0   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: 5.11.0.3 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1722817 (view as bug list) Environment:
Last Closed: 2019-12-13 15:09:11 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: Bug
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: CFME Core Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1722817    
Attachments:
Description Flags
issue displayed none

Description Ahmed El-Rayess 2019-03-09 07:52:58 UTC
Description of problem:
when custom buttons are attached to VM/Instance and launched from the Classic UI, there is no issues, but fails when calling it from the Service UI.

it fails on the first line to get the current vm using $evm.root['vm']

the below error is displayed in the automation.log

The following error occurred during method evaluation:
  RuntimeError: VM is nil from $evm.root['vm']
VM is nil from $evm.root['vm'] (RuntimeError)

Version-Release number of selected component (if applicable):
cfme-appliance-common-5.10.1.2-1.el7cf.x86_64
cfme-gemset-5.10.1.2-2.el7cf.x86_64
cfme-5.10.1.2-3.el7cf.x86_64
cfme-appliance-5.10.1.2-1.el7cf.x86_64
rubygem-redhat_access_cfme-2.0.3-1.el7cf.noarch


How reproducible:
always

Steps to Reproduce:
1. create custom button on the VM/Instance level which uses a dynamic dialog
2. the code of the dynamic dialog should start with $evm.root['vm'] to get the current VM
3.

Actual results:
it fails when trying to get the current VM with the error displayed at the top

Expected results:
should work as it works in the classic UI

Additional info:

Comment 3 dmetzger 2019-03-11 13:58:01 UTC
Is this a regression?

Comment 4 Ahmed El-Rayess 2019-03-11 15:02:34 UTC
I first tested the custom from the service UI with version 5.9 which failed, then I upgraded to 5.10 with latest hot fixes and still the same issue.

I could see there was a similar bug for the custom button on a service where the user was not able to get the current service. the bug states that it was fixed.

Comment 9 Niyaz Akhtar Ansari 2019-03-20 06:37:44 UTC
Loic,

Yes we do test Dynamic Dialog in both UI Classic UI and SUI.
also we have test Dynamic Dialog with custom button on Classic UI.

This issue is Dynamic Dialog with custom button on SUI.
Nikhil added the test for that.

Comment 12 Ahmed El-Rayess 2019-04-03 18:26:09 UTC
Created attachment 1551485 [details]
issue displayed

attached is a video recording of the issue
and this is a sample code that you can use to test

@vm = $evm.root['vm']
dialog_hash = {}
dialog_hash[@vm.id] = @vm.name
$evm.object['default_value'] = dialog_hash.first[0]
$evm.object['values'] = dialog_hash

the video first shows that code then how it is working fine from the Classic UI, then how it is not working on the Service UI with the error from the automation log.

Comment 15 Tina Fitzgerald 2019-04-29 20:35:54 UTC
I suspect the SUI is using the wrong API call for the VM.

Comment 20 CFME Bot 2019-05-03 15:27:12 UTC
New commit detected on ManageIQ/manageiq-ui-service/master:

https://github.com/ManageIQ/manageiq-ui-self_service/commit/41a30d5d3a34c76ecb9d9b19ec7b5351f7fc6158
commit 41a30d5d3a34c76ecb9d9b19ec7b5351f7fc6158
Author:     Martin Hradil <mhradil>
AuthorDate: Tue Apr 30 11:45:48 2019 -0400
Commit:     Martin Hradil <mhradil>
CommitDate: Tue Apr 30 11:45:48 2019 -0400

    VM custom button dialog - use the VM instead of the parent service

    Triggering a VM-based custom button on a Service's VM Resource causes the right dialog to appear..

    But the inital data assumes the associated resource is the service, not the VM.
    Subsequent field refresh requests and submit already use the VM, but the initial load was missed in https://github.com/ManageIQ/manageiq-ui-service/pull/1022.

    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1687061

 client/app/states/services/custom_button_details/custom_button_details.state.js | 4 +
 1 file changed, 4 insertions(+)