Class: VirtPowerManager

Inherits:
PowerManager show all
Defined in:
app/models/power_manager/virt_power_manager.rb

Constant Summary

Constants inherited from PowerManager

PowerManager::SUPPORTED_ACTIONS

Instance Method Summary collapse

Methods inherited from PowerManager

#logger, method_missing

Constructor Details

#initialize(opts = {}) ⇒ VirtPowerManager


3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/models/power_manager/virt_power_manager.rb', line 3

def initialize(opts = {})
  super(opts)
  begin
    timeout(15) do
      @vm = host.compute_resource.find_vm_by_uuid(host.uuid)
    end
  rescue Timeout::Error
    raise Foreman::Exception.new(N_("Timeout has occurred while communicating with %s"), host.compute_resource)
  rescue => e
    logger.warn "Error has occurred while communicating to #{host.compute_resource}: #{e}"
    logger.debug e.backtrace
    raise Foreman::Exception.new(N_("Error has occurred while communicating with %{cr}: %{e}"), { :cr => host.compute_resource, :e => e })
  end
end

Instance Method Details

#stateObject


18
19
20
21
22
# File 'app/models/power_manager/virt_power_manager.rb', line 18

def state
  # make sure we fetch latest vm status
  vm.reload
  vm.state
end