guignol 0.1.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/.gitignore +2 -0
  2. data/.rspec +2 -1
  3. data/Gemfile.lock +29 -18
  4. data/LICENCE +26 -0
  5. data/README.md +67 -38
  6. data/Rakefile +0 -26
  7. data/bin/guignol +3 -33
  8. data/guignol.gemspec +4 -30
  9. data/lib/core_ext/array/collect_key.rb +6 -0
  10. data/lib/core_ext/hash/map_to_hash.rb +31 -0
  11. data/lib/guignol.rb +15 -35
  12. data/lib/guignol/commands/base.rb +53 -66
  13. data/lib/guignol/commands/clone.rb +49 -0
  14. data/lib/guignol/commands/create.rb +14 -33
  15. data/lib/guignol/commands/execute.rb +69 -0
  16. data/lib/guignol/commands/fix_dns.rb +12 -33
  17. data/lib/guignol/commands/kill.rb +18 -36
  18. data/lib/guignol/commands/list.rb +19 -45
  19. data/lib/guignol/commands/start.rb +14 -33
  20. data/lib/guignol/commands/stop.rb +18 -37
  21. data/lib/guignol/commands/uuid.rb +19 -32
  22. data/lib/guignol/configuration.rb +43 -0
  23. data/lib/guignol/connection.rb +33 -0
  24. data/lib/guignol/env.rb +19 -0
  25. data/lib/guignol/logger.rb +29 -0
  26. data/lib/guignol/models/base.rb +125 -0
  27. data/lib/guignol/models/instance.rb +244 -0
  28. data/lib/guignol/models/volume.rb +91 -0
  29. data/lib/guignol/shell.rb +27 -42
  30. data/lib/guignol/tty_spinner.rb +6 -29
  31. data/lib/guignol/version.rb +1 -27
  32. data/spec/guignol/configuration_spec.rb +72 -0
  33. data/spec/guignol/instance_spec.rb +48 -8
  34. data/spec/guignol/volume_spec.rb +17 -0
  35. data/spec/spec_helper.rb +12 -0
  36. data/tmp/.keepme +0 -0
  37. metadata +79 -52
  38. data/lib/guignol/array/collect_key.rb +0 -32
  39. data/lib/guignol/commands.rb +0 -48
  40. data/lib/guignol/commands/help.rb +0 -77
  41. data/lib/guignol/instance.rb +0 -270
  42. data/lib/guignol/shared.rb +0 -80
  43. data/lib/guignol/volume.rb +0 -124
@@ -1,30 +1,4 @@
1
- # Copyright (c) 2012, HouseTrip SA.
2
- # All rights reserved.
3
- #
4
- # Redistribution and use in source and binary forms, with or without
5
- # modification, are permitted provided that the following conditions are met:
6
- #
7
- # 1. Redistributions of source code must retain the above copyright notice, this
8
- # list of conditions and the following disclaimer.
9
- # 2. Redistributions in binary form must reproduce the above copyright notice,
10
- # this list of conditions and the following disclaimer in the documentation
11
- # and/or other materials provided with the distribution.
12
- #
13
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
- # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17
- # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
- # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
- # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
- # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
- # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
- # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
- #
24
- # The views and conclusions contained in the software and documentation are those
25
- # of the authors and should not be interpreted as representing official policies,
26
- # either expressed or implied, of the authors.
27
1
 
28
2
  module Guignol
29
- VERSION = "0.1.2.1"
3
+ VERSION = "0.3.0"
30
4
  end
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+ require 'guignol'
3
+
4
+ describe Guignol::Configuration do
5
+ subject { Object.new.extend(described_class) }
6
+ let(:test_path) { Pathname.new 'tmp/test.yml' }
7
+ let(:result) { subject.configuration }
8
+
9
+ before do
10
+ ENV['GUIGNOL_YML'] = test_path
11
+ test_path.open('w') do |io|
12
+ io.write config_data
13
+ end
14
+ end
15
+
16
+ after do
17
+ test_path.delete
18
+ end
19
+
20
+ shared_examples_for 'loaded config' do
21
+ it 'should load' do
22
+ result.should be_a_kind_of(Hash)
23
+ end
24
+
25
+ it 'loads volumes' do
26
+ result['john-mcfoo'][:volumes].should_not be_empty
27
+ end
28
+ end
29
+
30
+
31
+ context '(with new hash config)' do
32
+ let(:config_data) {%Q{---
33
+ john-mcfoo:
34
+ :domain: housetripdev.com.
35
+ :uuid: 0BADCODE-1337-1337-1337-00DEADBEEF00
36
+ :flavor_id: c1.medium
37
+ :image_id: ami-27013f53
38
+ :key_name: john
39
+ :security_group_ids:
40
+ - sg-6e718319
41
+ - sg-12341234
42
+ :volumes:
43
+ foo-disk:
44
+ :dev: /dev/sdf
45
+ :uuid: 1234
46
+ }}
47
+
48
+ it_should_behave_like 'loaded config'
49
+ end
50
+
51
+
52
+ context '(with old array config)' do
53
+ let(:config_data) {%Q{---
54
+ - :name: john-mcfoo
55
+ :domain: housetripdev.com.
56
+ :uuid: 0BADCODE-1337-1337-1337-00DEADBEEF00
57
+ :flavor_id: c1.medium
58
+ :image_id: ami-27013f53
59
+ :key_name: john
60
+ :security_group_ids:
61
+ - sg-6e718319
62
+ - sg-12341234
63
+ :volumes:
64
+ - :size: 6
65
+ :name: foo-disk
66
+ :dev: /dev/sdf
67
+ :uuid: 1234
68
+ }}
69
+
70
+ it_should_behave_like 'loaded config'
71
+ end
72
+ end
@@ -1,16 +1,17 @@
1
- require 'guignol/instance'
1
+ require 'spec_helper'
2
+ require 'guignol/models/instance'
2
3
 
3
- describe Guignol::Instance do
4
- subject { Guignol::Instance.new(options) }
4
+ describe Guignol::Models::Instance do
5
+ subject { described_class.new(name, options) }
5
6
 
7
+ let(:name) { "foobar" }
6
8
  let(:options) {{
7
- :name => 'foobar',
8
9
  :uuid => '948DB8E9-A356-4F66-8857-165FBDF5A71F'
9
10
  }}
10
11
 
11
12
  before(:each) do
12
- connection = stub(:servers => [])
13
- Fog::Compute.stub(:new).and_return(connection)
13
+ # connection = stub(:servers => [])
14
+ # Fog::Compute.stub(:new).and_return(connection)
14
15
  end
15
16
 
16
17
  describe '#initialize' do
@@ -19,8 +20,8 @@ describe Guignol::Instance do
19
20
  expect { subject }.to raise_error
20
21
  end
21
22
 
22
- it 'should require :name' do
23
- options.delete :name
23
+ it 'should require a name' do
24
+ name.replace ""
24
25
  expect { subject }.to raise_error
25
26
  end
26
27
 
@@ -28,4 +29,43 @@ describe Guignol::Instance do
28
29
  subject
29
30
  end
30
31
  end
32
+
33
+
34
+ shared_examples_for 'server setup' do
35
+ it 'set server tags'
36
+ it 'configures DNS properly'
37
+ end
38
+
39
+
40
+ describe '#create' do
41
+ it 'should pass with minimal options' do
42
+ subject.create
43
+ end
44
+
45
+ it 'reuses existing volumes'
46
+ it 'fails when existing volumes are in different zones'
47
+
48
+ it 'starts up the server'
49
+
50
+ it_should_behave_like 'server setup'
51
+ end
52
+
53
+
54
+ describe '#start' do
55
+ it_should_behave_like 'server setup'
56
+
57
+ it 'returns when the server does not exist' do
58
+ subject.start
59
+ end
60
+
61
+ it 'returns with a server marked as "running"'
62
+
63
+ end
64
+
65
+
66
+ describe '#destroy' do
67
+ it 'should pass with minimal options' do
68
+ subject.destroy
69
+ end
70
+ end
31
71
  end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+ require 'guignol/models/volume'
3
+
4
+ describe Guignol::Models::Volume do
5
+ subject { described_class.new(name, options) }
6
+
7
+ let(:name) { 'foo' }
8
+ let(:options) {{
9
+ :uuid => 'bar'
10
+ }}
11
+
12
+ describe '#initialize' do
13
+ it 'should pass with minimal options' do
14
+ subject
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ require 'rspec'
2
+ require 'rspec/mocks'
3
+ require 'fog'
4
+
5
+ Fog.mock!
6
+
7
+ ENV['GUIGNOL_ENV'] = 'test'
8
+ ENV['GUIGNOL_LOG'] = '/dev/null'
9
+
10
+ RSpec.configure do |config|
11
+ # nib
12
+ end
File without changes
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guignol
3
3
  version: !ruby/object:Gem::Version
4
- hash: 77
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 2
10
- - 1
11
- version: 0.1.2.1
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
12
11
  platform: ruby
13
12
  authors:
14
13
  - Julien Letessier
@@ -16,13 +15,11 @@ autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2012-05-08 00:00:00 +01:00
18
+ date: 2012-09-30 00:00:00 +01:00
20
19
  default_executable:
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
23
- name: bundler
24
- prerelease: false
25
- version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ requirement: &id001 !ruby/object:Gem::Requirement
26
23
  none: false
27
24
  requirements:
28
25
  - - ">="
@@ -33,12 +30,12 @@ dependencies:
33
30
  - 0
34
31
  - 0
35
32
  version: 1.0.0
33
+ prerelease: false
34
+ name: bundler
36
35
  type: :development
37
- requirement: *id001
36
+ version_requirements: *id001
38
37
  - !ruby/object:Gem::Dependency
39
- name: rspec
40
- prerelease: false
41
- version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ requirement: &id002 !ruby/object:Gem::Requirement
42
39
  none: false
43
40
  requirements:
44
41
  - - ~>
@@ -49,12 +46,12 @@ dependencies:
49
46
  - 4
50
47
  - 0
51
48
  version: 2.4.0
49
+ prerelease: false
50
+ name: rspec
52
51
  type: :development
53
- requirement: *id002
52
+ version_requirements: *id002
54
53
  - !ruby/object:Gem::Dependency
55
- name: rake
56
- prerelease: false
57
- version_requirements: &id003 !ruby/object:Gem::Requirement
54
+ requirement: &id003 !ruby/object:Gem::Requirement
58
55
  none: false
59
56
  requirements:
60
57
  - - ">="
@@ -63,12 +60,12 @@ dependencies:
63
60
  segments:
64
61
  - 0
65
62
  version: "0"
63
+ prerelease: false
64
+ name: rake
66
65
  type: :development
67
- requirement: *id003
66
+ version_requirements: *id003
68
67
  - !ruby/object:Gem::Dependency
69
- name: awesome_print
70
- prerelease: false
71
- version_requirements: &id004 !ruby/object:Gem::Requirement
68
+ requirement: &id004 !ruby/object:Gem::Requirement
72
69
  none: false
73
70
  requirements:
74
71
  - - ">="
@@ -77,28 +74,42 @@ dependencies:
77
74
  segments:
78
75
  - 0
79
76
  version: "0"
77
+ prerelease: false
78
+ name: pry
80
79
  type: :development
81
- requirement: *id004
80
+ version_requirements: *id004
82
81
  - !ruby/object:Gem::Dependency
83
- name: fog
82
+ requirement: &id005 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
84
91
  prerelease: false
85
- version_requirements: &id005 !ruby/object:Gem::Requirement
92
+ name: pry-nav
93
+ type: :development
94
+ version_requirements: *id005
95
+ - !ruby/object:Gem::Dependency
96
+ requirement: &id006 !ruby/object:Gem::Requirement
86
97
  none: false
87
98
  requirements:
88
99
  - - ~>
89
100
  - !ruby/object:Gem::Version
90
- hash: 23
101
+ hash: 15
91
102
  segments:
92
103
  - 1
93
- - 1
94
- - 2
95
- version: 1.1.2
104
+ - 6
105
+ - 0
106
+ version: 1.6.0
107
+ prerelease: false
108
+ name: fog
96
109
  type: :runtime
97
- requirement: *id005
110
+ version_requirements: *id006
98
111
  - !ruby/object:Gem::Dependency
99
- name: parallel
100
- prerelease: false
101
- version_requirements: &id006 !ruby/object:Gem::Requirement
112
+ requirement: &id007 !ruby/object:Gem::Requirement
102
113
  none: false
103
114
  requirements:
104
115
  - - ~>
@@ -109,12 +120,12 @@ dependencies:
109
120
  - 5
110
121
  - 14
111
122
  version: 0.5.14
123
+ prerelease: false
124
+ name: parallel
112
125
  type: :runtime
113
- requirement: *id006
126
+ version_requirements: *id007
114
127
  - !ruby/object:Gem::Dependency
115
- name: active_support
116
- prerelease: false
117
- version_requirements: &id007 !ruby/object:Gem::Requirement
128
+ requirement: &id008 !ruby/object:Gem::Requirement
118
129
  none: false
119
130
  requirements:
120
131
  - - ">="
@@ -123,12 +134,12 @@ dependencies:
123
134
  segments:
124
135
  - 0
125
136
  version: "0"
137
+ prerelease: false
138
+ name: active_support
126
139
  type: :runtime
127
- requirement: *id007
140
+ version_requirements: *id008
128
141
  - !ruby/object:Gem::Dependency
129
- name: term-ansicolor
130
- prerelease: false
131
- version_requirements: &id008 !ruby/object:Gem::Requirement
142
+ requirement: &id009 !ruby/object:Gem::Requirement
132
143
  none: false
133
144
  requirements:
134
145
  - - ">="
@@ -137,12 +148,12 @@ dependencies:
137
148
  segments:
138
149
  - 0
139
150
  version: "0"
151
+ prerelease: false
152
+ name: uuidtools
140
153
  type: :runtime
141
- requirement: *id008
154
+ version_requirements: *id009
142
155
  - !ruby/object:Gem::Dependency
143
- name: uuidtools
144
- prerelease: false
145
- version_requirements: &id009 !ruby/object:Gem::Requirement
156
+ requirement: &id010 !ruby/object:Gem::Requirement
146
157
  none: false
147
158
  requirements:
148
159
  - - ">="
@@ -151,8 +162,10 @@ dependencies:
151
162
  segments:
152
163
  - 0
153
164
  version: "0"
165
+ prerelease: false
166
+ name: thor
154
167
  type: :runtime
155
- requirement: *id009
168
+ version_requirements: *id010
156
169
  description: "\n Create, start, stop, destroy instances from the command line\n based on a YAML description of your instances.\n "
157
170
  email:
158
171
  - julien.letessier@gmail.com
@@ -163,33 +176,44 @@ extensions: []
163
176
  extra_rdoc_files: []
164
177
 
165
178
  files:
179
+ - .gitignore
166
180
  - .rspec
167
181
  - Gemfile
168
182
  - Gemfile.lock
183
+ - LICENCE
169
184
  - README.md
170
185
  - Rakefile
171
186
  - bin/guignol
172
187
  - guignol.gemspec
188
+ - lib/core_ext/array/collect_key.rb
189
+ - lib/core_ext/hash/map_to_hash.rb
173
190
  - lib/guignol.rb
174
- - lib/guignol/array/collect_key.rb
175
- - lib/guignol/commands.rb
176
191
  - lib/guignol/commands/base.rb
192
+ - lib/guignol/commands/clone.rb
177
193
  - lib/guignol/commands/create.rb
194
+ - lib/guignol/commands/execute.rb
178
195
  - lib/guignol/commands/fix_dns.rb
179
- - lib/guignol/commands/help.rb
180
196
  - lib/guignol/commands/kill.rb
181
197
  - lib/guignol/commands/list.rb
182
198
  - lib/guignol/commands/start.rb
183
199
  - lib/guignol/commands/stop.rb
184
200
  - lib/guignol/commands/uuid.rb
185
- - lib/guignol/instance.rb
186
- - lib/guignol/shared.rb
201
+ - lib/guignol/configuration.rb
202
+ - lib/guignol/connection.rb
203
+ - lib/guignol/env.rb
204
+ - lib/guignol/logger.rb
205
+ - lib/guignol/models/base.rb
206
+ - lib/guignol/models/instance.rb
207
+ - lib/guignol/models/volume.rb
187
208
  - lib/guignol/shell.rb
188
209
  - lib/guignol/tty_spinner.rb
189
210
  - lib/guignol/version.rb
190
- - lib/guignol/volume.rb
211
+ - spec/guignol/configuration_spec.rb
191
212
  - spec/guignol/instance_spec.rb
213
+ - spec/guignol/volume_spec.rb
192
214
  - spec/spec.opts
215
+ - spec/spec_helper.rb
216
+ - tmp/.keepme
193
217
  has_rdoc: true
194
218
  homepage: https://github.com/mezis/guignol
195
219
  licenses: []
@@ -222,10 +246,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
246
  requirements: []
223
247
 
224
248
  rubyforge_project:
225
- rubygems_version: 1.6.2
249
+ rubygems_version: 1.3.9.5
226
250
  signing_key:
227
251
  specification_version: 3
228
252
  summary: Manipulate Amazon EC2 instances
229
253
  test_files:
254
+ - spec/guignol/configuration_spec.rb
230
255
  - spec/guignol/instance_spec.rb
256
+ - spec/guignol/volume_spec.rb
231
257
  - spec/spec.opts
258
+ - spec/spec_helper.rb