opennebula 6.0.0.1 → 6.0.0.2

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: 6f9aa7355cf72de3df70da8d7fceb82907f97396
4
- data.tar.gz: 749eef5d47ae22112fb3c8c1a1dc1d7f313ab5a7
3
+ metadata.gz: f022212cfa3668cae363f0592a9423a77f3f0a63
4
+ data.tar.gz: f1aa5e2a2d9c2f7d06f8c63defc79b004fdd21a8
5
5
  SHA512:
6
- metadata.gz: ba3c4cfcf52af7756cdc67ccefb827e773bf60c5b38a2b8ba32e1dc232582edbb57e1e45994168052e0cc572f14b9d70c4504cb7ea82796122df5f6564609d56
7
- data.tar.gz: 40ecec9f0e8f2cd10ea50241e97a0554eb6e14204feaf0780879990373415d5eaaceea254efb7cb09b112ffb464ebc7324a17fb980d6306edfef92816c29a745
6
+ metadata.gz: eb414c6b219cdbcd4217d69219ba161273a1e7ba802fd4c94936a83aba776d2f781661fa684372e77c86fd18d707823cc7f172bc23f2b794dcbb8984cab63b93
7
+ data.tar.gz: 9d6c490f638e47dcb1f4aa558853806a92b835a9c0217a1bb2a6c84207bd375b4406e13702a4423d733ee4f8294d796a50ecd40045a2f5ca66c046d8eb1a2ede
@@ -51,7 +51,7 @@ end
51
51
  module CloudClient
52
52
 
53
53
  # OpenNebula version
54
- VERSION = '6.0.0.1'
54
+ VERSION = '6.0.0.2'
55
55
 
56
56
  # #########################################################################
57
57
  # Default location for the authentication file
data/lib/datacenter.rb CHANGED
@@ -500,7 +500,7 @@ module VCenterDriver
500
500
  end
501
501
 
502
502
  # Determine if a network must be excluded from the list
503
- def exclude_network?(vc_network, one_host, args, vc_network_hash)
503
+ def exclude_network?(one_host, args, vc_network_hash, network_type)
504
504
  vc_network_name = vc_network_hash[:vc_network_name]
505
505
  vc_network_host = vc_network_hash[:vc_network_host]
506
506
  vc_network_tag = vc_network_hash[:vc_network_tag]
@@ -514,12 +514,6 @@ module VCenterDriver
514
514
  ]
515
515
 
516
516
  # Only NSX-V and NSX-T can be excluded
517
- network_type = VCenterDriver::Network
518
- .get_network_type(
519
- vc_network,
520
- vc_network_name
521
- )
522
-
523
517
  return true if network_types.include? network_type
524
518
  end
525
519
  # Exclude networks without hosts
@@ -533,7 +527,7 @@ module VCenterDriver
533
527
  return true
534
528
  end
535
529
  # Exclude portgroup used for VXLAN communication in NSX
536
- if vc_network['name'].match(/^vxw-vmknicPg-dvs-(.*)/)
530
+ if vc_network_name.match(/^vxw-vmknicPg-dvs-(.*)/)
537
531
  return true
538
532
  end
539
533
 
@@ -543,7 +537,7 @@ module VCenterDriver
543
537
  end
544
538
 
545
539
  # Proccess each network
546
- def process_network(params)
540
+ def process_network(params, networks_type, hosts_list, host_list_object)
547
541
  vc_network = params[:vc_network]
548
542
  vcenter_instance_name = params[:vcenter_instance_name]
549
543
  vcenter_uuid = params[:vcenter_uuid]
@@ -577,23 +571,31 @@ module VCenterDriver
577
571
  opts = {}
578
572
 
579
573
  # Add network type to network hash
580
- network_type = \
581
- VCenterDriver::Network.get_network_type(
582
- vc_network,
583
- vc_network_name
584
- )
574
+ if networks_type.key?(vc_network_hash[:vc_network_ref])
575
+ network_type = networks_type[vc_network_hash[:vc_network_ref]]
576
+ else
577
+ network_type =
578
+ VCenterDriver::Network.get_network_type(
579
+ vc_network,
580
+ vc_network_name
581
+ )
582
+ networks_type[vc_network_hash[:vc_network_ref]] = network_type
583
+ end
584
+
585
585
  network[vc_network_ref][:network_type] = network_type
586
586
  network[vc_network_ref][:type] = network_type
587
587
 
588
588
  # Determine if the network must be excluded
589
589
  network[vc_network_ref][:excluded] = exclude_network?(
590
- vc_network,
591
590
  one_host,
592
591
  args,
593
- vc_network_hash
592
+ vc_network_hash,
593
+ network_type
594
594
  )
595
595
 
596
- return if network[vc_network_ref][:excluded] == true
596
+ if network[vc_network_ref][:excluded] == true
597
+ return [nil, networks_type, hosts_list, host_list_object]
598
+ end
597
599
 
598
600
  if full_process
599
601
  case network[vc_network_ref][:network_type]
@@ -651,31 +653,50 @@ module VCenterDriver
651
653
  vc_hosts = vc_network.host
652
654
  vc_hosts.each do |vc_host|
653
655
  # Get vCenter Cluster
654
- vc_cluster = vc_host.parent
655
- vc_cluster_ref = vc_cluster._ref
656
- vc_cluster_name = vc_cluster.name
657
- # Get one host from each vCenter cluster
658
- one_host = VCenterDriver::VIHelper
659
- .find_by_ref(OpenNebula::HostPool,
660
- 'TEMPLATE/VCENTER_CCR_REF',
661
- vc_cluster_ref,
662
- vcenter_uuid)
656
+ vc_host_ref = vc_host._ref
657
+ if !host_list_object.key?(vc_host_ref)
658
+ vc_cluster = vc_host.parent
659
+ vc_cluster_ref = vc_cluster._ref
660
+ vc_cluster_name = vc_cluster.name
661
+ host_list_object[vc_host_ref] = {
662
+ :vc_cluster_ref => vc_cluster_ref,
663
+ :vc_cluster_name => vc_cluster_name
664
+ }
665
+ end
666
+
667
+ vc_cluster = host_list_object[vc_host_ref]
668
+
669
+ if hosts_list.key? vc_cluster[:vc_cluster_ref]
670
+ one_host = hosts_list[vc_cluster[:vc_cluster_ref]]
671
+ else
672
+ one_host = VCenterDriver::VIHelper
673
+ .find_by_ref(OpenNebula::HostPool,
674
+ 'TEMPLATE/VCENTER_CCR_REF',
675
+ vc_cluster[:vc_cluster_ref],
676
+ vcenter_uuid)
677
+ hosts_list[vc_cluster[:vc_cluster_ref]] = one_host
678
+ end
663
679
  # Check if network is excluded from each host
664
680
  next if exclude_network?(
665
- vc_network,
666
681
  one_host,
667
682
  args,
668
- vc_network_hash
683
+ vc_network_hash,
684
+ network_type
669
685
  )
670
686
 
671
687
  # Insert vCenter cluster ref
672
- network[vc_network_ref][:clusters][:refs] << vc_cluster_ref
688
+ network[vc_network_ref][:clusters][:refs] <<
689
+ vc_cluster[:vc_cluster_ref]
690
+
673
691
  # Insert OpenNebula cluster id
674
692
  cluster_id = one_cluster_id(one_host)
675
- network[vc_network_ref][:clusters][:one_ids] << cluster_id
693
+ network[vc_network_ref][:clusters][:one_ids] <<
694
+ cluster_id
695
+
676
696
  # Insert vCenter cluster name
677
- network[vc_network_ref][:clusters][:names] << vc_cluster_name
678
- opts[:dc_name] = vc_cluster_name
697
+ network[vc_network_ref][:clusters][:names] <<
698
+ vc_cluster[:vc_cluster_name]
699
+ opts[:dc_name] = vc_cluster[:vc_cluster_name]
679
700
  end
680
701
 
681
702
  # Remove duplicate entries
@@ -706,7 +727,7 @@ module VCenterDriver
706
727
  network[vc_network_ref]['name']
707
728
  end
708
729
 
709
- network
730
+ [network, networks_type, hosts_list, host_list_object]
710
731
  end
711
732
 
712
733
  # rubocop:disable Style/GlobalVars
@@ -723,13 +744,15 @@ module VCenterDriver
723
744
  $conf[:one_xmlrpc]
724
745
  )
725
746
  end
726
-
727
747
  one_host = OpenNebula::Host.new_with_id(args[:host], one_client)
728
748
  rc = one_host.info
729
749
  raise rc.message if OpenNebula.is_error? rc
730
750
 
731
751
  # Get all networks in vcenter cluster (one_host)
732
752
  vc_cluster_networks = cluster_networks(one_host)
753
+ networks_type = {}
754
+ hosts_list = {}
755
+ host_list_object = {}
733
756
 
734
757
  # Iterate over vcenter networks
735
758
  vc_cluster_networks.each do |vc_cluster_network|
@@ -751,7 +774,20 @@ module VCenterDriver
751
774
  params[:one_host]= one_host
752
775
  params[:args] = args
753
776
 
754
- network = process_network(params)
777
+ network,
778
+ networks_type_new,
779
+ hosts_list_new,
780
+ host_list_object_new =
781
+ process_network(
782
+ params,
783
+ networks_type,
784
+ hosts_list,
785
+ host_list_object
786
+ )
787
+
788
+ networks_type = networks_type_new
789
+ hosts_list = hosts_list_new
790
+ host_list_object = host_list_object_new
755
791
 
756
792
  networks.merge!(network) unless network.nil?
757
793
  end
@@ -29,14 +29,27 @@ module NSXDriver
29
29
  unless defined?(GEMS_LOCATION)
30
30
  end
31
31
 
32
- if File.directory?(GEMS_LOCATION)
33
- real_gems_path = File.realpath(GEMS_LOCATION)
34
- if !defined?(Gem) || Gem.path != [real_gems_path]
35
- $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
32
+ # rubocop: disable all
33
+ # %%RUBYGEMS_SETUP_BEGIN%%
34
+ if File.directory?(GEMS_LOCATION)
35
+ real_gems_path = File.realpath(GEMS_LOCATION)
36
+ if !defined?(Gem) || Gem.path != [real_gems_path]
37
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
38
+
39
+ # Suppress warnings from Rubygems
40
+ # https://github.com/OpenNebula/one/issues/5379
41
+ begin
42
+ verb = $VERBOSE
43
+ $VERBOSE = nil
36
44
  require 'rubygems'
37
45
  Gem.use_paths(real_gems_path)
46
+ ensure
47
+ $VERBOSE = verb
38
48
  end
39
49
  end
50
+ end
51
+ # %%RUBYGEMS_SETUP_END%%
52
+ # rubocop: enable all
40
53
 
41
54
  $LOAD_PATH << RUBY_LIB_LOCATION
42
55
 
data/lib/network.rb CHANGED
@@ -534,7 +534,13 @@ module VCenterDriver
534
534
  params[:one_host] = one_host
535
535
  params[:args] = {}
536
536
 
537
- selected = dc_folder.process_network(params)
537
+ selected, _networks_type, _hosts_list, _clusters_list =
538
+ dc_folder.process_network(
539
+ params,
540
+ {},
541
+ {},
542
+ {}
543
+ )
538
544
 
539
545
  selected = selected[index]
540
546
 
data/lib/nsx_client.rb CHANGED
@@ -29,14 +29,27 @@ module NSXDriver
29
29
  unless defined?(GEMS_LOCATION)
30
30
  end
31
31
 
32
- if File.directory?(GEMS_LOCATION)
33
- real_gems_path = File.realpath(GEMS_LOCATION)
34
- if !defined?(Gem) || Gem.path != [real_gems_path]
35
- $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
32
+ # rubocop: disable all
33
+ # %%RUBYGEMS_SETUP_BEGIN%%
34
+ if File.directory?(GEMS_LOCATION)
35
+ real_gems_path = File.realpath(GEMS_LOCATION)
36
+ if !defined?(Gem) || Gem.path != [real_gems_path]
37
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
38
+
39
+ # Suppress warnings from Rubygems
40
+ # https://github.com/OpenNebula/one/issues/5379
41
+ begin
42
+ verb = $VERBOSE
43
+ $VERBOSE = nil
36
44
  require 'rubygems'
37
45
  Gem.use_paths(real_gems_path)
46
+ ensure
47
+ $VERBOSE = verb
38
48
  end
39
49
  end
50
+ end
51
+ # %%RUBYGEMS_SETUP_END%%
52
+ # rubocop: enable all
40
53
 
41
54
  $LOAD_PATH << RUBY_LIB_LOCATION
42
55
 
data/lib/nsx_constants.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  # a copy of the License at #
7
7
  # #
8
8
  # http://www.apache.org/licenses/LICENSE-2.0 #
9
- # #
9
+ # #
10
10
  # Unless required by applicable law or agreed to in writing, software #
11
11
  # distributed under the License is distributed on an "AS IS" BASIS, #
12
12
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
@@ -29,14 +29,27 @@ module NSXDriver
29
29
  unless defined?(GEMS_LOCATION)
30
30
  end
31
31
 
32
- if File.directory?(GEMS_LOCATION)
33
- real_gems_path = File.realpath(GEMS_LOCATION)
34
- if !defined?(Gem) || Gem.path != [real_gems_path]
35
- $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
32
+ # rubocop: disable all
33
+ # %%RUBYGEMS_SETUP_BEGIN%%
34
+ if File.directory?(GEMS_LOCATION)
35
+ real_gems_path = File.realpath(GEMS_LOCATION)
36
+ if !defined?(Gem) || Gem.path != [real_gems_path]
37
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
38
+
39
+ # Suppress warnings from Rubygems
40
+ # https://github.com/OpenNebula/one/issues/5379
41
+ begin
42
+ verb = $VERBOSE
43
+ $VERBOSE = nil
36
44
  require 'rubygems'
37
45
  Gem.use_paths(real_gems_path)
46
+ ensure
47
+ $VERBOSE = verb
38
48
  end
39
49
  end
50
+ end
51
+ # %%RUBYGEMS_SETUP_END%%
52
+ # rubocop: enable all
40
53
 
41
54
  $LOAD_PATH << RUBY_LIB_LOCATION
42
55
 
data/lib/nsx_driver.rb CHANGED
@@ -36,14 +36,27 @@ end
36
36
 
37
37
  ENV['LANG'] = 'C'
38
38
 
39
+ # rubocop: disable all
40
+ # %%RUBYGEMS_SETUP_BEGIN%%
39
41
  if File.directory?(GEMS_LOCATION)
40
42
  real_gems_path = File.realpath(GEMS_LOCATION)
41
43
  if !defined?(Gem) || Gem.path != [real_gems_path]
42
44
  $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
43
- require 'rubygems'
44
- Gem.use_paths(real_gems_path)
45
+
46
+ # Suppress warnings from Rubygems
47
+ # https://github.com/OpenNebula/one/issues/5379
48
+ begin
49
+ verb = $VERBOSE
50
+ $VERBOSE = nil
51
+ require 'rubygems'
52
+ Gem.use_paths(real_gems_path)
53
+ ensure
54
+ $VERBOSE = verb
55
+ end
45
56
  end
46
57
  end
58
+ # %%RUBYGEMS_SETUP_END%%
59
+ # rubocop: enable all
47
60
 
48
61
  $LOAD_PATH << LIB_LOCATION + '/ruby'
49
62
  $LOAD_PATH << LIB_LOCATION + '/ruby/nsx_driver'
data/lib/nsx_rule.rb CHANGED
@@ -33,14 +33,27 @@ module NSXDriver
33
33
  unless defined?(GEMS_LOCATION)
34
34
  end
35
35
 
36
- if File.directory?(GEMS_LOCATION)
37
- real_gems_path = File.realpath(GEMS_LOCATION)
38
- if !defined?(Gem) || Gem.path != [real_gems_path]
39
- $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
36
+ # rubocop: disable all
37
+ # %%RUBYGEMS_SETUP_BEGIN%%
38
+ if File.directory?(GEMS_LOCATION)
39
+ real_gems_path = File.realpath(GEMS_LOCATION)
40
+ if !defined?(Gem) || Gem.path != [real_gems_path]
41
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
42
+
43
+ # Suppress warnings from Rubygems
44
+ # https://github.com/OpenNebula/one/issues/5379
45
+ begin
46
+ verb = $VERBOSE
47
+ $VERBOSE = nil
40
48
  require 'rubygems'
41
49
  Gem.use_paths(real_gems_path)
50
+ ensure
51
+ $VERBOSE = verb
42
52
  end
43
53
  end
54
+ end
55
+ # %%RUBYGEMS_SETUP_END%%
56
+ # rubocop: enable all
44
57
 
45
58
  $LOAD_PATH << RUBY_LIB_LOCATION
46
59
 
data/lib/nsxt_client.rb CHANGED
@@ -29,14 +29,27 @@ module NSXDriver
29
29
  unless defined?(GEMS_LOCATION)
30
30
  end
31
31
 
32
- if File.directory?(GEMS_LOCATION)
33
- real_gems_path = File.realpath(GEMS_LOCATION)
34
- if !defined?(Gem) || Gem.path != [real_gems_path]
35
- $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
32
+ # rubocop: disable all
33
+ # %%RUBYGEMS_SETUP_BEGIN%%
34
+ if File.directory?(GEMS_LOCATION)
35
+ real_gems_path = File.realpath(GEMS_LOCATION)
36
+ if !defined?(Gem) || Gem.path != [real_gems_path]
37
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
38
+
39
+ # Suppress warnings from Rubygems
40
+ # https://github.com/OpenNebula/one/issues/5379
41
+ begin
42
+ verb = $VERBOSE
43
+ $VERBOSE = nil
36
44
  require 'rubygems'
37
45
  Gem.use_paths(real_gems_path)
46
+ ensure
47
+ $VERBOSE = verb
38
48
  end
39
49
  end
50
+ end
51
+ # %%RUBYGEMS_SETUP_END%%
52
+ # rubocop: enable all
40
53
 
41
54
  $LOAD_PATH << RUBY_LIB_LOCATION
42
55
 
data/lib/nsxv_client.rb CHANGED
@@ -29,14 +29,27 @@ module NSXDriver
29
29
  unless defined?(GEMS_LOCATION)
30
30
  end
31
31
 
32
- if File.directory?(GEMS_LOCATION)
33
- real_gems_path = File.realpath(GEMS_LOCATION)
34
- if !defined?(Gem) || Gem.path != [real_gems_path]
35
- $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
32
+ # rubocop: disable all
33
+ # %%RUBYGEMS_SETUP_BEGIN%%
34
+ if File.directory?(GEMS_LOCATION)
35
+ real_gems_path = File.realpath(GEMS_LOCATION)
36
+ if !defined?(Gem) || Gem.path != [real_gems_path]
37
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
38
+
39
+ # Suppress warnings from Rubygems
40
+ # https://github.com/OpenNebula/one/issues/5379
41
+ begin
42
+ verb = $VERBOSE
43
+ $VERBOSE = nil
36
44
  require 'rubygems'
37
45
  Gem.use_paths(real_gems_path)
46
+ ensure
47
+ $VERBOSE = verb
38
48
  end
39
49
  end
50
+ end
51
+ # %%RUBYGEMS_SETUP_END%%
52
+ # rubocop: enable all
40
53
 
41
54
  $LOAD_PATH << RUBY_LIB_LOCATION
42
55
 
data/lib/opennebula.rb CHANGED
@@ -77,5 +77,5 @@ require 'opennebula/flow'
77
77
  module OpenNebula
78
78
 
79
79
  # OpenNebula version
80
- VERSION = '6.0.0.1'
80
+ VERSION = '6.0.0.2'
81
81
  end
@@ -361,8 +361,8 @@ module OpenNebula
361
361
  # exceeds the limit
362
362
  new_name = "#{template.name}-#{name}"
363
363
 
364
- if new_name.size > 128
365
- new_name = "#{template.name[0..(126 - name.size)]}-#{name}"
364
+ if new_name.size > 119
365
+ new_name = "#{template.name[0..(119 - name.size)]}-#{name}"
366
366
  end
367
367
 
368
368
  rc = template.clone(new_name, recursive)
@@ -267,17 +267,20 @@ module OpenNebula::VirtualMachineExt
267
267
  # --------------------------------------------------------------
268
268
  # Check backup consistency
269
269
  # --------------------------------------------------------------
270
- unless binfo
271
- rc = info
272
- raise rc.message if OpenNebula.is_error?(rc)
270
+ rc = info
273
271
 
274
- binfo = backup_info
272
+ raise rc.message if OpenNebula.is_error?(rc)
273
+
274
+ binfo.merge!(backup_info) do |key, old_val, new_val|
275
+ new_val.nil? ? old_val : new_val
275
276
  end
276
277
 
277
278
  raise 'No backup information' if binfo.nil?
278
279
 
279
280
  raise 'No frequency defined' unless valid?(binfo[:freq])
280
281
 
282
+ raise 'No marketplace defined' unless valid?(binfo[:market])
283
+
281
284
  return if Time.now.to_i - binfo[:last].to_i < binfo[:freq].to_i
282
285
 
283
286
  # --------------------------------------------------------------
@@ -319,19 +322,12 @@ module OpenNebula::VirtualMachineExt
319
322
  # --------------------------------------------------------------
320
323
  # Cleanup
321
324
  # --------------------------------------------------------------
322
- logger.info "Deleting template #{tmp.id}" if logger
323
-
324
- tmp.delete(true)
325
-
326
- binfo[:apps].each do |id|
327
- logger.info "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]
325
+ backup_cleanup(keep, logger, binfo, tmp)
333
326
  rescue Error, StandardError => e
327
+ backup_cleanup(keep, logger, binfo, tmp)
328
+
334
329
  logger.fatal(e.inspect) if logger
330
+
335
331
  raise
336
332
  end
337
333
 
@@ -421,9 +417,9 @@ module OpenNebula::VirtualMachineExt
421
417
 
422
418
  private
423
419
 
424
- # --------------------------------------------------------------
420
+ #-------------------------------------------------------------------
425
421
  # Check an attribute is defined and valid
426
- # --------------------------------------------------------------
422
+ #-------------------------------------------------------------------
427
423
  def valid?(att)
428
424
  return false if att.nil?
429
425
 
@@ -454,6 +450,9 @@ module OpenNebula::VirtualMachineExt
454
450
  binfo
455
451
  end
456
452
 
453
+ #-------------------------------------------------------------------
454
+ # Generate backup information string
455
+ #-------------------------------------------------------------------
457
456
  def backup_attr(binfo, ids)
458
457
  'BACKUP=[' \
459
458
  " MARKETPLACE_APP_IDS = \"#{ids.join(',')}\"," \
@@ -462,6 +461,25 @@ module OpenNebula::VirtualMachineExt
462
461
  " MARKETPLACE_ID = \"#{binfo[:market]}\" ]"
463
462
  end
464
463
 
464
+ #-------------------------------------------------------------------
465
+ # Cleanup backup leftovers in case of failure
466
+ #-------------------------------------------------------------------
467
+ def backup_cleanup(keep, logger, binfo, template)
468
+ if template
469
+ logger.info "Deleting template #{template.id}" if logger
470
+
471
+ template.delete(true)
472
+ end
473
+
474
+ binfo[:apps].each do |id|
475
+ logger.info "Deleting applicance #{id}" if logger
476
+
477
+ papp = OpenNebula::MarketPlaceApp.new_with_id(id, @client)
478
+
479
+ papp.delete
480
+ end if !keep && binfo[:apps]
481
+ end
482
+
465
483
  end
466
484
  end
467
485
 
@@ -36,14 +36,25 @@ end
36
36
 
37
37
  ENV['LANG'] = 'C'
38
38
 
39
+ # %%RUBYGEMS_SETUP_BEGIN%%
39
40
  if File.directory?(GEMS_LOCATION)
40
41
  real_gems_path = File.realpath(GEMS_LOCATION)
41
42
  if !defined?(Gem) || Gem.path != [real_gems_path]
42
43
  $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
43
- require 'rubygems'
44
- Gem.use_paths(real_gems_path)
44
+
45
+ # Suppress warnings from Rubygems
46
+ # https://github.com/OpenNebula/one/issues/5379
47
+ begin
48
+ verb = $VERBOSE
49
+ $VERBOSE = nil
50
+ require 'rubygems'
51
+ Gem.use_paths(real_gems_path)
52
+ ensure
53
+ $VERBOSE = verb
54
+ end
45
55
  end
46
56
  end
57
+ # %%RUBYGEMS_SETUP_END%%
47
58
 
48
59
  $LOAD_PATH << LIB_LOCATION + '/ruby/vendors/rbvmomi/lib'
49
60
  $LOAD_PATH << LIB_LOCATION + '/ruby'
@@ -496,9 +496,9 @@ module VCenterDriver
496
496
  end
497
497
 
498
498
  #
499
- # Create and allocate a Opennebula Object.
499
+ # Create and allocate a OpenNebula Object.
500
500
  #
501
- # @param info [String] Info passed to opennebula Core.
501
+ # @param info [String] Info passed to OpenNebula Core.
502
502
  #
503
503
  # @return [&block] the allocated object through a block.
504
504
  #
@@ -33,14 +33,27 @@ module VCenterDriver
33
33
  end
34
34
  end
35
35
 
36
- if File.directory?(GEMS_LOCATION)
37
- real_gems_path = File.realpath(GEMS_LOCATION)
38
- if !defined?(Gem) || Gem.path != [real_gems_path]
39
- $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
36
+ # rubocop: disable all
37
+ # %%RUBYGEMS_SETUP_BEGIN%%
38
+ if File.directory?(GEMS_LOCATION)
39
+ real_gems_path = File.realpath(GEMS_LOCATION)
40
+ if !defined?(Gem) || Gem.path != [real_gems_path]
41
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
42
+
43
+ # Suppress warnings from Rubygems
44
+ # https://github.com/OpenNebula/one/issues/5379
45
+ begin
46
+ verb = $VERBOSE
47
+ $VERBOSE = nil
40
48
  require 'rubygems'
41
49
  Gem.use_paths(real_gems_path)
50
+ ensure
51
+ $VERBOSE = verb
42
52
  end
43
53
  end
54
+ end
55
+ # %%RUBYGEMS_SETUP_END%%
56
+ # rubocop: enable all
44
57
 
45
58
  $LOAD_PATH << RUBY_LIB_LOCATION
46
59
 
@@ -1041,7 +1054,8 @@ module VCenterDriver
1041
1054
  else
1042
1055
  if snapshots?
1043
1056
  error = 'Disk metadata not present and snapshots exist. ' \
1044
- 'OpenNebula cannot manage this VM.'
1057
+ 'Please remove imported VM with "onevm recover ' \
1058
+ '--delete-db".'
1045
1059
  raise error
1046
1060
  end
1047
1061
 
@@ -2401,6 +2415,15 @@ module VCenterDriver
2401
2415
 
2402
2416
  # Attach DISK to VM (hotplug)
2403
2417
  def attach_disk(disk)
2418
+ # Adding a new disk in newer vSphere versions
2419
+ # automatically cleans all system snapshots
2420
+ # https://github.com/OpenNebula/one/issues/5409
2421
+ if snapshots? or one_snapshots?
2422
+ error_message = 'Existing sytem snapshots, cannot change disks. '
2423
+ error_message << 'Please remove all snapshots and try again.'
2424
+ raise error_message
2425
+ end
2426
+
2404
2427
  spec_hash = {}
2405
2428
  device_change = []
2406
2429
 
@@ -2582,6 +2605,12 @@ module VCenterDriver
2582
2605
  def detach_disk(disk)
2583
2606
  return unless disk.exists?
2584
2607
 
2608
+ if snapshots? or one_snapshots?
2609
+ error_message = 'Existing sytem snapshots, cannot change disks. '
2610
+ error_message << 'Please remove all snapshots and try again.'
2611
+ raise error_message
2612
+ end
2613
+
2585
2614
  spec_hash = {}
2586
2615
  spec_hash[:extraConfig] = [disk.config(:delete)]
2587
2616
  spec_hash[:deviceChange] = [{
@@ -2611,15 +2640,15 @@ module VCenterDriver
2611
2640
  # - The disk is managed by OpenNebula
2612
2641
  detachable= !(one_vm['LCM_STATE'].to_i == 11 && !disk.managed?)
2613
2642
  detachable &&= disk.exists?
2614
-
2643
+
2615
2644
  return unless detachable
2616
2645
 
2617
2646
  detach_disk(disk)
2618
2647
 
2619
2648
  # Check if we want to keep the non persistent disk
2620
2649
  keep_non_persistent_disks =
2621
- VCenterDriver::CONFIG[:keep_non_persistent_disks]
2622
-
2650
+ VCenterDriver::CONFIG[:keep_non_persistent_disks]
2651
+
2623
2652
  return if keep_non_persistent_disks == true
2624
2653
 
2625
2654
  disk.destroy
@@ -2816,7 +2845,7 @@ module VCenterDriver
2816
2845
  # Convert VM to template in vCenter
2817
2846
  mark_as_template
2818
2847
 
2819
- # Edit the Opennebula template
2848
+ # Edit the OpenNebula template
2820
2849
  one_client = OpenNebula::Client.new
2821
2850
  template_id = one_item['TEMPLATE/TEMPLATE_ID']
2822
2851
  new_template = OpenNebula::Template.new_with_id(template_id,
@@ -2867,6 +2896,15 @@ module VCenterDriver
2867
2896
  self['rootSnapshot'] && !self['rootSnapshot'].empty?
2868
2897
  end
2869
2898
 
2899
+ def one_snapshots?
2900
+ begin
2901
+ !one_item['TEMPLATE/SNAPSHOT'].nil?
2902
+ rescue StandardError
2903
+ # one_item may not be retrieved if deploy_id hasn't been set
2904
+ false
2905
+ end
2906
+ end
2907
+
2870
2908
  def instantiated_as_persistent?
2871
2909
  begin
2872
2910
  !one_item['TEMPLATE/CLONING_TEMPLATE_ID'].nil?
data/lib/vm_template.rb CHANGED
@@ -1573,9 +1573,8 @@ module VCenterDriver
1573
1573
  str << "]\n"
1574
1574
 
1575
1575
  if annotation.nil? || annotation.empty?
1576
- str << 'DESCRIPTION = "vCenter Template \
1577
- imported by OpenNebula' \
1578
- " from Cluster #{ccr_name}\"\n"
1576
+ str << 'DESCRIPTION = "vCenter Template imported by OpenNebula'\
1577
+ " from Cluster #{ccr_name}\"\n"
1579
1578
  else
1580
1579
  notes = annotation.gsub('\\', '\\\\').gsub('"', '\\"')
1581
1580
  str << "DESCRIPTION = \"#{notes}\"\n"
data/lib/vmm_importer.rb CHANGED
@@ -54,6 +54,14 @@ module VCenterDriver
54
54
 
55
55
  vc_vm = VCenterDriver::VirtualMachine.new_without_id(@vi_client,
56
56
  vm_ref)
57
+
58
+ # Importing Wild VMs with snapshots is not supported
59
+ # https://github.com/OpenNebula/one/issues/1268
60
+ if vc_vm.snapshots? && vc_vm.disk_keys.empty?
61
+ raise 'Disk metadata not present and snapshots exist, '\
62
+ 'cannot import this VM'
63
+ end
64
+
57
65
  vname = vc_vm['name']
58
66
 
59
67
  type = { :object => 'VM', :id => vname }
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: 6.0.0.1
4
+ version: 6.0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenNebula
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-28 00:00:00.000000000 Z
11
+ date: 2021-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -227,10 +227,10 @@ files:
227
227
  - lib/opennebula/zone.rb
228
228
  - lib/opennebula/flow/grammar.rb
229
229
  - lib/opennebula/flow/service_pool.rb
230
- - lib/opennebula/flow/service_template.rb
231
230
  - lib/opennebula/flow/service_template_ext.rb
232
231
  - lib/opennebula/flow/service_template_pool.rb
233
232
  - lib/opennebula/flow/validator.rb
233
+ - lib/opennebula/flow/service_template.rb
234
234
  - lib/opennebula/ldap_auth.rb
235
235
  - lib/opennebula/ldap_auth_spec.rb
236
236
  - lib/opennebula/server_cipher_auth.rb