Skip to content

Commit

Permalink
B #3189: Add alternative reboot for LXD
Browse files Browse the repository at this point in the history
  • Loading branch information
dann1 committed Aug 18, 2019
1 parent 707f03d commit c92fbf0
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 56 deletions.
146 changes: 92 additions & 54 deletions src/vmm_mad/exec/one_vmm_exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -390,32 +390,32 @@ def deploy(id, drv_message)
end

steps.concat([
# Execute pre-boot networking setup
{
:driver => :vnm,
:action => :pre
},
# Boot the Virtual Machine
{
:driver => :vmm,
:action => :deploy,
:parameters => [dfile, :host],
:stdin => domain
},
# Execute post-boot networking setup
{
:driver => :vnm,
:action => :post,
:parameters => [:deploy_info],
:fail_actions => [
{
:driver => :vmm,
:action => :cancel,
:parameters => [:deploy_info, :host]
}
]
}
])
# Execute pre-boot networking setup
{
:driver => :vnm,
:action => :pre
},
# Boot the Virtual Machine
{
:driver => :vmm,
:action => :deploy,
:parameters => [dfile, :host],
:stdin => domain
},
# Execute post-boot networking setup
{
:driver => :vnm,
:action => :post,
:parameters => [:deploy_info],
:fail_actions => [
{
:driver => :vmm,
:action => :cancel,
:parameters => [:deploy_info, :host]
}
]
}
])

action.run(steps)
end
Expand Down Expand Up @@ -479,31 +479,31 @@ def restore(id, drv_message)
action = VmmAction.new(self, id, :restore, drv_message)

steps.concat([
# Execute pre-boot networking setup
{
:driver => :vnm,
:action => :pre
},
# Restore the Virtual Machine from checkpoint
{
:driver => :vmm,
:action => :restore,
:parameters => [:checkpoint_file, :host, :deploy_id]
},
# Execute post-boot networking setup
{
:driver => :vnm,
:action => :post,
:parameters => [:deploy_id],
:fail_actions => [
{
:driver => :vmm,
:action => :cancel,
:parameters => [:deploy_id, :host]
}
]
}
])
# Execute pre-boot networking setup
{
:driver => :vnm,
:action => :pre
},
# Restore the Virtual Machine from checkpoint
{
:driver => :vmm,
:action => :restore,
:parameters => [:checkpoint_file, :host, :deploy_id]
},
# Execute post-boot networking setup
{
:driver => :vnm,
:action => :post,
:parameters => [:deploy_id],
:fail_actions => [
{
:driver => :vmm,
:action => :cancel,
:parameters => [:deploy_id, :host]
}
]
}
])

action.run(steps)
end
Expand Down Expand Up @@ -593,11 +593,49 @@ def poll(id, drv_message)
:stdin => xml_data)
end

#
# REBOOT action, reboots a running VM
#
def reboot(id, drv_message)
restart(id, drv_message, :reboot)
if @hypervisor == 'lxd'
reboot_lxd(id, drv_message)
else
restart(id, drv_message, :reboot)
end
end

def reboot_lxd(id, drv_message)
action = VmmAction.new(self, id, :reboot, drv_message)

reboot_step = {
:driver => :vmm,
:action => :reboot,
:parameters => [:deploy_id, :host]
}
steps = [
reboot_step,
{
:driver => :vnm,
:action => :clean
},
{
:driver => :vnm,
:action => :pre
},
reboot_step,
{
:driver => :vnm,
:action => :post,
:parameters => [:deploy_info],
:fail_actions => [
{
:driver => :vmm,
:action => :cancel,
:parameters => [:deploy_info, :host]
}
]
}
]

action.run(steps)
end

#
Expand Down
12 changes: 10 additions & 2 deletions src/vmm_mad/remotes/lxd/reboot
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,13 @@ container = Container.get(vm_name, container.config['user.xml'], client)
# ------------------------------------------------------------------------------
# Stop the container, start it
# ------------------------------------------------------------------------------
container.check_stop
container.start
case container.config['user.reboot_state']
when 'STOPPED'
container.start
container.config['user.reboot_state'] = 'RUNNING'
else
container.check_stop
container.config['user.reboot_state'] = 'STOPPED'
end

container.update

0 comments on commit c92fbf0

Please sign in to comment.