File: ReflectManagedMethodExecuter.rb

package info (click to toggle)
ruby-rbvmomi 1.8.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,756 kB
  • sloc: ruby: 5,590; sh: 36; makefile: 7
file content (30 lines) | stat: -rw-r--r-- 857 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module RbVmomi

class VIM::ReflectManagedMethodExecuter
  def fetch moid, prop
    result = FetchSoap(:moid => moid, :version => 'urn:vim25/5.0', :prop => prop)
    xml = Nokogiri(result.response)
    _connection.deserializer.deserialize xml.root, nil
  end

  def execute moid, method, args
    soap_args = args.map do |k,v|
      VIM::ReflectManagedMethodExecuterSoapArgument.new.tap do |soap_arg|
        soap_arg.name = k
        xml = Builder::XmlMarkup.new :indent => 0
        _connection.obj2xml xml, k, :anyType, false, v
        soap_arg.val = xml.target!
      end
    end
    result = ExecuteSoap(:moid => moid, :version => 'urn:vim25/5.0',
                         :method => method, :argument => soap_args)
    if result
      _connection.deserializer.deserialize Nokogiri(result.response).root, nil
    else
      nil
    end
  end
end

end