opennebula 6.0.0.1 → 6.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f9aa7355cf72de3df70da8d7fceb82907f97396
4
- data.tar.gz: 749eef5d47ae22112fb3c8c1a1dc1d7f313ab5a7
3
+ metadata.gz: ae4c2d6ffef598e821e3b6bcc4a429f766caadbf
4
+ data.tar.gz: 2e65f273fb1f2d383d799fa4fd31e6d2fb66cb41
5
5
  SHA512:
6
- metadata.gz: ba3c4cfcf52af7756cdc67ccefb827e773bf60c5b38a2b8ba32e1dc232582edbb57e1e45994168052e0cc572f14b9d70c4504cb7ea82796122df5f6564609d56
7
- data.tar.gz: 40ecec9f0e8f2cd10ea50241e97a0554eb6e14204feaf0780879990373415d5eaaceea254efb7cb09b112ffb464ebc7324a17fb980d6306edfef92816c29a745
6
+ metadata.gz: ce66ed43b8db71bcb0f8572a7e3a48de18b3e7c4819006d93333709e892718cd83c724a723c81870538b404ed3d80bc33786b1b1cc0bbd8a882412992c56bd17
7
+ data.tar.gz: e3694d73c467089a0ec6720c2ac22034bfcb49f273d14b607915d9aa1ba23abf6c5045a436ec08f47d7f87e5c394981c0e95d8b1614833f87c3666f64b731291
@@ -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.0.1'
54
+ VERSION = '6.0.3'
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/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 \
@@ -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
@@ -514,8 +552,12 @@ module OpenNebula
514
552
  [true, nil]
515
553
  end
516
554
 
517
- def deploy_networks
518
- body = JSON.parse(self['TEMPLATE/BODY'])
555
+ def deploy_networks(deploy = true)
556
+ if deploy
557
+ body = JSON.parse(self['TEMPLATE/BODY'])
558
+ else
559
+ body = @body
560
+ end
519
561
 
520
562
  return if body['networks_values'].nil?
521
563
 
@@ -531,7 +573,7 @@ module OpenNebula
531
573
  if OpenNebula.is_error?(rc)
532
574
  return rc
533
575
  end
534
- end
576
+ end if deploy
535
577
 
536
578
  # Replace $attibute by the corresponding value
537
579
  resolve_attributes(body)