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

F #5177: Compatibility with existing containers

(cherry picked from commit 826d5e9af064aa0d945f2d5cae90f2bdfe394df6)
This commit is contained in:
Ruben S. Montero 2020-11-17 13:26:15 +01:00
parent 80a742b0e0
commit 57a69c580d
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
2 changed files with 13 additions and 2 deletions

View File

@ -497,7 +497,7 @@ class Container
container_key = 'user.xml' # TODO: lxdrc ?
@lxc['config'].update(container_key => Base64.encode64(one_xml))
@lxc['config'].update(container_key => Base64.strict_encode64(one_xml))
end
private

View File

@ -23,6 +23,15 @@ require 'base64'
require_relative '../../scripts_common'
# Ref: https://rgxdb.com/r/1NUN74O6
def base64?(str)
b64_rexp = %r{^(?:[a-zA-Z0-9+/]{4})*(?:|(?:[a-zA-Z0-9+/]{3}=)|(?:[a-zA-Z0-9+/]{2}==)|(?:[a-zA-Z0-9+/]{1}===))$}
b64_rexp.match?(str.strip)
rescue StandardError
false
end
# ------------------------------------------------------------------------------
# Action Arguments, STDIN doesn't include XML description of the OpenNebula VM
# ------------------------------------------------------------------------------
@ -31,7 +40,9 @@ vm_name = ARGV[0]
client = LXDClient.new
container = Container.get(vm_name, nil, client)
xml = Base64.decode64(container.config['user.xml'])
xml = container.config['user.xml']
xml = Base64.decode64(xml) if base64?(xml)
container = Container.get(vm_name, xml, client)
force = false