Skip to content

Commit

Permalink
B #3390: Use LXD REST exec on reconfigure. Update odd hash deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
dann1 authored and rsmontero committed Jun 11, 2019
1 parent 4dd138d commit 0355990
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
17 changes: 14 additions & 3 deletions src/vmm_mad/remotes/lib/lxd/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,24 @@ def get_metadata
@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)
Expand Down Expand Up @@ -325,7 +336,7 @@ def detach_context

csrc = @lxc['devices']['context']['source'].clone

@lxc['devices'].delete('context')['source']
@lxc['devices'].delete('context')

update

Expand Down Expand Up @@ -374,7 +385,7 @@ def detach_disk
container devices\n#{@lxc['devices']}"
end

@lxc['devices'].delete(disk_name)['source']
@lxc['devices'].delete(disk_name)

update

Expand Down
4 changes: 1 addition & 3 deletions src/vmm_mad/remotes/lxd/reconfigure
Original file line number Diff line number Diff line change
Expand Up @@ -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')

0 comments on commit 0355990

Please sign in to comment.