Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
Add ability to set operation ID for tracing
Browse files Browse the repository at this point in the history
- add ability to pass in operation ID when connecting
- add ability to modify operation ID on connection

Fixes #105
  • Loading branch information
jrgarcia committed Apr 5, 2017
1 parent 5877f49 commit 2ea53c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/rbvmomi/trivial_soap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
require 'pp'

class RbVmomi::TrivialSoap
attr_accessor :debug, :cookie
attr_accessor :debug, :cookie, :operation_id
attr_reader :http

def initialize opts
Expand All @@ -17,6 +17,7 @@ def initialize opts
return unless @opts[:host] # for testcases
@debug = @opts[:debug]
@cookie = @opts[:cookie]
@operation_id = @opts[:operation_id]
@lock = Mutex.new
@http = nil
restart_http
Expand Down Expand Up @@ -64,11 +65,13 @@ def soap_envelope
xsi = 'http://www.w3.org/2001/XMLSchema-instance'
xml = Builder::XmlMarkup.new :indent => 0
xml.tag!('env:Envelope', 'xmlns:xsd' => xsd, 'xmlns:env' => env, 'xmlns:xsi' => xsi) do
if @vcSessionCookie
if @vcSessionCookie || @operation_id
xml.tag!('env:Header') do
xml.tag!('vcSessionCookie', @vcSessionCookie)
xml.tag!('vcSessionCookie', @vcSessionCookie) if @vcSessionCookie
xml.tag!('operationID', @operation_id) if @operation_id
end
end

xml.tag!('env:Body') do
yield xml if block_given?
end
Expand Down
1 change: 1 addition & 0 deletions lib/rbvmomi/vim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class VIM < Connection
# @option opts [String] :password Password.
# @option opts [String] :path (/sdk) SDK endpoint path.
# @option opts [Boolean] :debug (false) If true, print SOAP traffic to stderr.
# @option opts [String] :operation_id If set, use for operationID
def self.connect opts
fail unless opts.is_a? Hash
fail "host option required" unless opts[:host]
Expand Down

0 comments on commit 2ea53c3

Please sign in to comment.