dew 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -35,7 +35,7 @@ class EnvironmentsCommand < Clamp::Command
35
35
 
36
36
  parameter "ENVIRONMENT_NAME", "Name of the environment"
37
37
  option ['-j', '--json'], :flag, "Output as JSON", :default => false
38
-
38
+
39
39
  def execute
40
40
  controller.show(environment_name, :json => json?)
41
41
  end
@@ -69,8 +69,9 @@ class EnvironmentsCommand < Clamp::Command
69
69
  end
70
70
  end
71
71
 
72
- subcommand "ssh", "SSH to an environment" do
72
+ subcommand "ssh", "ssh to an environment" do
73
73
  parameter "ENVIRONMENT_NAME", "Name of the environment"
74
+ parameter "[COMMAND]", "Command to execute on the environment"
74
75
  option ['-i', '--instance'], 'INSTANCE_NUMBER', "Which instance to SSH to", :default => 1 do |s|
75
76
  Integer(s)
76
77
  end
@@ -82,26 +83,57 @@ class EnvironmentsCommand < Clamp::Command
82
83
  if print?
83
84
  puts server.credentials
84
85
  else
85
- command = "ssh #{server.credentials}"
86
- Inform.debug("Running %{command}", :command => command)
87
- system command
86
+ cmd = "ssh #{server.credentials} #{command}".strip
87
+ Inform.debug("Running %{cmd}", :cmd => cmd)
88
+ system cmd
88
89
  end
89
90
  end
90
91
  end
91
92
  end
92
-
93
+
94
+ subcommand "scp", "ie. scp ENV_NAME:file1 file2 or scp file1 ENV_NAME:file2" do
95
+ option ['-i', '--instance'], 'INSTANCE_NUMBER', "Which instance to SSH to", :default => 1 do |s|
96
+ Integer(s)
97
+ end
98
+ parameter "FILE1", "Source file"
99
+ parameter "FILE2", "Destination file"
100
+
101
+ def execute
102
+ if file1.include?(':')
103
+ direction = :to
104
+ env_name, src_file = file1.split(':')
105
+ dest_file = file2
106
+ elsif file2.include?(':')
107
+ direction = :from
108
+ src_file = file1
109
+ env_name, dest_file = file2.split(':')
110
+ else
111
+ raise help
112
+ end
113
+
114
+ server = get_server(env_name, instance)
115
+ if server.credentials
116
+ args = server.credentials.split
117
+ host = args.pop
118
+ command = "scp #{args.join(' ')} #{direction == :to ? "#{[host, src_file].join(':')} #{dest_file}" : "#{[host, src_file].join(':')} #{dest_file}"}"
119
+ Inform.debug("Running %{command}", :command => command)
120
+ system command
121
+ end
122
+ end
123
+ end
124
+
93
125
  subcommand "run", "Run a script or command on each instance in the environment" do
94
126
  parameter "ENVIRONMENT_NAME", "Name of the environment"
95
127
  option ['-s', '--script'], "FILENAME", "Script to run on each instance"
96
128
  option ['-a', '--args'], "ARGUMENTS", "Optional arguments to the script provided in --script", :default => ''
97
129
  option ['-c', '--command'], "COMMAND", "Command to run on each instance"
98
-
130
+
99
131
  def execute
100
132
  raise "Please supply either -s or -c" unless script or command
101
133
  raise "--args only compatiable with --script" if command and args
102
-
134
+
103
135
  env = Environment.get(environment_name)
104
-
136
+
105
137
  Inform.info("Running on %{l} servers", :l => env.servers.length) do
106
138
  env.servers.each do |server|
107
139
  start = Time.now
@@ -133,6 +165,10 @@ class EnvironmentsCommand < Clamp::Command
133
165
 
134
166
  def get_server(environment_name, instance_no)
135
167
  env = Environment.get(environment_name)
168
+ unless env
169
+ Environment.index
170
+ raise "Unknown environment: #{environment_name}"
171
+ end
136
172
  server = env.servers[instance_no - 1]
137
173
  raise "Environment only has #{env.servers.length} instances, can't SSH to instance ##{instance}" unless server
138
174
  server
@@ -29,7 +29,7 @@ class Server < FogModel
29
29
  end
30
30
 
31
31
  def username
32
- tags['Username'] || 'ubuntu'
32
+ fog_object.tags['Username'] || 'ubuntu'
33
33
  end
34
34
 
35
35
  def ssh
@@ -1,3 +1,3 @@
1
1
  module Dew
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,293 +1,297 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: dew
3
- version: !ruby/object:Gem::Version
4
- version: 0.2.0
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
5
+ version: 0.2.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - PlayUp Devops
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-24 00:00:00.000000000 +10:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+
13
+ date: 2011-08-28 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
16
  name: inform
17
- requirement: &15304020 !ruby/object:Gem::Requirement
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
18
19
  none: false
19
- requirements:
20
+ requirements:
20
21
  - - ~>
21
- - !ruby/object:Gem::Version
22
+ - !ruby/object:Gem::Version
22
23
  version: 0.0.4
23
24
  type: :runtime
24
- prerelease: false
25
- version_requirements: *15304020
26
- - !ruby/object:Gem::Dependency
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
27
  name: clamp
28
- requirement: &15303520 !ruby/object:Gem::Requirement
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
29
30
  none: false
30
- requirements:
31
+ requirements:
31
32
  - - ~>
32
- - !ruby/object:Gem::Version
33
+ - !ruby/object:Gem::Version
33
34
  version: 0.2.2
34
35
  type: :runtime
35
- prerelease: false
36
- version_requirements: *15303520
37
- - !ruby/object:Gem::Dependency
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
38
  name: fog
39
- requirement: &15303060 !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
40
41
  none: false
41
- requirements:
42
+ requirements:
42
43
  - - ~>
43
- - !ruby/object:Gem::Version
44
+ - !ruby/object:Gem::Version
44
45
  version: 0.8.2
45
46
  type: :runtime
46
- prerelease: false
47
- version_requirements: *15303060
48
- - !ruby/object:Gem::Dependency
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
49
  name: gofer
50
- requirement: &15302600 !ruby/object:Gem::Requirement
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
51
52
  none: false
52
- requirements:
53
+ requirements:
53
54
  - - ~>
54
- - !ruby/object:Gem::Version
55
+ - !ruby/object:Gem::Version
55
56
  version: 0.2.5
56
57
  type: :runtime
57
- prerelease: false
58
- version_requirements: *15302600
59
- - !ruby/object:Gem::Dependency
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
60
  name: highline
61
- requirement: &15302140 !ruby/object:Gem::Requirement
61
+ prerelease: false
62
+ requirement: &id005 !ruby/object:Gem::Requirement
62
63
  none: false
63
- requirements:
64
+ requirements:
64
65
  - - ~>
65
- - !ruby/object:Gem::Version
66
+ - !ruby/object:Gem::Version
66
67
  version: 1.6.2
67
68
  type: :runtime
68
- prerelease: false
69
- version_requirements: *15302140
70
- - !ruby/object:Gem::Dependency
69
+ version_requirements: *id005
70
+ - !ruby/object:Gem::Dependency
71
71
  name: terminal-table
72
- requirement: &15301680 !ruby/object:Gem::Requirement
72
+ prerelease: false
73
+ requirement: &id006 !ruby/object:Gem::Requirement
73
74
  none: false
74
- requirements:
75
+ requirements:
75
76
  - - ~>
76
- - !ruby/object:Gem::Version
77
+ - !ruby/object:Gem::Version
77
78
  version: 1.4.2
78
79
  type: :runtime
79
- prerelease: false
80
- version_requirements: *15301680
81
- - !ruby/object:Gem::Dependency
80
+ version_requirements: *id006
81
+ - !ruby/object:Gem::Dependency
82
82
  name: opensrs
83
- requirement: &15301300 !ruby/object:Gem::Requirement
83
+ prerelease: false
84
+ requirement: &id007 !ruby/object:Gem::Requirement
84
85
  none: false
85
- requirements:
86
- - - ! '>='
87
- - !ruby/object:Gem::Version
88
- version: '0'
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: "0"
89
90
  type: :runtime
90
- prerelease: false
91
- version_requirements: *15301300
92
- - !ruby/object:Gem::Dependency
91
+ version_requirements: *id007
92
+ - !ruby/object:Gem::Dependency
93
93
  name: nokogiri
94
- requirement: &15300840 !ruby/object:Gem::Requirement
94
+ prerelease: false
95
+ requirement: &id008 !ruby/object:Gem::Requirement
95
96
  none: false
96
- requirements:
97
- - - ! '>='
98
- - !ruby/object:Gem::Version
99
- version: '0'
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: "0"
100
101
  type: :runtime
101
- prerelease: false
102
- version_requirements: *15300840
103
- - !ruby/object:Gem::Dependency
102
+ version_requirements: *id008
103
+ - !ruby/object:Gem::Dependency
104
104
  name: rake
105
- requirement: &15300340 !ruby/object:Gem::Requirement
105
+ prerelease: false
106
+ requirement: &id009 !ruby/object:Gem::Requirement
106
107
  none: false
107
- requirements:
108
+ requirements:
108
109
  - - ~>
109
- - !ruby/object:Gem::Version
110
+ - !ruby/object:Gem::Version
110
111
  version: 0.8.7
111
112
  type: :development
112
- prerelease: false
113
- version_requirements: *15300340
114
- - !ruby/object:Gem::Dependency
113
+ version_requirements: *id009
114
+ - !ruby/object:Gem::Dependency
115
115
  name: rspec
116
- requirement: &15299840 !ruby/object:Gem::Requirement
116
+ prerelease: false
117
+ requirement: &id010 !ruby/object:Gem::Requirement
117
118
  none: false
118
- requirements:
119
+ requirements:
119
120
  - - ~>
120
- - !ruby/object:Gem::Version
121
+ - !ruby/object:Gem::Version
121
122
  version: 2.6.0
122
123
  type: :development
123
- prerelease: false
124
- version_requirements: *15299840
125
- - !ruby/object:Gem::Dependency
124
+ version_requirements: *id010
125
+ - !ruby/object:Gem::Dependency
126
126
  name: cucumber
127
- requirement: &15299380 !ruby/object:Gem::Requirement
127
+ prerelease: false
128
+ requirement: &id011 !ruby/object:Gem::Requirement
128
129
  none: false
129
- requirements:
130
+ requirements:
130
131
  - - ~>
131
- - !ruby/object:Gem::Version
132
+ - !ruby/object:Gem::Version
132
133
  version: 0.10.3
133
134
  type: :development
134
- prerelease: false
135
- version_requirements: *15299380
136
- - !ruby/object:Gem::Dependency
135
+ version_requirements: *id011
136
+ - !ruby/object:Gem::Dependency
137
137
  name: simplecov
138
- requirement: &15298920 !ruby/object:Gem::Requirement
138
+ prerelease: false
139
+ requirement: &id012 !ruby/object:Gem::Requirement
139
140
  none: false
140
- requirements:
141
+ requirements:
141
142
  - - ~>
142
- - !ruby/object:Gem::Version
143
+ - !ruby/object:Gem::Version
143
144
  version: 0.4.0
144
145
  type: :development
145
- prerelease: false
146
- version_requirements: *15298920
147
- - !ruby/object:Gem::Dependency
146
+ version_requirements: *id012
147
+ - !ruby/object:Gem::Dependency
148
148
  name: flay
149
- requirement: &15298460 !ruby/object:Gem::Requirement
149
+ prerelease: false
150
+ requirement: &id013 !ruby/object:Gem::Requirement
150
151
  none: false
151
- requirements:
152
+ requirements:
152
153
  - - ~>
153
- - !ruby/object:Gem::Version
154
+ - !ruby/object:Gem::Version
154
155
  version: 1.4.2
155
156
  type: :development
156
- prerelease: false
157
- version_requirements: *15298460
158
- - !ruby/object:Gem::Dependency
157
+ version_requirements: *id013
158
+ - !ruby/object:Gem::Dependency
159
159
  name: geminabox
160
- requirement: &15298080 !ruby/object:Gem::Requirement
160
+ prerelease: false
161
+ requirement: &id014 !ruby/object:Gem::Requirement
161
162
  none: false
162
- requirements:
163
- - - ! '>='
164
- - !ruby/object:Gem::Version
165
- version: '0'
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: "0"
166
167
  type: :development
167
- prerelease: false
168
- version_requirements: *15298080
169
- description: ! 'Dew is a layer between fog and the ground
168
+ version_requirements: *id014
169
+ description: |
170
+ Dew is a layer between fog and the ground
170
171
 
171
- '
172
- email:
172
+ email:
173
173
  - devops@playup.com
174
- executables:
174
+ executables:
175
175
  - dew
176
176
  extensions: []
177
+
177
178
  extra_rdoc_files: []
178
- files:
179
- - lib/tasks/spec.rake
180
- - lib/dew.rb
179
+
180
+ files:
181
+ - lib/dew/commands.rb
182
+ - lib/dew/controllers/deploy_controller.rb
183
+ - lib/dew/controllers/environments_controller.rb
184
+ - lib/dew/controllers/amis_controller.rb
181
185
  - lib/dew/base_command.rb
182
- - lib/dew/commands/tidy.rb
183
- - lib/dew/commands/environments.rb
184
- - lib/dew/commands/deploy.rb
186
+ - lib/dew/models/deploy/puge.rb
187
+ - lib/dew/models/deploy/run.rb
188
+ - lib/dew/models/deploy.rb
189
+ - lib/dew/models/server.rb
190
+ - lib/dew/models/profile.rb
191
+ - lib/dew/models/environment.rb
192
+ - lib/dew/models/account.rb
193
+ - lib/dew/models/database.rb
194
+ - lib/dew/models/fog_model.rb
195
+ - lib/dew/password.rb
196
+ - lib/dew/controllers.rb
185
197
  - lib/dew/commands/ami.rb
186
- - lib/dew/commands/deploy/templates/rvmrc
187
198
  - lib/dew/commands/deploy/templates/known_hosts
199
+ - lib/dew/commands/deploy/templates/rvmrc
188
200
  - lib/dew/commands/deploy/templates/apache.conf.erb
201
+ - lib/dew/commands/deploy.rb
202
+ - lib/dew/commands/environments.rb
189
203
  - lib/dew/commands/console.rb
204
+ - lib/dew/commands/tidy.rb
190
205
  - lib/dew/commands/console/irb_override.rb
191
- - lib/dew/models.rb
192
- - lib/dew/models/database.rb
193
- - lib/dew/models/account.rb
194
- - lib/dew/models/deploy.rb
195
- - lib/dew/models/fog_model.rb
196
- - lib/dew/models/deploy/puge.rb
197
- - lib/dew/models/deploy/run.rb
198
- - lib/dew/models/server.rb
199
- - lib/dew/models/environment.rb
200
- - lib/dew/models/profile.rb
201
- - lib/dew/commands.rb
206
+ - lib/dew/tasks/spec.rake
202
207
  - lib/dew/view.rb
203
- - lib/dew/controllers/environments_controller.rb
204
- - lib/dew/controllers/deploy_controller.rb
205
- - lib/dew/controllers/amis_controller.rb
208
+ - lib/dew/models.rb
209
+ - lib/dew/aws_resources.yaml
206
210
  - lib/dew/version.rb
207
- - lib/dew/password.rb
208
- - lib/dew/cloud.rb
209
- - lib/dew/tasks/spec.rake
210
211
  - lib/dew/validations.rb
211
- - lib/dew/controllers.rb
212
- - lib/dew/aws_resources.yaml
212
+ - lib/dew/cloud.rb
213
+ - lib/tasks/spec.rake
214
+ - lib/dew.rb
213
215
  - README.md
214
216
  - LICENSE
217
+ - example/dew/profiles/test-full.yaml
215
218
  - example/dew/profiles/template.yaml
216
219
  - example/dew/profiles/test-light.yaml
217
- - example/dew/profiles/test-full.yaml
218
220
  - example/dew/accounts/development.yaml
219
221
  - Rakefile
220
- - spec/dew/view_spec.rb
221
- - spec/dew/models/fog_model_spec.rb
222
- - spec/dew/models/server_spec.rb
223
- - spec/dew/models/account_spec.rb
222
+ - spec/dew/controllers/deploy_controller_spec.rb
223
+ - spec/dew/controllers/amis_controller_spec.rb
224
+ - spec/dew/controllers/environments_controller_spec.rb
225
+ - spec/dew/models/profile_spec.rb
224
226
  - spec/dew/models/deploy/puge_spec.rb
225
227
  - spec/dew/models/deploy/run_spec.rb
226
228
  - spec/dew/models/environment_spec.rb
227
- - spec/dew/models/profile_spec.rb
229
+ - spec/dew/models/fog_model_spec.rb
230
+ - spec/dew/models/account_spec.rb
231
+ - spec/dew/models/server_spec.rb
228
232
  - spec/dew/models/database_spec.rb
229
- - spec/dew/controllers/deploy_controller_spec.rb
230
- - spec/dew/controllers/amis_controller_spec.rb
231
- - spec/dew/controllers/environments_controller_spec.rb
232
233
  - spec/dew/password_spec.rb
233
- - spec/dew/spec_helper.rb
234
234
  - spec/dew/cloud_spec.rb
235
- - features/deploy-puge.feature
236
- - features/create-ami.feature
237
- - features/create-environments.feature
235
+ - spec/dew/spec_helper.rb
236
+ - spec/dew/view_spec.rb
238
237
  - features/support/hooks.rb
239
238
  - features/support/env.rb
239
+ - features/deploy-puge.feature
240
240
  - features/step_definitions/deploy-puge-steps.rb
241
241
  - features/step_definitions/aws-steps.rb
242
+ - features/create-ami.feature
243
+ - features/create-environments.feature
242
244
  - config/cucumber.yaml
243
245
  - bin/dew
244
- has_rdoc: true
245
246
  homepage: http://github.com/playup/dew
246
247
  licenses: []
248
+
247
249
  post_install_message:
248
250
  rdoc_options: []
249
- require_paths:
251
+
252
+ require_paths:
250
253
  - lib
251
- required_ruby_version: !ruby/object:Gem::Requirement
254
+ required_ruby_version: !ruby/object:Gem::Requirement
252
255
  none: false
253
- requirements:
254
- - - ! '>='
255
- - !ruby/object:Gem::Version
256
- version: '0'
257
- required_rubygems_version: !ruby/object:Gem::Requirement
256
+ requirements:
257
+ - - ">="
258
+ - !ruby/object:Gem::Version
259
+ version: "0"
260
+ required_rubygems_version: !ruby/object:Gem::Requirement
258
261
  none: false
259
- requirements:
260
- - - ! '>='
261
- - !ruby/object:Gem::Version
262
- version: '0'
262
+ requirements:
263
+ - - ">="
264
+ - !ruby/object:Gem::Version
265
+ version: "0"
263
266
  requirements: []
267
+
264
268
  rubyforge_project:
265
- rubygems_version: 1.6.2
269
+ rubygems_version: 1.8.9
266
270
  signing_key:
267
271
  specification_version: 3
268
272
  summary: Uses fog to access the cloud
269
- test_files:
273
+ test_files:
270
274
  - Rakefile
271
- - spec/dew/view_spec.rb
272
- - spec/dew/models/fog_model_spec.rb
273
- - spec/dew/models/server_spec.rb
274
- - spec/dew/models/account_spec.rb
275
+ - spec/dew/controllers/deploy_controller_spec.rb
276
+ - spec/dew/controllers/amis_controller_spec.rb
277
+ - spec/dew/controllers/environments_controller_spec.rb
278
+ - spec/dew/models/profile_spec.rb
275
279
  - spec/dew/models/deploy/puge_spec.rb
276
280
  - spec/dew/models/deploy/run_spec.rb
277
281
  - spec/dew/models/environment_spec.rb
278
- - spec/dew/models/profile_spec.rb
282
+ - spec/dew/models/fog_model_spec.rb
283
+ - spec/dew/models/account_spec.rb
284
+ - spec/dew/models/server_spec.rb
279
285
  - spec/dew/models/database_spec.rb
280
- - spec/dew/controllers/deploy_controller_spec.rb
281
- - spec/dew/controllers/amis_controller_spec.rb
282
- - spec/dew/controllers/environments_controller_spec.rb
283
286
  - spec/dew/password_spec.rb
284
- - spec/dew/spec_helper.rb
285
287
  - spec/dew/cloud_spec.rb
286
- - features/deploy-puge.feature
287
- - features/create-ami.feature
288
- - features/create-environments.feature
288
+ - spec/dew/spec_helper.rb
289
+ - spec/dew/view_spec.rb
289
290
  - features/support/hooks.rb
290
291
  - features/support/env.rb
292
+ - features/deploy-puge.feature
291
293
  - features/step_definitions/deploy-puge-steps.rb
292
294
  - features/step_definitions/aws-steps.rb
295
+ - features/create-ami.feature
296
+ - features/create-environments.feature
293
297
  - config/cucumber.yaml