1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

F #5228: add support for LXC raw section (#923)

This commit is contained in:
Christian González 2021-03-07 23:37:49 +01:00 committed by GitHub
parent 9e16e6864a
commit 011f584d18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -123,7 +123,8 @@ class LXCVM < OpenNebulaVM
"g 0 #{@lxcrc[:id_map]} #{@lxcrc[:max_map]}"]
# rubocop:enable Layout/LineLength
hash_to_lxc(lxc)
# hash_to_lxc values should prevail over raw section values
hash_to_lxc(parse_raw.merge(lxc))
end
# Returns an Array of Disk objects, each one represents an OpenNebula DISK
@ -171,6 +172,37 @@ class LXCVM < OpenNebulaVM
lxc
end
def parse_raw
raw_map = {}
begin
return raw_map if @xml['//RAW/TYPE'].downcase != 'lxc'
# only add valid lxc configuration statements
regex = /^(lxc\.(?:[a-zA-Z0-9]+\.)*[a-zA-Z0-9]+\s*)=(.*)$/
@xml['//RAW/DATA'].each_line do |l|
l.strip!
match = l.match(regex)
next if match.nil?
key = match[1].strip
value = match[2].strip
if !raw_map[key].nil?
raw_map[key] = value
else
raw_map[key] = Array(raw_map[key]) << value
end
end
rescue StandardError
end
raw_map
end
end
# ------------------------------------------------------------------------------