Class: EC2Launcher::Environment

Inherits:
Object
  • Object
show all
Includes:
EmailNotifications
Defined in:
lib/ec2launcher/environment.rb

Instance Attribute Summary collapse

Attributes included from EmailNotifications

#email_notifications

Class Method Summary collapse

Instance Method Summary collapse

Methods included from EmailNotifications

#email_notification

Constructor Details

#initializeEnvironment

Returns a new instance of Environment.



14
15
16
17
18
19
20
21
# File 'lib/ec2launcher/environment.rb', line 14

def initialize()
	@aliases = []
	@email_notifications = nil
	@gems = []
	@packages = []
	@precommands = []
	@postcommands = []
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/ec2launcher/environment.rb', line 10

def name
  @name
end

#postcommandsObject (readonly)

Returns the value of attribute postcommands.



12
13
14
# File 'lib/ec2launcher/environment.rb', line 12

def postcommands
  @postcommands
end

#precommandsObject (readonly)

Returns the value of attribute precommands.



11
12
13
# File 'lib/ec2launcher/environment.rb', line 11

def precommands
  @precommands
end

Class Method Details

.load(dsl) ⇒ Object



216
217
218
219
# File 'lib/ec2launcher/environment.rb', line 216

def self.load(dsl)
	env = Environment.new.instance_eval(dsl)
	env
end

Instance Method Details

#aliases(*aliases) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ec2launcher/environment.rb', line 38

def aliases(*aliases)
	if aliases.empty?
		@aliases
	else
		if aliases[0].kind_of? String
			@aliases = [ aliases[0] ]
		else
			@aliases = aliases[0]
		end
	end
end

#ami_name(*ami_name) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/ec2launcher/environment.rb', line 50

def ami_name(*ami_name)
	if ami_name.empty?
		@ami_name
	else
		if ami_name[0].kind_of? String
			@ami_name = /#{ami_name[0]}/
		else
			@ami_name = ami_name[0]
		end
		self
	end
end

#availability_zone(*zone) ⇒ Object



63
64
65
66
67
68
69
70
# File 'lib/ec2launcher/environment.rb', line 63

def availability_zone(*zone)
	if zone.empty?
		@availability_zone
	else
		@availability_zone = zone[0].to_s
		self
	end
end

#aws_keyfile(*aws_keyfile) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/ec2launcher/environment.rb', line 29

def aws_keyfile(*aws_keyfile)
	if aws_keyfile.empty?
		@aws_keyfile
	else
		@aws_keyfile = aws_keyfile[0]
		self
	end
end

#chef_server_url(*server_url) ⇒ Object



72
73
74
75
76
77
78
79
# File 'lib/ec2launcher/environment.rb', line 72

def chef_server_url(*server_url)
	if server_url.empty?
		@chef_server_url
	else
		@chef_server_url = server_url[0]
		self
	end
end

#chef_validation_pem_url(*chef_validation_pem_url) ⇒ Object



81
82
83
84
85
86
87
88
# File 'lib/ec2launcher/environment.rb', line 81

def chef_validation_pem_url(*chef_validation_pem_url)
	if chef_validation_pem_url.empty?
		@chef_validation_pem_url
	else
		@chef_validation_pem_url = chef_validation_pem_url[0]
		self
	end
end

#domain_name(*domain_name) ⇒ Object



90
91
92
93
94
95
96
97
# File 'lib/ec2launcher/environment.rb', line 90

def domain_name(*domain_name)
	if domain_name.empty?
		@domain_name
	else
		@domain_name = domain_name[0]
		self
	end
end

#environment(name) {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



23
24
25
26
27
# File 'lib/ec2launcher/environment.rb', line 23

def environment(name)
	@name = name
	yield self
	self
end

#gems(*gems) ⇒ Object



99
100
101
102
103
104
105
106
# File 'lib/ec2launcher/environment.rb', line 99

def gems(*gems)
	if gems.empty?
		@gems
	else
		@gems = gems[0]
		self
	end
end

#inherit(*inherit_type) ⇒ Object



108
109
110
111
112
113
114
# File 'lib/ec2launcher/environment.rb', line 108

def inherit(*inherit_type)
	if inherit_type.empty?
		@inherit_type
	else
		@inherit_type = inherit_type[0]
	end
end

#key_name(*key) ⇒ Object



116
117
118
119
120
121
122
123
# File 'lib/ec2launcher/environment.rb', line 116

def key_name(*key)
	if key.empty?
		@key_name
	else
		@key_name = key[0]
		self
	end
end

#load(dsl) ⇒ Object



211
212
213
214
# File 'lib/ec2launcher/environment.rb', line 211

def load(dsl)
	self.instance_eval(dsl)
	self
end

#merge(other_env) ⇒ Object

Takes values from the other environment and merges them into this one



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/ec2launcher/environment.rb', line 190

def merge(other_env)
		@name =other_env.name

		@aliases = other_env.aliases.nil? ? nil : other_env.aliases

		@aws_keyfile = other_env.aws_keyfile unless other_env.aws_keyfile.nil?
		@availability_zone = other_env.availability_zone unless other_env.availability_zone.nil?
		@chef_server_url = other_env.chef_server_url unless other_env.chef_server_url.nil?
		@chef_validation_pem_url = other_env.chef_validation_pem_url unless other_env.chef_validation_pem_url.nil?
		@domain_name = other_env.domain_name unless other_env.domain_name
		@email_notifications = other_env.email_notifications unless other_env.email_notifications.nil?
		@gems = other_env.gems unless other_env.gems.nil?
		@key_name = other_env.key_name unless other_env.key_name.nil?
		@packages = other_env.packages unless other_env.packages.nil?
		@precommands = other_env.precommands unless other_env.precommands.nil?
		@postcommands = other_env.postcommands unless other_env.postcommands.nil?
		@roles = other_env.roles unless other_env.roles.nil?
		@security_groups = other_env.security_groups unless other_env.security_groups.nil?
		@subnet = other_env.subnet unless other_env.subnet.nil?
end

#packages(*packages) ⇒ Object



125
126
127
128
129
130
131
132
# File 'lib/ec2launcher/environment.rb', line 125

def packages(*packages)
	if packages.empty?
		@packages
	else
		@packages = packages[0]
		self
	end
end

#postcommand(*command) ⇒ Object



138
139
140
# File 'lib/ec2launcher/environment.rb', line 138

def postcommand(*command)
	@postcommands << command[0]
end

#precommand(*command) ⇒ Object



134
135
136
# File 'lib/ec2launcher/environment.rb', line 134

def precommand(*command)
	@precommands << command[0]
end

#roles(*roles) ⇒ Object



142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/ec2launcher/environment.rb', line 142

def roles(*roles)
	if roles.empty?
		@roles
	else
		@roles = [] if @roles.nil?
		if roles[0].kind_of? Array
			@roles += roles[0]
		else
			@roles = []
			@roles << roles[0]
		end
		self
	end
end

#security_groups(*security_groups) ⇒ Object



157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/ec2launcher/environment.rb', line 157

def security_groups(*security_groups)
	if security_groups.empty?
		@security_groups
	else
		@security_groups = [] if @security_groups.nil?
		if security_groups[0].kind_of? Array
			@security_groups += security_groups[0]
		else
			@security_groups << security_groups[0]
		end
		self
	end
end

#short_name(*short_name) ⇒ Object



171
172
173
174
175
176
177
178
# File 'lib/ec2launcher/environment.rb', line 171

def short_name(*short_name)
	if short_name.empty?
		@short_name
	else
		@short_name = short_name[0]
		self
	end
end

#subnet(*subnet) ⇒ Object



180
181
182
183
184
185
186
187
# File 'lib/ec2launcher/environment.rb', line 180

def subnet(*subnet)
	if subnet.empty?
		@subnet
	else
		@subnet = subnet[0]
		self
	end
end