Class: AmazonInstance
- Inherits:
-
Object
- Object
- AmazonInstance
- Defined in:
- lib/amazon-instance.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#config_dir ⇒ Object
Returns the value of attribute config_dir.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#project ⇒ Object
Returns the value of attribute project.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#initialize(environment, project, config_dir, verbose = false) ⇒ AmazonInstance
constructor
A new instance of AmazonInstance.
- #launch(ec2 = nil) ⇒ Object
Constructor Details
#initialize(environment, project, config_dir, verbose = false) ⇒ AmazonInstance
Returns a new instance of AmazonInstance.
13 14 15 16 17 18 19 20 21 |
# File 'lib/amazon-instance.rb', line 13 def initialize(environment, project, config_dir, verbose=false) @config = load_general_config(config_dir) @config_dir = config_dir @environment = environment @verbose = verbose @project = Project::load(project, environment, config_dir) end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
7 8 9 |
# File 'lib/amazon-instance.rb', line 7 def config @config end |
#config_dir ⇒ Object
Returns the value of attribute config_dir.
8 9 10 |
# File 'lib/amazon-instance.rb', line 8 def config_dir @config_dir end |
#environment ⇒ Object
Returns the value of attribute environment.
9 10 11 |
# File 'lib/amazon-instance.rb', line 9 def environment @environment end |
#project ⇒ Object
Returns the value of attribute project.
10 11 12 |
# File 'lib/amazon-instance.rb', line 10 def project @project end |
#verbose ⇒ Object
Returns the value of attribute verbose.
11 12 13 |
# File 'lib/amazon-instance.rb', line 11 def verbose @verbose end |
Instance Method Details
#launch(ec2 = nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/amazon-instance.rb', line 23 def launch(ec2=nil) ec2 = AmazonEC2.new(@config['access_key_id'], @config['secret_key_id'], URI.parse(@config['ec2_zone_url']).host, URI.parse(@config['elb_zone_url']).host) if ec2.nil? group = @project[:security_group] raise 'Invalid security group: '+group unless ec2.valid_group?(group) ('Creating instance') if @verbose host = ec2.launch_instance(@environment, @project, @config_dir) ('Instance created', :ok) if @verbose # Wait till ssh port is open ('Checking SSH port') if @verbose ec2.sleep_till_ssh_is_open(host) ('SSH port open: '+host, :ok) if @verbose host end |