Class: RodeoClown::EC2
- Inherits:
-
Struct
- Object
- Struct
- RodeoClown::EC2
show all
- Includes:
- InstanceBuilder
- Defined in:
- lib/rodeo_clown/ec2.rb
Constant Summary
collapse
- STATUS =
%w[pending running shutting-down terminated stopping stopped]
Instance Attribute Summary collapse
#availability_zones, #key_pair, #options, #tags
Class Method Summary
collapse
Instance Method Summary
collapse
#build_instances, #build_options, #many_from_options
Instance Attribute Details
#ec2 ⇒ Object
Returns the value of attribute ec2
3
4
5
|
# File 'lib/rodeo_clown/ec2.rb', line 3
def ec2
@ec2
end
|
Class Method Details
.by_name(name) ⇒ Object
26
27
28
|
# File 'lib/rodeo_clown/ec2.rb', line 26
def self.by_name(name)
new instances[name]
end
|
Filter by had of tag values. Keys and values as strings
Examples
RodeoClown::EC2.by_tags("app" => "rodeo", "version" = "2.1")
# => [ instance-1, instanc-2 ]
Returns an array of instances
38
39
40
41
42
43
44
45
|
# File 'lib/rodeo_clown/ec2.rb', line 38
def self.by_tags(options = {})
return instances if options.nil? || options.empty?
instances.tagged_values(options.values).select do |instance|
tags = instance.tags.to_h
(options.to_a - tags.to_a).empty?
end
end
|
.create_instance(options) ⇒ Object
16
17
18
19
20
|
# File 'lib/rodeo_clown/ec2.rb', line 16
def self.create_instance(options)
new_instance = instances.create(options)
instances.wait_for_status(:running, 2, [*new_instance])
new_instance
end
|
.ec2 ⇒ Object
12
13
14
|
# File 'lib/rodeo_clown/ec2.rb', line 12
def self.ec2
@ec2 ||= AWS::EC2.new
end
|
.instances ⇒ Object
8
9
10
|
# File 'lib/rodeo_clown/ec2.rb', line 8
def self.instances
ec2.instances
end
|
Instance Method Details
#create_instance(options) ⇒ Object
22
23
24
|
# File 'lib/rodeo_clown/ec2.rb', line 22
def create_instance(options)
self.class.create_instance(options)
end
|
#dns_name ⇒ Object
67
68
69
|
# File 'lib/rodeo_clown/ec2.rb', line 67
def dns_name
ec2.dns_name
end
|
#pending? ⇒ Boolean
51
52
53
|
# File 'lib/rodeo_clown/ec2.rb', line 51
def pending?
ec2.status == :pending
end
|
#reboot ⇒ Object
47
48
49
|
# File 'lib/rodeo_clown/ec2.rb', line 47
def reboot
ec2.reboot
end
|
#running? ⇒ Boolean
55
56
57
|
# File 'lib/rodeo_clown/ec2.rb', line 55
def running?
ec2.status == :running
end
|
#stopped? ⇒ Boolean
59
60
61
|
# File 'lib/rodeo_clown/ec2.rb', line 59
def stopped?
ec2.status == :stopped
end
|
#terminated? ⇒ Boolean
63
64
65
|
# File 'lib/rodeo_clown/ec2.rb', line 63
def terminated?
ec2.status == :terminated
end
|