$evm.root method can't be used


#1

Hi

I’m using rails console debugging automation, $evm.vmdb, evm.log can use, but evm.root method can not be used, I would not rails, hoping to get answers.

Like this

irb(main):014:0> $evm.root['vm']
NoMethodError: undefined method `[]' for nil:NilClass
	from (irb):14
	from /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/gems/railties-5.0.0.rc2/lib/rails/commands/console.rb:65:in `start'
	from /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/gems/railties-5.0.0.rc2/lib/rails/commands/console_helper.rb:9:in `start'
	from /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/gems/railties-5.0.0.rc2/lib/rails/commands/commands_tasks.rb:78:in `console'
	from /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/gems/railties-5.0.0.rc2/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
	from /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/gems/railties-5.0.0.rc2/lib/rails/commands.rb:18:in `<top (required)>'
	from bin/rails:4:in `require'
	from bin/rails:4:in `<main>'

#2

Hi

Which version of ManageIQ are you running, and how have you defined your $evm variable?

Thanks,
pemcg


#3

Hi pemcg!

ManageIQ is darga2, I do reference https://pemcg.gitbooks.io/introduction-to-cloudforms-automation/content/chapter9/investigative_debugging.html

I go through the rails console debugging


#4

You can think of $evm.root as the first object (i.e. automate datastore instance) launched by the automation engine when you entered automate. From a button or from simulation this might be /ManageIQ/SYSTEM/PROCESS/Request for example; for a VM provision request it is probably /ManageIQ/System/Process/AUTOMATION. $evm.root only really has meaning when running in the context of the automation engine.

When you’re simulating $evm from the rails console you’re not launching an automate datastore instance, so you won’t have a root object.

Hope this helps,
pemcg


#5

@pemcg
thank you for you detailed anwser, But there is no better way to debug $evm.root? Rather than log.


#6

It depends what kind of debugging you want to do. If you want to look at the attributes and properties of $evm.root and the object hierarchy in a particular automation workflow, you can call either Kevin’s InspectMe or object_walker from your method, and you should see a lot of information (but you’re right, it still goes to the log file).

pemcg


#7

thank you very much