Skip to content

Commit

Permalink
Implement :reboot_guest for VM
Browse files Browse the repository at this point in the history
  • Loading branch information
matobet committed Jun 23, 2017
1 parent 4d39634 commit 989b055
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ def shutdown_guest(operation)
rescue Ovirt::VmIsNotRunning
end

def reboot_guest(operation)
operation.with_provider_object(&:reboot)
rescue Ovirt::VmIsNotRunning
end

def start_clone(source, clone_options, phase_context)
source.with_provider_object do |rhevm_template|
vm = rhevm_template.create_vm(clone_options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ def shutdown_guest(operation)
rescue OvirtSDK4::Error
end

def reboot_guest(operation)
operation.with_provider_object(VERSION_HASH, &:reboot)
rescue OvirtSDK4::Error
end

def start_clone(source, clone_options, phase_context)
source.with_provider_object(VERSION_HASH) do |rhevm_template|
vm = rhevm_template.create_vm(clone_options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,18 @@ module ManageIQ::Providers::Redhat::InfraManager::Vm::Operations::Guest
unsupported_reason_add(:shutdown_guest, unsupported_reason(:control)) unless supports_control?
unsupported_reason_add(:shutdown_guest, _("The VM is not powered on")) unless current_state == "on"
end

supports :reboot_guest do
unsupported_reason_add(:reboot_guest, unsupported_reason(:control)) unless supports_control?
unsupported_reason_add(:reboot_guest, _("The VM is not powered on")) unless current_state == "on"
end
end

def raw_shutdown_guest
ext_management_system.ovirt_services.shutdown_guest(self)
end

def raw_reboot_guest
ext_management_system.ovirt_services.reboot_guest(self)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

context("with :reboot_guest") do
let(:state) { :reboot_guest }
include_examples "Vm operation is not available"
include_examples 'Vm operation is available when powered on'
end

context("with :reset") do
Expand Down

0 comments on commit 989b055

Please sign in to comment.