opennebula 6.0.1 → 6.1.90.pre

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: f663dcec1594a07beb54bc3a4065b53818669846
4
- data.tar.gz: 63d9ffe94c43fb81d6cc7e2a0563ed6d711ebc48
3
+ metadata.gz: 2297734850551fc2c89b8d6bbccd43408724e330
4
+ data.tar.gz: e7bc524512feaa2dd9215214aa2b273dd6a9f8d5
5
5
  SHA512:
6
- metadata.gz: 905fbdea52975558d07f8720c64c5f37365672d487a1bb334c94e0e4ea5026be94468c3320b667c2d7acc6f31f312e0e58b951cbf136bf45ebfc1d4efaa7e857
7
- data.tar.gz: ddb7dadb1c1d2df3454b11a4c7f91385049ee2b134de1d75c0c27b7e59b554b2f9db5ca6135e85a9d0e8ff3b0e0565f3f4e34dd121830c151a1f468347187ad6
6
+ metadata.gz: 6df4eefbb624baa5f43f4959d188f43ef1ad36cb25814f76b829480bd26b60946489029d0623727d96881eff87efe9755a823884a7988fe68206d43fe86442af
7
+ data.tar.gz: 547a06b4424a0f2dfaeec1a2c4c9ac4a5fa8854665338fe34e7ebc9b6cbd0de3682c6ade82b9360fb7e68a9c9bbb2d4fb3a89c05757652e8e98c732951e52447
@@ -34,17 +34,9 @@ require 'base64'
34
34
  # * Log messages will be sent to STDOUT
35
35
  # * The script will return 0 if it succeded or any other value
36
36
  # if there was a failure
37
- # * In case of failure the cause of the error will be written to STDERR
38
- # wrapped by start and end marks as follows:
39
- #
40
- # ERROR MESSAGE --8<------
41
- # error message for the failure
42
- # ERROR MESSAGE ------>8--
43
-
37
+ # * In case of failure the cause of the error will be written to STDERR.
44
38
 
45
39
  class GenericCommand
46
- ERROR_OPEN = "ERROR MESSAGE --8<------"
47
- ERROR_CLOSE = "ERROR MESSAGE ------>8--"
48
40
 
49
41
  attr_reader :code, :stdout, :stderr, :command
50
42
 
@@ -93,8 +85,9 @@ class GenericCommand
93
85
  end
94
86
 
95
87
  log(error_message)
96
- @stderr = ERROR_OPEN + "\n" + error_message + "\n" + ERROR_CLOSE
97
- @code = 255
88
+
89
+ @stderr = error_message
90
+ @code = 255
98
91
  end
99
92
 
100
93
  return @code
@@ -102,9 +95,9 @@ class GenericCommand
102
95
 
103
96
  # Parses error message from +stderr+ output
104
97
  def get_error_message
105
- tmp=@stderr.scan(/^#{ERROR_OPEN}\n(.*?)#{ERROR_CLOSE}$/m)
106
- return "-" if !tmp[0]
107
- tmp[0].join(' ').strip
98
+ return '-' if @stderr.empty?
99
+
100
+ @stderr.tr("\n",' ').strip
108
101
  end
109
102
 
110
103
  def to_xml
@@ -176,8 +169,12 @@ private
176
169
  end
177
170
  }
178
171
 
179
- i.write stdin_data
180
- i.close
172
+ begin
173
+ i.write stdin_data
174
+ i.close
175
+ rescue Errno::EPIPE
176
+ # the cmd doesn't read the input, ignore error
177
+ end
181
178
 
182
179
  # blocking wait for process termination
183
180
  t.value
@@ -124,31 +124,21 @@ module DriverExecHelper
124
124
  # Sends a log message to ONE. The +message+ can be multiline, it will
125
125
  # be automatically splitted by lines.
126
126
  def log(number, message, all = true)
127
- in_error_message=false
128
- msg=message.strip
127
+ msg = message.strip
128
+
129
129
  msg.each_line do |line|
130
130
  all ? severity='I' : severity=nil
131
- l=line.strip
132
-
133
- if l=='ERROR MESSAGE --8<------'
134
- in_error_message=true
135
- next
136
- elsif l=='ERROR MESSAGE ------>8--'
137
- in_error_message=false
138
- next
139
- else
140
- if in_error_message
131
+
132
+ if line.match(/^(ERROR|DEBUG|INFO):(.*)$/)
133
+ line=Regexp.last_match(2)
134
+
135
+ case Regexp.last_match(1)
136
+ when 'ERROR'
141
137
  severity='E'
142
- elsif line.match(/^(ERROR|DEBUG|INFO):(.*)$/)
143
- line=Regexp.last_match(2)
144
- case Regexp.last_match(1)
145
- when 'ERROR'
146
- severity='E'
147
- when 'DEBUG'
148
- severity='D'
149
- when 'INFO'
150
- severity='I'
151
- end
138
+ when 'DEBUG'
139
+ severity='D'
140
+ when 'INFO'
141
+ severity='I'
152
142
  end
153
143
  end
154
144
 
@@ -51,7 +51,7 @@ end
51
51
  module CloudClient
52
52
 
53
53
  # OpenNebula version
54
- VERSION = '6.0.1'
54
+ VERSION = '6.1.90'
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
data/lib/datastore.rb CHANGED
@@ -558,8 +558,12 @@ module VCenterDriver
558
558
  raise 'Could not get file size or capacity' if size.nil?
559
559
 
560
560
  size
561
- rescue StandardError
562
- raise 'Could not find file.'
561
+ rescue StandardError => e
562
+ message = "Could not find file. Reason: \"#{e.message}\"."
563
+ if VCenterDriver::CONFIG[:debug_information]
564
+ message += ' ' + e.backtrace
565
+ end
566
+ raise message
563
567
  end
564
568
  end
565
569
 
@@ -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/file_helper.rb CHANGED
@@ -81,6 +81,10 @@ module VCenterDriver
81
81
  file.match(%r{^https?://}) || file.match(%r{^s3?://})
82
82
  end
83
83
 
84
+ def self.from_s3?(file)
85
+ file.match(%r{^s3?://})
86
+ end
87
+
84
88
  def self.vmdk?(file)
85
89
  type = `file #{file}`
86
90
 
data/lib/host.rb CHANGED
@@ -1145,14 +1145,14 @@ module VCenterDriver
1145
1145
  vswitchspec =
1146
1146
  RbVmomi::VIM::HostVirtualSwitchSpec(
1147
1147
  :bridge => hostbridge,
1148
- :mtu => mtu,
1149
- :numPorts => num_ports
1148
+ :mtu => mtu,
1149
+ :numPorts => num_ports
1150
1150
  )
1151
1151
  begin
1152
1152
  nws
1153
1153
  .UpdateVirtualSwitch(
1154
1154
  :vswitchName => name,
1155
- :spec => vswitchspec
1155
+ :spec => vswitchspec
1156
1156
  )
1157
1157
  rescue StandardError => e
1158
1158
  raise "The standard switch with name #{name} \
@@ -1463,7 +1463,7 @@ module VCenterDriver
1463
1463
  nws
1464
1464
  .UpdatePortGroup(
1465
1465
  :pgName => nr[:name],
1466
- :portgrp => nr[:spec]
1466
+ :portgrp => nr[:spec]
1467
1467
  )
1468
1468
  rescue StandardError => e
1469
1469
  raise "A rollback operation for standard \
data/lib/models/role.rb CHANGED
@@ -571,11 +571,20 @@ module OpenNebula
571
571
  vm = OpenNebula::VirtualMachine.new_with_id(vm_id,
572
572
  @service.client)
573
573
 
574
- rc = vm.info
574
+ if do_offset
575
+ offset = (index / vms_per_period.to_i).floor
576
+ time_offset = offset * period.to_i
577
+ end
578
+
579
+ tmp_str = 'SCHED_ACTION = ['
580
+ tmp_str << "ACTION = #{action},"
581
+ tmp_str << "ARGS = \"#{args}\"," if args
582
+ tmp_str << "TIME = #{now + time_offset}]"
575
583
 
584
+ rc = vm.sched_action_add(tmp_str)
576
585
  if OpenNebula.is_error?(rc)
577
- msg = "Role #{name} : VM #{vm_id} monitorization failed;"\
578
- " #{rc.message}"
586
+ msg = "Role #{name} : VM #{vm_id} error scheduling "\
587
+ "action; #{rc.message}"
579
588
 
580
589
  error_msgs << msg
581
590
 
@@ -583,40 +592,7 @@ module OpenNebula
583
592
 
584
593
  @service.log_error(msg)
585
594
  else
586
- ids = vm.retrieve_elements('USER_TEMPLATE/SCHED_ACTION/ID')
587
-
588
- id = 0
589
- if !ids.nil? && !ids.empty?
590
- ids.map! {|e| e.to_i }
591
- id = ids.max + 1
592
- end
593
-
594
- tmp_str = vm.user_template_str
595
-
596
- if do_offset
597
- offset = (index / vms_per_period.to_i).floor
598
- time_offset = offset * period.to_i
599
- end
600
-
601
- tmp_str << "\nSCHED_ACTION = ["
602
- tmp_str << "ID = #{id},"
603
- tmp_str << "ACTION = #{action},"
604
- tmp_str << "ARGS = \"#{args}\"," if args
605
- tmp_str << "TIME = #{now + time_offset}]"
606
-
607
- rc = vm.update(tmp_str)
608
- if OpenNebula.is_error?(rc)
609
- msg = "Role #{name} : VM #{vm_id} error scheduling "\
610
- "action; #{rc.message}"
611
-
612
- error_msgs << msg
613
-
614
- Log.error LOG_COMP, msg, @service.id
615
-
616
- @service.log_error(msg)
617
- else
618
- vms_id << vm.id
619
- end
595
+ vms_id << vm.id
620
596
  end
621
597
  end
622
598
 
@@ -140,12 +140,14 @@ module OpenNebula
140
140
  # Return true if the service can be undeployed
141
141
  # @return true if the service can be undeployed, false otherwise
142
142
  def can_undeploy?
143
+ # rubocop:disable Style/IfWithBooleanLiteralBranches
143
144
  if (transient_state? && state != Service::STATE['UNDEPLOYING']) ||
144
- state == Service::STATE['DONE'] || failed_state?
145
+ state == Service::STATE['DONE'] || failed_state?
145
146
  false
146
147
  else
147
148
  true
148
149
  end
150
+ # rubocop:enable Style/IfWithBooleanLiteralBranches
149
151
  end
150
152
 
151
153
  # Return true if the service can be updated
@@ -166,6 +168,12 @@ module OpenNebula
166
168
  RECOVER_SCALE_STATES.include? STATE_STR[state]
167
169
  end
168
170
 
171
+ # Return true if the service is running
172
+ # @return true if the service is runnning, false otherwise
173
+ def running?
174
+ state_str == 'RUNNING'
175
+ end
176
+
169
177
  # Returns the running_status_vm option
170
178
  # @return [true, false] true if the running_status_vm option is enabled
171
179
  def report_ready?
@@ -323,6 +331,36 @@ module OpenNebula
323
331
  nil
324
332
  end
325
333
 
334
+ # Adds a role to the service
335
+ #
336
+ # @param template [Hash] Role information
337
+ #
338
+ # @return [OpenNebula::Role] New role
339
+ def add_role(template)
340
+ template['state'] ||= Role::STATE['PENDING']
341
+ role = Role.new(template, self)
342
+
343
+ if @roles[role.name]
344
+ return OpenNebula::Error.new("Role #{role.name} already exists")
345
+ end
346
+
347
+ @roles[role.name] = role
348
+ @body['roles'] << template if @body && @body['roles']
349
+
350
+ role
351
+ end
352
+
353
+ # Removes a role from the service
354
+ #
355
+ # @param name [String] Role name to delete
356
+ def remove_role(name)
357
+ @roles.delete(name)
358
+
359
+ @body['roles'].delete_if do |role|
360
+ role['name'] == name
361
+ end
362
+ end
363
+
326
364
  # Retrieves the information of the Service and all its Nodes.
327
365
  #
328
366
  # @return [nil, OpenNebula::Error] nil in case of success, Error
@@ -484,38 +522,51 @@ module OpenNebula
484
522
 
485
523
  # Check that changes values are correct
486
524
  #
487
- # @param template_json [String] New template
525
+ # @param template_json [String] New template
526
+ # @param append [Boolean] True to append template to the current
488
527
  #
489
528
  # @return [Boolean, String] True, nil if everything is correct
490
529
  # False, attr if attr was changed
491
- def check_new_template(template_json)
530
+ def check_new_template(template_json, append)
492
531
  template = JSON.parse(template_json)
493
532
 
494
- if template['roles'].size != @roles.size
495
- return [false, 'service/roles size']
496
- end
533
+ if append
534
+ IMMUTABLE_ATTRS.each do |attr|
535
+ next if template[attr].nil?
497
536
 
498
- IMMUTABLE_ATTRS.each do |attr|
499
- next if template[attr] == @body[attr]
537
+ return [false, "service/#{attr}"]
538
+ end
539
+ else
540
+ if template['roles'].size != @roles.size
541
+ return [false, 'service/roles size']
542
+ end
500
543
 
501
- return [false, "service/#{attr}"]
502
- end
544
+ IMMUTABLE_ATTRS.each do |attr|
545
+ next if template[attr] == @body[attr]
503
546
 
504
- template['roles'].each do |role|
505
- # Role name can't be changed, if it is changed some problems
506
- # may appear, as name is used to reference roles
507
- return [false, 'name'] unless @roles[role['name']]
547
+ return [false, "service/#{attr}"]
548
+ end
549
+
550
+ template['roles'].each do |role|
551
+ # Role name can't be changed, if it is changed some problems
552
+ # may appear, as name is used to reference roles
553
+ return [false, 'name'] unless @roles[role['name']]
508
554
 
509
- rc = @roles[role['name']].check_new_template(role)
555
+ rc = @roles[role['name']].check_new_template(role)
510
556
 
511
- return rc unless rc[0]
557
+ return rc unless rc[0]
558
+ end
512
559
  end
513
560
 
514
561
  [true, nil]
515
562
  end
516
563
 
517
- def deploy_networks
518
- body = JSON.parse(self['TEMPLATE/BODY'])
564
+ def deploy_networks(deploy = true)
565
+ if deploy
566
+ body = JSON.parse(self['TEMPLATE/BODY'])
567
+ else
568
+ body = @body
569
+ end
519
570
 
520
571
  return if body['networks_values'].nil?
521
572
 
@@ -531,7 +582,7 @@ module OpenNebula
531
582
  if OpenNebula.is_error?(rc)
532
583
  return rc
533
584
  end
534
- end
585
+ end if deploy
535
586
 
536
587
  # Replace $attibute by the corresponding value
537
588
  resolve_attributes(body)
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