Sha256: 8ae6a3375e6cbe52558af2ef70a8bc7e6001c6a76861abb94e998a04c0948e94

Contents?: true

Size: 672 Bytes

Versions: 1

Compression:

Stored size: 672 Bytes

Contents

class Base::GetMachine
  include Interactor

  # @param client
  # @param action_handler (optional)
  # @param machine_spec
  def call
    machine_id = context.machine_spec.reference["server_id"]
    response = context.client.get("server/#{machine_id}")
    case response.status_code
    when 404
      context.action_handler.perform_action "Machine #{machine_id} does not exist.\n" do
        context.machine_spec.reference = nil
      end if context.action_handler
      context.machine = nil
    when 200
      puts "Machine #{machine_id} exist.\n"
      context.machine = JSON.parse(response.body)["server"]
    else
      fail "Unexpected response"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chef-provisioning-upcloud-0.2.0 lib/chef/provisioning/interactors/base/get_machine.rb