opennebula 6.4.3 → 6.4.5

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: f5f6ca2f486dd7127edf5b9320376397e778f33335e3d9403b6fa2f2b96fc2cd
4
- data.tar.gz: 0101d985b9b7d4bc22499a3a2478b54a98fdb6d1384a235f66515851fab9f399
3
+ metadata.gz: 34ad5b5d6ddf88c8d92248d3c321d7e6891609fbc83776ef6d0a71ea6e634977
4
+ data.tar.gz: 2efb015748722ee63a336106a59b1306b0382049cdeb44ef86eee11a957f7379
5
5
  SHA512:
6
- metadata.gz: 619e3110a10dcb5959009b1c077685448b38cae6cd8e5bb2e53ff1ec3d922d660e6e91be9d17012f5046ea5b9055697399a80ddbb7b7408fd9fedb196c46e0fa
7
- data.tar.gz: 12561af3a0ceffd756e90da166dba0625444118cf137ebb9d781f034175b330ee4d0cd8fe99997285ac0ee55c51af58acca4ec9dea0f494f4a27d3b22301eede
6
+ metadata.gz: f3a43640e13e4a9e73e2b3efc8ae5da0793b50a56b8655a855e4b42820869515d602a7fd3ede1ace8f8996d64cbb78b82461c5f90466256498538d9f048e70c6
7
+ data.tar.gz: 54c3b592674fdca5ed5836aac7b32336fd4a1970dc2b816ad0236c622133559f136fc545b4be56a26f3fee847572c4f30970d5cd8ba44fdc92af0d4e53484403
@@ -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.3'
54
+ VERSION = '6.4.5'
55
55
 
56
56
  # #########################################################################
57
57
  # Default location for the authentication file
data/lib/datastore.rb CHANGED
@@ -743,9 +743,9 @@ module VCenterDriver
743
743
  image_path = ''
744
744
 
745
745
  # Skip not relevant files
746
- next unless %w[FloppyImageFileInfo
747
- IsoImageFileInfo
748
- VmDiskFileInfo].include? image.class.to_s
746
+ next unless ['FloppyImageFileInfo',
747
+ 'IsoImageFileInfo',
748
+ 'VmDiskFileInfo'].include? image.class.to_s
749
749
 
750
750
  # Get image path and name
751
751
  image_path << folderpath << image.path
data/lib/file_helper.rb CHANGED
@@ -109,7 +109,7 @@ module VCenterDriver
109
109
  def self.needs_unpack?(file_path)
110
110
  type = get_type(file_path)
111
111
  type.gsub!(%r{^application/(x-)?}, '')
112
- %w[bzip2 gzip tar].include?(type)
112
+ ['bzip2', 'gzip', 'tar'].include?(type)
113
113
  end
114
114
 
115
115
  def self.vcenter_file_info(file_path)
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
@@ -32,26 +32,26 @@ module OpenNebula
32
32
  attr_reader :service
33
33
 
34
34
  # Actions that can be performed on the VMs of a given Role
35
- SCHEDULE_ACTIONS = %w[
36
- terminate
37
- terminate-hard
38
- undeploy
39
- undeploy-hard
40
- hold
41
- release
42
- stop
43
- suspend
44
- resume
45
- reboot
46
- reboot-hard
47
- poweroff
48
- poweroff-hard
49
- snapshot-create
50
- snapshot-revert
51
- snapshot-delete
52
- disk-snapshot-create
53
- disk-snapshot-revert
54
- disk-snapshot-delete
35
+ SCHEDULE_ACTIONS = [
36
+ 'terminate',
37
+ 'terminate-hard',
38
+ 'undeploy',
39
+ 'undeploy-hard',
40
+ 'hold',
41
+ 'release',
42
+ 'stop',
43
+ 'suspend',
44
+ 'resume',
45
+ 'reboot',
46
+ 'reboot-hard',
47
+ 'poweroff',
48
+ 'poweroff-hard',
49
+ 'snapshot-create',
50
+ 'snapshot-revert',
51
+ 'snapshot-delete',
52
+ 'disk-snapshot-create',
53
+ 'disk-snapshot-revert',
54
+ 'disk-snapshot-delete'
55
55
  ]
56
56
 
57
57
  STATE = {
@@ -69,52 +69,52 @@ module OpenNebula
69
69
  'HOLD' => 11
70
70
  }
71
71
 
72
- STATE_STR = %w[
73
- PENDING
74
- DEPLOYING
75
- RUNNING
76
- UNDEPLOYING
77
- WARNING
78
- DONE
79
- FAILED_UNDEPLOYING
80
- FAILED_DEPLOYING
81
- SCALING
82
- FAILED_SCALING
83
- COOLDOWN
84
- HOLD
72
+ STATE_STR = [
73
+ 'PENDING',
74
+ 'DEPLOYING',
75
+ 'RUNNING',
76
+ 'UNDEPLOYING',
77
+ 'WARNING',
78
+ 'DONE',
79
+ 'FAILED_UNDEPLOYING',
80
+ 'FAILED_DEPLOYING',
81
+ 'SCALING',
82
+ 'FAILED_SCALING',
83
+ 'COOLDOWN',
84
+ 'HOLD'
85
85
  ]
86
86
 
87
- RECOVER_DEPLOY_STATES = %w[
88
- FAILED_DEPLOYING
89
- DEPLOYING
90
- PENDING
87
+ RECOVER_DEPLOY_STATES = [
88
+ 'FAILED_DEPLOYING',
89
+ 'DEPLOYING',
90
+ 'PENDING'
91
91
  ]
92
92
 
93
- RECOVER_UNDEPLOY_STATES = %w[
94
- FAILED_UNDEPLOYING
95
- UNDEPLOYING
93
+ RECOVER_UNDEPLOY_STATES = [
94
+ 'FAILED_UNDEPLOYING',
95
+ 'UNDEPLOYING'
96
96
  ]
97
97
 
98
- RECOVER_SCALE_STATES = %w[
99
- FAILED_SCALING
100
- SCALING
98
+ RECOVER_SCALE_STATES = [
99
+ 'FAILED_SCALING',
100
+ 'SCALING'
101
101
  ]
102
102
 
103
- VM_FAILURE_STATES = %w[
104
- BOOT_FAILURE
105
- BOOT_MIGRATE_FAILURE
106
- PROLOG_MIGRATE_FAILURE
107
- PROLOG_FAILURE
108
- EPILOG_FAILURE
109
- EPILOG_STOP_FAILURE
110
- EPILOG_UNDEPLOY_FAILURE
111
- PROLOG_MIGRATE_POWEROFF_FAILURE
112
- PROLOG_MIGRATE_SUSPEND_FAILURE
113
- PROLOG_MIGRATE_UNKNOWN_FAILURE
114
- BOOT_UNDEPLOY_FAILURE
115
- BOOT_STOPPED_FAILURE
116
- PROLOG_RESUME_FAILURE
117
- PROLOG_UNDEPLOY_FAILURE
103
+ VM_FAILURE_STATES = [
104
+ 'BOOT_FAILURE',
105
+ 'BOOT_MIGRATE_FAILURE',
106
+ 'PROLOG_MIGRATE_FAILURE',
107
+ 'PROLOG_FAILURE',
108
+ 'EPILOG_FAILURE',
109
+ 'EPILOG_STOP_FAILURE',
110
+ 'EPILOG_UNDEPLOY_FAILURE',
111
+ 'PROLOG_MIGRATE_POWEROFF_FAILURE',
112
+ 'PROLOG_MIGRATE_SUSPEND_FAILURE',
113
+ 'PROLOG_MIGRATE_UNKNOWN_FAILURE',
114
+ 'BOOT_UNDEPLOY_FAILURE',
115
+ 'BOOT_STOPPED_FAILURE',
116
+ 'PROLOG_RESUME_FAILURE',
117
+ 'PROLOG_UNDEPLOY_FAILURE'
118
118
  ]
119
119
 
120
120
  SCALE_WAYS = {
@@ -129,17 +129,17 @@ module OpenNebula
129
129
  # parents: this has only sense in deploy operation
130
130
  # state: this is internal information managed by OneFlow server
131
131
  # vm_template: this will affect scale operation
132
- IMMUTABLE_ATTRS = %w[
133
- cardinality
134
- last_vmname
135
- nodes
136
- parents
137
- state
138
- vm_template
132
+ IMMUTABLE_ATTRS = [
133
+ 'cardinality',
134
+ 'last_vmname',
135
+ 'nodes',
136
+ 'parents',
137
+ 'state',
138
+ 'vm_template'
139
139
  ]
140
140
 
141
141
  # VM information to save in document
142
- VM_INFO = %w[ID UID GID UNAME GNAME NAME]
142
+ VM_INFO = ['ID', 'UID', 'GID', 'UNAME', 'GNAME', 'NAME']
143
143
 
144
144
  LOG_COMP = 'ROL'
145
145
 
@@ -42,64 +42,64 @@ module OpenNebula
42
42
  'HOLD' => 15
43
43
  }
44
44
 
45
- STATE_STR = %w[
46
- PENDING
47
- DEPLOYING
48
- RUNNING
49
- UNDEPLOYING
50
- WARNING
51
- DONE
52
- FAILED_UNDEPLOYING
53
- FAILED_DEPLOYING
54
- SCALING
55
- FAILED_SCALING
56
- COOLDOWN
57
- DEPLOYING_NETS
58
- UNDEPLOYING_NETS
59
- FAILED_DEPLOYING_NETS
60
- FAILED_UNDEPLOYING_NETS
61
- HOLD
45
+ STATE_STR = [
46
+ 'PENDING',
47
+ 'DEPLOYING',
48
+ 'RUNNING',
49
+ 'UNDEPLOYING',
50
+ 'WARNING',
51
+ 'DONE',
52
+ 'FAILED_UNDEPLOYING',
53
+ 'FAILED_DEPLOYING',
54
+ 'SCALING',
55
+ 'FAILED_SCALING',
56
+ 'COOLDOWN',
57
+ 'DEPLOYING_NETS',
58
+ 'UNDEPLOYING_NETS',
59
+ 'FAILED_DEPLOYING_NETS',
60
+ 'FAILED_UNDEPLOYING_NETS',
61
+ 'HOLD'
62
62
  ]
63
63
 
64
- TRANSIENT_STATES = %w[
65
- DEPLOYING
66
- UNDEPLOYING
67
- SCALING
68
- COOLDOWN
69
- DEPLOYING_NETS
70
- UNDEPLOYING_NETS
64
+ TRANSIENT_STATES = [
65
+ 'DEPLOYING',
66
+ 'UNDEPLOYING',
67
+ 'SCALING',
68
+ 'COOLDOWN',
69
+ 'DEPLOYING_NETS',
70
+ 'UNDEPLOYING_NETS'
71
71
  ]
72
72
 
73
- FAILED_STATES = %w[
74
- FAILED_DEPLOYING
75
- FAILED_UNDEPLOYING
76
- FAILED_SCALING
77
- FAILED_DEPLOYING_NETS
78
- FAILED_UNDEPLOYING_NETS
73
+ FAILED_STATES = [
74
+ 'FAILED_DEPLOYING',
75
+ 'FAILED_UNDEPLOYING',
76
+ 'FAILED_SCALING',
77
+ 'FAILED_DEPLOYING_NETS',
78
+ 'FAILED_UNDEPLOYING_NETS'
79
79
  ]
80
80
 
81
- RECOVER_DEPLOY_STATES = %w[
82
- FAILED_DEPLOYING
83
- DEPLOYING
84
- PENDING
81
+ RECOVER_DEPLOY_STATES = [
82
+ 'FAILED_DEPLOYING',
83
+ 'DEPLOYING',
84
+ 'PENDING'
85
85
  ]
86
86
 
87
- RECOVER_UNDEPLOY_STATES = %w[
88
- FAILED_UNDEPLOYING
89
- UNDEPLOYING
90
- FAILED_UNDEPLOYING_NETS
87
+ RECOVER_UNDEPLOY_STATES = [
88
+ 'FAILED_UNDEPLOYING',
89
+ 'UNDEPLOYING',
90
+ 'FAILED_UNDEPLOYING_NETS'
91
91
  ]
92
92
 
93
- RECOVER_SCALE_STATES = %w[
94
- FAILED_SCALING
95
- SCALING
93
+ RECOVER_SCALE_STATES = [
94
+ 'FAILED_SCALING',
95
+ 'SCALING'
96
96
  ]
97
97
 
98
- RECOVER_DEPLOY_NETS_STATES = %w[DEPLOYING_NETS FAILED_DEPLOYING_NETS]
98
+ RECOVER_DEPLOY_NETS_STATES = ['DEPLOYING_NETS', 'FAILED_DEPLOYING_NETS']
99
99
 
100
- RECOVER_UNDEPLOY_NETS_STATES = %w[
101
- UNDEPLOYING_NETS
102
- FAILED_UNDEPLOYING_NETS
100
+ RECOVER_UNDEPLOY_NETS_STATES = [
101
+ 'UNDEPLOYING_NETS',
102
+ 'FAILED_UNDEPLOYING_NETS'
103
103
  ]
104
104
 
105
105
  # List of attributes that can't be changed in update operation
@@ -114,17 +114,17 @@ module OpenNebula
114
114
  # ready_status_gate: it only has sense when deploying, not in running
115
115
  # state: this is internal information managed by OneFlow server
116
116
  # start_time: this is internal information managed by OneFlow server
117
- IMMUTABLE_ATTRS = %w[
118
- custom_attrs
119
- custom_attrs_values
120
- deployment
121
- log
122
- name
123
- networks
124
- networks_values
125
- ready_status_gate
126
- state
127
- start_time
117
+ IMMUTABLE_ATTRS = [
118
+ 'custom_attrs',
119
+ 'custom_attrs_values',
120
+ 'deployment',
121
+ 'log',
122
+ 'name',
123
+ 'networks',
124
+ 'networks_values',
125
+ 'ready_status_gate',
126
+ 'state',
127
+ 'start_time'
128
128
  ]
129
129
 
130
130
  LOG_COMP = 'SER'
@@ -677,7 +677,7 @@ module OpenNebula
677
677
  vnet.each do |_, net|
678
678
  key = net.keys.first
679
679
 
680
- next unless %w[template_id reserve_from].include?(key)
680
+ next unless ['template_id', 'reserve_from'].include?(key)
681
681
 
682
682
  rc = OpenNebula::VirtualNetwork.new_with_id(
683
683
  net['id'],
data/lib/nsx_constants.rb CHANGED
@@ -127,7 +127,7 @@ end
127
127
  }
128
128
  }
129
129
  NSXV_RULE_BASE = 'xxx'
130
- NSX_RULE_IPSEC_PORTS = %w[500 4500]
130
+ NSX_RULE_IPSEC_PORTS = ['500', '4500']
131
131
  # Logical Ports
132
132
  NSXT_LP_BASE = NSXT_BASE + '/logical-ports/'
133
133
  NSXV_LP_BASE = ''
@@ -50,11 +50,11 @@ module OpenNebula
50
50
  },
51
51
  'shutdown_action' => {
52
52
  :type => :string,
53
- :enum => %w[
54
- terminate
55
- terminate-hard
56
- shutdown
57
- shutdown-hard
53
+ :enum => [
54
+ 'terminate',
55
+ 'terminate-hard',
56
+ 'shutdown',
57
+ 'shutdown-hard'
58
58
  ],
59
59
  :required => false
60
60
  },
@@ -84,10 +84,10 @@ module OpenNebula
84
84
  :properties => {
85
85
  'type' => {
86
86
  :type => :string,
87
- :enum => %w[
88
- CHANGE
89
- CARDINALITY
90
- PERCENTAGE_CHANGE
87
+ :enum => [
88
+ 'CHANGE',
89
+ 'CARDINALITY',
90
+ 'PERCENTAGE_CHANGE'
91
91
  ],
92
92
  :required => true
93
93
  },
@@ -133,10 +133,10 @@ module OpenNebula
133
133
  :properties => {
134
134
  'type' => {
135
135
  :type => :string,
136
- :enum => %w[
137
- CHANGE
138
- CARDINALITY
139
- PERCENTAGE_CHANGE
136
+ :enum => [
137
+ 'CHANGE',
138
+ 'CARDINALITY',
139
+ 'PERCENTAGE_CHANGE'
140
140
  ],
141
141
  :required => true
142
142
  },
@@ -172,7 +172,7 @@ module OpenNebula
172
172
  },
173
173
  'deployment' => {
174
174
  :type => :string,
175
- :enum => %w[none straight],
175
+ :enum => ['none', 'straight'],
176
176
  :default => 'none'
177
177
  },
178
178
  'description' => {
@@ -181,11 +181,11 @@ module OpenNebula
181
181
  },
182
182
  'shutdown_action' => {
183
183
  :type => :string,
184
- :enum => %w[
185
- terminate
186
- terminate-hard
187
- shutdown
188
- shutdown-hard
184
+ :enum => [
185
+ 'terminate',
186
+ 'terminate-hard',
187
+ 'shutdown',
188
+ 'shutdown-hard'
189
189
  ],
190
190
  :required => false
191
191
  },
@@ -235,8 +235,8 @@ module OpenNebula
235
235
  # List of attributes that can't be changed in update operation
236
236
  #
237
237
  # registration_time: this is internal info managed by OneFlow server
238
- IMMUTABLE_ATTRS = %w[
239
- registration_time
238
+ IMMUTABLE_ATTRS = [
239
+ 'registration_time'
240
240
  ]
241
241
 
242
242
  def self.init_default_vn_name_template(vn_name_template)
@@ -314,9 +314,9 @@ module OpenNebula::MarketPlaceAppExt
314
314
  # @param image [OpenNebula::Image] Image information
315
315
  def create_vcenter_template(ds, options, template, image = nil)
316
316
  ret = {}
317
- keys = %w[VCENTER_TEMPLATE_REF
318
- VCENTER_CCR_REF
319
- VCENTER_INSTANCE_ID]
317
+ keys = ['VCENTER_TEMPLATE_REF',
318
+ 'VCENTER_CCR_REF',
319
+ 'VCENTER_INSTANCE_ID']
320
320
 
321
321
  if ds['//VCENTER_TEMPLATE_REF']
322
322
  keys.each do |key|
@@ -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
@@ -79,7 +79,7 @@ module OpenNebula::TemplateExt
79
79
  image['STATE'].to_i
80
80
  ]
81
81
 
82
- unless %w[LOCKED READY USED].include?(i_state)
82
+ unless ['LOCKED', 'READY', 'USED'].include?(i_state)
83
83
  logger.fatal "Wrong image state #{i_state}" if logger
84
84
 
85
85
  rollback(ids)
@@ -204,7 +204,7 @@ module OpenNebula::TemplateExt
204
204
  # @param nic [XMLElement] to delete attributes from
205
205
  #-------------------------------------------------------------------
206
206
  def delete_nic_attributes(nic)
207
- %w[NETWORK NETWORK_ID NETWORK_UNAME SECURITY_GROUPS].each do |a|
207
+ ['NETWORK', 'NETWORK_ID', 'NETWORK_UNAME', 'SECURITY_GROUPS'].each do |a|
208
208
  nic.delete_element(a)
209
209
  end
210
210
  end
@@ -47,17 +47,16 @@ module OpenNebula::VirtualMachineExt
47
47
  # @return [Integer, OpenNebula::Error] the new Template ID in case
48
48
  # of success, error otherwise
49
49
  #-------------------------------------------------------------------
50
- REMOVE_VNET_ATTRS = %w[AR_ID BRIDGE CLUSTER_ID IP MAC TARGET NIC_ID
51
- NETWORK_ID VN_MAD SECURITY_GROUPS VLAN_ID
52
- BRIDGE_TYPE]
53
-
54
- REMOVE_IMAGE_ATTRS = %w[DEV_PREFIX SOURCE ORIGINAL_SIZE SIZE
55
- DISK_SNAPSHOT_TOTAL_SIZE DRIVER IMAGE_STATE
56
- SAVE CLONE READONLY PERSISTENT TARGET
57
- ALLOW_ORPHANS CLONE_TARGET CLUSTER_ID
58
- DATASTORE DATASTORE_ID DISK_ID DISK_TYPE
59
- IMAGE_ID IMAGE IMAGE_UNAME IMAGE_UID
60
- LN_TARGET TM_MAD TYPE OPENNEBULA_MANAGED]
50
+ REMOVE_VNET_ATTRS = ['AR_ID', 'BRIDGE', 'CLUSTER_ID', 'IP', 'MAC', 'TARGET', 'NIC_ID',
51
+ 'NETWORK_ID', 'VN_MAD', 'SECURITY_GROUPS', 'VLAN_ID',
52
+ 'BRIDGE_TYPE']
53
+
54
+ REMOVE_IMAGE_ATTRS = ['DEV_PREFIX', 'SOURCE', 'ORIGINAL_SIZE', 'SIZE',
55
+ 'DISK_SNAPSHOT_TOTAL_SIZE', 'DRIVER', 'IMAGE_STATE', 'SAVE',
56
+ 'CLONE', 'READONLY', 'PERSISTENT', 'TARGET', 'ALLOW_ORPHANS',
57
+ 'CLONE_TARGET', 'CLUSTER_ID', 'DATASTORE', 'DATASTORE_ID',
58
+ 'DISK_ID', 'DISK_TYPE', 'IMAGE_ID', 'IMAGE', 'IMAGE_UNAME',
59
+ 'IMAGE_UID', 'LN_TARGET', 'TM_MAD', 'TYPE', 'OPENNEBULA_MANAGED']
61
60
 
62
61
  def save_as_template(name, desc, opts = {})
63
62
  opts = {
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.3'
80
+ VERSION = '6.4.5'
81
81
  end
@@ -1126,7 +1126,7 @@ end
1126
1126
  when OPAQUE_CARD.to_s
1127
1127
  # Select only Opaque Networks
1128
1128
  opaque_networks = @item.network.select do |net|
1129
- RbVmomi::VIM::OpaqueNetwork == net.class
1129
+ net.class == RbVmomi::VIM::OpaqueNetwork
1130
1130
  end
1131
1131
  opaque_network = opaque_networks.find do |opn|
1132
1132
  backing.opaqueNetworkId == opn.summary.opaqueNetworkId
@@ -1296,7 +1296,7 @@ end
1296
1296
  when OPAQUE_CARD.to_s
1297
1297
  # Select only Opaque Networks
1298
1298
  opaque_networks = @item.network.select do |net|
1299
- RbVmomi::VIM::OpaqueNetwork == net.class
1299
+ net.class == RbVmomi::VIM::OpaqueNetwork
1300
1300
  end
1301
1301
  opaque_network = opaque_networks.find do |opn|
1302
1302
  nic.backing.opaqueNetworkId ==
@@ -3302,6 +3302,12 @@ end
3302
3302
  @item.MarkAsTemplate
3303
3303
  end
3304
3304
 
3305
+ def mark_as_virtual_machine
3306
+ @item.MarkAsVirtualMachine(
3307
+ :pool => cluster['resourcePool']
3308
+ )
3309
+ end
3310
+
3305
3311
  def reset
3306
3312
  @item.ResetVM_Task.wait_for_completion
3307
3313
  end
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.3
4
+ version: 6.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenNebula
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-30 00:00:00.000000000 Z
11
+ date: 2023-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri