opennebula 6.6.2 → 6.7.80.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
  SHA256:
3
- metadata.gz: d0911e0ad571781c4b94ee39d8459948d92ef8eb0d95aa9e06387bf402d2abd9
4
- data.tar.gz: 98c66b223bdf54a82a8d4524288067b9b41045781ff90d4828328db18066d67f
3
+ metadata.gz: 1c791a9b245b95bd0627930d9f17845003130bec8aba4e363997e583725399b0
4
+ data.tar.gz: bef534bfd10f3b9453101a4d639d6ad2a79a2c70b2b34e44c8502d51b83b25c4
5
5
  SHA512:
6
- metadata.gz: 9fc7ce19570b9ee1c5b3047e4d0503bd7028b4cee025fd37b8c42526fbe440fb0398ca2c9ba7a803e524e4fd9415f54c971e6be8aaa16a3513df91677cb1f557
7
- data.tar.gz: 6e39b6567ce933244ddcedb2700abb82e002ccf3ed6199b78cccd064330fd93e7774d44defa7d6901b6a9d08ffd0abc798cd17f1706088f24897d7efcaaaeef5
6
+ metadata.gz: 7c5b274de24813610fe09de2db614024f719d67b4987e6020b6cf403998f0386c866534f4db702287bb5f9e6ae8943e4ad489f3efad2334b57a4cf73362638ef
7
+ data.tar.gz: 0420c6b94f5ad7df4270cd76ff3525d529fa69f82dbaf6aa408bd8bf2d06002832acf5e9e9ed06ee07e7bd4d2b8ca4cd37c5bb557c9898252588c9434c923b4e
@@ -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
@@ -0,0 +1,111 @@
1
+ # -------------------------------------------------------------------------- #
2
+ # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
3
+ # #
4
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
+ # not use this file except in compliance with the License. You may obtain #
6
+ # a copy of the License at #
7
+ # #
8
+ # http://www.apache.org/licenses/LICENSE-2.0 #
9
+ # #
10
+ # Unless required by applicable law or agreed to in writing, software #
11
+ # distributed under the License is distributed on an "AS IS" BASIS, #
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
13
+ # See the License for the specific language governing permissions and #
14
+ # limitations under the License. #
15
+ # -------------------------------------------------------------------------- #
16
+
17
+ # rubocop:disable Lint/MissingCopEnableDirective
18
+ # rubocop:disable Layout/FirstArgumentIndentation
19
+ # rubocop:disable Layout/FirstHashElementIndentation
20
+ # rubocop:disable Layout/HashAlignment
21
+ # rubocop:disable Layout/HeredocIndentation
22
+ # rubocop:disable Layout/IndentationWidth
23
+ # rubocop:disable Style/HashSyntax
24
+ # rubocop:disable Style/ParallelAssignment
25
+
26
+ require 'CommandManager'
27
+
28
+ # This helper module introduces a common routine that synchronizes
29
+ # the "remotes".
30
+ class HostSyncManager
31
+
32
+ def initialize(one_config = nil)
33
+ one_location = ENV['ONE_LOCATION']&.delete("'")
34
+ if one_location.nil?
35
+ @one_config_path = '/var/lib/one/config'
36
+ @local_scripts_base_path = '/var/lib/one/remotes'
37
+ else
38
+ @one_config_path = one_location + '/var/config'
39
+ @local_scripts_base_path = one_location + '/var/remotes'
40
+ end
41
+
42
+ # Do a simple parsing of the config file unless the values
43
+ # are already provided. NOTE: We don't care about "arrays" here..
44
+ one_config ||= File.read(@one_config_path).lines.each_with_object({}) \
45
+ do |line, object|
46
+ key, value = line.split('=').map(&:strip)
47
+ object[key.upcase] = value
48
+ end
49
+
50
+ @remote_scripts_base_path = one_config['SCRIPTS_REMOTE_DIR']
51
+ @remote_scripts_base_path&.delete!("'")
52
+ end
53
+
54
+ def update_remotes(hostname, logger = nil, copy_method = :rsync, subset = nil)
55
+ sources = '.'
56
+
57
+ if subset && copy_method == :rsync
58
+ # Make sure all files in the subset exist (and are relative).
59
+ subset.each do |path|
60
+ File.realpath path, @local_scripts_base_path
61
+ end
62
+
63
+ sources = subset.join(' ')
64
+ end
65
+
66
+ assemble_cmd = lambda do |steps|
67
+ "exec 2>/dev/null; #{steps.join(' && ')}"
68
+ end
69
+
70
+ case copy_method
71
+ when :ssh
72
+ mkdir_cmd = assemble_cmd.call [
73
+ "rm -rf '#{@remote_scripts_base_path}'/",
74
+ "mkdir -p '#{@remote_scripts_base_path}'/"
75
+ ]
76
+
77
+ sync_cmd = assemble_cmd.call [
78
+ "cd '#{@local_scripts_base_path}'/",
79
+ "scp -rp #{sources} " \
80
+ "'#{hostname}':'#{@remote_scripts_base_path}'/"
81
+ ]
82
+ when :rsync
83
+ mkdir_cmd = assemble_cmd.call [
84
+ "mkdir -p '#{@remote_scripts_base_path}'/"
85
+ ]
86
+
87
+ sync_cmd = assemble_cmd.call [
88
+ "cd '#{@local_scripts_base_path}'/",
89
+ "rsync -LRaz --delete #{sources} " \
90
+ "'#{hostname}':'#{@remote_scripts_base_path}'/"
91
+ ]
92
+ end
93
+
94
+ cmd = SSHCommand.run(mkdir_cmd, hostname, logger)
95
+ return cmd.code if error?(cmd)
96
+
97
+ cmd = LocalCommand.run(sync_cmd, logger)
98
+ return cmd.code if error?(cmd)
99
+
100
+ 0
101
+ end
102
+
103
+ def error?(cmd)
104
+ return false if cmd.code == 0
105
+
106
+ STDERR.puts cmd.stderr
107
+ STDOUT.puts cmd.stdout
108
+ true
109
+ end
110
+
111
+ end
@@ -51,7 +51,7 @@ end
51
51
  module CloudClient
52
52
 
53
53
  # OpenNebula version
54
- VERSION = '6.6.2'
54
+ VERSION = '6.7.80'
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"
@@ -73,7 +73,8 @@ module OpenNebula
73
73
  "MARKETPLACE" => 0x8000000000000,
74
74
  "MARKETPLACEAPP"=> 0x10000000000000,
75
75
  "VMGROUP" => 0x20000000000000,
76
- "VNTEMPLATE" => 0x40000000000000
76
+ "VNTEMPLATE" => 0x40000000000000,
77
+ "BACKUPJOB" =>0x100000000000000
77
78
  }
78
79
 
79
80
  RIGHTS =
@@ -0,0 +1,250 @@
1
+ # -------------------------------------------------------------------------- #
2
+ # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
3
+ # #
4
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
+ # not use this file except in compliance with the License. You may obtain #
6
+ # a copy of the License at #
7
+ # #
8
+ # http://www.apache.org/licenses/LICENSE-2.0 #
9
+ # #
10
+ # Unless required by applicable law or agreed to in writing, software #
11
+ # distributed under the License is distributed on an "AS IS" BASIS, #
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
13
+ # See the License for the specific language governing permissions and #
14
+ # limitations under the License. #
15
+ #--------------------------------------------------------------------------- #
16
+
17
+ require 'opennebula/lockable_ext'
18
+ require 'opennebula/pool_element'
19
+
20
+ module OpenNebula
21
+
22
+ # Class for representing a Backup Job object
23
+ class BackupJob < PoolElement
24
+
25
+ #######################################################################
26
+ # Constants and Class Methods
27
+ #######################################################################
28
+
29
+ BACKUPJOB_METHODS = {
30
+ :allocate => 'backupjob.allocate',
31
+ :info => 'backupjob.info',
32
+ :update => 'backupjob.update',
33
+ :delete => 'backupjob.delete',
34
+ :chown => 'backupjob.chown',
35
+ :chmod => 'backupjob.chmod',
36
+ :clone => 'backupjob.clone',
37
+ :rename => 'backupjob.rename',
38
+ :lock => 'backupjob.lock',
39
+ :unlock => 'backupjob.unlock',
40
+ :backup => 'backupjob.backup',
41
+ :cancel => 'backupjob.cancel',
42
+ :retry => 'backupjob.retry',
43
+ :priority => 'backupjob.priority',
44
+ :schedadd => 'backupjob.schedadd',
45
+ :scheddelete => 'backupjob.scheddelete',
46
+ :schedupdate => 'backupjob.schedupdate'
47
+ }
48
+
49
+ # Creates a BackupJob description with just its identifier
50
+ # this method should be used to create plain BackupJob objects.
51
+ # +id+ the id of the user
52
+ #
53
+ # Example:
54
+ # bj = BackupJob.new(BackupJob.build_xml(3),rpc_client)
55
+ #
56
+ def self.build_xml(pe_id = nil)
57
+ if pe_id
58
+ obj_xml = "<BACKUPJOB><ID>#{pe_id}</ID></BACKUPJOB>"
59
+ else
60
+ obj_xml = '<BACKUPJOB></BACKUPJOB>'
61
+ end
62
+
63
+ XMLElement.build_xml(obj_xml, 'BACKUPJOB')
64
+ end
65
+
66
+ # Class constructor
67
+ def initialize(xml, client)
68
+ LockableExt.make_lockable(self, BACKUPJOB_METHODS)
69
+
70
+ super(xml, client)
71
+
72
+ @client = client
73
+ end
74
+
75
+ #######################################################################
76
+ # XML-RPC Methods for the Backup Job Object
77
+ #######################################################################
78
+
79
+ # Retrieves the information of the given Backup Job.
80
+ def info
81
+ return Error.new('ID not defined') unless @pe_id
82
+
83
+ rc = @client.call(BACKUPJOB_METHODS[:info], @pe_id)
84
+
85
+ if !OpenNebula.is_error?(rc)
86
+ initialize_xml(rc, 'BACKUPJOB')
87
+ rc = nil
88
+
89
+ @pe_id = self['ID'].to_i if self['ID']
90
+ @name = self['NAME'] if self['NAME']
91
+ end
92
+
93
+ rc
94
+ end
95
+
96
+ alias info! info
97
+
98
+ # Allocates a new Backup Job in OpenNebula
99
+ #
100
+ # @param description [String] The contents of the BackupJob.
101
+ #
102
+ # @return [nil, OpenNebula::Error] nil in case of success, Error
103
+ # otherwise
104
+ def allocate(description)
105
+ super(BACKUPJOB_METHODS[:allocate], description)
106
+ end
107
+
108
+ # Deletes the BackupJob
109
+ #
110
+ # @return [nil, OpenNebula::Error] nil in case of success, Error
111
+ # otherwise
112
+ def delete
113
+ call(BACKUPJOB_METHODS[:delete], @pe_id)
114
+ end
115
+
116
+ # Replaces the Backup Job contents
117
+ #
118
+ # @param new_template [String] New template contents
119
+ # @param append [true, false] True to append new attributes instead of
120
+ # replace the whole template
121
+ #
122
+ # @return [nil, OpenNebula::Error] nil in case of success, Error
123
+ # otherwise
124
+ def update(new_template, append = false)
125
+ super(BACKUPJOB_METHODS[:update], new_template, append ? 1 : 0)
126
+ end
127
+
128
+ # Changes the owner/group
129
+ # uid:: _Integer_ the new owner id. Set to -1 to leave the current one
130
+ # gid:: _Integer_ the new group id. Set to -1 to leave the current one
131
+ # [return] nil in case of success or an Error object
132
+ def chown(uid, gid)
133
+ super(BACKUPJOB_METHODS[:chown], uid, gid)
134
+ end
135
+
136
+ # Changes the Backup Job permissions.
137
+ #
138
+ # @param octet [String] Permissions octed , e.g. 640
139
+ #
140
+ # @return [nil, OpenNebula::Error] nil in case of success, Error
141
+ # otherwise
142
+ def chmod_octet(octet)
143
+ super(BACKUPJOB_METHODS[:chmod], octet)
144
+ end
145
+
146
+ # Changes the Backup Job permissions.
147
+ # Each [Integer] argument must be 1 to allow, 0 deny, -1 do not change
148
+ #
149
+ # @return [nil, OpenNebula::Error] nil in case of success, Error
150
+ # otherwise
151
+ # rubocop:disable Metrics/ParameterLists
152
+ def chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u,
153
+ other_m, other_a)
154
+ call(BACKUPJOB_METHODS[:chmod], @pe_id, owner_u, owner_m, owner_a, group_u,
155
+ group_m, group_a, other_u, other_m, other_a)
156
+ end
157
+ # rubocop:enable Metrics/ParameterLists
158
+
159
+ # Renames this Backup Job
160
+ #
161
+ # @param name [String] New name for the Backup Job.
162
+ #
163
+ # @return [nil, OpenNebula::Error] nil in case of success, Error
164
+ # otherwise
165
+ def rename(name)
166
+ call(BACKUPJOB_METHODS[:rename], @pe_id, name)
167
+ end
168
+
169
+ # Starts the Backup Job
170
+ #
171
+ # @return [nil, OpenNebula::Error] nil in case of success, Error
172
+ # otherwise
173
+ def backup
174
+ call(BACKUPJOB_METHODS[:backup], @pe_id)
175
+ end
176
+
177
+ # Cancel pending Backup Job, removing VMs from waiting list
178
+ #
179
+ # @return [nil, OpenNebula::Error] nil in case of success, Error
180
+ # otherwise
181
+ def cancel
182
+ call(BACKUPJOB_METHODS[:cancel], @pe_id)
183
+ end
184
+
185
+ # Retry backup for VMs in error list
186
+ #
187
+ # @return [nil, OpenNebula::Error] nil in case of success, Error
188
+ # otherwise
189
+ def retry
190
+ call(BACKUPJOB_METHODS[:retry], @pe_id)
191
+ end
192
+
193
+ # Change priority of Backup Job
194
+ #
195
+ # @return [nil, OpenNebula::Error] nil in case of success, Error
196
+ # otherwise
197
+ def priority(pr)
198
+ call(BACKUPJOB_METHODS[:priority], @pe_id, pr)
199
+ end
200
+
201
+ # Add Scheduled action
202
+ #
203
+ # @param sched_template [String] Template with SCHED_ACTIONs
204
+ # @return [nil, OpenNebula::Error] nil in case of success, Error
205
+ # otherwise
206
+ def sched_action_add(sched_template)
207
+ call(BACKUPJOB_METHODS[:schedadd], @pe_id, sched_template)
208
+ end
209
+
210
+ # Delete Scheduled Action
211
+ #
212
+ # @param sched_id [Int] id of the SCHED_ACTION
213
+ # @return [nil, OpenNebula::Error] nil in case of success, Error
214
+ # otherwise
215
+ def sched_action_delete(sched_id)
216
+ call(BACKUPJOB_METHODS[:scheddelete], @pe_id, sched_id.to_i)
217
+ end
218
+
219
+ # Update Scheduled Action
220
+ #
221
+ # @param sched_id [Int] id of the SCHED_ACTION
222
+ # @param sched_template [String] Template containing a SCHED_ACTION
223
+ # @return [nil, OpenNebula::Error] nil in case of success, Error
224
+ # otherwise
225
+ def sched_action_update(sched_id, sched_template)
226
+ call(BACKUPJOB_METHODS[:schedupdate], @pe_id,
227
+ sched_id.to_i, sched_template)
228
+ end
229
+
230
+ #######################################################################
231
+ # Helpers to get Template information
232
+ #######################################################################
233
+
234
+ # Returns the group identifier
235
+ # [return] _Integer_ the element's group ID
236
+ def gid
237
+ self['GID'].to_i
238
+ end
239
+
240
+ def owner_id
241
+ self['UID'].to_i
242
+ end
243
+
244
+ def public?
245
+ self['PERMISSIONS/GROUP_U'] == '1' || self['PERMISSIONS/OTHER_U'] == '1'
246
+ end
247
+
248
+ end
249
+
250
+ end
@@ -0,0 +1,82 @@
1
+ # -------------------------------------------------------------------------- #
2
+ # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
3
+ # #
4
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
+ # not use this file except in compliance with the License. You may obtain #
6
+ # a copy of the License at #
7
+ # #
8
+ # http://www.apache.org/licenses/LICENSE-2.0 #
9
+ # #
10
+ # Unless required by applicable law or agreed to in writing, software #
11
+ # distributed under the License is distributed on an "AS IS" BASIS, #
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
13
+ # See the License for the specific language governing permissions and #
14
+ # limitations under the License. #
15
+ #--------------------------------------------------------------------------- #
16
+
17
+ require 'opennebula/pool'
18
+
19
+ module OpenNebula
20
+
21
+ # Class representing a Backup Job pool
22
+ class BackupJobPool < Pool
23
+
24
+ #######################################################################
25
+ # Constants and Class attribute accessors
26
+ #######################################################################
27
+
28
+ BACKUPJOB_POOL_METHODS = {
29
+ :info => 'backupjobpool.info'
30
+ }
31
+
32
+ #######################################################################
33
+ # Class constructor & Pool Methods
34
+ #######################################################################
35
+
36
+ # +client+ a Client object that represents an XML-RPC connection
37
+ # +user_id+ used to refer to a Pool with Templates from that user
38
+ def initialize(client, user_id = -1)
39
+ super('BACKUPJOB_POOL', 'BACKUPJOB', client)
40
+
41
+ @user_id = user_id
42
+ end
43
+
44
+ # Factory method to create Backup Job objects
45
+ def factory(element_xml)
46
+ OpenNebula::BackupJob.new(element_xml, @client)
47
+ end
48
+
49
+ #######################################################################
50
+ # XML-RPC Methods for the Template Object
51
+ #######################################################################
52
+
53
+ # Retrieves all or part of the Templates in the pool.
54
+ def info(*args)
55
+ case args.size
56
+ when 0
57
+ info_filter(BACKUPJOB_POOL_METHODS[:info], @user_id, -1, -1)
58
+ when 3
59
+ info_filter(BACKUPJOB_POOL_METHODS[:info], args[0], args[1], args[2])
60
+ end
61
+ end
62
+
63
+ def info_all
64
+ super(BACKUPJOB_POOL_METHODS[:info])
65
+ end
66
+
67
+ def info_mine
68
+ super(BACKUPJOB_POOL_METHODS[:info])
69
+ end
70
+
71
+ def info_group
72
+ super(BACKUPJOB_POOL_METHODS[:info])
73
+ end
74
+
75
+ alias info! info
76
+ alias info_all! info_all
77
+ alias info_mine! info_mine
78
+ alias info_group! info_group
79
+
80
+ end
81
+
82
+ end
@@ -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"
@@ -37,7 +37,7 @@ module OpenNebula
37
37
  SELF = -1
38
38
 
39
39
  # Default resource ACL's for group users (create)
40
- GROUP_DEFAULT_ACLS = "VM+IMAGE+TEMPLATE+DOCUMENT+SECGROUP+VROUTER+VMGROUP"
40
+ GROUP_DEFAULT_ACLS = "VM+IMAGE+TEMPLATE+DOCUMENT+SECGROUP+VROUTER+VMGROUP+BACKUPJOB"
41
41
 
42
42
  # The default view for group and group admins, must be defined in
43
43
  # sunstone_views.yaml
@@ -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
 
@@ -125,6 +125,7 @@ module OpenNebula::LockableExt
125
125
  def self.lockable?(obj)
126
126
  # Lockable classes
127
127
  lockable = [
128
+ OpenNebula::BackupJob,
128
129
  OpenNebula::Document,
129
130
  OpenNebula::Hook,
130
131
  OpenNebula::Image,