How to simulate prov.options, prov.get_tags in automate/simulation?


#1

I would like to use prov.options and prov.get_tags in automation simulation, to test methods without modifying them: how can i do it?
Regards.


#2

I finally did that:

if ( prov == nil )
$evm.log(“info”, “Simulation”)

class Simulprov
def initialize
@options = Hash.new
@tags = Hash.new
end

def options
@options
end

def get_tags
@tags
end
end

prov = Simulprov.new

prov.options[:vm_name] = 'XXX’
prov.get_tags[:mytag] = 'AAAl’
end

is this sufficient to detect we are in simulation mode? Or is there a best way?


#3

How can a structure be a class with attributes and methods and be an array at the same time?

prov = $evm.root[“miq_provision”]

prov.get_tags -> method

miq_request_id = prov[“miq_request_id”] ->array

(i am not a ruby expert …)
I would like to integrate prov[“miq_request_id”] syntax in my simulation class, and i don’t know how to do it.


#4

ok i have done a class inheriting from hash. it works now.