Sha256: de4dd098a91c00f2b6baada26301ac060323db90eda34f01e9e68d5d0a8722f1
Contents?: true
Size: 1.45 KB
Versions: 3
Compression:
Stored size: 1.45 KB
Contents
require 'log4r' module VagrantPlugins module ArubaCloud module Action # This action reads the state of the machine and puts it in the # `:machine_state_id` key in the environment. class ReadState def initialize(app, env) @app = app @env = env @logger = Log4r::Logger.new('vagrant_arubacloud::action::read_state') end def call(env) env[:machine_state_id] = read_state(env[:arubacloud_compute], env[:machine]) @app.call(env) end def read_state(arubacloud, machine) return :not_created if machine.id.nil? # Find the machine server = arubacloud.servers.get(machine.id) unless server.instance_of? Fog::ArubaCloud::Compute::Server msg = "VagrantPlugins::ArubaCloud::Action::ReadState.read_state, 'server' must be Fog::ArubaCloud::Compute::Server, got: #{server.class}" @logger.critical("#{msg}") end if server.nil? || server.state == Fog::ArubaCloud::Compute::Server::DELETED # The machine can't be found @logger.info('Machine not found or deleted, assuming it got destroyed.') machine.id = nil return :not_created end @logger.debug("VagrantPlugins::ArubaCloud::Action::ReadState.read_state, server state : #{server.state}") # Return the state server.state end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems