opennebula 6.10.3 → 6.99.85.pre

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.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cloud/CloudClient.rb +3 -3
  3. data/lib/models/role.rb +349 -823
  4. data/lib/models/service.rb +156 -80
  5. data/lib/models/vmrole.rb +703 -0
  6. data/lib/models/vrrole.rb +284 -0
  7. data/lib/models.rb +3 -1
  8. data/lib/opennebula/acl.rb +1 -1
  9. data/lib/opennebula/acl_pool.rb +1 -1
  10. data/lib/opennebula/backupjob.rb +1 -1
  11. data/lib/opennebula/backupjob_pool.rb +1 -1
  12. data/lib/opennebula/client.rb +1 -1
  13. data/lib/opennebula/cluster.rb +45 -2
  14. data/lib/opennebula/cluster_pool.rb +1 -1
  15. data/lib/opennebula/datastore.rb +1 -1
  16. data/lib/opennebula/datastore_pool.rb +1 -1
  17. data/lib/opennebula/document.rb +1 -1
  18. data/lib/opennebula/document_json.rb +1 -1
  19. data/lib/opennebula/document_pool.rb +1 -1
  20. data/lib/opennebula/document_pool_json.rb +1 -1
  21. data/lib/opennebula/error.rb +1 -1
  22. data/lib/opennebula/flow/grammar.rb +1 -1
  23. data/lib/opennebula/flow/service_pool.rb +1 -1
  24. data/lib/opennebula/flow/service_template.rb +353 -97
  25. data/lib/opennebula/flow/service_template_ext.rb +3 -3
  26. data/lib/opennebula/flow/service_template_pool.rb +1 -1
  27. data/lib/opennebula/flow/validator.rb +458 -410
  28. data/lib/opennebula/flow.rb +1 -1
  29. data/lib/opennebula/group.rb +1 -1
  30. data/lib/opennebula/group_pool.rb +1 -1
  31. data/lib/opennebula/hook.rb +1 -1
  32. data/lib/opennebula/hook_log.rb +1 -1
  33. data/lib/opennebula/hook_pool.rb +1 -1
  34. data/lib/opennebula/host.rb +1 -60
  35. data/lib/opennebula/host_pool.rb +1 -1
  36. data/lib/opennebula/image.rb +1 -1
  37. data/lib/opennebula/image_pool.rb +1 -1
  38. data/lib/opennebula/ldap_auth.rb +1 -1
  39. data/lib/opennebula/ldap_auth_spec.rb +1 -1
  40. data/lib/opennebula/lockable_ext.rb +1 -1
  41. data/lib/opennebula/marketplace.rb +1 -1
  42. data/lib/opennebula/marketplace_pool.rb +1 -1
  43. data/lib/opennebula/marketplaceapp.rb +1 -1
  44. data/lib/opennebula/marketplaceapp_ext.rb +14 -211
  45. data/lib/opennebula/marketplaceapp_pool.rb +1 -1
  46. data/lib/opennebula/oneflow_client.rb +11 -9
  47. data/lib/opennebula/pool.rb +1 -1
  48. data/lib/opennebula/pool_element.rb +1 -1
  49. data/lib/opennebula/security_group.rb +1 -1
  50. data/lib/opennebula/security_group_pool.rb +1 -1
  51. data/lib/opennebula/server_cipher_auth.rb +1 -1
  52. data/lib/opennebula/server_x509_auth.rb +1 -1
  53. data/lib/opennebula/ssh_auth.rb +1 -1
  54. data/lib/opennebula/system.rb +1 -1
  55. data/lib/opennebula/template.rb +1 -1
  56. data/lib/opennebula/template_ext.rb +1 -1
  57. data/lib/opennebula/template_pool.rb +1 -1
  58. data/lib/opennebula/user.rb +1 -1
  59. data/lib/opennebula/user_pool.rb +1 -1
  60. data/lib/opennebula/utils.rb +2 -2
  61. data/lib/opennebula/vdc.rb +1 -1
  62. data/lib/opennebula/vdc_pool.rb +1 -1
  63. data/lib/opennebula/virtual_machine.rb +3 -12
  64. data/lib/opennebula/virtual_machine_ext.rb +2 -31
  65. data/lib/opennebula/virtual_machine_pool.rb +1 -1
  66. data/lib/opennebula/virtual_network.rb +1 -1
  67. data/lib/opennebula/virtual_network_pool.rb +1 -1
  68. data/lib/opennebula/virtual_router.rb +1 -1
  69. data/lib/opennebula/virtual_router_pool.rb +1 -1
  70. data/lib/opennebula/vm_group.rb +1 -1
  71. data/lib/opennebula/vm_group_pool.rb +1 -1
  72. data/lib/opennebula/vntemplate.rb +1 -1
  73. data/lib/opennebula/vntemplate_pool.rb +1 -1
  74. data/lib/opennebula/wait_ext.rb +1 -1
  75. data/lib/opennebula/x509_auth.rb +1 -1
  76. data/lib/opennebula/xml_element.rb +2 -2
  77. data/lib/opennebula/xml_pool.rb +1 -1
  78. data/lib/opennebula/xml_utils.rb +1 -1
  79. data/lib/opennebula/zone.rb +1 -1
  80. data/lib/opennebula/zone_pool.rb +1 -1
  81. data/lib/opennebula.rb +2 -2
  82. metadata +6 -67
  83. data/lib/ActionManager.rb +0 -280
  84. data/lib/CommandManager.rb +0 -328
  85. data/lib/DriverExecHelper.rb +0 -213
  86. data/lib/HostSyncManager.rb +0 -111
  87. data/lib/OpenNebulaDriver.rb +0 -223
  88. data/lib/VirtualMachineDriver.rb +0 -404
  89. data/lib/datacenter.rb +0 -1319
  90. data/lib/datastore.rb +0 -1049
  91. data/lib/distributed_firewall.rb +0 -293
  92. data/lib/file_helper.rb +0 -374
  93. data/lib/host.rb +0 -1518
  94. data/lib/logical_port.rb +0 -50
  95. data/lib/logical_switch.rb +0 -77
  96. data/lib/memoize.rb +0 -74
  97. data/lib/network.rb +0 -705
  98. data/lib/nsx_client.rb +0 -157
  99. data/lib/nsx_component.rb +0 -28
  100. data/lib/nsx_constants.rb +0 -162
  101. data/lib/nsx_driver.rb +0 -91
  102. data/lib/nsx_error.rb +0 -77
  103. data/lib/nsx_rule.rb +0 -206
  104. data/lib/nsxt_client.rb +0 -189
  105. data/lib/nsxt_dfw.rb +0 -196
  106. data/lib/nsxt_logical_port.rb +0 -94
  107. data/lib/nsxt_rule.rb +0 -188
  108. data/lib/nsxt_tz.rb +0 -38
  109. data/lib/nsxv_client.rb +0 -189
  110. data/lib/nsxv_dfw.rb +0 -202
  111. data/lib/nsxv_logical_port.rb +0 -107
  112. data/lib/nsxv_rule.rb +0 -172
  113. data/lib/nsxv_tz.rb +0 -41
  114. data/lib/opaque_network.rb +0 -134
  115. data/lib/rest_client.rb +0 -191
  116. data/lib/scripts_common.rb +0 -176
  117. data/lib/transport_zone.rb +0 -43
  118. data/lib/vcenter_driver.rb +0 -152
  119. data/lib/vcenter_importer.rb +0 -626
  120. data/lib/vi_client.rb +0 -273
  121. data/lib/vi_helper.rb +0 -328
  122. data/lib/virtual_machine.rb +0 -3574
  123. data/lib/virtual_wire.rb +0 -158
  124. data/lib/vm_device.rb +0 -80
  125. data/lib/vm_disk.rb +0 -202
  126. data/lib/vm_folder.rb +0 -69
  127. data/lib/vm_helper.rb +0 -30
  128. data/lib/vm_monitor.rb +0 -305
  129. data/lib/vm_nic.rb +0 -70
  130. data/lib/vm_template.rb +0 -2112
  131. data/lib/vmm_importer.rb +0 -165
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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 #
@@ -213,60 +213,6 @@ module OpenNebula
213
213
  return call(HOST_METHODS[:rename], @pe_id, name)
214
214
  end
215
215
 
216
- # Imports a wild VM from the host and puts it in running state
217
- #
218
- # @param name [String] Name of the VM to import
219
- # @param ipv4 [Array] Array with IP4s to set
220
- # @param ipv6 [Array] Array with IP6s to set
221
- #
222
- # @return [nil, OpenNebula::Error] nil in case of success, Error
223
- # otherwise
224
- def import_wild(name, ipv4 = nil, ipv6 = nil)
225
- vms = importable_wilds.select {|vm| vm['VM_NAME'] == name }
226
-
227
- if vms.length == 0
228
- return OpenNebula::Error.new("No importable wilds with name " <<
229
- "'#{name}' found.")
230
- elsif vms.length > 1
231
- return OpenNebula::Error.new("More than one importable wild " <<
232
- "with name '#{name}' found.")
233
- end
234
-
235
- wild = vms.first
236
-
237
- template = Base64.decode64(wild['IMPORT_TEMPLATE'])
238
-
239
- xml = OpenNebula::VirtualMachine.build_xml
240
- vm = OpenNebula::VirtualMachine.new(xml, @client)
241
-
242
- # vCenter wild VMs has a different process
243
- # image and vnets objects representing existing nics and disks
244
- # must be created and referenced
245
- vcenter_wild_vm = wild.key? "VCENTER_TEMPLATE"
246
- if vcenter_wild_vm
247
- require 'vcenter_driver'
248
- vi_client = VCenterDriver::VIClient.new_from_host(self["ID"])
249
- importer = VCenterDriver::VmmImporter.new(@client, vi_client)
250
-
251
- return importer.import(
252
- { :wild => wild,
253
- :template => template,
254
- :one_item => vm,
255
- :host => self['ID'],
256
- :ipv4 => ipv4,
257
- :ipv6 => ipv6
258
- }
259
- )
260
- else
261
- rc = vm.allocate(template)
262
-
263
- return rc if OpenNebula.is_error?(rc)
264
-
265
- vm.deploy(id, false)
266
- return vm.id
267
- end
268
- end
269
-
270
216
  #######################################################################
271
217
  # Helpers to get Host information
272
218
  #######################################################################
@@ -297,11 +243,6 @@ module OpenNebula
297
243
  [self.to_hash['HOST']['TEMPLATE']['VM']].flatten.compact
298
244
  end
299
245
 
300
- # Get importable wild VMs in the host
301
- def importable_wilds
302
- wilds.select {|w| Hash === w && w['IMPORT_TEMPLATE'] }
303
- end
304
-
305
246
  private
306
247
  def set_status(status)
307
248
  return Error.new('ID not defined') if !@pe_id
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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 #
@@ -97,7 +97,7 @@ module OpenNebula::MarketPlaceAppExt
97
97
  # :f_dsid [String] Files Datastore id
98
98
  # :notemplate [Bool] if true do not create vm_template (if any)
99
99
  # :template [Integer] Template id to use with image
100
- # :default_template [String] Default template id for vCenter
100
+ # :default_template [String] Default template id
101
101
  # @return [Hash]
102
102
  # :image [Array] of the new image
103
103
  # :image_type [String] of the new image (CONTEXT, KERNEL, CDROM)
@@ -144,16 +144,6 @@ module OpenNebula::MarketPlaceAppExt
144
144
  end
145
145
  end
146
146
 
147
- ds = OpenNebula::Datastore.new_with_id(dsid, @client)
148
- rc = ds.info
149
-
150
- is_vcenter = !OpenNebula.is_error?(rc) &&
151
- (ds['TEMPLATE/DRIVER'] == 'vcenter')
152
-
153
- if is_vcenter && options[:template].nil?
154
- options = update_options_with_template(options)
155
- end
156
-
157
147
  #---------------------------------------------------------------
158
148
  # Allocate the image in OpenNebula
159
149
  #---------------------------------------------------------------
@@ -170,35 +160,12 @@ module OpenNebula::MarketPlaceAppExt
170
160
 
171
161
  image.delete_element('TEMPLATE/FORMAT')
172
162
  image.delete_element('TEMPLATE/DRIVER')
173
- image.delete_element('TEMPLATE/DEV_PREFIX') if is_vcenter
174
163
 
175
164
  image.update(image.template_xml)
176
165
 
177
166
  rc_info[:image] = [image.id]
178
167
  rc_info[:image_type] = image.type_str
179
168
 
180
- #---------------------------------------------------------------
181
- # Created an associated VMTemplate if needed
182
- #---------------------------------------------------------------
183
- if is_vcenter &&
184
- !options[:notemplate] &&
185
- (!options[:template] || options[:template] == -1)
186
- tmpl = create_vcenter_template(
187
- ds,
188
- options,
189
- self['TEMPLATE/VMTEMPLATE64'],
190
- image
191
- )
192
-
193
- if OpenNebula.is_error?(tmpl)
194
- rc_info[:vmtemplate] = [tmpl]
195
- else
196
- rc_info[:vmtemplate] = [tmpl.id]
197
- end
198
-
199
- return rc_info
200
- end
201
-
202
169
  if self['TEMPLATE/VMTEMPLATE64'].nil? ||
203
170
  options[:notemplate] ||
204
171
  options[:template] == -1
@@ -300,139 +267,6 @@ module OpenNebula::MarketPlaceAppExt
300
267
  rc
301
268
  end
302
269
 
303
- # Create a VM template in vCenter in order to use it when
304
- # deploying an app from the marketplace
305
- #
306
- # @param ds [OpenNebula::Datastore] Datastore information
307
- # @param options [Hash] Export options
308
- # @param template [String] App template
309
- # @param image [OpenNebula::Image] Image information
310
- def create_vcenter_template(ds, options, template, image = nil)
311
- ret = {}
312
- keys = ['VCENTER_TEMPLATE_REF',
313
- 'VCENTER_CCR_REF',
314
- 'VCENTER_INSTANCE_ID']
315
-
316
- if ds['//VCENTER_TEMPLATE_REF']
317
- keys.each do |key|
318
- ret[key] = ds["//#{key}"]
319
- end
320
- else
321
- require 'vcenter_driver'
322
-
323
- # Get vi client for current datastore
324
- vi_client = VCenterDriver::VIClient.new_from_datastore(
325
- ds.id
326
- )
327
-
328
- # Get datastore object
329
- ds_ref = ds['//VCENTER_DS_REF']
330
- datastore = VCenterDriver::Datastore.new_from_ref(
331
- ds_ref,
332
- vi_client
333
- )
334
-
335
- # Get resource pool
336
- host_ref = datastore['host'].first.key.parent._ref
337
- vi_client.ccr_ref = host_ref
338
-
339
- host = VCenterDriver::ClusterComputeResource.new_from_ref(
340
- host_ref,
341
- vi_client
342
- )
343
-
344
- rp = host.resource_pools.first
345
-
346
- # Get vCentrer instance ID
347
- uuid = vi_client.vim.serviceContent.about.instanceUuid
348
-
349
- # Create VM folder it not exists
350
- dc = datastore.obtain_dc.item
351
- vm_folder = dc.find_folder('one_default_template')
352
-
353
- if vm_folder.nil?
354
- dc.vmFolder.CreateFolder(
355
- :name => 'one_default_template'
356
- )
357
- vm_folder = dc.find_folder('one_default_template')
358
- end
359
-
360
- # Define default VM config
361
- vm_cfg = { :name => "one_app_template-#{ds.id}",
362
- :guestId => 'otherGuest',
363
- :numCPUs => 1,
364
- :memoryMB => 128,
365
- :files => {
366
- :vmPathName => "[#{datastore.item.name}]"
367
- } }
368
-
369
- # Create the VM
370
- vm = vm_folder.CreateVM_Task(
371
- :config => vm_cfg,
372
- :pool => rp
373
- ).wait_for_completion
374
-
375
- # Create the VM template
376
- vm.MarkAsTemplate
377
-
378
- ret['VCENTER_TEMPLATE_REF'] = vm._ref
379
- ret['VCENTER_CCR_REF'] = host_ref
380
- ret['VCENTER_INSTANCE_ID'] = uuid
381
-
382
- ret.each do |key, value|
383
- ds.update("#{key}=\"#{value}\"", true)
384
- end
385
- end
386
-
387
- tmpl = <<-EOT
388
- NAME = "#{options[:vmtemplate_name] || options[:name]}"
389
- HYPERVISOR = "vcenter"
390
- EOT
391
-
392
- tmpl << "DISK = [ IMAGE_ID = \"#{image.id}\" ]" if image
393
-
394
- template ||= ''
395
- template = Base64.decode64(template)
396
-
397
- template.split("\n").each do |line|
398
- # Legacy, some apps in the marketplace have the sched
399
- # requirement to just be run on KVM, with this
400
- # the template cannot be run on vCenter, so don't add
401
- # it in the final VM template
402
- next if line =~ /SCHED_REQUIREMENTS/ || line.empty?
403
-
404
- tmpl << "#{line}\n"
405
- end
406
-
407
- ret.each do |key, value|
408
- tmpl << "#{key}=\"#{value}\"\n"
409
- end
410
-
411
- vmtpl = Template.new(Template.build_xml, @client)
412
-
413
- rc = vmtpl.allocate(tmpl)
414
-
415
- if OpenNebula.is_error?(rc)
416
- rc
417
- else
418
- Template.new_with_id(vmtpl.id, @client)
419
- end
420
- end
421
-
422
- def update_options_with_template(options)
423
- path = "#{VAR_LOCATION}/remotes/etc/vmm/vcenter/vcenterrc"
424
-
425
- return options unless File.file?(path)
426
-
427
- config = YAML.load_file(path)
428
-
429
- return options unless config.key?(:default_template)
430
-
431
- options[:template] = config[:default_template]
432
-
433
- options
434
- end
435
-
436
270
  # Creates a VM template based on the APPTEMPLATE64 attribute
437
271
  # @param [Hash] options
438
272
  # :export_name [String] name of the vm template
@@ -441,52 +275,21 @@ module OpenNebula::MarketPlaceAppExt
441
275
  #
442
276
  # @return [Integer, OpenNebula::Error] template id or error
443
277
  def create_vm_template(options, disks)
444
- dsid = options[:dsid]
445
- ds = OpenNebula::Datastore.new_with_id(dsid, @client)
446
- rc = ds.info
447
-
448
- is_vcenter = !OpenNebula.is_error?(rc) && ds['TEMPLATE/DRIVER'] == 'vcenter'
449
-
450
- if is_vcenter
451
- if options[:template].nil?
452
- options = update_options_with_template(options)
453
- end
454
-
455
- if !options[:template] || options[:template] == -1
456
- vmtpl = create_vcenter_template(
457
- ds,
458
- options,
459
- self['TEMPLATE/VMTEMPLATE64']
460
- )
461
- else
462
- template_id = options[:template]
463
- template = Template.new_with_id(template_id, @client)
464
-
465
- vmtpl_id = template.clone(
466
- options[:vmtemplate_name] || options[:name]
467
- )
468
-
469
- vmtpl = Template.new_with_id(vmtpl_id, @client)
470
- end
471
-
472
- rc = vmtpl.info
473
- else
474
- # ----------------------------------------------------------
475
- # Allocate Template
476
- # ----------------------------------------------------------
477
- if self['TEMPLATE/APPTEMPLATE64'].nil?
478
- return Error.new(
479
- "Missing APPTEMPLATE64 for App #{id}"
480
- )
481
- end
278
+ # ----------------------------------------------------------
279
+ # Allocate Template
280
+ # ----------------------------------------------------------
281
+ if self['TEMPLATE/APPTEMPLATE64'].nil?
282
+ return Error.new(
283
+ "Missing APPTEMPLATE64 for App #{id}"
284
+ )
285
+ end
482
286
 
483
- tmpl = Base64.decode64(self['TEMPLATE/APPTEMPLATE64'])
287
+ tmpl = Base64.decode64(self['TEMPLATE/APPTEMPLATE64'])
484
288
 
485
- tmpl << "\nNAME=\"#{options[:name]}\"\n"
289
+ tmpl << "\nNAME=\"#{options[:name]}\"\n"
486
290
 
487
- vmtpl = Template.new(Template.build_xml, @client)
488
- rc = vmtpl.allocate(tmpl)
489
- end
291
+ vmtpl = Template.new(Template.build_xml, @client)
292
+ rc = vmtpl.allocate(tmpl)
490
293
 
491
294
  return rc if OpenNebula.is_error?(rc)
492
295
 
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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 #
@@ -344,6 +344,9 @@ module Service
344
344
  @username = opts[:username] || ENV['ONEFLOW_USER']
345
345
  @password = opts[:password] || ENV['ONEFLOW_PASSWORD']
346
346
 
347
+ # By default oneflow uses JSON as content type
348
+ @content_type = opts[:content_type] || 'application/json'
349
+
347
350
  if opts[:url]
348
351
  url = opts[:url]
349
352
  elsif ENV['ONEFLOW_URL']
@@ -408,10 +411,6 @@ module Service
408
411
  @port = uri_proxy.port
409
412
  end
410
413
 
411
- def set_content_type(content_type)
412
- @content_type = content_type
413
- end
414
-
415
414
  def get(path)
416
415
  req = Net::HTTP::Proxy(@host, @port)::Get.new(path)
417
416
 
@@ -420,7 +419,11 @@ module Service
420
419
 
421
420
  def delete(path, body = nil)
422
421
  req = Net::HTTP::Proxy(@host, @port)::Delete.new(path)
423
- req.body = body if body
422
+
423
+ if body
424
+ req.body = body
425
+ req.content_type = @content_type
426
+ end
424
427
 
425
428
  do_request(req)
426
429
  end
@@ -428,16 +431,15 @@ module Service
428
431
  def post(path, body)
429
432
  req = Net::HTTP::Proxy(@host, @port)::Post.new(path)
430
433
  req.body = body
434
+ req.content_type = @content_type
431
435
 
432
- if path.start_with?('/service_template') && !@content_type.nil?
433
- req.content_type = @content_type
434
- end
435
436
  do_request(req)
436
437
  end
437
438
 
438
439
  def put(path, body)
439
440
  req = Net::HTTP::Proxy(@host, @port)::Put.new(path)
440
441
  req.body = body
442
+ req.content_type = @content_type
441
443
 
442
444
  do_request(req)
443
445
  end
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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-2024, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2025, 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 #