cloud-maker 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,7 @@ require 'rest-client'
9
9
  require 'termios'
10
10
 
11
11
  require 'cloud_maker/config'
12
+ require 'cloud_maker/elb_interface'
12
13
  require 'cloud_maker/ec2'
13
14
  require 'cloud_maker/s3_archiver'
14
15
  require 'cloud_maker/shell_executor'
@@ -45,6 +45,10 @@ module CloudMaker
45
45
  },
46
46
  'block_device_mappings' => {
47
47
  'description' => "A hash of block devices mappings. ie. { /dev/sda1 => { volume_size => <value_in_GB>, snapshot_id => <id>, delete_on_termination => <boolean> } }"
48
+ },
49
+ 'elb' => {
50
+ 'default' => '',
51
+ 'description' => "The load balancer to use."
48
52
  }
49
53
  }
50
54
  }
@@ -172,6 +176,18 @@ module CloudMaker
172
176
  end
173
177
  end
174
178
 
179
+ if cloud_maker_config.elb?
180
+ while instance.status == :pending
181
+ #wait
182
+ end
183
+ elb_interface = ElbInterface.new(
184
+ :instance => instance,
185
+ :aws_access_key_id => self.aws_access_key_id,
186
+ :aws_secret_access_key => self.aws_secret_access_key,
187
+ :elb_name => cloud_maker_config["elb"]
188
+ ).attach
189
+ end
190
+
175
191
  archiver = S3Archiver.new(
176
192
  :instance_id => instance.id,
177
193
  :aws_access_key_id => self.aws_access_key_id,
@@ -0,0 +1,44 @@
1
+ module CloudMaker
2
+ class ElbInterface
3
+ # Public: Gets/Sets the AWS access key.
4
+ attr_accessor :aws_secret_access_key
5
+ # Public: Gets/Sets the AWS secret.
6
+ attr_accessor :aws_access_key_id
7
+ # Public: Gets/Sets the EC2 instance.
8
+ attr_accessor :instance
9
+ # Internal: Gets/Sets the the elb name.
10
+ attr_accessor :elb_name
11
+
12
+ # Public: Creates a new ElbInterface instance
13
+ #
14
+ # options - Elb configuration options
15
+ # :aws_access_key_id - (required) The AWS access key
16
+ # :aws_secret_access_key - (required) The AWS secret
17
+ # :elb_name - (required) The name of the elb to use
18
+ # :instance - (required) The AWS instance
19
+ #
20
+ # Returns a new CloudMaker::ElbInterface instance
21
+ # Raises RuntimeError if any of the required options are not specified
22
+
23
+ def initialize(options)
24
+ required_keys = [:aws_access_key_id, :aws_secret_access_key, :instance, :elb_name]
25
+ unless (required_keys - options.keys).empty?
26
+ raise RuntimeError.new("Instantiated #{self.class} without required attributes: #{required_keys - options.keys}.")
27
+ end
28
+
29
+ self.instance = options[:instance]
30
+ self.aws_access_key_id = options[:aws_access_key_id]
31
+ self.aws_secret_access_key = options[:aws_secret_access_key]
32
+
33
+ @elb = AWS::ELB.new(
34
+ :access_key_id => self.aws_access_key_id,
35
+ :secret_access_key => self.aws_secret_access_key
36
+ ).load_balancers[options[:elb_name]]
37
+ end
38
+
39
+ def attach
40
+ @elb.instances.register([self.instance])
41
+ raise RuntimeError.new("The instance was not registerd correctly. id:#{self.instance.id}") unless @elb.instances[self.instance.id]
42
+ end
43
+ end
44
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloud-maker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-09 00:00:00.000000000 Z
13
+ date: 2012-11-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: colorize
@@ -139,6 +139,7 @@ files:
139
139
  - lib/cloud-maker.rb
140
140
  - lib/cloud_maker/config.rb
141
141
  - lib/cloud_maker/ec2.rb
142
+ - lib/cloud_maker/elb_interface.rb
142
143
  - lib/cloud_maker/s3_archiver.rb
143
144
  - lib/cloud_maker/shell_executor.rb
144
145
  - bin/cloud-maker