opennebula 5.12.13 → 5.13.80.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +5 -5
  2. data/lib/ActionManager.rb +1 -1
  3. data/lib/CommandManager.rb +1 -1
  4. data/lib/DriverExecHelper.rb +44 -28
  5. data/lib/OpenNebulaDriver.rb +8 -4
  6. data/lib/VirtualMachineDriver.rb +9 -2
  7. data/lib/cloud/CloudClient.rb +3 -3
  8. data/lib/datacenter.rb +1258 -0
  9. data/lib/datastore.rb +1025 -0
  10. data/lib/distributed_firewall.rb +280 -0
  11. data/lib/file_helper.rb +370 -0
  12. data/lib/host.rb +1517 -0
  13. data/lib/logical_port.rb +50 -0
  14. data/lib/logical_switch.rb +77 -0
  15. data/lib/memoize.rb +74 -0
  16. data/lib/models/role.rb +39 -8
  17. data/lib/models/service.rb +92 -31
  18. data/lib/models.rb +5 -5
  19. data/lib/network.rb +635 -0
  20. data/lib/nsx_client.rb +144 -0
  21. data/lib/nsx_component.rb +28 -0
  22. data/lib/nsx_constants.rb +149 -0
  23. data/lib/nsx_driver.rb +78 -0
  24. data/lib/nsx_error.rb +77 -0
  25. data/lib/nsx_rule.rb +193 -0
  26. data/lib/nsxt_client.rb +176 -0
  27. data/lib/nsxt_dfw.rb +196 -0
  28. data/lib/nsxt_logical_port.rb +94 -0
  29. data/lib/nsxt_rule.rb +188 -0
  30. data/lib/nsxt_tz.rb +38 -0
  31. data/lib/nsxv_client.rb +176 -0
  32. data/lib/nsxv_dfw.rb +202 -0
  33. data/lib/nsxv_logical_port.rb +107 -0
  34. data/lib/nsxv_rule.rb +172 -0
  35. data/lib/nsxv_tz.rb +41 -0
  36. data/lib/opaque_network.rb +134 -0
  37. data/lib/opennebula/acl.rb +1 -1
  38. data/lib/opennebula/acl_pool.rb +1 -1
  39. data/lib/opennebula/client.rb +1 -1
  40. data/lib/opennebula/cluster.rb +1 -1
  41. data/lib/opennebula/cluster_pool.rb +1 -1
  42. data/lib/opennebula/datastore.rb +1 -1
  43. data/lib/opennebula/datastore_pool.rb +1 -1
  44. data/lib/opennebula/document.rb +8 -29
  45. data/lib/opennebula/document_json.rb +42 -12
  46. data/lib/opennebula/document_pool.rb +1 -1
  47. data/lib/opennebula/document_pool_json.rb +1 -1
  48. data/lib/opennebula/error.rb +4 -1
  49. data/lib/opennebula/flow/grammar.rb +1195 -0
  50. data/lib/{models → opennebula/flow}/service_pool.rb +26 -2
  51. data/lib/{models → opennebula/flow}/service_template.rb +86 -17
  52. data/lib/opennebula/flow/service_template_ext.rb +84 -0
  53. data/lib/{models → opennebula/flow}/service_template_pool.rb +1 -1
  54. data/lib/opennebula/flow/validator.rb +499 -0
  55. data/lib/opennebula/flow.rb +23 -0
  56. data/lib/opennebula/group.rb +1 -1
  57. data/lib/opennebula/group_pool.rb +1 -1
  58. data/lib/opennebula/hook.rb +5 -12
  59. data/lib/opennebula/hook_log.rb +1 -1
  60. data/lib/opennebula/hook_pool.rb +1 -1
  61. data/lib/opennebula/host.rb +1 -1
  62. data/lib/opennebula/host_pool.rb +1 -1
  63. data/lib/opennebula/image.rb +17 -14
  64. data/lib/opennebula/image_pool.rb +1 -1
  65. data/lib/opennebula/ldap_auth.rb +1 -1
  66. data/lib/opennebula/ldap_auth_spec.rb +1 -1
  67. data/lib/opennebula/lockable_ext.rb +163 -0
  68. data/lib/opennebula/marketplace.rb +1 -1
  69. data/lib/opennebula/marketplace_pool.rb +1 -1
  70. data/lib/opennebula/marketplaceapp.rb +9 -119
  71. data/lib/opennebula/marketplaceapp_ext.rb +522 -0
  72. data/lib/opennebula/marketplaceapp_pool.rb +1 -1
  73. data/lib/opennebula/oneflow_client.rb +4 -3
  74. data/lib/opennebula/pool.rb +4 -3
  75. data/lib/opennebula/pool_element.rb +1 -1
  76. data/lib/opennebula/security_group.rb +1 -1
  77. data/lib/opennebula/security_group_pool.rb +1 -1
  78. data/lib/opennebula/server_cipher_auth.rb +1 -1
  79. data/lib/opennebula/server_x509_auth.rb +1 -1
  80. data/lib/opennebula/ssh_auth.rb +1 -1
  81. data/lib/opennebula/system.rb +1 -1
  82. data/lib/opennebula/template.rb +4 -13
  83. data/lib/opennebula/template_ext.rb +325 -0
  84. data/lib/opennebula/template_pool.rb +1 -1
  85. data/lib/opennebula/user.rb +26 -2
  86. data/lib/opennebula/user_pool.rb +1 -1
  87. data/lib/opennebula/utils.rb +1 -1
  88. data/lib/opennebula/vdc.rb +1 -1
  89. data/lib/opennebula/vdc_pool.rb +1 -1
  90. data/lib/opennebula/virtual_machine.rb +25 -207
  91. data/lib/opennebula/virtual_machine_ext.rb +469 -0
  92. data/lib/opennebula/virtual_machine_pool.rb +1 -5
  93. data/lib/opennebula/virtual_network.rb +4 -10
  94. data/lib/opennebula/virtual_network_pool.rb +1 -1
  95. data/lib/opennebula/virtual_router.rb +4 -12
  96. data/lib/opennebula/virtual_router_pool.rb +1 -1
  97. data/lib/opennebula/vm_group.rb +4 -11
  98. data/lib/opennebula/vm_group_pool.rb +1 -1
  99. data/lib/opennebula/vntemplate.rb +4 -13
  100. data/lib/opennebula/vntemplate_pool.rb +1 -1
  101. data/lib/opennebula/wait_ext.rb +222 -0
  102. data/lib/opennebula/x509_auth.rb +1 -1
  103. data/lib/opennebula/xml_element.rb +1 -1
  104. data/lib/opennebula/xml_pool.rb +1 -1
  105. data/lib/opennebula/xml_utils.rb +1 -1
  106. data/lib/opennebula/zone.rb +1 -1
  107. data/lib/opennebula/zone_pool.rb +1 -1
  108. data/lib/opennebula.rb +5 -2
  109. data/lib/rest_client.rb +201 -0
  110. data/lib/scripts_common.rb +180 -0
  111. data/lib/transport_zone.rb +43 -0
  112. data/lib/vcenter_driver.rb +9 -22
  113. data/lib/vcenter_importer.rb +616 -0
  114. data/lib/vi_client.rb +281 -0
  115. data/lib/vi_helper.rb +312 -0
  116. data/lib/virtual_machine.rb +3477 -0
  117. data/lib/virtual_wire.rb +158 -0
  118. data/lib/vm_device.rb +80 -0
  119. data/lib/vm_disk.rb +202 -0
  120. data/lib/vm_folder.rb +69 -0
  121. data/lib/vm_helper.rb +30 -0
  122. data/lib/vm_monitor.rb +303 -0
  123. data/lib/vm_nic.rb +70 -0
  124. data/lib/vm_template.rb +1961 -0
  125. data/lib/vmm_importer.rb +121 -0
  126. metadata +101 -35
@@ -0,0 +1,469 @@
1
+ # -------------------------------------------------------------------------- #
2
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
3
+ # #
4
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
+ # not use this file except in compliance with the License. You may obtain #
6
+ # a copy of the License at #
7
+ # #
8
+ # http://www.apache.org/licenses/LICENSE-2.0 #
9
+ # #
10
+ # Unless required by applicable law or agreed to in writing, software #
11
+ # distributed under the License is distributed on an "AS IS" BASIS, #
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
13
+ # See the License for the specific language governing permissions and #
14
+ # limitations under the License. #
15
+ #--------------------------------------------------------------------------- #
16
+
17
+ require 'opennebula/template_ext'
18
+
19
+ # Module to decorate VirtualMachine class with additional helpers not directly
20
+ # exposed through the OpenNebula XMLRPC API. The extensions include
21
+ # - mp_import helper that imports a template into a marketplace
22
+ #
23
+ # rubocop:disable Style/ClassAndModuleChildren
24
+ module OpenNebula::VirtualMachineExt
25
+
26
+ def self.extend_object(obj)
27
+ if !obj.is_a?(OpenNebula::VirtualMachine)
28
+ raise StandardError, "Cannot extended #{obj.class} "\
29
+ ' with MarketPlaceAppExt'
30
+ end
31
+
32
+ class << obj
33
+
34
+ ####################################################################
35
+ # Public extended interface
36
+ ####################################################################
37
+
38
+ #-------------------------------------------------------------------
39
+ # Clones the VM's source Template, replacing the disks with live
40
+ # snapshots of the current disks. The VM capacity and NICs are also
41
+ # preserved
42
+ #
43
+ # @param name [String] Name for the new Template
44
+ # @param name [true,false,nil] Optional, true to make the saved
45
+ # images persistent, false make them non-persistent
46
+ #
47
+ # @return [Integer, OpenNebula::Error] the new Template ID in case
48
+ # of success, error otherwise
49
+ #-------------------------------------------------------------------
50
+ REMOVE_VNET_ATTRS = %w[AR_ID BRIDGE CLUSTER_ID IP MAC TARGET NIC_ID
51
+ NETWORK_ID VN_MAD SECURITY_GROUPS VLAN_ID
52
+ BRIDGE_TYPE]
53
+
54
+ REMOVE_IMAGE_ATTRS = %w[DEV_PREFIX SOURCE ORIGINAL_SIZE SIZE
55
+ DISK_SNAPSHOT_TOTAL_SIZE DRIVER IMAGE_STATE
56
+ SAVE CLONE READONLY PERSISTENT TARGET
57
+ ALLOW_ORPHANS CLONE_TARGET CLUSTER_ID
58
+ DATASTORE DATASTORE_ID DISK_ID DISK_TYPE
59
+ IMAGE_ID IMAGE IMAGE_UNAME IMAGE_UID
60
+ LN_TARGET TM_MAD TYPE OPENNEBULA_MANAGED]
61
+
62
+ def save_as_template(name, desc, opts = {})
63
+ opts = {
64
+ :persistent => false,
65
+ :poweroff => false,
66
+ :logger => nil
67
+ }.merge(opts)
68
+
69
+ img_ids = []
70
+ ntid = nil
71
+ logger = opts[:logger]
72
+ poweron = false
73
+
74
+ rc = info
75
+
76
+ raise rc.message if OpenNebula.is_error?(rc)
77
+
78
+ tid = self['TEMPLATE/TEMPLATE_ID']
79
+
80
+ raise 'VM has no associated template' unless valid?(tid)
81
+
82
+ # --------------------------------------------------------------
83
+ # Check VM state and poweroff it if needed
84
+ # --------------------------------------------------------------
85
+ if state_str != 'POWEROFF'
86
+ raise 'VM must be POWEROFF' unless opts[:poweroff]
87
+
88
+ logger.info 'Powering off VM' if logger
89
+
90
+ poweron = true
91
+
92
+ rc = poweroff
93
+
94
+ raise rc.message if OpenNebula.is_error?(rc)
95
+ end
96
+
97
+ # --------------------------------------------------------------
98
+ # Clone the source template
99
+ # --------------------------------------------------------------
100
+ vm_template = OpenNebula::Template.new_with_id(tid, @client)
101
+
102
+ ntid = vm_template.clone(name)
103
+
104
+ raise ntid.message if OpenNebula.is_error?(ntid)
105
+
106
+ # --------------------------------------------------------------
107
+ # Replace the original template's capacity with VM values
108
+ # --------------------------------------------------------------
109
+ cpu = self['TEMPLATE/CPU']
110
+ vcpu = self['TEMPLATE/VCPU']
111
+ mem = self['TEMPLATE/MEMORY']
112
+
113
+ replace = ''
114
+ replace << "DESCRIPTION = \"#{desc}\"\n" if valid?(desc)
115
+ replace << "CPU = #{cpu}\n" if valid?(cpu)
116
+ replace << "VCPU = #{vcpu}\n" if valid?(vcpu)
117
+ replace << "MEMORY = #{mem}\n" if valid?(mem)
118
+
119
+ # --------------------------------------------------------------
120
+ # Process VM DISKs
121
+ # --------------------------------------------------------------
122
+ logger.info 'Processing VM disks' if logger
123
+
124
+ each('TEMPLATE/DISK') do |disk|
125
+ # Wait for any pending operation
126
+ rc = wait_state2('POWEROFF', 'LCM_INIT')
127
+
128
+ raise rc.message if OpenNebula.is_error?(rc)
129
+
130
+ disk_id = disk['DISK_ID']
131
+ image_id = disk['IMAGE_ID']
132
+
133
+ omng = disk['OPENNEBULA_MANAGED']
134
+ type = disk['TYPE']
135
+
136
+ raise 'Missing DISK_ID' unless valid?(disk_id)
137
+
138
+ REMOVE_IMAGE_ATTRS.each do |attr|
139
+ disk.delete_element(attr)
140
+ end
141
+
142
+ # Volatile disks cannot be saved, copy definition
143
+ if !valid?(image_id)
144
+ logger.info 'Adding volatile disk' if logger
145
+
146
+ disk_str = template_like_str(
147
+ 'TEMPLATE',
148
+ true,
149
+ "DISK [ DISK_ID = #{disk_id} ]"
150
+ )
151
+
152
+ replace << "#{disk_str}\n"
153
+
154
+ next
155
+ end
156
+
157
+ # CDROM disk, copy definition
158
+ if type == 'CDROM'
159
+ logger.info 'Adding CDROM disk' if logger
160
+
161
+ replace << "DISK = [ IMAGE_ID = #{image_id}"
162
+ replace << ", OPENNEBULA_MANAGED=#{omng}" if omng
163
+ replace << " ]\n"
164
+
165
+ next
166
+ end
167
+
168
+ # Regular disk, saveas it
169
+ logger.info 'Adding and saving regular disk' if logger
170
+
171
+ ndisk_name = "#{name}-disk-#{disk_id}"
172
+
173
+ rc = disk_saveas(disk_id.to_i, ndisk_name, '', -1)
174
+
175
+ raise rc.message if OpenNebula.is_error?(rc)
176
+
177
+ if opts[:persistent]
178
+ logger.info 'Making disk persistent' if logger
179
+
180
+ nimg = OpenNebula::Image.new_with_id(rc.to_i, @client)
181
+ nimg.persistent
182
+ end
183
+
184
+ img_ids << rc.to_i
185
+
186
+ disk_tmpl = disk.template_like_str('.').tr("\n", ",\n")
187
+
188
+ replace << "DISK = [ IMAGE_ID = #{rc} "
189
+ replace << ", #{disk_tmpl}" unless disk_tmpl.empty?
190
+ replace << " ]\n"
191
+ end
192
+
193
+ # --------------------------------------------------------------
194
+ # Process VM NICs
195
+ # --------------------------------------------------------------
196
+ logger.info 'Processing VM NICs' if logger
197
+
198
+ each('TEMPLATE/NIC') do |nic|
199
+ nic_id = nic['NIC_ID']
200
+
201
+ raise 'Missing NIC_ID' unless valid?(nic_id)
202
+
203
+ REMOVE_VNET_ATTRS.each do |attr|
204
+ nic.delete_element(attr)
205
+ end
206
+
207
+ replace << 'NIC = [ '
208
+ replace << nic.template_like_str('.').tr("\n", ",\n")
209
+ replace << " ] \n"
210
+ end
211
+
212
+ # --------------------------------------------------------------
213
+ # Extra. Required by the Sunstone Cloud View
214
+ # --------------------------------------------------------------
215
+ replace << "SAVED_TEMPLATE_ID = #{tid}\n"
216
+
217
+ new_tmpl = OpenNebula::Template.new_with_id(ntid, @client)
218
+
219
+ logger.info 'Updating VM Template' if logger
220
+
221
+ rc = new_tmpl.update(replace, true)
222
+
223
+ raise rc.message if OpenNebula.is_error?(rc)
224
+
225
+ # --------------------------------------------------------------
226
+ # Resume VM if needed
227
+ # --------------------------------------------------------------
228
+ if poweron
229
+ logger.info 'Powering on VM' if logger
230
+
231
+ rc = wait_state2('POWEROFF', 'LCM_INIT')
232
+
233
+ raise rc.message if OpenNebula.is_error?(rc)
234
+
235
+ resume
236
+
237
+ rc = wait_state2('ACTIVE', 'RUNNING')
238
+
239
+ raise rc.message if OpenNebula.is_error?(rc)
240
+ end
241
+
242
+ ntid
243
+ rescue StandardError
244
+ # --------------------------------------------------------------
245
+ # Rollback. Delete the template and the images created
246
+ # --------------------------------------------------------------
247
+ if ntid
248
+ ntmpl = OpenNebula::Template.new_with_id(ntid, @client)
249
+ ntmpl.delete
250
+ end
251
+
252
+ img_ids.each do |id|
253
+ img = OpenNebula::Image.new_with_id(id, @client)
254
+ img.delete
255
+ end
256
+
257
+ raise
258
+ end
259
+
260
+ #-------------------------------------------------------------------
261
+ # Backups a VM. TODO Add final description
262
+ # @param keep [Bool]
263
+ # @param logger[Logger]
264
+ # @param binfo[Hash] Oneshot
265
+ #-------------------------------------------------------------------
266
+ def backup(keep = false, logger = nil, binfo = nil)
267
+ # --------------------------------------------------------------
268
+ # Check backup consistency
269
+ # --------------------------------------------------------------
270
+ unless binfo
271
+ rc = info
272
+ raise rc.message if OpenNebula.is_error?(rc)
273
+
274
+ binfo = backup_info
275
+ end
276
+
277
+ raise 'No backup information' if binfo.nil?
278
+
279
+ raise 'No frequency defined' unless valid?(binfo[:freq])
280
+
281
+ return if Time.now.to_i - binfo[:last].to_i < binfo[:freq].to_i
282
+
283
+ # --------------------------------------------------------------
284
+ # Save VM as new template
285
+ # --------------------------------------------------------------
286
+ logger.info 'Saving VM as template' if logger
287
+
288
+ tid = save_as_template(
289
+ binfo[:name], '', :poweroff => true, :logger => logger
290
+ )
291
+
292
+ tmp = OpenNebula::Template.new_with_id(tid, @client)
293
+ rc = tmp.info
294
+
295
+ raise rc.message if OpenNebula.is_error?(rc)
296
+
297
+ # --------------------------------------------------------------
298
+ # Import template into Marketplace & update VM info
299
+ # --------------------------------------------------------------
300
+ logger.info "Importing template #{tmp.id} to marketplace "\
301
+ "#{binfo[:market]}" if logger
302
+
303
+ tmp.extend(OpenNebula::TemplateExt)
304
+
305
+ rc, ids = tmp.mp_import(binfo[:market], true, binfo[:name],
306
+ :wait => true, :logger => logger)
307
+
308
+ raise rc.message if OpenNebula.is_error?(rc)
309
+
310
+ logger.info "Imported app ids: #{ids.join(',')}" if logger
311
+
312
+ rc = update(backup_attr(binfo, ids), true)
313
+
314
+ if OpenNebula.is_error?(rc)
315
+ raise 'Could not update the backup reference: ' \
316
+ " #{rc.message}. New backup ids are #{ids.join(',')}."
317
+ end
318
+
319
+ # --------------------------------------------------------------
320
+ # Cleanup
321
+ # --------------------------------------------------------------
322
+ logger.info "Deleting template #{tmp.id}" if logger
323
+
324
+ tmp.delete(true)
325
+
326
+ binfo[:apps].each do |id|
327
+ log "Deleting applicance #{id}" if logger
328
+
329
+ papp = OpenNebula::MarketPlaceApp.new_with_id(id, @client)
330
+
331
+ papp.delete
332
+ end if !keep && binfo[:apps]
333
+ rescue Error, StandardError => e
334
+ logger.fatal(e.inspect) if logger
335
+ raise
336
+ end
337
+
338
+ #-------------------------------------------------------------------
339
+ # Restores VM information from previous backup
340
+ #
341
+ # @param datastore [Integer] Datastore ID to import app backup
342
+ # @param logger [Logger] Logger instance to print debug info
343
+ #
344
+ # @return [Integer] VM ID
345
+ #-------------------------------------------------------------------
346
+ def restore(datastore, logger = nil)
347
+ rc = info
348
+
349
+ if OpenNebula.is_error?(rc)
350
+ raise "Error getting VM: #{rc.message}"
351
+ end
352
+
353
+ logger.info 'Reading backup information' if logger
354
+
355
+ backup_ids = backup_info[:apps]
356
+
357
+ # highest (=last) of the app ids is the template id
358
+ app_id = backup_ids.last
359
+
360
+ app = OpenNebula::MarketPlaceApp.new_with_id(app_id, @client)
361
+ rc = app.info
362
+
363
+ if OpenNebula.is_error?(rc)
364
+ raise "Can not find appliance #{app_id}: #{rc.message}."
365
+ end
366
+
367
+ if logger
368
+ logger.info "Restoring VM #{self['ID']} from " \
369
+ "saved appliance #{app_id}"
370
+ end
371
+
372
+ app.extend(OpenNebula::MarketPlaceAppExt)
373
+
374
+ exp = app.export(:dsid => Integer(datastore),
375
+ :name => "#{self['NAME']} - RESTORED")
376
+
377
+ if OpenNebula.is_error?(exp)
378
+ raise "Can not restore app: #{exp.message}."
379
+ end
380
+
381
+ # Check possible errors when exporting apps
382
+ exp[:image].each do |image|
383
+ next unless OpenNebula.is_error?(image)
384
+
385
+ raise "Error restoring image: #{image.message}."
386
+ end
387
+
388
+ template = exp[:vmtemplate].first
389
+
390
+ if OpenNebula.is_error?(template)
391
+ raise "Error restoring template: #{template.message}."
392
+ end
393
+
394
+ if logger
395
+ logger.info(
396
+ "Backup restored, VM template: #{exp[:vmtemplate]}, " \
397
+ "images: #{exp[:image]}"
398
+ )
399
+
400
+ logger.info(
401
+ "Instantiating the template #{exp[:vmtemplate]}"
402
+ )
403
+ end
404
+
405
+ tmpl = OpenNebula::Template.new_with_id(template, @client)
406
+ rc = tmpl.instantiate
407
+
408
+ if OpenNebula.is_error?(rc)
409
+ raise "Can not instantiate the template: #{rc.message}."
410
+ end
411
+
412
+ rc
413
+ rescue Error, StandardError => e
414
+ logger.fatal(e.inspect) if logger
415
+ raise
416
+ end
417
+
418
+ ####################################################################
419
+ # Private extended interface
420
+ ####################################################################
421
+
422
+ private
423
+
424
+ # --------------------------------------------------------------
425
+ # Check an attribute is defined and valid
426
+ # --------------------------------------------------------------
427
+ def valid?(att)
428
+ return false if att.nil?
429
+
430
+ return !att.nil? && !att.empty? if att.is_a? String
431
+
432
+ !att.nil?
433
+ end
434
+
435
+ #-------------------------------------------------------------------
436
+ # Get backup information from the VM
437
+ #-------------------------------------------------------------------
438
+ def backup_info
439
+ base = '//USER_TEMPLATE/BACKUP'
440
+ binfo = {}
441
+
442
+ app_ids = self["#{base}/MARKETPLACE_APP_IDS"] || ''
443
+
444
+ binfo[:name] = "#{self['NAME']} - BACKUP " \
445
+ " - #{Time.now.strftime('%Y%m%d_%k%M')}"
446
+
447
+ binfo[:freq] = self["#{base}/FREQUENCY_SECONDS"]
448
+ binfo[:last] = self["#{base}/LAST_BACKUP_TIME"]
449
+ binfo[:market] = Integer(self["#{base}/MARKETPLACE_ID"])
450
+ binfo[:apps] = app_ids.split(',')
451
+
452
+ binfo
453
+ rescue StandardError
454
+ binfo
455
+ end
456
+
457
+ def backup_attr(binfo, ids)
458
+ 'BACKUP=[' \
459
+ " MARKETPLACE_APP_IDS = \"#{ids.join(',')}\"," \
460
+ " FREQUENCY_SECONDS = \"#{binfo[:freq]}\"," \
461
+ " LAST_BACKUP_TIME = \"#{Time.now.to_i}\"," \
462
+ " MARKETPLACE_ID = \"#{binfo[:market]}\" ]"
463
+ end
464
+
465
+ end
466
+ end
467
+
468
+ end
469
+ # rubocop:enable Style/ClassAndModuleChildren
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -450,10 +450,6 @@ module OpenNebula
450
450
  private
451
451
 
452
452
  def build_accounting(filter_flag, options, &block)
453
-
454
- options[:start_time] = -1 if options[:start_time].nil?
455
- options[:end_time] = -1 if options[:end_time].nil?
456
-
457
453
  xml_str = @client.call(VM_POOL_METHODS[:accounting],
458
454
  filter_flag,
459
455
  options[:start_time],
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -14,7 +14,7 @@
14
14
  # limitations under the License. #
15
15
  #--------------------------------------------------------------------------- #
16
16
 
17
-
17
+ require 'opennebula/lockable_ext'
18
18
  require 'opennebula/pool_element'
19
19
  require 'ipaddr'
20
20
 
@@ -62,6 +62,8 @@ module OpenNebula
62
62
 
63
63
  # Class constructor
64
64
  def initialize(xml, client)
65
+ LockableExt.make_lockable(self, VN_METHODS)
66
+
65
67
  super(xml,client)
66
68
  end
67
69
 
@@ -338,14 +340,6 @@ module OpenNebula
338
340
  return array
339
341
  end
340
342
 
341
- def lock(level)
342
- return call(VN_METHODS[:lock], @pe_id, level)
343
- end
344
-
345
- def unlock()
346
- return call(VN_METHODS[:unlock], @pe_id)
347
- end
348
-
349
343
  private
350
344
  def set_publish(published)
351
345
  group_u = published ? 1 : 0
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -14,7 +14,7 @@
14
14
  # limitations under the License. #
15
15
  #--------------------------------------------------------------------------- #
16
16
 
17
-
17
+ require 'opennebula/lockable_ext'
18
18
  require 'opennebula/pool_element'
19
19
 
20
20
  module OpenNebula
@@ -57,6 +57,8 @@ module OpenNebula
57
57
 
58
58
  # Class constructor
59
59
  def initialize(xml, client)
60
+ LockableExt.make_lockable(self, VIRTUAL_ROUTER_METHODS)
61
+
60
62
  super(xml,client)
61
63
 
62
64
  @client = client
@@ -177,16 +179,6 @@ module OpenNebula
177
179
  return call(VIRTUAL_ROUTER_METHODS[:detachnic], @pe_id, nic_id)
178
180
  end
179
181
 
180
- # Lock a VRouter
181
- def lock(level)
182
- return call(VIRTUAL_ROUTER_METHODS[:lock], @pe_id, level)
183
- end
184
-
185
- # Unlock a VRouter
186
- def unlock()
187
- return call(VIRTUAL_ROUTER_METHODS[:unlock], @pe_id)
188
- end
189
-
190
182
  #######################################################################
191
183
  # Helpers to get VirtualRouter information
192
184
  #######################################################################
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -14,6 +14,7 @@
14
14
  # limitations under the License. #
15
15
  #--------------------------------------------------------------------------- #
16
16
 
17
+ require 'opennebula/lockable_ext'
17
18
  require 'opennebula/pool_element'
18
19
 
19
20
  module OpenNebula
@@ -48,6 +49,8 @@ module OpenNebula
48
49
 
49
50
  # Class constructor
50
51
  def initialize(xml, client)
52
+ LockableExt.make_lockable(self, VMGROUP_METHODS)
53
+
51
54
  super(xml,client)
52
55
 
53
56
  @client = client
@@ -131,16 +134,6 @@ module OpenNebula
131
134
  return call(VMGROUP_METHODS[:rename], @pe_id, name)
132
135
  end
133
136
 
134
- # Lock a VMGroup
135
- def lock(level)
136
- return call(VMGROUP_METHODS[:lock], @pe_id, level)
137
- end
138
-
139
- # Unlock a VMGroup
140
- def unlock()
141
- return call(VMGROUP_METHODS[:unlock], @pe_id)
142
- end
143
-
144
137
  #######################################################################
145
138
  # Helpers to get VMGroup information
146
139
  #######################################################################
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -14,7 +14,7 @@
14
14
  # limitations under the License. #
15
15
  #--------------------------------------------------------------------------- #
16
16
 
17
-
17
+ require 'opennebula/lockable_ext'
18
18
  require 'opennebula/pool_element'
19
19
 
20
20
  module OpenNebula
@@ -23,7 +23,6 @@ module OpenNebula
23
23
  # Constants and Class Methods
24
24
  #######################################################################
25
25
 
26
-
27
26
  TEMPLATE_METHODS = {
28
27
  :allocate => "vntemplate.allocate",
29
28
  :instantiate => "vntemplate.instantiate",
@@ -57,6 +56,8 @@ module OpenNebula
57
56
 
58
57
  # Class constructor
59
58
  def initialize(xml, client)
59
+ LockableExt.make_lockable(self, TEMPLATE_METHODS)
60
+
60
61
  super(xml,client)
61
62
 
62
63
  @client = client
@@ -231,16 +232,6 @@ module OpenNebula
231
232
  self['UID'].to_i
232
233
  end
233
234
 
234
- # Lock a VNTemplate
235
- def lock(level)
236
- return call(TEMPLATE_METHODS[:lock], @pe_id, level)
237
- end
238
-
239
- # Unlock a VNTemplate
240
- def unlock()
241
- return call(TEMPLATE_METHODS[:unlock], @pe_id)
242
- end
243
-
244
235
  def public?
245
236
  if self['PERMISSIONS/GROUP_U'] == "1" || self['PERMISSIONS/OTHER_U'] == "1"
246
237
  true