opennebula 6.4.4 → 6.4.6

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
  SHA256:
3
- metadata.gz: 96a1db3dafa076b57aaa80ad46375d0830f6819fa0e70124b77b1ca8d648f29c
4
- data.tar.gz: bbed8b41708c8c6e1a3348b320c3995bc141efbcc0e7e95a051e5ceeb25dc18f
3
+ metadata.gz: 1a95c466615797446ff59c56f025cd24189252b20b4ebbfe74e014dcdabae31f
4
+ data.tar.gz: ce36fa2c5d7e790e901a4c3d34dfb0640bff319628ccbde2d0d19c949d7a636e
5
5
  SHA512:
6
- metadata.gz: 2750f136ca555d0a4e2f002bf58f6b6706d5a9a92d6094fa84d1afba3d7148e5cd9ae1b7911a90a58ae0a913ba64b9052c2e021dd5da07f7ee94e04c42a8a89c
7
- data.tar.gz: 2b0252237e2513b95bf2da0355275dc6a3d797b7c5f6a5dba4ec9b64fe9cc017de031042e740921ecd870fbedda4a8ee73e047168307a3c6676e3c3527f3ae25
6
+ metadata.gz: d94ce7a4e3efd9dc50942606be49edcdeb1f58e94bb83ebe98ca6577e2b26943f6ba51e4c1da001f3a63e2f62ad1cf5770e79f54aaef5b2413376c6b3b6da443
7
+ data.tar.gz: 89bebd801fcae46af21192d7d2a93c8e65d9ee81b8c0e0e4f9621e827c7717414dde553134876ee331fdd42c559d18fd91168446dff80eb2e79b14cdd3b792ed
@@ -189,7 +189,7 @@ module DriverExecHelper
189
189
  cfg=file.read
190
190
  end
191
191
 
192
- cfg.split(/\n/).each do |line|
192
+ cfg.split("\n").each do |line|
193
193
  m=line.match(/^([^=]+)=(.*)$/)
194
194
 
195
195
  next unless m
@@ -51,7 +51,7 @@ end
51
51
  module CloudClient
52
52
 
53
53
  # OpenNebula version
54
- VERSION = '6.4.4'
54
+ VERSION = '6.4.6'
55
55
 
56
56
  # #########################################################################
57
57
  # Default location for the authentication file
data/lib/host.rb CHANGED
@@ -352,7 +352,7 @@ module VCenterDriver
352
352
  str_info << 'USEDMEMORY=' << (total_mem - free_mem).to_s << "\n"
353
353
 
354
354
  # DRS enabled
355
- str_info << 'VCENTER_DRS=' << drs_enabled.to_s << "\n"
355
+ str_info << 'VCENTER_DRS=' << drs_enabled.to_s << "\n"
356
356
 
357
357
  # HA enabled
358
358
  str_info << 'VCENTER_HA=' << ha_enabled.to_s << "\n"
data/lib/models/role.rb CHANGED
@@ -634,8 +634,8 @@ module OpenNebula
634
634
  return OpenNebula::Error.new("Role #{name} is in DONE state")
635
635
  end
636
636
 
637
- do_offset = (!period.nil? && period.to_i > 0 &&
638
- !vms_per_period.nil? && vms_per_period.to_i > 0)
637
+ do_offset = !period.nil? && period.to_i > 0 &&
638
+ !vms_per_period.nil? && vms_per_period.to_i > 0
639
639
 
640
640
  nodes.each_with_index do |node, index|
641
641
  vm_id = node['deploy_id']
@@ -140,9 +140,9 @@ module OpenNebula
140
140
  @one_endpoint = endpoint
141
141
  elsif ENV["ONE_XMLRPC"]
142
142
  @one_endpoint = ENV["ONE_XMLRPC"]
143
- elsif ENV['HOME'] and File.exists?(ENV['HOME']+"/.one/one_endpoint")
143
+ elsif ENV['HOME'] and File.exist?(ENV['HOME']+"/.one/one_endpoint")
144
144
  @one_endpoint = File.read(ENV['HOME']+"/.one/one_endpoint")
145
- elsif File.exists?("/var/lib/one/.one/one_endpoint")
145
+ elsif File.exist?("/var/lib/one/.one/one_endpoint")
146
146
  @one_endpoint = File.read("/var/lib/one/.one/one_endpoint")
147
147
  else
148
148
  @one_endpoint = "http://localhost:2633/RPC2"
@@ -89,7 +89,7 @@ class OpenNebula::LdapAuth
89
89
  file=@options[:mapping_file_path]
90
90
  generate = false
91
91
 
92
- if File.exists?(file)
92
+ if File.exist?(file)
93
93
  stat = File.stat(file)
94
94
  age = Time.now.to_i - stat.mtime.to_i
95
95
  generate = true if age > @options[:mapping_timeout]
@@ -124,7 +124,7 @@ class OpenNebula::LdapAuth
124
124
 
125
125
  @mapping = {}
126
126
 
127
- if File.exists?(file)
127
+ if File.exist?(file)
128
128
  @mapping = YAML.load(File.read(file))
129
129
  end
130
130
 
@@ -339,9 +339,9 @@ module Service
339
339
  url = opts[:url]
340
340
  elsif ENV['ONEFLOW_URL']
341
341
  url = ENV['ONEFLOW_URL']
342
- elsif ENV['HOME'] && File.exists?(ENV['HOME'] + endpoint)
342
+ elsif ENV['HOME'] && File.exist?(ENV['HOME'] + endpoint)
343
343
  url = File.read(ENV['HOME'] + endpoint).strip
344
- elsif File.exists?('/var/lib/one/.one/oneflow_endpoint')
344
+ elsif File.exist?('/var/lib/one/.one/oneflow_endpoint')
345
345
  url = File.read('/var/lib/one/.one/oneflow_endpoint').strip
346
346
  else
347
347
  url = 'http://localhost:2474'
@@ -454,11 +454,14 @@ module Service
454
454
 
455
455
  req['User-Agent'] = @user_agent
456
456
 
457
- res = CloudClient::http_start(@uri, @timeout) do |http|
457
+ if !@uri.path.nil?
458
+ req.instance_variable_set(:@path, @uri.path + req.path)
459
+ end
460
+
461
+ CloudClient.http_start(@uri, @timeout) do |http|
458
462
  http.request(req)
459
463
  end
460
464
 
461
- res
462
465
  end
463
466
  end
464
467
  end
@@ -14,104 +14,127 @@
14
14
  # limitations under the License. #
15
15
  #--------------------------------------------------------------------------- #
16
16
 
17
-
18
- require 'pp'
19
17
  require 'openssl'
20
18
  require 'base64'
21
19
  require 'fileutils'
20
+ require 'open3'
21
+ require 'tempfile'
22
+
23
+ module OpenNebula
24
+
25
+ # SSH key authentication class. It can be used as a driver for auth_mad
26
+ # as auth method is defined. It also holds some helper methods to be used
27
+ # by oneauth command
28
+ class SshAuth
29
+
30
+ # Initialize SshAuth object
31
+ #
32
+ # @param [Hash] default options for path
33
+ # @option options [String] :public_key public key for the user
34
+ # @option options [String] :private_key key private key for the user.
35
+ def initialize(options = {})
36
+ @private_key = nil
37
+ @public_key = nil
38
+
39
+ # Initialize the private key
40
+ if options[:private_key]
41
+ begin
42
+ @private_key = File.read(options[:private_key])
43
+ rescue StandardError => e
44
+ raise "Cannot read #{options[:private_key]}\n #{e}"
45
+ end
22
46
 
23
- module OpenNebula; end
24
-
25
- # SSH key authentication class. It can be used as a driver for auth_mad
26
- # as auth method is defined. It also holds some helper methods to be used
27
- # by oneauth command
28
- class OpenNebula::SshAuth
29
- # Initialize SshAuth object
30
- #
31
- # @param [Hash] default options for path
32
- # @option options [String] :public_key public key for the user
33
- # @option options [String] :private_key key private key for the user.
34
- def initialize(options={})
35
- @private_key = nil
36
- @public_key = nil
37
-
38
- # Initialize the private key
39
- if options[:private_key]
40
- begin
41
- @private_key = File.read(options[:private_key])
42
- rescue Exception => e
43
- raise "Cannot read #{options[:private_key]}"
47
+ begin
48
+ @private_key_rsa = OpenSSL::PKey::RSA.new(@private_key)
49
+ rescue OpenSSL::PKey::RSAError
50
+ private_key_pem = openssh_to_pem(@private_key)
51
+ @private_key_rsa = OpenSSL::PKey::RSA.new(private_key_pem)
52
+ end
53
+ end
54
+
55
+ # Initialize the public key
56
+ if options[:public_key]
57
+ @public_key = options[:public_key]
58
+ elsif !@private_key.nil?
59
+ # Init ssh keys using private key. public key is extracted in a
60
+ # format compatible with openssl. The public key does not contain
61
+ # "---- BEGIN/END PUBLIC KEY ----" and is in a single line
62
+ @public_key = @private_key_rsa.public_key.to_pem.split("\n")
63
+ @public_key = @public_key.reject {|l| l.match(/PUBLIC KEY/) }.join('')
64
+ end
65
+
66
+ if @private_key.nil? && @public_key.nil?
67
+ raise 'You have to define at least one of the keys'
44
68
  end
45
69
 
46
- @private_key_rsa = OpenSSL::PKey::RSA.new(@private_key)
70
+ @public_key_rsa = OpenSSL::PKey::RSA.new(Base64.decode64(@public_key))
47
71
  end
48
72
 
49
- # Initialize the public key
50
- if options[:public_key]
51
- @public_key = options[:public_key]
52
- elsif @private_key != nil
53
- # Init ssh keys using private key. public key is extracted in a
54
- # format compatible with openssl. The public key does not contain
55
- # "---- BEGIN/END PUBLIC KEY ----" and is in a single line
56
- @public_key = @private_key_rsa.public_key.to_pem.split("\n")
57
- @public_key = @public_key.reject {|l| l.match(/PUBLIC KEY/) }.join('')
73
+ # Creates a login token for ssh authentication.
74
+ # By default it is valid for 1 hour but it can be changed to any number
75
+ # of seconds with expire parameter (in seconds)
76
+ def login_token(user, expire = 3600)
77
+ expire ||= 3600
78
+
79
+ return encrypt("#{user}:#{Time.now.to_i + expire.to_i}")
58
80
  end
59
81
 
60
- if @private_key.nil? && @public_key.nil?
61
- raise "You have to define at least one of the keys"
82
+ # Returns a valid password string to create a user using this auth driver.
83
+ # In this case the ssh public key.
84
+ def password
85
+ @public_key
62
86
  end
63
87
 
64
- @public_key_rsa = OpenSSL::PKey::RSA.new(Base64::decode64(@public_key))
65
- end
88
+ # Checks the proxy created with the login method
89
+ def authenticate(user, token)
90
+ begin
91
+ token_plain = decrypt(token)
92
+ t_user, time = token_plain.split(':')
66
93
 
67
- # Creates a login token for ssh authentication.
68
- # By default it is valid for 1 hour but it can be changed to any number
69
- # of seconds with expire parameter (in seconds)
70
- def login_token(user, expire=3600)
71
- expire ||= 3600
94
+ return 'invalid credentials' unless user == t_user
95
+ return 'ssh proxy expired, login again to renew it' if Time.now.to_i >= time.to_i
72
96
 
73
- return encrypt("#{user}:#{Time.now.to_i + expire.to_i}")
74
- end
97
+ return true
98
+ rescue StandardError
99
+ return 'error'
100
+ end
101
+ end
75
102
 
76
- # Returns a valid password string to create a user using this auth driver.
77
- # In this case the ssh public key.
78
- def password
79
- @public_key
80
- end
103
+ private
81
104
 
82
- # Checks the proxy created with the login method
83
- def authenticate(user, token)
84
- begin
85
- token_plain = decrypt(token)
86
- _user, time = token_plain.split(':')
87
-
88
- if user == _user
89
- if Time.now.to_i >= time.to_i
90
- return "ssh proxy expired, login again to renew it"
91
- else
92
- return true
93
- end
94
- else
95
- return "invalid credentials"
96
- end
97
- rescue
98
- return "error"
105
+ def openssh_to_pem(private_key)
106
+ temp_file = Tempfile.new('private_key')
107
+
108
+ File.write(temp_file.path, private_key)
109
+
110
+ # Use ssh-keygen to convert the key
111
+ command = "ssh-keygen -p -N '' -m PEM -f #{temp_file.path}"
112
+
113
+ _out, err, status = Open3.capture3(command)
114
+
115
+ raise "Failed to convert key: #{err}" unless status.success?
116
+
117
+ pem_key = File.read(temp_file.path)
118
+ return pem_key
119
+ ensure
120
+ temp_file.close
121
+ temp_file.unlink if temp_file
122
+ end
123
+
124
+ ###########################################################################
125
+ # Methods to handle ssh keys
126
+ ###########################################################################
127
+ # Encrypts data with the private key of the user and returns
128
+ # base 64 encoded output in a single line
129
+ def encrypt(data)
130
+ Base64.encode64(@private_key_rsa.private_encrypt(data)).gsub!("\n", '').strip
99
131
  end
100
- end
101
132
 
102
- private
133
+ # Decrypts base 64 encoded data with pub_key (public key)
134
+ def decrypt(data)
135
+ @public_key_rsa.public_decrypt(Base64.decode64(data))
136
+ end
103
137
 
104
- ###########################################################################
105
- # Methods to handle ssh keys
106
- ###########################################################################
107
- # Encrypts data with the private key of the user and returns
108
- # base 64 encoded output in a single line
109
- def encrypt(data)
110
- Base64::encode64(@private_key_rsa.private_encrypt(data)).gsub!(/\n/, '').strip
111
138
  end
112
139
 
113
- # Decrypts base 64 encoded data with pub_key (public key)
114
- def decrypt(data)
115
- @public_key_rsa.public_decrypt(Base64::decode64(data))
116
- end
117
140
  end
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.4.4'
80
+ VERSION = '6.4.6'
81
81
  end
@@ -104,9 +104,6 @@ module OpenNebula
104
104
  file_name = 'monitord.conf'
105
105
 
106
106
  begin
107
- # Suppress augeas require warning message
108
- $VERBOSE = nil
109
-
110
107
  require 'augeas'
111
108
 
112
109
  aug = Augeas.create(:no_modl_autoload => true,
@@ -2720,7 +2720,7 @@ end
2720
2720
  img_name = VCenterDriver::FileHelper.unescape_path(img_name_escaped)
2721
2721
 
2722
2722
  vc_disks.each do |d|
2723
- key_matches = (unmanaged_key && d[:key] == unmanaged_key.to_i)
2723
+ key_matches = unmanaged_key && d[:key] == unmanaged_key.to_i
2724
2724
  path_matches = (d[:path_wo_ds] == img_name)
2725
2725
 
2726
2726
  if key_matches || path_matches
data/lib/virtual_wire.rb CHANGED
@@ -91,7 +91,7 @@ module NSXDriver
91
91
  .get(url)
92
92
  .xpath(NSXConstants::NSXV_LS_XPATH)
93
93
  virtualwires.each do |virtualwire|
94
- lsname_arr = name.split(/-sid-/)
94
+ lsname_arr = name.split('-sid-')
95
95
  lsname = lsname_arr[-1].split('-', 2)[-1]
96
96
  lsid = lsname_arr[0].split(/vxw-dvs-\w.-/)[-1]
97
97
  if virtualwire.xpath('name').text == lsname &&
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.4.4
4
+ version: 6.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenNebula
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-10 00:00:00.000000000 Z
11
+ date: 2024-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri