opennebula 5.13.90.pre → 6.0.0

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
  SHA1:
3
- metadata.gz: f9a8c00c023d39dac1d3d0c866851beca57f8b4a
4
- data.tar.gz: e44c5056a014e41ba5f2f5f928d36d3bdfcafd15
3
+ metadata.gz: 6198250d78ce52345198a1d86230f430589cef5c
4
+ data.tar.gz: 3caf470ee5faab9e3c09576f79ad781db3653803
5
5
  SHA512:
6
- metadata.gz: 1efacac3e2a1dc06134672c69f3d563a89d2cdbbb810bd8289c0d7f5e7e7dbd7de1a247fe5976f36d9df796355160b0d1de3f9fb8013c0fe4c3e30116212ab96
7
- data.tar.gz: 08304bf5ee0386bbef56d81e6a65668010452130b259ced25a75fdc5693109d7fa667248cb3cec5157636d1c965425fb44dfa043bdadcf821f4f6d3d2f9d1fdb
6
+ metadata.gz: 4695c98d18bdd50b28c5f185e7bdb6e2bc1ef153562d5c690635af667a954edd78ab3073f014aa5c9059e755d9f1ab34859004bf88ffd6e99853a47acb5a0bc4
7
+ data.tar.gz: ada07168177c2121930a8f0707329f23a34cc91a28f2e3f45d0f24a926bd0682d188a7ba04b4b144c1d9ad1427ebe9b41cedf6a523e84e0eefc1f141966513fc
@@ -51,7 +51,7 @@ end
51
51
  module CloudClient
52
52
 
53
53
  # OpenNebula version
54
- VERSION = '5.13.90'
54
+ VERSION = '6.0.0'
55
55
 
56
56
  # #########################################################################
57
57
  # Default location for the authentication file
data/lib/datacenter.rb CHANGED
@@ -576,7 +576,6 @@ module VCenterDriver
576
576
  # Initialize opts hash used to inject data into one template
577
577
  opts = {}
578
578
 
579
- # if full_process
580
579
  # Add network type to network hash
581
580
  network_type = \
582
581
  VCenterDriver::Network.get_network_type(
@@ -585,7 +584,6 @@ module VCenterDriver
585
584
  )
586
585
  network[vc_network_ref][:network_type] = network_type
587
586
  network[vc_network_ref][:type] = network_type
588
- # end
589
587
 
590
588
  # Determine if the network must be excluded
591
589
  network[vc_network_ref][:excluded] = exclude_network?(
data/lib/network.rb CHANGED
@@ -486,7 +486,7 @@ module VCenterDriver
486
486
  @defaults = { :size => '255', :type => 'ether' }
487
487
  end
488
488
 
489
- def process_import(indexes, opts = {}, &block)
489
+ def process_import(indexes, opts = {}, &_block)
490
490
  indexes = indexes.gsub(/\s*\,\s*/, ',').strip.split(',')
491
491
 
492
492
  dc_folder = VCenterDriver::DatacenterFolder.new(@vi_client)
@@ -526,30 +526,21 @@ module VCenterDriver
526
526
  "#{hpool.message}"
527
527
  end
528
528
 
529
- opts = {}
530
-
531
529
  params = {}
532
530
  params[:vc_network] = vc_cluster_network
533
531
  params[:vcenter_instance_name] = vcenter_instance_name
534
532
  params[:vcenter_uuid] = vcenter_uuid
535
533
  params[:_hpool] = hpool
536
534
  params[:one_host] = one_host
537
- params[:args] = opts
535
+ params[:args] = {}
538
536
 
539
537
  selected = dc_folder.process_network(params)
540
538
 
541
539
  selected = selected[index]
542
540
 
543
- if block_given?
544
- @info[index][:opts] = block.call(selected)
545
- elsif opts[index]
546
- @info[index][:opts] = opts[index]
547
- else
548
- @info[index][:opts] = defaults
549
- end
550
-
551
541
  # import the object
552
- @info[:success] << import(selected)
542
+ opts[index] ||= @defaults
543
+ @info[:success] << import(selected, opts[index])
553
544
  rescue StandardError => e
554
545
  @info[:error] << { index => e.message }
555
546
  @info[index][:e] = e
@@ -645,8 +636,8 @@ module VCenterDriver
645
636
  str
646
637
  end
647
638
 
648
- def import(selected)
649
- opts = @info[selected[:ref]][:opts]
639
+ def import(selected, opts = nil)
640
+ opts = @info[selected[:ref]][:opts] if opts.nil?
650
641
 
651
642
  net = VCenterDriver::Network
652
643
  .new_from_ref(selected[:ref], @vi_client)
data/lib/opennebula.rb CHANGED
@@ -77,5 +77,5 @@ require 'opennebula/flow'
77
77
  module OpenNebula
78
78
 
79
79
  # OpenNebula version
80
- VERSION = '5.13.90'
80
+ VERSION = '6.0.0'
81
81
  end
@@ -155,6 +155,10 @@ module OpenNebula::MarketPlaceAppExt
155
155
  is_vcenter = !OpenNebula.is_error?(rc) &&
156
156
  (ds['TEMPLATE/DRIVER'] == 'vcenter')
157
157
 
158
+ if is_vcenter && options[:template].nil?
159
+ options = update_options_with_template(options)
160
+ end
161
+
158
162
  #---------------------------------------------------------------
159
163
  # Allocate the image in OpenNebula
160
164
  #---------------------------------------------------------------
@@ -181,15 +185,17 @@ module OpenNebula::MarketPlaceAppExt
181
185
  #---------------------------------------------------------------
182
186
  # Created an associated VMTemplate if needed
183
187
  #---------------------------------------------------------------
184
- if self['TEMPLATE/VMTEMPLATE64'].nil? || options[:notemplate]
188
+ if (self['TEMPLATE/VMTEMPLATE64'].nil? && !is_vcenter) ||
189
+ options[:notemplate] ||
190
+ options[:template] == -1
185
191
  return rc_info
186
192
  end
187
193
 
188
194
  if !options[:template].nil?
189
195
  template_id = options[:template]
190
196
 
191
- if template_id == -1
192
- template_id = options[:default_template]
197
+ if template_id < 0
198
+ raise 'Invalid option, template_id must be a valid ID'
193
199
  end
194
200
 
195
201
  template = Template.new_with_id(template_id, @client)
@@ -280,6 +286,33 @@ module OpenNebula::MarketPlaceAppExt
280
286
  rc
281
287
  end
282
288
 
289
+ def update_options_with_template(options, _validate = false)
290
+ vcenterrc_path =
291
+ "#{VAR_LOCATION}/remotes/etc/vmm/vcenter/vcenterrc"
292
+
293
+ if File.file?(vcenterrc_path)
294
+ config_vcenter = YAML.load_file(vcenterrc_path)
295
+
296
+ if config_vcenter.key?(:default_template)
297
+ options[:template] =
298
+ config_vcenter[:default_template]
299
+
300
+ options
301
+ else
302
+ raise "Couldn't find default_template " \
303
+ 'configuration in vcenterrc conf ' \
304
+ 'file. Please use the --template ' \
305
+ 'file to define a VM Template ID if ' \
306
+ 'needed or add default_template to' \
307
+ ' vcenterrc conf file'
308
+ end
309
+ else
310
+ raise "Couldn't find vcenterrc conf file. " \
311
+ ' Please use the --template file to define' \
312
+ ' a VM Template ID if needed.'
313
+ end
314
+ end
315
+
283
316
  # Creates a VM template based on the APPTEMPLATE64 attribute
284
317
  # @param [Hash] options
285
318
  # :export_name [String] name of the vm template
@@ -288,19 +321,50 @@ module OpenNebula::MarketPlaceAppExt
288
321
  #
289
322
  # @return [Integer, OpenNebula::Error] template id or error
290
323
  def create_vm_template(options, disks)
291
- # --------------------------------------------------------------
292
- # Allocate Template
293
- # --------------------------------------------------------------
294
- if self['TEMPLATE/APPTEMPLATE64'].nil?
295
- return Error.new("Missing APPTEMPLATE64 for App #{id}")
296
- end
324
+ dsid = options[:dsid]
325
+ ds = OpenNebula::Datastore.new_with_id(dsid, @client)
326
+ rc = ds.info
297
327
 
298
- tmpl = Base64.decode64(self['TEMPLATE/APPTEMPLATE64'])
328
+ is_vcenter =
329
+ !OpenNebula.is_error?(rc) &&
330
+ (ds['TEMPLATE/DRIVER'] == 'vcenter')
331
+
332
+ if is_vcenter
333
+ if options[:template].nil?
334
+ options = update_options_with_template(options)
335
+ end
336
+
337
+ template_id = options[:template]
338
+
339
+ if template_id < 0
340
+ return
341
+ end
342
+
343
+ template = Template.new_with_id(template_id, @client)
344
+
345
+ vmtpl_id = template.clone(
346
+ options[:vmtemplate_name] || options[:name]
347
+ )
348
+
349
+ vmtpl = Template.new_with_id(vmtpl_id, @client)
350
+ rc = vmtpl.info
351
+ else
352
+ # ----------------------------------------------------------
353
+ # Allocate Template
354
+ # ----------------------------------------------------------
355
+ if self['TEMPLATE/APPTEMPLATE64'].nil?
356
+ return Error.new(
357
+ "Missing APPTEMPLATE64 for App #{id}"
358
+ )
359
+ end
360
+
361
+ tmpl = Base64.decode64(self['TEMPLATE/APPTEMPLATE64'])
299
362
 
300
- tmpl << "\nNAME=\"#{options[:name]}\"\n"
363
+ tmpl << "\nNAME=\"#{options[:name]}\"\n"
301
364
 
302
- vmtpl = Template.new(Template.build_xml, @client)
303
- rc = vmtpl.allocate(tmpl)
365
+ vmtpl = Template.new(Template.build_xml, @client)
366
+ rc = vmtpl.allocate(tmpl)
367
+ end
304
368
 
305
369
  return rc if OpenNebula.is_error?(rc)
306
370
 
@@ -14,6 +14,8 @@
14
14
  # limitations under the License. #
15
15
  #--------------------------------------------------------------------------- #
16
16
 
17
+ require 'shellwords'
18
+
17
19
  module OpenNebula
18
20
 
19
21
  # Generic log function
@@ -76,6 +78,7 @@ module OpenNebula
76
78
  # If a second parameter is present it is used as the error message when
77
79
  # the command fails
78
80
  def self.exec_and_log(command, message=nil, allowed_return_code=0)
81
+ command = command.shellsplit.shelljoin # escape
79
82
  output=`#{command} 2>&1 1>/dev/null`
80
83
  code=$?.exitstatus
81
84
 
data/lib/vi_helper.rb CHANGED
@@ -231,10 +231,11 @@ module VCenterDriver
231
231
  @ref_hash[attribute][refkey]
232
232
  end
233
233
 
234
+ require 'addressable'
234
235
  def self.find_image_by(att, the_class, path, ds_id, pool = nil)
235
236
  pool = one_pool(the_class, false) if pool.nil?
236
237
  pool.find do |e|
237
- e[att] == path &&
238
+ e[att] == Addressable::URI.escape(path) &&
238
239
  e['DATASTORE_ID'] == ds_id
239
240
  end
240
241
  end
@@ -3032,7 +3032,7 @@ module VCenterDriver
3032
3032
  # Create a snapshot for the VM
3033
3033
  def create_snapshot(snap_id, snap_name)
3034
3034
  memory_dumps = true
3035
- memory_dumps = CONFIG[:memory_dumps] if CONFIG[:memory_dumps]
3035
+ memory_dumps = CONFIG[:memory_dumps] unless CONFIG[:memory_dumps].nil?
3036
3036
 
3037
3037
  snapshot_hash = {
3038
3038
  :name => snap_id,
data/lib/vm_template.rb CHANGED
@@ -1659,10 +1659,12 @@ module VCenterDriver
1659
1659
  folders = []
1660
1660
  until item.instance_of? RbVmomi::VIM::Datacenter
1661
1661
  item = item.parent
1662
- first_condition = item.instance_of? RbVmomi::VIM::Datacenter
1663
- second_condition = item.name != 'vm'
1662
+ first_condition =
1663
+ !(item.instance_of? RbVmomi::VIM::Datacenter)
1664
+ second_condition =
1665
+ item.name != 'vm'
1664
1666
 
1665
- unless first_condition && second_condition
1667
+ if first_condition && second_condition
1666
1668
  folders << item.name
1667
1669
  end
1668
1670
  if item.nil?
@@ -1693,8 +1695,8 @@ module VCenterDriver
1693
1695
  one_tmp[:dc_name] = dc_name
1694
1696
  one_tmp[:template_name] = template_name
1695
1697
  one_tmp[:sunstone_template_name]=
1696
- "#{template_name} [ Cluster: #{template_ccr_name} \
1697
- - Template location: #{location} ]"
1698
+ "#{template_name} [ Cluster: #{template_ccr_name}" \
1699
+ " - Template location: #{location} ]"
1698
1700
  one_tmp[:template_location] = location
1699
1701
  one_tmp[:vcenter_ccr_ref] = template_ccr_ref
1700
1702
  one_tmp[:vcenter_ref] = template_ref
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opennebula
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.13.90.pre
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenNebula
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-24 00:00:00.000000000 Z
11
+ date: 2021-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -255,9 +255,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
255
255
  version: '0'
256
256
  required_rubygems_version: !ruby/object:Gem::Requirement
257
257
  requirements:
258
- - - '>'
258
+ - - '>='
259
259
  - !ruby/object:Gem::Version
260
- version: 1.3.1
260
+ version: '0'
261
261
  requirements: []
262
262
  rubyforge_project:
263
263
  rubygems_version: 2.0.14.1