Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restart a Virtual Machine #263

Merged
merged 3 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading