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]
https://github.com/ManageIQ/manageiq/pull/11663
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(-)
Verified in 5.8.0.3.20170301174324_1e2e0c4. "Cancel vCenter" action works as expected.