Bug 1381255

Summary: Cannot cancel clone via policy with cancel vcenter task
Product: Red Hat CloudForms Management Engine Reporter: Roderick Moore <rmoore>
Component: ControlAssignee: Lucy Fu <lufu>
Status: CLOSED CURRENTRELEASE QA Contact: Dmitry Misharov <dmisharo>
Severity: medium Docs Contact:
Priority: high    
Version: 5.6.0CC: cpelland, dmisharo, jhardy, obarenbo, simaishi
Target Milestone: GAKeywords: TestOnly
Target Release: 5.8.0   
Hardware: x86_64   
OS: Unspecified   
Whiteboard: control
Fixed In Version: 5.8.0.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1382406 1383372 (view as bug list) Environment:
Last Closed: 2017-06-12 17:37:20 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: VMware Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1382406, 1383372    
Attachments:
Description Flags
policy used to test the cancel vcenter task action none

Description Roderick Moore 2016-10-03 13:48:59 UTC
Created attachment 1206899 [details]
policy used to test the cancel vcenter task action

Description of problem: I tried to create a policy that prevents the cloning of specially tagged vms in a VMware environment. Here's the basic policy design:
  event: vm clone start
  condition: check to see if tagged as do not clone
  action: cancel vcenter task




Actual results: The clone was not cancelled. It successfully completed


Expected results: The clone task should have been cancelled


Additional info: I verified that the policy was successfully resolved. Here is the relevant log snippet:

[----] I, [2016-09-29T06:15:46.992366 #2834:741990]  INFO -- : MIQ(policy-enforce_policy): Event: [vm_clone_start], To: [rmvm06_0001]
[----] I, [2016-09-29T06:15:47.189004 #2834:741990]  INFO -- : MIQ(policy-enforce_policy): Resolving policy [Prevent VM Cloning Based on Tag]...
[----] I, [2016-09-29T06:15:47.199201 #2834:741990]  INFO -- : MIQ(condition-eval): Name: tagged as do not clone, Expression evaluation result: [true]
[----] I, [2016-09-29T06:15:47.314369 #2834:741990]  INFO -- : MIQ(action-invoke) Invoking action [Cancel vCenter Task] for successful policy [Prevent VM Cloning Based on Tag], event: [VM Clone Start], entity name: [rmvm06_0001], entity type: [Virtual Machine (VMware)], sequence: [1], synchronous? [true]
[----] I, [2016-09-29T06:29:43.141084 #2838:741990]  INFO -- : MIQ(policy-enforce_policy): Event: [vm_clone], To: [rmvm06_0001]

Comment 3 CFME Bot 2016-10-05 17:01:18 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/bb4f5884f84948f6d8f8071f956bd4a6591ab5d9

commit bb4f5884f84948f6d8f8071f956bd4a6591ab5d9
Author:     Lucy Fu <lufu>
AuthorDate: Mon Oct 3 16:07:46 2016 -0400
Commit:     Lucy Fu <lufu>
CommitDate: Tue Oct 4 13:27:53 2016 -0400

    Need to keep and pass along the EmsEvent that triggers vm_clone_start event.
    
    To be able to cancel a vCenter task, we need to get the vCenter task id that is saved in CloneVM_Task event that triggers vm_clone_start event.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1381255

 app/models/miq_action.rb       | 11 ++++++-----
 app/models/miq_event.rb        | 13 +++++++++++++
 spec/models/miq_action_spec.rb |  8 ++++++++
 spec/models/miq_event_spec.rb  | 22 ++++++++++++++++++++++
 4 files changed, 49 insertions(+), 5 deletions(-)

Comment 5 Dmitry Misharov 2017-03-02 14:09:09 UTC
Verified in 5.8.0.3.20170301174324_1e2e0c4. "Cancel vCenter" action works as expected.