Class: MiqDevUtil::Automate

Inherits:
Object
  • Object
show all
Defined in:
lib/miq_dev_util/automate.rb

Overview

The Automate class is intended to hold methods that are useful when interacting with the ManageIQ automate system directly.

Instance Method Summary collapse

Constructor Details

#initialize(evm) ⇒ Automate

Returns a new instance of Automate.



6
7
8
# File 'lib/miq_dev_util/automate.rb', line 6

def initialize(evm)
  @evm = evm
end

Instance Method Details

#get_instance_with_attributes(path) ⇒ Object

This is a hacky workaround used to get an instance without executing the methods on it. It fails if a message is passed in the path or if the message field on the any of the methods are *.



24
25
26
27
28
29
30
31
32
# File 'lib/miq_dev_util/automate.rb', line 24

def get_instance_with_attributes(path)
  if path =~ /#/
    raise "Does not work with messages in the path."
  end
  fake_message = "callingWithAFakeMessage"
  empty_instance = @evm.instantiate("#{path}##{fake_message}")
  instance_name = empty_instance.name
  @evm.instance_get(instance_name)
end

#instantiate_or_raise(path, message) ⇒ Object

Instantiate an automate instance at path or raise an exception with the message provided if the instantiation returns nil (not found).



12
13
14
15
16
17
18
19
# File 'lib/miq_dev_util/automate.rb', line 12

def instantiate_or_raise(path, message)
  object = @evm.instantiate(path)
  if object.nil?
    raise message
  end

  object
end