vmware_web_service 0.4.10 → 1.0.4

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
  SHA256:
3
- metadata.gz: 55282eac83a1152907a531201ac903f05f0c282cdcb60cd807ab4e695fc3e945
4
- data.tar.gz: 1dd7bb1f11ed5121ae33989e09a0fb4abebb1c4efc4125d4e964a7ba433d99cb
3
+ metadata.gz: bf458b0ee907d865de6b6f76056211521d9ea407d679b89820b6b5e830f5b391
4
+ data.tar.gz: 236271031fa9a0ccf67db10cddba18715d28f4ea4a3eac7b200afefd32681ac8
5
5
  SHA512:
6
- metadata.gz: 5d762d75ce5e3590b078fe64c813b8a9d7bd6865017f1fde052d52003e6b0a1986bcf72d9888ca78a47544b899f1f8cc16383e68222b35d0a8716af8c1463dc1
7
- data.tar.gz: 1f4eb2f599c2c35ea2d7f8f5d9dc7e9b0ef14b8298596501c27acbd38e878705683c28459f82c1dad42eac6cab12cdd8433b360361019a26cdd2e067312289f4
6
+ metadata.gz: b757264625977fcd1168dd70a0b1dd6fa64dfdf8481036dc988c529e929a05f2dc0967931cfb71b1dcfdafadeb61a600502126a70fc6eaa028ebb883ee72ab3e
7
+ data.tar.gz: ed2f8d1f3697d9523a59ce5ce2f721769e30c07cb890b7d3e19f16d87c5729c8b1f710ab4bbb466d488071367faa050bfca0a6a6b2056e685e5b072a4f08be8e
@@ -1,5 +1,4 @@
1
1
  require 'VMwareWebService/MiqVim'
2
- require 'VMwareWebService/MiqVimUpdate'
3
2
  require 'VMwareWebService/DMiqVimSync'
4
3
 
5
4
  #
@@ -20,66 +19,24 @@ class DMiqVim < MiqVim
20
19
  alias_method :conditionalCopy, :deepClone
21
20
 
22
21
  include DRb::DRbUndumped
23
- include MiqVimUpdate
24
22
  include DMiqVimSync
25
23
 
26
- attr_reader :updateThread
27
-
24
+ # @param server [String] DNS name or IP address of the vCenter Server
25
+ # @param username [String] Username to connect to the vCenter Server
26
+ # @param password [String] Password to connect to the vCenter Server
27
+ # @param broker [MiqVimBroker] Instance of the broker worker this connection belongs to
28
+ # @param preLoad [Bool] Should the cache be built before returning the connection (default: false)
29
+ # @param debugUpdates [Bool] Should we print debug info for each update (default: false)
30
+ # @param notifyMethod [Method] A optional method to call for each update (default: nil)
31
+ # @param cacheScope [Symbol] A pre-defined set of properties to cache (default: nil)
32
+ # @param maxWait [Integer] How many seconds to wait before breaking out of WaitForUpdates (default: 60)
33
+ # @param maxObjects [Integer] How many objects to return from each WaitForUpdates page (default: 250)
28
34
  def initialize(server, username, password, broker, preLoad = false, debugUpdates = false, notifyMethod = nil, cacheScope = nil, maxWait = 60, maxObjects = 250)
29
- super(server, username, password, cacheScope)
35
+ super(server, username, password, cacheScope, monitor_updates = true, preLoad, debugUpdates, notifyMethod, maxWait, maxObjects)
30
36
 
31
- log_prefix = "DMiqVim.initialize (#{@connId})"
32
- @broker = broker
33
- @updateMonitorReady = false
34
- @error = nil
35
- @notifyMethod = notifyMethod
37
+ @broker = broker
36
38
  @connectionShuttingDown = false
37
- @connectionRemoved = false
38
- @debugUpdates = debugUpdates
39
- @maxWait = maxWait
40
- @maxObjects = maxObjects
41
-
42
- checkForOrphanedMonitors
43
- $vim_log.info "#{log_prefix}: starting update monitor thread" if $vim_log
44
- @updateThread = Thread.new { monitor(preLoad) }
45
- @updateThread[:vim_connection_id] = connId
46
- $vim_log.info "#{log_prefix}: waiting for update monitor to become ready" if $vim_log
47
- until @updateMonitorReady
48
- raise @error unless @error.nil?
49
- break unless @updateThread.alive?
50
- Thread.pass
51
- end
52
- $vim_log.info "#{log_prefix}: update monitor ready" if $vim_log
53
- end
54
-
55
- # VC sometimes throws: Handsoap::Fault { :code => 'ServerFaultCode', :reason => 'The session is not authenticated.' }
56
- # Handle this condition by reconnecting and monitoring again
57
- # See http://communities.vmware.com/thread/190531
58
- def handleSessionNotAuthenticated(err)
59
- return false unless err.respond_to?(:reason) && err.reason == 'The session is not authenticated.'
60
-
61
- log_prefix = "DMiqVim.handleSessionNotAuthenticated (#{@connId})"
62
- $vim_log.error "#{log_prefix}: Reconnecting Session because '#{err.reason}'" if $vim_log
63
- $vim_log.info "#{log_prefix}: Session(server=#{server}, username=#{username}) isAlive? => #{self.isAlive?.inspect}" if $vim_log
64
-
65
- begin
66
- $vim_log.info "#{log_prefix}: Disconnecting Session" if $vim_log
67
- serverPrivateDisconnect
68
- $vim_log.info "#{log_prefix}: Disconnecting Session...Complete" if $vim_log
69
- rescue => disconnect_err
70
- $vim_log.error "#{log_prefix}: Disconnecting Session...Error #{disconnect_err}" if $vim_log
71
- end
72
-
73
- begin
74
- $vim_log.info "#{log_prefix}: Connecting Session" if $vim_log
75
- serverPrivateConnect
76
- $vim_log.info "#{log_prefix}: Connecting Session...Complete" if $vim_log
77
- rescue => connect_err
78
- $vim_log.error "#{log_prefix}: Connecting Session...Error #{connect_err}" if $vim_log
79
- @error = err
80
- end
81
-
82
- @error.nil?
39
+ @connectionRemoved = false
83
40
  end
84
41
 
85
42
  def monitor(preLoad)
@@ -116,31 +73,10 @@ class DMiqVim < MiqVim
116
73
  log_prefix = "DMiqVim.shutdownConnection (#{@connId})"
117
74
  $vim_log.info "#{log_prefix}: for address=<#{@server}>, username=<#{@username}>...Starting" if $vim_log
118
75
  @connectionShuttingDown = true
119
- stopUpdateMonitor
120
- begin
121
- if @updateThread != Thread.current && @updateThread.alive?
122
- $vim_log.info "#{log_prefix}: waiting for Update Monitor Thread...Starting" if $vim_log
123
- @updateThread.join
124
- $vim_log.info "#{log_prefix}: waiting for Update Monitor Thread...Complete" if $vim_log
125
- end
126
- rescue => err
127
- end
128
76
  serverPrivateDisconnect if self.isAlive?
129
77
  $vim_log.info "#{log_prefix}: for address=<#{@server}>, username=<#{@username}>...Complete" if $vim_log
130
78
  end
131
79
 
132
- def checkForOrphanedMonitors
133
- log_prefix = "DMiqVim.checkForOrphanedMonitors (#{@connId})"
134
- $vim_log.debug "#{log_prefix}: called..."
135
- Thread.list.each do |thr|
136
- next unless thr[:vim_connection_id] == connId
137
- $vim_log.error "#{log_prefix}: Terminating orphaned update monitor <#{thr.object_id}>"
138
- thr.raise "Orphaned update monitor (#{@connId}) <#{thr.object_id}>, terminated by <#{Thread.current.object_id}>"
139
- thr.wakeup
140
- end
141
- $vim_log.debug "#{log_prefix}: done."
142
- end
143
-
144
80
  def connectionRemoved?
145
81
  @connectionRemoved
146
82
  end
@@ -13,15 +13,39 @@ require 'VMwareWebService/MiqVimEventHistoryCollector'
13
13
  require 'VMwareWebService/MiqCustomFieldsManager'
14
14
  require 'VMwareWebService/MiqVimAlarmManager'
15
15
  require 'VMwareWebService/MiqVimCustomizationSpecManager'
16
+ require 'VMwareWebService/MiqVimUpdate'
16
17
 
17
18
  class MiqVim < MiqVimInventory
18
19
  include MiqVimVdlConnectionMod
19
20
  include MiqPbmInventory
21
+ include MiqVimUpdate
20
22
 
21
- def initialize(server, username, password, cacheScope = nil)
22
- super
23
+ attr_reader :updateThread, :monitor_updates
24
+
25
+ # @param server [String] DNS name or IP address of the vCenter Server
26
+ # @param username [String] Username to connect to the vCenter Server
27
+ # @param password [String] Password to connect to the vCenter Server
28
+ # @param cacheScope [Symbol] A pre-defined set of properties to cache (default: nil)
29
+ # @param monitor_updates [Bool] Should a thread be started to monitor updates (default: false)
30
+ # @param preLoad [Bool] Should the cache be built before returning the connection (default: false)
31
+ # @param debugUpdates [Bool] Should we print debug info for each update (default: false)
32
+ # @param notifyMethod [Method] A optional method to call for each update (default: nil)
33
+ # @param maxWait [Integer] How many seconds to wait before breaking out of WaitForUpdates (default: 60)
34
+ # @param maxObjects [Integer] How many objects to return from each WaitForUpdates page (default: 250)
35
+ def initialize(server, username, password, cacheScope = nil, monitor_updates = false, preLoad = false, debugUpdates = false, notifyMethod = nil, maxWait = 60, maxObjects = 250)
36
+ super(server, username, password, cacheScope)
23
37
 
24
38
  pbm_initialize(self)
39
+
40
+ @monitor_updates = monitor_updates
41
+ @updateMonitorReady = false
42
+ @error = nil
43
+ @notifyMethod = notifyMethod
44
+ @debugUpdates = debugUpdates
45
+ @maxWait = maxWait
46
+ @maxObjects = maxObjects
47
+
48
+ start_monitor_updates_thread(preLoad) if @monitor_updates
25
49
  end
26
50
 
27
51
  def getVimVm(path)
@@ -227,6 +251,60 @@ class MiqVim < MiqVimInventory
227
251
  end
228
252
 
229
253
  def disconnect
254
+ shutdown_monitor_updates_thread if @monitor_updates
255
+
230
256
  super
231
257
  end
258
+
259
+ private
260
+
261
+ def start_monitor_updates_thread(preLoad)
262
+ checkForOrphanedMonitors
263
+ log_prefix = "MiqVim.initialize (#{@connId})"
264
+ $vim_log.info "#{log_prefix}: starting update monitor thread" if $vim_log
265
+ @updateThread = Thread.new { monitor(preLoad) }
266
+ @updateThread[:vim_connection_id] = connId
267
+ $vim_log.info "#{log_prefix}: waiting for update monitor to become ready" if $vim_log
268
+ until @updateMonitorReady
269
+ raise @error unless @error.nil?
270
+ break unless @updateThread.alive?
271
+ Thread.pass
272
+ end
273
+ $vim_log.info "#{log_prefix}: update monitor ready" if $vim_log
274
+ end
275
+
276
+ def checkForOrphanedMonitors
277
+ log_prefix = "MiqVim.checkForOrphanedMonitors (#{@connId})"
278
+ $vim_log.debug "#{log_prefix}: called..."
279
+ Thread.list.each do |thr|
280
+ next unless thr[:vim_connection_id] == connId
281
+ $vim_log.error "#{log_prefix}: Terminating orphaned update monitor <#{thr.object_id}>"
282
+ thr.raise "Orphaned update monitor (#{@connId}) <#{thr.object_id}>, terminated by <#{Thread.current.object_id}>"
283
+ thr.wakeup
284
+ end
285
+ $vim_log.debug "#{log_prefix}: done."
286
+ end
287
+
288
+ def monitor(preLoad)
289
+ log_prefix = "MiqVim.monitor (#{@connId})"
290
+ begin
291
+ monitorUpdates(preLoad)
292
+ rescue Exception => err
293
+ $vim_log.info "#{log_prefix}: returned from monitorUpdates via #{err.class} exception" if $vim_log
294
+ @error = err
295
+ end
296
+ end
297
+
298
+ def shutdown_monitor_updates_thread
299
+ log_prefix = "MiqVim.disconnect (#{@connId})"
300
+ stopUpdateMonitor
301
+ begin
302
+ if @updateThread != Thread.current && @updateThread.alive?
303
+ $vim_log.info "#{log_prefix}: waiting for Update Monitor Thread...Starting" if $vim_log
304
+ @updateThread.join
305
+ $vim_log.info "#{log_prefix}: waiting for Update Monitor Thread...Complete" if $vim_log
306
+ end
307
+ rescue
308
+ end
309
+ end
232
310
  end # module MiqVim
@@ -873,6 +873,34 @@ class MiqVimVm
873
873
  waitForTask(taskMor)
874
874
  end # def removeDiskByFile
875
875
 
876
+ def resizeDisk(backingFile, newSizeInKb)
877
+ disk = getDeviceByBacking(backingFile)
878
+ raise "resizeDisk: no virtual device associated with: #{backingFile}" unless disk
879
+ raise "resizeDisk: cannot reduce the size of a disk" unless newSizeInKb >= Integer(disk.capacityInKB)
880
+ $vim_log.debug "MiqVimVm::resizeDisk: backingFile = #{backingFile} current size = #{device.capacityInKB} newSize = #{newSizeInKb} KB" if $vim_log
881
+
882
+ vmConfigSpec = VimHash.new("VirtualMachineConfigSpec") do |vmcs|
883
+ vmcs.deviceChange = VimArray.new("ArrayOfVirtualDeviceConfigSpec") do |vmcs_vca|
884
+ vmcs_vca << VimHash.new("VirtualDeviceConfigSpec") do |vdcs|
885
+ vdcs.operation = VirtualDeviceConfigSpecOperation::Edit
886
+
887
+ vdcs.device = VimHash.new("VirtualDisk") do |vDev|
888
+ vDev.backing = disk.backing
889
+ vDev.capacityInKB = newSizeInKb
890
+ vDev.controllerKey = disk.controllerKey
891
+ vDev.key = disk.key
892
+ vDev.unitNumber = disk.unitNumber
893
+ end
894
+ end
895
+ end
896
+ end
897
+
898
+ $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).resizeDisk: calling reconfigVM_Task" if $vim_log
899
+ taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
900
+ $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).resizeDisk: returned from reconfigVM_Task" if $vim_log
901
+ waitForTask(taskMor)
902
+ end
903
+
876
904
  #
877
905
  # Find a SCSI controller and
878
906
  # return its key and next available unit number.
@@ -27,10 +27,11 @@ end
27
27
  class VimHash < Hash
28
28
  include VimType
29
29
 
30
- undef_method(:id) if method_defined?(:id)
31
- undef_method(:type) if method_defined?(:type)
32
- undef_method(:size) if method_defined?(:size)
33
- undef_method(:key) if method_defined?(:key)
30
+ undef_method(:id) if method_defined?(:id)
31
+ undef_method(:type) if method_defined?(:type)
32
+ undef_method(:size) if method_defined?(:size)
33
+ undef_method(:key) if method_defined?(:key)
34
+ undef_method(:filter) if method_defined?(:filter)
34
35
 
35
36
  def initialize(xsiType = nil, vimType = nil)
36
37
  self.xsiType = xsiType
@@ -1,3 +1,3 @@
1
1
  module VMwareWebService
2
- VERSION = '0.4.10'.freeze
2
+ VERSION = '1.0.4'.freeze
3
3
  end
@@ -0,0 +1,11 @@
1
+ # THIS FILE WAS AUTOGENERATED. DO NOT MODIFY.
2
+ ---
3
+ dynamicType:
4
+ :type: :SOAP::SOAPString
5
+ dynamicProperty:
6
+ :type: :DynamicProperty
7
+ :isArray: true
8
+ opaqueNetworkId:
9
+ :type: :SOAP::SOAPString
10
+ opaqueNetworkType:
11
+ :type: :SOAP::SOAPString
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.4.10
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ManageIQ Developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-22 00:00:00.000000000 Z
11
+ date: 2020-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -92,14 +92,14 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: 2.0.0
95
+ version: '2.0'
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: 2.0.0
102
+ version: '2.0'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: bundler
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -4062,6 +4062,7 @@ files:
4062
4062
  - lib/VMwareWebService/wsdl41/methods/VirtualEthernetCardNetworkBackingOption.yml
4063
4063
  - lib/VMwareWebService/wsdl41/methods/VirtualEthernetCardNotSupported.yml
4064
4064
  - lib/VMwareWebService/wsdl41/methods/VirtualEthernetCardNotSupportedFault.yml
4065
+ - lib/VMwareWebService/wsdl41/methods/VirtualEthernetCardOpaqueNetworkBackingInfo.yml
4065
4066
  - lib/VMwareWebService/wsdl41/methods/VirtualEthernetCardOption.yml
4066
4067
  - lib/VMwareWebService/wsdl41/methods/VirtualFloppy.yml
4067
4068
  - lib/VMwareWebService/wsdl41/methods/VirtualFloppyDeviceBackingInfo.yml
@@ -4469,7 +4470,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
4469
4470
  - !ruby/object:Gem::Version
4470
4471
  version: '0'
4471
4472
  requirements: []
4472
- rubygems_version: 3.1.2
4473
+ rubygems_version: 3.1.3
4473
4474
  signing_key:
4474
4475
  specification_version: 4
4475
4476
  summary: A ruby interface to Vmware Web Services SDK