Class: MiqFaultTolerantVim
- Inherits:
-
Object
- Object
- MiqFaultTolerantVim
show all
- Defined in:
- lib/VMwareWebService/miq_fault_tolerant_vim.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of MiqFaultTolerantVim.
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
31
32
33
34
|
# File 'lib/VMwareWebService/miq_fault_tolerant_vim.rb', line 6
def initialize(*options)
options = options.first if options.first.kind_of?(Hash)
@vim = nil
@erec = options[:ems]
auth_type = options[:auth_type] || :ws
ip = options[:ip] || @erec.hostname
user = options[:user] || @erec.authentication_userid(auth_type)
pass = options[:pass] || @erec.authentication_password(auth_type)
@ems = [ip, user, pass]
@use_broker = options.key?(:use_broker) ? options[:use_broker] : true
if @use_broker
if options[:vim_broker_drb_port].respond_to?(:call)
@vim_broker_drb_port_method = options[:vim_broker_drb_port]
@vim_broker_drb_port = @vim_broker_drb_port_method.call
else
@vim_broker_drb_port_method = nil
@vim_broker_drb_port = options[:vim_broker_drb_port]
end
end
begin
_connect
rescue MiqException::MiqVimBrokerUnavailable
retry if _handle_broker_port_change
raise
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args) ⇒ Object
40
41
42
|
# File 'lib/VMwareWebService/miq_fault_tolerant_vim.rb', line 40
def method_missing(m, *args)
_execute(m == :disconnect ? :on_disconnect : :on_execute) { |vim| vim.send(m, *args) unless vim.nil? }
end
|
Instance Method Details
#_ems_address ⇒ Object
48
49
50
|
# File 'lib/VMwareWebService/miq_fault_tolerant_vim.rb', line 48
def _ems_address
@ems[0]
end
|
#_ems_name ⇒ Object
44
45
46
|
# File 'lib/VMwareWebService/miq_fault_tolerant_vim.rb', line 44
def _ems_name
@erec.nil? ? _ems_address : @erec.name
end
|
#_ems_userid ⇒ Object
52
53
54
|
# File 'lib/VMwareWebService/miq_fault_tolerant_vim.rb', line 52
def _ems_userid
@ems[1]
end
|
#_reconnect ⇒ Object
64
65
66
67
|
# File 'lib/VMwareWebService/miq_fault_tolerant_vim.rb', line 64
def _reconnect
_disconnect
_connect
end
|
#_use_broker ⇒ Object
56
57
58
|
# File 'lib/VMwareWebService/miq_fault_tolerant_vim.rb', line 56
def _use_broker
@use_broker
end
|
#_vim_broker_drb_port ⇒ Object
60
61
62
|
# File 'lib/VMwareWebService/miq_fault_tolerant_vim.rb', line 60
def _vim_broker_drb_port
@vim_broker_drb_port
end
|
#execute(&block) ⇒ Object
36
37
38
|
# File 'lib/VMwareWebService/miq_fault_tolerant_vim.rb', line 36
def execute(&block)
_execute(&block)
end
|