vmware_web_service 0.2.13 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c928bedb5eb3eff7198d23dee64dcf0762ec025
4
- data.tar.gz: f068c16fa2aaca98da5fb26419080c87b60cb5ce
3
+ metadata.gz: 4aad1c37f7d0f84ae2588d905da9793e0002d709
4
+ data.tar.gz: 3f843141887206673235d16ded28f1f872740834
5
5
  SHA512:
6
- metadata.gz: 2ee5b51c875807726e357e8475c7a2b726845dafade638ce5ffef6e3d9968820f3655dc0314177faaa6f419adfed1e4a9a33775d4af62c800dd8ab77d3624319
7
- data.tar.gz: e3d9d3f29f25ec9187e13054ce680eb10d2380f52805a59be197bf0b39aaed5e488773440a98b9ad82da3ec5790b585db52f0e831ddcbf8e3a75c840ade114f0
6
+ metadata.gz: 2e41f397f84815a3d9cd7fa54d9f504d184609a8ddab1ff39c6d986c232a364895ee6de5e6cc65d111f131a34884cd70c96e18bec6d75161e001b49c73598a01
7
+ data.tar.gz: c1c3c7a237ecbbfefb1e44669a8841edb4a769f2898b71b26f2bfa8d1e394bce13df2c95f33ef589fed7fb0382ac71ec8120cf272b55e730f0293108b3e54a26
@@ -1,6 +1,7 @@
1
1
  require 'drb'
2
2
  require 'drb/acl'
3
3
  require 'sync'
4
+ require 'tmpdir'
4
5
 
5
6
  require 'VMwareWebService/MiqVimInventory'
6
7
  require 'VMwareWebService/VimTypes'
@@ -32,7 +33,7 @@ class MiqVimBroker
32
33
  @@maxWait = 60
33
34
  @@maxObjects = 250
34
35
 
35
- def initialize(mode = :client, port = 9001)
36
+ def initialize(mode = :client, uri = nil)
36
37
  if mode == :client
37
38
  require 'rubygems'
38
39
  require 'httpclient' # needed for exception classes
@@ -66,7 +67,8 @@ class MiqVimBroker
66
67
  rescue DRb::DRbServerNotFound
67
68
  DRb.start_service
68
69
  end
69
- @broker = DRbObject.new(nil, "druby://127.0.0.1:#{port}")
70
+
71
+ @broker = DRbObject.new(nil, uri)
70
72
  elsif mode == :server
71
73
  require 'timeout'
72
74
  require 'VMwareWebService/broker_timeout'
@@ -95,7 +97,11 @@ class MiqVimBroker
95
97
 
96
98
  acl = ACL.new(%w( deny all allow 127.0.0.1/32 ))
97
99
  DRb.install_acl(acl)
98
- DRb.start_service("druby://127.0.0.1:#{port}", self, :idconv => VimBrokerIdConv.new)
100
+
101
+ Dir::Tmpname.create('MiqVimBroker', nil) do |path|
102
+ DRb.start_service("drbunix://#{path}", self, :idconv => VimBrokerIdConv.new)
103
+ FileUtils.chmod(0o750, path)
104
+ end
99
105
  else
100
106
  raise "MiqVimBroker: unrecognized mode #{mode}"
101
107
  end
@@ -16,19 +16,19 @@ class MiqFaultTolerantVim
16
16
 
17
17
  @use_broker = options.key?(:use_broker) ? options[:use_broker] : true
18
18
  if @use_broker
19
- if options[:vim_broker_drb_port].respond_to?(:call)
20
- @vim_broker_drb_port_method = options[:vim_broker_drb_port]
21
- @vim_broker_drb_port = @vim_broker_drb_port_method.call
19
+ if options[:vim_broker_drb_uri].respond_to?(:call)
20
+ @vim_broker_drb_uri_method = options[:vim_broker_drb_uri]
21
+ @vim_broker_drb_uri = @vim_broker_drb_uri_method.call
22
22
  else
23
- @vim_broker_drb_port_method = nil
24
- @vim_broker_drb_port = options[:vim_broker_drb_port]
23
+ @vim_broker_drb_uri_method = nil
24
+ @vim_broker_drb_uri = options[:vim_broker_drb_uri]
25
25
  end
26
26
  end
27
27
 
28
28
  begin
29
29
  _connect
30
30
  rescue MiqException::MiqVimBrokerUnavailable
31
- retry if _handle_broker_port_change
31
+ retry if _handle_broker_uri_change
32
32
  raise
33
33
  end
34
34
  end
@@ -57,8 +57,8 @@ class MiqFaultTolerantVim
57
57
  @use_broker
58
58
  end
59
59
 
60
- def _vim_broker_drb_port
61
- @vim_broker_drb_port
60
+ def _vim_broker_drb_uri
61
+ @vim_broker_drb_uri
62
62
  end
63
63
 
64
64
  def _reconnect
@@ -116,7 +116,7 @@ class MiqFaultTolerantVim
116
116
  # 'DRb::DRbConnError: druby://localhost:9001 - #<Errno::ECONNREFUSED: Connection refused - connect(2)>'
117
117
  #
118
118
  if err.kind_of?(DRb::DRbConnError)
119
- if _handle_broker_port_change
119
+ if _handle_broker_uri_change
120
120
  _connect
121
121
  retry
122
122
  end
@@ -204,9 +204,9 @@ class MiqFaultTolerantVim
204
204
 
205
205
  def _connect_broker_client
206
206
  return unless $vim_broker_client.nil?
207
- raise MiqException::MiqVimBrokerUnavailable, "Broker is not available (not running)." if @vim_broker_drb_port.blank?
208
- $vim_broker_client = MiqVimBroker.new(:client, @vim_broker_drb_port)
209
- $vim_broker_client_port = @vim_broker_drb_port
207
+ raise MiqException::MiqVimBrokerUnavailable, "Broker is not available (not running)." if @vim_broker_drb_uri.blank?
208
+ $vim_broker_client = MiqVimBroker.new(:client, @vim_broker_drb_uri)
209
+ $vim_broker_client_uri = @vim_broker_drb_uri
210
210
  end
211
211
 
212
212
  def _disconnect_broker_client
@@ -229,16 +229,16 @@ class MiqFaultTolerantVim
229
229
  err.to_s
230
230
  end
231
231
 
232
- def _handle_broker_port_change
233
- log_header = "MIQ(#{self.class.name}._handle_broker_port_change)"
234
- if @vim_broker_drb_port_method
235
- new_port = @vim_broker_drb_port_method.call
236
- if new_port != $vim_broker_client_port
237
- $log.warn("#{log_header} Retrying communication via VimBroker to [#{_ems_address}] because [Broker DRb Port changed from #{$vim_broker_client_port} to #{new_port}]") if $log && !new_port.blank?
238
- @vim_broker_drb_port = new_port
232
+ def _handle_broker_uri_change
233
+ log_header = "MIQ(#{self.class.name}._handle_broker_uri_change)"
234
+ if @vim_broker_drb_uri_method
235
+ new_uri = @vim_broker_drb_uri_method.call
236
+ if new_uri != $vim_broker_client_uri
237
+ $log.warn("#{log_header} Retrying communication via VimBroker to [#{_ems_address}] because [Broker DRb URI changed from #{$vim_broker_client_uri} to #{new_uri}]") if $log && !new_uri.blank?
238
+ @vim_broker_drb_uri = new_uri
239
239
  _disconnect
240
240
  _disconnect_broker_client
241
- return (new_port.blank? ? false : true)
241
+ return (new_uri.blank? ? false : true)
242
242
  end
243
243
  end
244
244
  false
@@ -1,3 +1,3 @@
1
1
  module VMwareWebService
2
- VERSION = '0.2.13'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmware_web_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.13
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ManageIQ Developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-02 00:00:00.000000000 Z
11
+ date: 2018-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport