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

development: Add 1810 workaround for snap issue

This commit is contained in:
Daniel Clavijo Coca 2018-12-21 13:41:46 -06:00 committed by Ruben S. Montero
parent ff0e72391d
commit 82551a7059
2 changed files with 13 additions and 6 deletions

View File

@ -53,11 +53,6 @@ module Command
execute(cmd, lock) unless running?(cmd.split[0])
end
def self.lxc_execute(lxd_id, cmd)
cmd = "lxc exec #{lxd_id} -- #{cmd}"
execute(cmd, true)
end
# Return true if command is running
def self.running?(command)
!`ps --noheaders -C #{command}`.empty?

View File

@ -35,6 +35,7 @@ class Container
# Class Constants API and Containers Paths
#---------------------------------------------------------------------------
CONTAINERS = 'containers'.freeze
LXC_COMMAND = 'lxc'
#---------------------------------------------------------------------------
# Methods to access container attributes
@ -161,7 +162,18 @@ class Container
# Runs command inside container
# @param command [String] to execute through lxc exec
def exec(command)
Command.lxc_execute(name, command)
cmd = "#{LXC_COMMAND} exec #{@one.vm_name} -- #{command}"
rc, o, e = Command.execute(cmd, true)
# TODO this should be removed when Snap bug is fixed
# Snap patch
rc, o, e = Command.execute("sudo #{cmd}", true) if e.include?('cannot create user data directory:')
return [rc, o, e] unless rc != 0
OpenNebula.log_error("#{__method__}: Failed to run command #{cmd}: #{e}")
[rc, o, e]
end
#---------------------------------------------------------------------------