Sha256: 5adc6bb502bb1ceb51ba0b788adbc634d2eeaa0a07f5e6dc222f7488e44a0da5
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
module Jellyfish module Fog module AWS class Infrastructure < ::Provisioner def provision # TODO: Must get an image_id from product details = { 'image_id' => 'ami-acca47c4' } server = nil handle_errors do server = connection.servers.create(details).tap { |s| s.wait_for { ready? } } end @order_item.provision_status = 'ok' @order_item.payload_response = server.to_json end def retire handle_errors do connection.servers.delete(server_identifier) end @order_item.provision_status = 'retired' end private def connection ::Fog::Compute.new( provider: 'AWS', aws_access_key_id: aws_settings.fetch(:access_key), aws_secret_access_key: aws_settings.fetch(:secret_key) ) end def server_identifier @order_item.payload_response['id'] end def handle_errors yield rescue Excon::Errors::BadRequest, Excon::Errors::Forbidden => e raise e, 'Bad request. Check for valid credentials and proper permissions.', e.backtrace end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jellyfish_fog_aws-0.1.0 | lib/jellyfish_fog_aws/infrastructure.rb |
jellyfish_fog_aws-0.0.1 | lib/jellyfish_fog_aws/infrastructure.rb |