Class: Blimpy::Boxes::AWS
- Inherits:
-
Blimpy::Box
- Object
- Blimpy::Box
- Blimpy::Boxes::AWS
- Defined in:
- lib/blimpy/boxes/aws.rb
Constant Summary collapse
- DEFAULT_REGION =
Default to US West (Oregon)
'us-west-2'
- DEFAULT_IMAGE_ID =
Default to 12.04 64-bit
'ami-4438b474'
Instance Attribute Summary
Attributes inherited from Blimpy::Box
#allowed_regions, #dns, #flavor, #fleet_id, #group, #image_id, #internal_dns, #livery, #name, #ports, #provision_on_start, #region, #ssh_port, #tags, #username
Class Method Summary collapse
Instance Method Summary collapse
- #fog ⇒ Object
-
#initialize(server = nil) ⇒ AWS
constructor
A new instance of AWS.
- #validate! ⇒ Object
Methods inherited from Blimpy::Box
#bootstrap, #bootstrap_livery, #destroy, from_instance_id, #immutable_attributes, #online!, #postdestroy, #poststart, #predestroy, #prestart, #provision, #resume, #run_command, #scp_file, #scp_files, #serializable_attributes, #ssh_commands, #ssh_into, #start, #state_file, #stop, #type, #wait_for_sshd, #wait_for_state, #with_data, #write_state_file
Methods included from Helpers::State
#ensure_state_folder, #state_file, #state_folder
Constructor Details
#initialize(server = nil) ⇒ AWS
Returns a new instance of AWS.
18 19 20 21 22 23 24 25 26 |
# File 'lib/blimpy/boxes/aws.rb', line 18 def initialize(server=nil) super(server) @allowed_regions = ['us-west-1', 'us-west-2', 'us-east-1'] @region = DEFAULT_REGION @image_id = DEFAULT_IMAGE_ID @username = 'ubuntu' @flavor = 't1.micro' @group = 'default' end |
Class Method Details
.fog_server_for_instance(id, blimpdata) ⇒ Object
12 13 14 15 16 |
# File 'lib/blimpy/boxes/aws.rb', line 12 def self.fog_server_for_instance(id, blimpdata) region = blimpdata[:region] || DEFAULT_REGION fog = Fog::Compute.new(:provider => 'AWS', :region => region) fog.servers.get(id) end |
Instance Method Details
#fog ⇒ Object
38 39 40 41 42 |
# File 'lib/blimpy/boxes/aws.rb', line 38 def fog @fog ||= begin Fog::Compute.new(:provider => 'AWS', :region => @region) end end |
#validate! ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/blimpy/boxes/aws.rb', line 28 def validate! if @region.nil? raise Blimpy::BoxValidationError, "Cannot spin up machine without a set region" end if fog.security_groups.get(@group).nil? raise Blimpy::BoxValidationError, "The security group '#{@group}' does not exist in #{@region}" end end |