opennebula 5.13.80.pre → 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: cc16996ef3b6218367420d87066688a52ee86042
4
- data.tar.gz: dae462f84f7ec7bfed459506c56981be1e27974e
3
+ metadata.gz: f022212cfa3668cae363f0592a9423a77f3f0a63
4
+ data.tar.gz: f1aa5e2a2d9c2f7d06f8c63defc79b004fdd21a8
5
5
  SHA512:
6
- metadata.gz: d6a40c0cbf0a2125a07d18348d0d13471562d81581c06318126a7d671025bdcf34a30c5228af30bd37014af65329714ada099de91fcde70db29198b2731c0fc8
7
- data.tar.gz: 4a53d311862746b7712066d355120306a5b3d4311315dabf24513f5e20dc509acb4254e5d58556090b768f3aa33e89df2311c10127d87c918f7c0befe2b6c8a1
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 = '5.13.80'
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]
@@ -576,25 +570,32 @@ module VCenterDriver
576
570
  # Initialize opts hash used to inject data into one template
577
571
  opts = {}
578
572
 
579
- if full_process
580
- # Add network type to network hash
581
- network_type = \
573
+ # Add network type to network hash
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 =
582
578
  VCenterDriver::Network.get_network_type(
583
579
  vc_network,
584
580
  vc_network_name
585
581
  )
586
- network[vc_network_ref][:network_type] = network_type
582
+ networks_type[vc_network_hash[:vc_network_ref]] = network_type
587
583
  end
588
584
 
585
+ network[vc_network_ref][:network_type] = network_type
586
+ network[vc_network_ref][:type] = network_type
587
+
589
588
  # Determine if the network must be excluded
590
589
  network[vc_network_ref][:excluded] = exclude_network?(
591
- vc_network,
592
590
  one_host,
593
591
  args,
594
- vc_network_hash
592
+ vc_network_hash,
593
+ network_type
595
594
  )
596
595
 
597
- 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
598
599
 
599
600
  if full_process
600
601
  case network[vc_network_ref][:network_type]
@@ -652,31 +653,50 @@ module VCenterDriver
652
653
  vc_hosts = vc_network.host
653
654
  vc_hosts.each do |vc_host|
654
655
  # Get vCenter Cluster
655
- vc_cluster = vc_host.parent
656
- vc_cluster_ref = vc_cluster._ref
657
- vc_cluster_name = vc_cluster.name
658
- # Get one host from each vCenter cluster
659
- one_host = VCenterDriver::VIHelper
660
- .find_by_ref(OpenNebula::HostPool,
661
- 'TEMPLATE/VCENTER_CCR_REF',
662
- vc_cluster_ref,
663
- 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
664
679
  # Check if network is excluded from each host
665
680
  next if exclude_network?(
666
- vc_network,
667
681
  one_host,
668
682
  args,
669
- vc_network_hash
683
+ vc_network_hash,
684
+ network_type
670
685
  )
671
686
 
672
687
  # Insert vCenter cluster ref
673
- network[vc_network_ref][:clusters][:refs] << vc_cluster_ref
688
+ network[vc_network_ref][:clusters][:refs] <<
689
+ vc_cluster[:vc_cluster_ref]
690
+
674
691
  # Insert OpenNebula cluster id
675
692
  cluster_id = one_cluster_id(one_host)
676
- network[vc_network_ref][:clusters][:one_ids] << cluster_id
693
+ network[vc_network_ref][:clusters][:one_ids] <<
694
+ cluster_id
695
+
677
696
  # Insert vCenter cluster name
678
- network[vc_network_ref][:clusters][:names] << vc_cluster_name
679
- 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]
680
700
  end
681
701
 
682
702
  # Remove duplicate entries
@@ -707,7 +727,7 @@ module VCenterDriver
707
727
  network[vc_network_ref]['name']
708
728
  end
709
729
 
710
- network
730
+ [network, networks_type, hosts_list, host_list_object]
711
731
  end
712
732
 
713
733
  # rubocop:disable Style/GlobalVars
@@ -724,13 +744,15 @@ module VCenterDriver
724
744
  $conf[:one_xmlrpc]
725
745
  )
726
746
  end
727
-
728
747
  one_host = OpenNebula::Host.new_with_id(args[:host], one_client)
729
748
  rc = one_host.info
730
749
  raise rc.message if OpenNebula.is_error? rc
731
750
 
732
751
  # Get all networks in vcenter cluster (one_host)
733
752
  vc_cluster_networks = cluster_networks(one_host)
753
+ networks_type = {}
754
+ hosts_list = {}
755
+ host_list_object = {}
734
756
 
735
757
  # Iterate over vcenter networks
736
758
  vc_cluster_networks.each do |vc_cluster_network|
@@ -752,7 +774,20 @@ module VCenterDriver
752
774
  params[:one_host]= one_host
753
775
  params[:args] = args
754
776
 
755
- 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
756
791
 
757
792
  networks.merge!(network) unless network.nil?
758
793
  end
data/lib/datastore.rb CHANGED
@@ -653,8 +653,8 @@ module VCenterDriver
653
653
 
654
654
  wout.close
655
655
  size = rout.readlines.select do |l|
656
- l.start_with?('Content-Length')
657
- end[0].sub('Content-Length: ', '')
656
+ l.downcase.start_with?('content-length')
657
+ end[0].downcase.sub('content-length: ', '')
658
658
  rout.close
659
659
  size.chomp.to_i < 4096 # If <4k, then is a descriptor
660
660
  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
@@ -486,6 +486,76 @@ module VCenterDriver
486
486
  @defaults = { :size => '255', :type => 'ether' }
487
487
  end
488
488
 
489
+ def process_import(indexes, opts = {}, &_block)
490
+ indexes = indexes.gsub(/\s*\,\s*/, ',').strip.split(',')
491
+
492
+ dc_folder = VCenterDriver::DatacenterFolder.new(@vi_client)
493
+ vcenter_instance_name = @vi_client.vc_name
494
+ vcenter_uuid = @vi_client.vim.serviceContent.about.instanceUuid
495
+ hpool = VCenterDriver::VIHelper.one_pool(
496
+ OpenNebula::HostPool,
497
+ false
498
+ )
499
+
500
+ one_client = OpenNebula::Client.new
501
+ one_host = OpenNebula::Host.new_with_id(opts[:host], one_client)
502
+
503
+ rc = one_host.info
504
+ raise rc.message if OpenNebula.is_error? rc
505
+
506
+ # Get all networks in vcenter cluster (one_host)
507
+ vc_cluster_networks = dc_folder.cluster_networks(one_host)
508
+
509
+ vc_cluster_networks_map_ref = {}
510
+
511
+ # Iterate over vcenter networks
512
+ vc_cluster_networks.each do |vc_cluster_network|
513
+ vc_cluster_networks_map_ref[vc_cluster_network._ref] =
514
+ vc_cluster_network
515
+ end
516
+
517
+ indexes.each do |index|
518
+ begin
519
+ @rollback = []
520
+ @info[index] = {}
521
+
522
+ vc_cluster_network = vc_cluster_networks_map_ref[index]
523
+
524
+ if hpool.respond_to?(:message)
525
+ raise 'Could not get OpenNebula HostPool: ' \
526
+ "#{hpool.message}"
527
+ end
528
+
529
+ params = {}
530
+ params[:vc_network] = vc_cluster_network
531
+ params[:vcenter_instance_name] = vcenter_instance_name
532
+ params[:vcenter_uuid] = vcenter_uuid
533
+ params[:_hpool] = hpool
534
+ params[:one_host] = one_host
535
+ params[:args] = {}
536
+
537
+ selected, _networks_type, _hosts_list, _clusters_list =
538
+ dc_folder.process_network(
539
+ params,
540
+ {},
541
+ {},
542
+ {}
543
+ )
544
+
545
+ selected = selected[index]
546
+
547
+ # import the object
548
+ opts[index] ||= @defaults
549
+ @info[:success] << import(selected, opts[index])
550
+ rescue StandardError => e
551
+ @info[:error] << { index => e.message }
552
+ @info[index][:e] = e
553
+
554
+ apply_rollback
555
+ end
556
+ end
557
+ end
558
+
489
559
  def get_list(args = {})
490
560
  dc_folder = VCenterDriver::DatacenterFolder.new(@vi_client)
491
561
 
@@ -496,8 +566,8 @@ module VCenterDriver
496
566
  false
497
567
  )
498
568
  if npool.respond_to?(:message)
499
- raise "Could not get \
500
- OpenNebula VirtualNetworkPool: #{npool.message}"
569
+ raise 'Could not get ' \
570
+ "OpenNebula VirtualNetworkPool: #{npool.message}"
501
571
  end
502
572
 
503
573
  # Get OpenNebula's host pool
@@ -572,8 +642,8 @@ module VCenterDriver
572
642
  str
573
643
  end
574
644
 
575
- def import(selected)
576
- opts = @info[selected[:ref]][:opts]
645
+ def import(selected, opts = nil)
646
+ opts = @info[selected[:ref]][:opts] if opts.nil?
577
647
 
578
648
  net = VCenterDriver::Network
579
649
  .new_from_ref(selected[:ref], @vi_client)
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'