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:
parent
80a742b0e0
commit
57a69c580d
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user