Skip to content

Commit

Permalink
Merge pull request #263 from Dhamo1107/vm_restart
Browse files Browse the repository at this point in the history
Restart a Virtual Machine
  • Loading branch information
agrare committed Jan 2, 2025
2 parents 3b3d098 + 4976181 commit 4cb507a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/manageiq/providers/kubevirt/infra_manager/vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class ManageIQ::Providers::Kubevirt::InfraManager::Vm < ManageIQ::Providers::Inf
supports :capture
supports :snapshots

supports :reboot_guest do
_('The VM is not powered on') unless current_state == 'on'
end
supports :reset
def self.calculate_power_state(raw)
POWER_STATES[raw] || super
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module ManageIQ::Providers::Kubevirt::InfraManager::Vm::Operations
extend ActiveSupport::Concern
include Power
include Snapshot
include Guest

included do
supports(:terminate) { unsupported_reason(:control) }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module ManageIQ::Providers::Kubevirt::InfraManager::Vm::Operations::Guest

def raw_reboot_guest
kubevirt = ext_management_system.parent_manager.connect(:service => "kubernetes", :path => "/apis/subresources.kubevirt.io", :version => "v1")
kubevirt.rest_client["namespaces/#{location}/virtualmachineinstances/#{name}/softreboot"].put({}.to_json, { 'Content-Type' => 'application/json' }.merge(kubevirt.get_headers))
end

def raw_reset
kubevirt = ext_management_system.parent_manager.connect(:service => "kubernetes", :path => "/apis/subresources.kubevirt.io", :version => "v1")
kubevirt.rest_client["namespaces/#{location}/virtualmachines/#{name}/restart"].put({}.to_json, { 'Content-Type' => 'application/json' }.merge(kubevirt.get_headers))
end
end

0 comments on commit 4cb507a

Please sign in to comment.