diff --git a/src/vmm_mad/remotes/lib/lxd/container.rb b/src/vmm_mad/remotes/lib/lxd/container.rb index ae75eadca9..c8e9a0dab6 100644 --- a/src/vmm_mad/remotes/lib/lxd/container.rb +++ b/src/vmm_mad/remotes/lib/lxd/container.rb @@ -170,13 +170,24 @@ class Container @lxc = @client.get("#{CONTAINERS}/#{name}")['metadata'] end - # Runs command inside container + # Runs command inside container using the LXD CLI # @param command [String] to execute through lxc exec def exec(command) cmd = "#{@lxc_command} exec #{@one.vm_name} -- #{command}" Command.execute(cmd, true) end + # Runs command inside container using REST. Execution isn't managed. + # @param full command [String] to execute + def exec_rest(command) + body = { 'command' => command.split(' '), + 'wait-for-websocket' => false, + 'record-output' => false, + 'interactive' => false } + + @client.post("#{CONTAINERS}/#{name}/exec", body) + end + def show_log cmd = "#{@lxc_command} info --show-log #{@lxc['name']}" rc, o, e = Command.execute(cmd, false) @@ -325,7 +336,7 @@ class Container csrc = @lxc['devices']['context']['source'].clone - @lxc['devices'].delete('context')['source'] + @lxc['devices'].delete('context') update @@ -374,7 +385,7 @@ class Container container devices\n#{@lxc['devices']}" end - @lxc['devices'].delete(disk_name)['source'] + @lxc['devices'].delete(disk_name) update diff --git a/src/vmm_mad/remotes/lxd/reconfigure b/src/vmm_mad/remotes/lxd/reconfigure index b3b83745a1..55c4a92f12 100755 --- a/src/vmm_mad/remotes/lxd/reconfigure +++ b/src/vmm_mad/remotes/lxd/reconfigure @@ -40,6 +40,4 @@ container = Container.get(vm_name, xml, client) raise 'Failed to attach context' unless container.attach_context -rc, _out, err = container.exec('service one-context-reconfigure restart') - -OpenNebula.log_error "Failed to run recontextualization service \n#{err}" unless rc.zero? +container.exec_rest('service one-context-reconfigure restart')