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

M #-: Save VM XML in base64

Co-authored-by: Daniel Clavijo Coca <dclavijo@opennebula.io>
This commit is contained in:
Daniel Clavijo Coca 2020-11-17 06:08:34 -06:00 committed by GitHub
parent 76636eeae1
commit 5d98f40a87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 4 deletions

View File

@ -227,7 +227,7 @@ class Container
begin
stop(:force => force)
rescue => e
rescue StandardError => e
OpenNebula.log_error "LXD Error: #{e}"
real_status = 'Unknown'
@ -243,7 +243,7 @@ class Container
begin
stop(:force => true) if real_status == 'Running'
rescue => e
rescue StandardError => e
error = "LXD Error: Cannot shut down container #{e}"
OpenNebula.log_error error
@ -491,6 +491,15 @@ class Container
@lxc['config']['user.one_status'] == '0'
end
# Intended to save the container xml
def save_xml(one_xml)
require 'base64'
container_key = 'user.xml' # TODO: lxdrc ?
@lxc['config'].update(container_key => Base64.encode64(one_xml))
end
private
def idmaps_file

View File

@ -83,7 +83,7 @@ end
#-------------------------------------------------------------------------------
# Updates container configuration with the OpenNebulaVM description
# ------------------------------------------------------------------------------
container.config.update('user.xml' => xml)
container.save_xml(xml)
container.transition_end unless container.wild?
container.update

View File

@ -19,6 +19,7 @@
$LOAD_PATH.unshift File.dirname(__FILE__)
require 'container'
require 'base64'
require_relative '../../scripts_common'
@ -29,7 +30,9 @@ vm_name = ARGV[0]
client = LXDClient.new
container = Container.get(vm_name, nil, client)
container = Container.get(vm_name, container.config['user.xml'], client)
xml = Base64.decode64(container.config['user.xml'])
container = Container.get(vm_name, xml, client)
force = false
force = true if ARGV[-1] == '-f'