Bug 1395175 - vm.create_snapshot fails for rhev vm with undefined method `create_snapshot'
Summary: vm.create_snapshot fails for rhev vm with undefined method `create_snapshot'
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Automate
Version: 5.7.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: GA
: 5.8.0
Assignee: Lucy Fu
QA Contact: Aziza Karol
URL:
Whiteboard: automate:snapshot
Depends On:
Blocks: 1399207
TreeView+ depends on / blocked
 
Reported: 2016-11-15 10:42 UTC by Aziza Karol
Modified: 2017-06-12 17:09 UTC (History)
8 users (show)

Fixed In Version: 5.8.0.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1399207 (view as bug list)
Environment:
Last Closed: 2017-06-12 17:09:03 UTC
Category: ---
Cloudforms Team: ---
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
snpshot (93.87 KB, image/png)
2016-11-15 10:42 UTC, Aziza Karol
no flags Details

Description Aziza Karol 2016-11-15 10:42:46 UTC
Created attachment 1220803 [details]
snpshot

Description of problem:


Version-Release number of selected component (if applicable):
5.7.0.10-beta3.20161109111947_9a61b18 

How reproducible:
100%

Steps to Reproduce:
1.Clone the Request class inside the System namespace into a new domain
2.Add a method named ``snapshot`` and insert the below provided code there.


###################################
#
# EVM Automate Method: createSnapshot
#
# Notes: This method creates a snapshot on a given VM via web service API
#
# Inputs: GUID, [snap_name, snap_description]
#
###################################
begin
  @method = 'createSnapshot'
  $evm.log("info", "#{@method} - EVM Automate Method Started")

  # Turn of verbose logging
  @debug = true

  ####################
  #
  # Method: createSnapshot
  #
  ####################
  def createSnapshot(vm, snap_name, snap_desc=snap_name)
    $evm.log("info","#{@method} - VM:<#{vm.name}> Creating Snapshot:<#{snap_name}> Description:<#{snap_desc}>")
    vm.create_snapshot(snap_name, snap_desc)
  end

  #$evm.root.attributes.sort.each { |k, v| $evm.log("info", "\t#{k}: #{v}")} if @debug

  # Get VM object from the root object
  vm = $evm.root['vm']

  # If VM is nil then assume web service call and look for GUID from root object
  if vm.nil?
    $evm.log("info","Execution of method:<#{@method}> via API detected") if @debug
    # Get GUID from foot object
    guid = $evm.root['guid']

    # Lookup VM by GUID
    vm = $evm.vmdb('vm').find_by_guid(guid)
    # Bail out if VM is not found
    raise "#{@method} - VM with GUID:<#{guid}> not found" if vm.nil?
    $evm.log("info","#{@method} - Assigning VM:<#{vm.name}> to root object") if @debug
    $evm.root['vm'] = vm
    $evm.log("info","#{@method} - Found VM:<#{vm.name}> via GUID:<#{guid}>") if @debug
  end

  snap_name = $evm.root['snap_name'] || "Snapshot #{Time.now}"
  snap_desc = $evm.root['snap_desc'] || "Snapshot:<#{snap_name}> for #{vm.name}"

  # Call createSnapshot method
  createSnapshot(vm, snap_name, snap_desc)

  #
  # Exit method
  #
  $evm.log("info", "#{@method} - EVM Automate Method Ended")
  exit MIQ_OK


  #
  # Set Ruby rescue behavior
  #
rescue => err
  $evm.log("error", "#{@method} - [#{err}]\n#{err.backtrace.join("\n")}")
  exit MIQ_ABORT
end

3.Add an instance named ``snapshot`` and set the methd from previous step as ``meth5``
4.Run the simulation of the method against the VM, preferably setting ``snap_name`` to something that can be checked 
5. Wait until snapshot with such name appears.
    

Actual results:
UI displays flash msg"Automation Error: Method exited with rc=MIQ_ABORT". see attached screenshot

Expected results:
snapshot should get created

Additional info:
automation.log
[----] I, [2016-11-15T05:36:28.747239 #2854:b009a0]  INFO -- : Invoking [inline] method [/domain1/System/Request/snapshot] with inputs [{}]
[----] I, [2016-11-15T05:36:28.748606 #2854:b009a0]  INFO -- : <AEMethod [/domain1/System/Request/snapshot]> Starting 
[----] I, [2016-11-15T05:36:29.528286 #2854:966068]  INFO -- : <AEMethod snapshot> createSnapshot - EVM Automate Method Started
[----] I, [2016-11-15T05:36:29.538717 #2854:966068]  INFO -- : <AEMethod snapshot> createSnapshot - VM:<test_2> Creating Snapshot:<snp2> Description:<Snapshot:<snp2> for test_2>
[----] E, [2016-11-15T05:36:29.547076 #2854:e419e8] ERROR -- : <AEMethod snapshot> createSnapshot - [undefined method `create_snapshot' for #<MiqAeMethodService::MiqAeServiceManageIQ_Providers_Redhat_InfraManager_Vm:0x00000017b797d0>]
(druby://127.0.0.1:38715) /var/www/miq/vmdb/lib/miq_automation_engine/engine/miq_ae_service_model_base.rb:189:in `method_missing'
(druby://127.0.0.1:38715) /opt/rh/rh-ruby23/root/usr/share/ruby/drb/drb.rb:1624:in `perform_without_block'
(druby://127.0.0.1:38715) /opt/rh/rh-ruby23/root/usr/share/ruby/drb/drb.rb:1584:in `perform'
(druby://127.0.0.1:38715) /opt/rh/rh-ruby23/root/usr/share/ruby/drb/drb.rb:1657:in `block (2 levels) in main_loop'
(druby://127.0.0.1:38715) /opt/rh/rh-ruby23/root/usr/share/ruby/drb/drb.rb:1653:in `loop'
(druby://127.0.0.1:38715) /opt/rh/rh-ruby23/root/usr/share/ruby/drb/drb.rb:1653:in `block in main_loop'
<code: vm.create_snapshot(snap_name, snap_desc)>:24:in `createSnapshot'
<code: createSnapshot(vm, snap_name, snap_desc)>:51:in `<main>'
[----] I, [2016-11-15T05:36:29.572263 #2854:b009a0]  INFO -- : <AEMethod [/domain1/System/Request/snapshot]> Ending
[----] I, [2016-11-15T05:36:29.572931 #2854:b009a0]  INFO -- : Aborting instantiation because [Method exited with rc=MIQ_ABORT]
[----] I, [2016-11-15T05:36:29.573379 #2854:b009a0]  INFO -- : Aborting instantiation because [Method exited with rc=MIQ_ABORT]

Comment 1 Aziza Karol 2016-11-15 10:46:33 UTC
Tried on Provider RHV-4.0.

Comment 5 CFME Bot 2016-11-21 17:21:18 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/3569ecf1e38569a85a509957ef6ba736a16ad2a5

commit 3569ecf1e38569a85a509957ef6ba736a16ad2a5
Author:     Lucy Fu <lufu>
AuthorDate: Thu Nov 17 15:36:09 2016 -0500
Commit:     Lucy Fu <lufu>
CommitDate: Mon Nov 21 10:02:20 2016 -0500

    Move snapshot code to Vm in service model.
    
    The snapshot code in automate was moved from VmOrTemplate to VMware specific class by PR https://github.com/ManageIQ/manageiq/pull/3707 when VMware was the only class that supports snapshot.
    But snapshot support has been added to RHEVM and Openstack as of version Euwe.
    The snapshot code in automate should be available at Vm level.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1395175

 ...e_manageiq-providers-vmware-infra_manager-vm.rb | 21 --------------
 .../service_models/miq_ae_service_vm.rb            | 24 ++++++++++++++++
 ...ageiq-providers-vmware-infra_manager-vm_spec.rb | 26 ++----------------
 .../service_methods/miq_ae_service_vm_spec.rb      | 32 ++++++++++++++++++++++
 4 files changed, 58 insertions(+), 45 deletions(-)

Comment 7 Aziza Karol 2017-04-19 07:39:16 UTC
Automate Snapshot creation work fine on RHV-4.0.

Verified:5.8.0.10-beta1.20170411212748_e47d319


Note You need to log in before you can comment on or make changes to this bug.