Module: Fog::Compute::Ovirt::Shared

Included in:
Mock, Real
Defined in:
lib/fog/ovirt/compute.rb

Instance Method Summary collapse

Instance Method Details

#ovirt_attrs(obj) ⇒ Object

converts an OVIRT object into an hash for fog to consume.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fog/ovirt/compute.rb', line 34

def ovirt_attrs obj
  opts = {:raw => obj}
  obj.instance_variables.each do |v|
    key = v.to_s.gsub("@","").to_sym
    value = obj.instance_variable_get(v)
    #ignore nil values
    next if value.nil?

    opts[key] = case value
                when OVIRT::Link
                  value.id
                when Hash
                  value
                else
                  value.to_s.strip
                end
  end
  opts
end