vmware_web_service 1.0.4 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf458b0ee907d865de6b6f76056211521d9ea407d679b89820b6b5e830f5b391
4
- data.tar.gz: 236271031fa9a0ccf67db10cddba18715d28f4ea4a3eac7b200afefd32681ac8
3
+ metadata.gz: 9387d2cd8bafbb20342e26e516df855fbc85d2a995d248fc092ad61a82b3864e
4
+ data.tar.gz: 7874514afcb8cdd2ef96b95bd6b06a7afdb8b2175465219ec5b88d08adfee024
5
5
  SHA512:
6
- metadata.gz: b757264625977fcd1168dd70a0b1dd6fa64dfdf8481036dc988c529e929a05f2dc0967931cfb71b1dcfdafadeb61a600502126a70fc6eaa028ebb883ee72ab3e
7
- data.tar.gz: ed2f8d1f3697d9523a59ce5ce2f721769e30c07cb890b7d3e19f16d87c5729c8b1f710ab4bbb466d488071367faa050bfca0a6a6b2056e685e5b072a4f08be8e
6
+ metadata.gz: 5387c14724142857b488e24bf49a8ac2cc79e38d85bed837441bd42b468e21cf029eed99b0779eab260440f8ee370972b61b9c23885d04a6dfe1c35f40bc7e97
7
+ data.tar.gz: 9f03fd556dcb003f139950d518ea08f21666f56ddd15acbd2a6cecc3571880ee48de5cbb941f4b7e047abcf98d77fec477a7846eb57be78b585ab36c3f3f4499
@@ -22,7 +22,7 @@ class MiqVim < MiqVimInventory
22
22
 
23
23
  attr_reader :updateThread, :monitor_updates
24
24
 
25
- # @param server [String] DNS name or IP address of the vCenter Server
25
+ # @param server [String] DNS name or IP address of the vCenter Server
26
26
  # @param username [String] Username to connect to the vCenter Server
27
27
  # @param password [String] Password to connect to the vCenter Server
28
28
  # @param cacheScope [Symbol] A pre-defined set of properties to cache (default: nil)
@@ -32,11 +32,14 @@ class MiqVim < MiqVimInventory
32
32
  # @param notifyMethod [Method] A optional method to call for each update (default: nil)
33
33
  # @param maxWait [Integer] How many seconds to wait before breaking out of WaitForUpdates (default: 60)
34
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)
35
+ def initialize(server, username, password, cacheScope = nil, monitor_updates = nil, preLoad = nil, debugUpdates = false, notifyMethod = nil, maxWait = 60, maxObjects = 250)
36
36
  super(server, username, password, cacheScope)
37
37
 
38
38
  pbm_initialize(self)
39
39
 
40
+ monitor_updates = self.class.monitor_updates if monitor_updates.nil?
41
+ preLoad = self.class.pre_load if preLoad.nil?
42
+
40
43
  @monitor_updates = monitor_updates
41
44
  @updateMonitorReady = false
42
45
  @error = nil
@@ -48,6 +51,25 @@ class MiqVim < MiqVimInventory
48
51
  start_monitor_updates_thread(preLoad) if @monitor_updates
49
52
  end
50
53
 
54
+ @@monitor_updates = false
55
+ @@pre_load = false
56
+
57
+ def self.monitor_updates
58
+ @@monitor_updates
59
+ end
60
+
61
+ def self.monitor_updates=(val)
62
+ @@monitor_updates = val
63
+ end
64
+
65
+ def self.pre_load
66
+ @@pre_load
67
+ end
68
+
69
+ def self.pre_load=(val)
70
+ @@pre_load = val
71
+ end
72
+
51
73
  def getVimVm(path)
52
74
  $vim_log.info "MiqVimMod.getVimVm: called"
53
75
  miqVimVm = nil
@@ -34,7 +34,7 @@ class MiqVimCustomizationSpecManager
34
34
  specs = info
35
35
  return [] if specs.nil?
36
36
 
37
- specs = specs.dup.to_miq_a
37
+ specs = Array.wrap(specs.dup)
38
38
  specs.each { |s| s['spec'] = getCustomizationSpec(s['name'].to_s).spec }
39
39
  specs
40
40
  end
@@ -290,8 +290,8 @@ class MiqVimDataStore
290
290
  if block_given?
291
291
  open(fileUrl, options) { |ret| yield(ret) }
292
292
  else
293
- meta = {}; data = nil
294
- open(fileUrl, options) { |ret| data = ret.read; meta = ret.meta }
293
+ data = nil
294
+ open(fileUrl, options) { |ret| data = ret.read }
295
295
  return data
296
296
  end
297
297
  end
@@ -120,7 +120,7 @@ class MiqVimEventMonitor < MiqVimInventory
120
120
  next unless (vmObj = virtualMachinesByMor_locked[eventVmObj['vm']])
121
121
 
122
122
  eventVmObj['path'] = vmObj['summary']['config']['vmPathName']
123
- eventVmObj['uuid'] = vmObj['summary']['config']['uuid']
123
+ eventVmObj['uuid'] = vmObj['summary']['config']['uuid'].presence
124
124
 
125
125
  removeVirtualMachine(eventVmObj['vm']) if event['eventType'] == 'VmRemovedEvent'
126
126
  end
@@ -366,7 +366,12 @@ class MiqVimInventory < MiqVimClientBase
366
366
  #
367
367
  # Hash snapshot info by create time.
368
368
  #
369
- ssMorHash[ssObj['createTime']] = ssObj
369
+ # VMware API strips trailing '0's from the fractional seconds
370
+ # which causes the string to not match what .iso8601(6) returns
371
+ #
372
+ # Example 12:12:59.123Z instead of 12:12:59.123000Z
373
+ create_time = Time.parse(ssObj['createTime']).iso8601(6)
374
+ ssMorHash[create_time] = ssObj
370
375
 
371
376
  #
372
377
  # Ensure childSnapshotList is always present and always an array,
@@ -1138,18 +1143,18 @@ class MiqVimInventory < MiqVimClientBase
1138
1143
 
1139
1144
  $vim_log.info "MiqVimInventory.datacenters_locked: loading Datacenter cache for #{@connId}"
1140
1145
  begin
1141
- @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
1146
+ @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
1142
1147
 
1143
- ra = getMoPropMulti(inventoryHash_locked['Datacenter'], @propMap[:Datacenter][:props])
1148
+ ra = getMoPropMulti(inventoryHash_locked['Datacenter'], @propMap[:Datacenter][:props])
1144
1149
 
1145
- @datacenters = {}
1146
- @datacentersByMor = {}
1147
- ra.each do |dcObj|
1148
- addObjHash(:Datacenter, dcObj)
1150
+ @datacenters = {}
1151
+ @datacentersByMor = {}
1152
+ ra.each do |dcObj|
1153
+ addObjHash(:Datacenter, dcObj)
1154
+ end
1155
+ ensure
1156
+ @cacheLock.sync_unlock if unlock
1149
1157
  end
1150
- ensure
1151
- @cacheLock.sync_unlock if unlock
1152
- end
1153
1158
  $vim_log.info "MiqVimInventory.datacenters_locked: loaded Datacenter cache for #{@connId}"
1154
1159
 
1155
1160
  @datacenters
@@ -112,7 +112,7 @@ module MiqVimUpdate
112
112
  version = updates_version
113
113
  sleep @updateDelay if @updateDelay
114
114
  end # while @monitor
115
- rescue SignalException => err
115
+ rescue SignalException
116
116
  # Ignore signals, except TERM
117
117
  rescue => herr
118
118
  if herr.respond_to?(:reason) && herr.reason == 'The task was canceled by a user.'
@@ -87,14 +87,6 @@ class MiqVimVm
87
87
  # @invObj.releaseObj(self)
88
88
  end
89
89
 
90
- def vmMor
91
- (@vmMor)
92
- end
93
-
94
- def vmh
95
- (@vmh)
96
- end
97
-
98
90
  #######################
99
91
  # Power state methods.
100
92
  #######################
@@ -317,24 +309,24 @@ class MiqVimVm
317
309
  return(@snapshotInfo) if @snapshotInfo && !refresh
318
310
 
319
311
  begin
320
- @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
321
-
322
- unless (ssp = @invObj.getMoProp_local(@vmMor, "snapshot"))
323
- @snapshotInfo = nil
324
- return(nil)
325
- end
312
+ @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
326
313
 
327
- ssObj = ssp["snapshot"]
328
- ssMorHash = {}
329
- rsl = ssObj['rootSnapshotList']
330
- rsl = [rsl] unless rsl.kind_of?(Array)
331
- rsl.each { |rs| @invObj.snapshotFixup(rs, ssMorHash) }
332
- ssObj['ssMorHash'] = ssMorHash
333
- @snapshotInfo = ssObj
334
- ensure
335
- @cacheLock.sync_unlock if unlock
314
+ unless (ssp = @invObj.getMoProp_local(@vmMor, "snapshot"))
315
+ @snapshotInfo = nil
316
+ return(nil)
336
317
  end
337
318
 
319
+ ssObj = ssp["snapshot"]
320
+ ssMorHash = {}
321
+ rsl = ssObj['rootSnapshotList']
322
+ rsl = [rsl] unless rsl.kind_of?(Array)
323
+ rsl.each { |rs| @invObj.snapshotFixup(rs, ssMorHash) }
324
+ ssObj['ssMorHash'] = ssMorHash
325
+ @snapshotInfo = ssObj
326
+ ensure
327
+ @cacheLock.sync_unlock if unlock
328
+ end
329
+
338
330
  (@snapshotInfo)
339
331
  end # def snapshotInfo_locked
340
332
 
@@ -800,11 +792,11 @@ class MiqVimVm
800
792
  bck.writeThrough = "false"
801
793
  bck.fileName = backingFile
802
794
  begin
803
- dsn = @invObj.path2dsName(@dsPath)
804
- bck.datastore = @invObj.dsName2mo_local(dsn)
805
- rescue
806
- bck.datastore = nil
807
- end
795
+ dsn = @invObj.path2dsName(@dsPath)
796
+ bck.datastore = @invObj.dsName2mo_local(dsn)
797
+ rescue
798
+ bck.datastore = nil
799
+ end
808
800
  end
809
801
  end
810
802
  end
@@ -856,11 +848,11 @@ class MiqVimVm
856
848
  bck.writeThrough = "false"
857
849
  bck.fileName = backingFile
858
850
  begin
859
- dsn = @invObj.path2dsName(@dsPath)
860
- bck.datastore = @invObj.dsName2mo(dsn)
861
- rescue
862
- bck.datastore = nil
863
- end
851
+ dsn = @invObj.path2dsName(@dsPath)
852
+ bck.datastore = @invObj.dsName2mo(dsn)
853
+ rescue
854
+ bck.datastore = nil
855
+ end
864
856
  end unless deleteBacking
865
857
  end
866
858
  end
@@ -917,13 +909,14 @@ class MiqVimVm
917
909
  scsi_controllers.sort_by { |s| s["key"].to_i }.each do |scsi_controller|
918
910
  # Skip if all controller units are populated
919
911
  # Bus has 16 units, controller takes up 1 unit itself
920
- next if scsi_controller["device"].to_miq_a.count >= MAX_SCSI_DEVICES
912
+ device = Array.wrap(scsi_controller["device"])
913
+ next if device.count >= MAX_SCSI_DEVICES
921
914
 
922
915
  # We've found the lowest scsi controller with an available unit
923
916
  controller_key = scsi_controller["key"]
924
917
 
925
918
  # Get a list of disks on this controller
926
- disks = devices.select { |dev| scsi_controller["device"].to_miq_a.include?(dev["key"]) }
919
+ disks = devices.select { |dev| device.include?(dev["key"]) }
927
920
 
928
921
  # Get a list of all populated units on the controller
929
922
  populated_units = disks.collect { |disk| disk["unitNumber"].to_i }
@@ -1037,24 +1030,24 @@ class MiqVimVm
1037
1030
  end
1038
1031
 
1039
1032
  begin
1040
- @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
1041
-
1042
- alarmManager = @sic.alarmManager
1043
- #
1044
- # Add disabled if VM is running.
1045
- #
1046
- if poweredOff?
1047
- aSpec = @miqAlarmSpecEnabled
1048
- else
1049
- aSpec = @miqAlarmSpecDisabled
1050
- end
1051
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).addMiqAlarm_locked: calling createAlarm" if $vim_log
1052
- alarmMor = @invObj.createAlarm(alarmManager, @vmMor, aSpec)
1053
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).addMiqAlarm_locked: returned from createAlarm" if $vim_log
1054
- @miqAlarmMor = alarmMor
1055
- ensure
1056
- @cacheLock.sync_unlock if unlock
1033
+ @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
1034
+
1035
+ alarmManager = @sic.alarmManager
1036
+ #
1037
+ # Add disabled if VM is running.
1038
+ #
1039
+ if poweredOff?
1040
+ aSpec = @miqAlarmSpecEnabled
1041
+ else
1042
+ aSpec = @miqAlarmSpecDisabled
1057
1043
  end
1044
+ $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).addMiqAlarm_locked: calling createAlarm" if $vim_log
1045
+ alarmMor = @invObj.createAlarm(alarmManager, @vmMor, aSpec)
1046
+ $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).addMiqAlarm_locked: returned from createAlarm" if $vim_log
1047
+ @miqAlarmMor = alarmMor
1048
+ ensure
1049
+ @cacheLock.sync_unlock if unlock
1050
+ end
1058
1051
 
1059
1052
  (alarmMor)
1060
1053
  end # def addMiqAlarm_locked
@@ -1,3 +1,3 @@
1
1
  module VMwareWebService
2
- VERSION = '1.0.4'.freeze
2
+ VERSION = '1.0.9'.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: 1.0.4
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - ManageIQ Developers
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-17 00:00:00.000000000 Z
11
+ date: 2021-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -76,16 +76,22 @@ dependencies:
76
76
  name: more_core_extensions
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - "~>"
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: '3.2'
82
+ - - "<"
83
+ - !ruby/object:Gem::Version
84
+ version: '5'
82
85
  type: :runtime
83
86
  prerelease: false
84
87
  version_requirements: !ruby/object:Gem::Requirement
85
88
  requirements:
86
- - - "~>"
89
+ - - ">="
87
90
  - !ruby/object:Gem::Version
88
91
  version: '3.2'
92
+ - - "<"
93
+ - !ruby/object:Gem::Version
94
+ version: '5'
89
95
  - !ruby/object:Gem::Dependency
90
96
  name: rbvmomi
91
97
  requirement: !ruby/object:Gem::Requirement
@@ -199,7 +205,7 @@ dependencies:
199
205
  - !ruby/object:Gem::Version
200
206
  version: '0'
201
207
  description: A ruby interface to Vmware Web Services SDK
202
- email:
208
+ email:
203
209
  executables: []
204
210
  extensions: []
205
211
  extra_rdoc_files: []
@@ -4455,7 +4461,7 @@ homepage: https://github.com/ManageIQ/vmware_web_service
4455
4461
  licenses:
4456
4462
  - Apache-2.0
4457
4463
  metadata: {}
4458
- post_install_message:
4464
+ post_install_message:
4459
4465
  rdoc_options: []
4460
4466
  require_paths:
4461
4467
  - lib
@@ -4470,8 +4476,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
4470
4476
  - !ruby/object:Gem::Version
4471
4477
  version: '0'
4472
4478
  requirements: []
4473
- rubygems_version: 3.1.3
4474
- signing_key:
4479
+ rubygems_version: 3.2.4
4480
+ signing_key:
4475
4481
  specification_version: 4
4476
4482
  summary: A ruby interface to Vmware Web Services SDK
4477
4483
  test_files: []