blimpy 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -18,3 +18,5 @@ tmp
18
18
  .blimpy.d
19
19
  .rvmrc
20
20
  Blimpyfile
21
+ features/report.html
22
+ features/reports
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ gemspec
5
5
 
6
6
  group :development do
7
7
  gem 'rake'
8
- gem 'rspec'
8
+ gem 'rspec', '~> 2.11.0'
9
9
  gem 'cucumber'
10
10
  gem 'ci_reporter'
11
11
  gem 'aruba'
data/README.md CHANGED
@@ -50,8 +50,8 @@ Here's an example Blimpfile:
50
50
  fleet.add(:aws) do |ship|
51
51
  ship.name = 'rails-app'
52
52
  ship.ports = [22, 80, 8080] # [Optional] Create a security group with these ports open
53
- ship.image_id = 'ami-349b495d' # [Optional] defaults to Ubuntu 10.04 64-bit
54
- ship.livery = 'rails' # [Optional]
53
+ ship.image_id = 'ami-4438b474' # [Optional] defaults to Ubuntu 12.04 64-bit
54
+ ship.livery = Blimpy::Livery::CWD # [Optional]
55
55
  ship.group = 'Simple' # [Optional] The name of the desired Security Group
56
56
  ship.region = 'us-west-1' # [Optional] defaults to us-west-2
57
57
  ship.username = 'ubuntu' # [Optional] SSH username, defaults to "ubuntu" for AWS machines
data/Rakefile CHANGED
@@ -9,28 +9,28 @@ RSpec::Core::RakeTask.new('spec') do |t|
9
9
  end
10
10
 
11
11
 
12
- namespace :cucumber do
13
- cucumber_opts = '--color --format progress --tags ~@wip'
12
+ Cucumber::Rake::Task.new('cucumber')
14
13
 
15
- Cucumber::Rake::Task.new('basic') do |t|
16
- t.cucumber_opts = cucumber_opts + ' --tags ~@slow'
14
+ namespace :cucumber do
15
+ Cucumber::Rake::Task.new('aws') do |t|
16
+ t.cucumber_opts = '-p aws'
17
17
  end
18
18
 
19
- Cucumber::Rake::Task.new('integration') do |t|
20
- t.cucumber_opts = cucumber_opts + ' --tags @slow --tags ~@openstack'
19
+ Cucumber::Rake::Task.new('openstack') do |t|
20
+ t.cucumber_opts = '-p openstack'
21
21
  end
22
22
 
23
- Cucumber::Rake::Task.new('openstack') do |t|
24
- t.cucumber_opts = cucumber_opts + ' --tags @openstack'
23
+ Cucumber::Rake::Task.new('wip') do |t|
24
+ t.cucumber_opts = '-p wip'
25
25
  end
26
26
  end
27
27
 
28
28
  desc 'Run the basic test suite'
29
- task :test => [:spec, :"cucumber:basic"]
29
+ task :test => ['spec', 'cucumber']
30
30
 
31
31
  namespace :test do
32
- desc 'Run all the tests, including the slow integration tests'
33
- task :all => [:spec, :'cucumber:basic', :'cucumber:integration']
32
+ desc 'Run all the tests, including the slow (AWS-based) integration tests'
33
+ task :all => ['spec', 'cucumber', 'cucumber:aws']
34
34
  end
35
35
 
36
36
 
@@ -0,0 +1,7 @@
1
+ <%
2
+ opts = "--color --format progress --format junit --out features/reports --format html --out features/report.html"
3
+ %>
4
+ default: <%= opts %> --tags ~@wip --tags ~@slow
5
+ aws: <%= opts %> --tags ~@wip --tags @slow --tags ~@openstack
6
+ openstack: <%= opts %> --tags ~@wip --tags @openstack
7
+ wip: <%= opts %> --tags @wip
@@ -0,0 +1,8 @@
1
+ Feature: Expose the current version to the user
2
+ As a user
3
+ I want to be able to check the blimpy version
4
+ So that I can tell if I should update or not
5
+
6
+ Scenario: Simple version check
7
+ When I run `blimpy version`
8
+ Then the output should contain the current Blimpy version
@@ -4,6 +4,32 @@ Feature: Craft machines based on a livery
4
4
  When I specify a specific livery then that livery should provision
5
5
  the host the way I would expect it to.
6
6
 
7
+ Scenario: Using a configuration-less livery
8
+ Given the following Blimpfile contents:
9
+ """
10
+ Blimpy.fleet do |f|
11
+ f.add(:aws) do |ship|
12
+ ship.name = 'cucumber-livery'
13
+ ship.livery = Blimpy::Livery::CWD
14
+ end
15
+ end
16
+ """
17
+ When I evaluate the Blimpfile
18
+ Then the CWD livery should be set up
7
19
 
8
- @slow @destroy @wip
9
- Scenario: freebsd_puppet
20
+ Scenario: Configuration-less liveries
21
+ Given the following Blimpfile contents:
22
+ """
23
+ Blimpy.fleet do |f|
24
+ f.add(:aws) do |ship|
25
+ ship.name = 'cucumber-livery'
26
+ ship.livery = Blimpy::Livery::Puppet.configure do |p|
27
+ p.module_path = './modules'
28
+ p.manifest_path = './test/site.pp'
29
+ p.options = '--verbose'
30
+ end
31
+ end
32
+ end
33
+ """
34
+ When I evaluate the Blimpfile
35
+ Then the Puppet livery should be correctly configured
@@ -52,3 +52,7 @@ Then /^the output should contain the right DNS info$/ do
52
52
  end
53
53
  step %{the output should contain "#{internal_name}"}
54
54
  end
55
+
56
+ Then /^the output should contain the current Blimpy version$/ do
57
+ assert_partial_output(Blimpy::VERSION, all_output)
58
+ end
@@ -0,0 +1,19 @@
1
+ Given /^the following Blimpfile contents:$/ do |buffer|
2
+ @blimpfile = buffer
3
+ end
4
+
5
+ When /^I evaluate the Blimpfile$/ do
6
+ @blimpfile.should_not be_nil
7
+ @fleet = eval(@blimpfile)
8
+ end
9
+
10
+ Then /^the CWD livery should be set up$/ do
11
+ @fleet.should_not be_nil
12
+ @fleet.ships.first.livery.should == Blimpy::Livery::CWD
13
+ end
14
+
15
+ Then /^the Puppet livery should be correctly configured$/ do
16
+ @fleet.should_not be_nil
17
+ @fleet.ships.first.livery.should be_instance_of(Blimpy::Livery::Puppet)
18
+ end
19
+
@@ -1,19 +1,26 @@
1
+ require 'rubygems'
1
2
  require 'aruba/cucumber'
2
3
  require 'fileutils'
4
+ require 'ruby-debug'
3
5
  require 'temp_dir'
4
6
 
5
7
 
6
8
  # Pull in my gem working directory bin directory
7
9
  ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
8
10
 
11
+ $:.unshift(File.expand_path(File.dirname(__FILE__) + "/../../lib"))
12
+ require 'blimpy'
13
+ require 'blimpy/livery'
9
14
 
10
- module BlimpyWorld
11
- def create_blimpfile(string)
12
- path = File.join(@tempdir, 'Blimpfile')
13
- File.open(path, 'w') do |f|
14
- f.write(string)
15
+ module Blimpy
16
+ module Cucumber
17
+ def create_blimpfile(string)
18
+ path = File.join(@tempdir, 'Blimpfile')
19
+ File.open(path, 'w') do |f|
20
+ f.write(string)
21
+ end
15
22
  end
16
23
  end
17
24
  end
18
25
 
19
- World(BlimpyWorld)
26
+ World(Blimpy::Cucumber)
@@ -1,5 +1,8 @@
1
+ require 'rubygems'
2
+ require 'fog/core'
3
+ require 'fog/compute'
4
+
1
5
  require 'blimpy/box'
2
- require 'blimpy/engine'
3
6
  require 'blimpy/fleet'
4
7
  require 'blimpy/version'
5
8
 
@@ -13,6 +16,22 @@ module Blimpy
13
16
  fleet
14
17
  end
15
18
 
19
+ def self.load_file(file_content)
20
+ if file_content.nil? || file_content.empty?
21
+ raise InvalidBlimpFileError, 'File appears empty'
22
+ end
23
+
24
+ begin
25
+ fleet = eval(file_content)
26
+ if fleet and !(fleet.instance_of? Blimpy::Fleet)
27
+ raise Exception, 'File does not create a Fleet'
28
+ end
29
+ rescue Exception => e
30
+ raise InvalidBlimpFileError, e.to_s
31
+ end
32
+ fleet
33
+ end
34
+
16
35
  class UnknownError < Exception
17
36
  end
18
37
  class InvalidBlimpFileError < Exception
@@ -27,4 +46,5 @@ module Blimpy
27
46
  end
28
47
  class UnsupportedFeatureException < Exception
29
48
  end
49
+ class InvalidLiveryException < Exception; end;
30
50
  end
@@ -75,10 +75,16 @@ module Blimpy
75
75
 
76
76
  def bootstrap
77
77
  @exec_commands = false
78
- unless livery.nil?
79
- wait_for_sshd
80
- bootstrap_livery
78
+ if @livery.nil?
79
+ return
80
+ end
81
+
82
+ if @livery.respond_to? :new
83
+ @livery = @livery.new
81
84
  end
85
+
86
+ wait_for_sshd
87
+ bootstrap_livery
82
88
  end
83
89
 
84
90
  def stop
@@ -204,46 +210,14 @@ module Blimpy
204
210
  end
205
211
 
206
212
  def bootstrap_livery
207
- script = File.expand_path(File.dirname(__FILE__) + "/../../scripts/#{livery}.sh")
208
-
209
- if livery == :cwd
210
- script = File.join(Dir.pwd, '/bootstrap.sh')
211
- end
212
-
213
- unless File.exists?(script)
214
- puts "Could not find `#{script}` which is needed to kick-start the machine"
215
- return
216
- end
217
-
218
- unpack_command = 'true'
219
- dir_name = File.basename(Dir.pwd)
220
-
221
- if can_rsync?
222
- unpack_command = "cd #{dir_name}"
223
- run_command('rsync', '-avL',
224
- '-e',
225
- 'ssh -o StrictHostKeyChecking=no',
226
- '--exclude=.git',
227
- '--exclude=.svn',
228
- '--exclude=.blimpy.d',
229
- '.',
230
- "#{username}@#{dns}:#{dir_name}/")
231
- else
232
- puts "Remote host has no rsync(1), falling back to copying a full tarball over"
233
- tarball = Blimpy::Livery.tarball_directory(Dir.pwd)
234
- scp_file(tarball)
235
- # HAXX
236
- basename = File.basename(tarball)
237
- ssh_into("tar -zxf #{basename} && cd #{dir_name}")
213
+ if @livery.kind_of? Symbol
214
+ raise Blimpy::InvalidLiveryException, 'Symbol liveries are unsupported!'
238
215
  end
239
216
 
240
- puts 'Bootstrapping the livery'
241
- run_sudo = 'sudo'
242
- if username == 'root'
243
- run_sudo = ''
244
- end
245
- scp_file(script, dir_name)
246
- ssh_into("cd #{dir_name} && #{run_sudo} ./#{File.basename(script)}")
217
+ @livery.setup_on(self)
218
+ @livery.preflight(self)
219
+ @livery.flight(self)
220
+ @livery.postflight(self)
247
221
  end
248
222
 
249
223
  def wait_for_sshd
@@ -273,10 +247,6 @@ module Blimpy
273
247
  raise NotImplementedError, '#fog should be implemented by cloud-specific subclasses'
274
248
  end
275
249
 
276
- def can_rsync?
277
- @can_rsync ||= ssh_into('-q', 'which rsync > /dev/null')
278
- end
279
-
280
250
 
281
251
  private
282
252
 
@@ -5,8 +5,8 @@ module Blimpy::Boxes
5
5
  class AWS < Blimpy::Box
6
6
  # Default to US West (Oregon)
7
7
  DEFAULT_REGION = 'us-west-2'
8
- # Default to 10.04 64-bit
9
- DEFAULT_IMAGE_ID = 'ami-ec0b86dc'
8
+ # Default to 12.04 64-bit
9
+ DEFAULT_IMAGE_ID = 'ami-4438b474'
10
10
 
11
11
  def self.fog_server_for_instance(id, blimpdata)
12
12
  region = blimpdata[:region] || DEFAULT_REGION
@@ -2,7 +2,6 @@ require 'rubygems'
2
2
  require 'thor'
3
3
 
4
4
  require 'blimpy'
5
- require 'blimpy/engine'
6
5
 
7
6
  module Blimpy
8
7
  class CLI < Thor
@@ -16,18 +15,16 @@ module Blimpy
16
15
  end
17
16
  end
18
17
 
19
- def load_engine
20
- engine = Blimpy::Engine.new
21
- engine.load_file(File.open(BLIMPFILE).read)
22
- engine
18
+ def load_blimpfile
19
+ Blimpy.load_file(File.open(BLIMPFILE).read)
23
20
  end
24
21
 
25
22
  def box_by_name(name)
26
- engine = load_engine
23
+ fleet = load_blimpfile
27
24
  box = nil
28
25
  ship_id = nil
29
26
  data = nil
30
- engine.fleet.members.each do |instance_id, instance_data|
27
+ fleet.members.each do |instance_id, instance_data|
31
28
  next unless instance_data[:name] == name
32
29
  ship_id = instance_id
33
30
  data = instance_data
@@ -38,7 +35,7 @@ module Blimpy
38
35
  return nil
39
36
  end
40
37
 
41
- engine.fleet.ships.each do |ship|
38
+ fleet.ships.each do |ship|
42
39
  next unless ship.name == name
43
40
  ship.with_data(ship_id, data)
44
41
  return ship
@@ -62,7 +59,7 @@ module Blimpy
62
59
  def start
63
60
  ensure_blimpfile
64
61
  begin
65
- engine = load_engine
62
+ fleet = load_blimpfile
66
63
  rescue Blimpy::InvalidBlimpFileError => e
67
64
  puts "The Blimpfile is invalid!"
68
65
  exit 1
@@ -73,7 +70,7 @@ module Blimpy
73
70
  exit 0
74
71
  end
75
72
 
76
- engine.fleet.start
73
+ fleet.start
77
74
  end
78
75
 
79
76
  desc 'status', 'Show running blimps'
@@ -185,5 +182,10 @@ end
185
182
  end
186
183
  end
187
184
  end
185
+
186
+ desc 'version', 'Print the current Blimpy gem version'
187
+ def version
188
+ puts Blimpy::VERSION
189
+ end
188
190
  end
189
191
  end
@@ -2,8 +2,11 @@ require 'rubygems'
2
2
  require 'zlib'
3
3
  require 'archive/tar/minitar'
4
4
 
5
+ require 'blimpy/livery/cwd'
6
+ require 'blimpy/livery/puppet'
7
+
5
8
  module Blimpy
6
- class Livery
9
+ module Livery
7
10
  def self.tarball_directory(directory)
8
11
  if directory.nil? || !(File.directory? directory)
9
12
  raise ArgumentError, "The argument '#{directory}' doesn't appear to be a directory"
@@ -0,0 +1,59 @@
1
+
2
+ module Blimpy
3
+ module Livery
4
+ class Base
5
+ def preflight(*args)
6
+ end
7
+
8
+ def flight(*args)
9
+ raise NotImplementedError
10
+ end
11
+
12
+ def postflight(*args)
13
+ end
14
+
15
+ def rsync_excludes
16
+ ['.git', '.svn', '.blimpy.d']
17
+ end
18
+
19
+ def rsync_command
20
+ excludes = rsync_excludes.map { |x| "--exclude=#{x}" }
21
+ ['rsync',
22
+ '-avL',
23
+ '-e',
24
+ 'ssh -o StrictHostKeyChecking=no'] + excludes
25
+ end
26
+
27
+ def can_rsync?(box)
28
+ @can_rsync ||= box.ssh_into('-q', 'which rsync > /dev/null')
29
+ end
30
+
31
+ def sync_to(box)
32
+ if can_rsync? box
33
+ command = rsync_command + ['.', "#{box.username}@#{box.dns}:#{dir_name}/"]
34
+ box.run_command(*command)
35
+ else
36
+ puts "Remote host has no rsync(1), falling back to copying a full tarball over"
37
+ tarball = Blimpy::Livery.tarball_directory(livery_root)
38
+ box.scp_file(tarball)
39
+ # HAXX
40
+ basename = File.basename(tarball)
41
+ box.ssh_into("tar -zxf #{basename} && cd #{dir_name}")
42
+ end
43
+
44
+ end
45
+
46
+ def livery_root
47
+ Dir.pwd
48
+ end
49
+
50
+ def dir_name
51
+ File.basename(livery_root)
52
+ end
53
+
54
+ def setup_on(box)
55
+ sync_to(box)
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,33 @@
1
+ require 'blimpy/livery/base'
2
+
3
+ module Blimpy
4
+ module Livery
5
+ class CWD < Base
6
+ def script
7
+ 'bootstrap.sh'
8
+ end
9
+
10
+ def preflight(box)
11
+ box.scp_file(bootstrap_script, dir_name)
12
+ end
13
+
14
+ def use_sudo?(box)
15
+ box.username != 'root'
16
+ end
17
+
18
+ def flight(box)
19
+ run_sudo = 'sudo'
20
+
21
+ unless use_sudo?(box)
22
+ run_sudo = ''
23
+ end
24
+
25
+ box.ssh_into("cd #{dir_name} && #{run_sudo} ./#{script}")
26
+ end
27
+
28
+ def bootstrap_script
29
+ File.join(livery_root, script)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,64 @@
1
+ require 'blimpy/livery/base'
2
+ require 'blimpy/livery/cwd'
3
+
4
+ module Blimpy
5
+ module Livery
6
+ class Puppet < CWD
7
+ attr_accessor :module_path, :manifest_path, :options
8
+
9
+ def initialize(*args)
10
+ super
11
+ @module_path = './modules'
12
+ @manifest_path = 'manifests/site.pp'
13
+ @options = '--verbose'
14
+ @puppet_exists = false
15
+ end
16
+
17
+ def script
18
+ 'puppet.sh'
19
+ end
20
+
21
+ def preflight(box)
22
+ # If we find Puppet in our default path, we don't really need to send
23
+ # the bootstrap script again
24
+ @puppet_exists = box.ssh_into('which puppet > /dev/null')
25
+ unless @puppet_exists
26
+ super(box)
27
+ end
28
+ end
29
+
30
+ def flight(box)
31
+ unless @puppet_exists
32
+ # This should get our puppet.sh bootstrap script run
33
+ super(box)
34
+ end
35
+
36
+ # At this point we should be safe to actually invoke Puppet
37
+ command = "puppet apply --modulepath=#{module_path} #{options} #{manifest_path}"
38
+
39
+ run_sudo = ''
40
+ run_sudo = 'sudo' if use_sudo?(box)
41
+
42
+ box.ssh_into("cd #{dir_name} && #{run_sudo} #{command}")
43
+ end
44
+
45
+ def postflight(box)
46
+ end
47
+
48
+ def bootstrap_script
49
+ File.expand_path(File.dirname(__FILE__) + "/../../../scripts/#{script}")
50
+ end
51
+
52
+ def self.configure(&block)
53
+ if block.nil?
54
+ raise Blimpy::InvalidLiveryException, "Puppet livery must be given a block in order to configure itself"
55
+ end
56
+ instance = self.new
57
+ yield instance
58
+ instance
59
+ end
60
+
61
+
62
+ end
63
+ end
64
+ end
@@ -1,3 +1,3 @@
1
1
  module Blimpy
2
- VERSION = "0.5.1"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -40,5 +40,3 @@ else
40
40
  fi
41
41
 
42
42
  fi
43
-
44
- puppet apply --modulepath=./modules --verbose manifests/site.pp
@@ -144,5 +144,55 @@ describe Blimpy::Box do
144
144
  end
145
145
  end
146
146
  end
147
+
148
+ describe '#bootstrap_livery' do
149
+ let(:livery) { double('Mock-livery') }
150
+
151
+ it 'should raise an error if the livery is a symbol (old style)' do
152
+ subject.livery = :deprecated
153
+ expect {
154
+ subject.bootstrap_livery
155
+ }.to raise_error(Blimpy::InvalidLiveryException)
156
+ end
157
+
158
+ it 'should invoke the correct livery methods' do
159
+ subject.livery = livery
160
+ livery.should_receive(:setup_on).with(subject)
161
+ livery.should_receive(:preflight).with(subject)
162
+ livery.should_receive(:flight).with(subject)
163
+ livery.should_receive(:postflight).with(subject)
164
+
165
+ subject.bootstrap_livery
166
+ end
167
+ end
168
+
169
+ describe '#bootstrap' do
170
+ context 'when livery is not defined' do
171
+ before :each do
172
+ subject.livery = nil
173
+ end
174
+
175
+ it 'should not call any of the bootstrap methods' do
176
+ subject.should_receive(:wait_for_sshd).never
177
+ subject.should_receive(:bootstrap_livery).never
178
+ subject.bootstrap
179
+ end
180
+ end
181
+
182
+ context 'when a livery is defined' do
183
+ before :each do
184
+ subject.should_receive(:wait_for_sshd)
185
+ subject.should_receive(:bootstrap_livery)
186
+ end
187
+
188
+ context 'as a class object' do
189
+ it 'should instantiate the livery' do
190
+ subject.livery = Blimpy::Livery::CWD
191
+ subject.livery.should_receive(:new)
192
+ subject.bootstrap
193
+ end
194
+ end
195
+ end
196
+ end
147
197
  end
148
198
  end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+ require 'blimpy/livery/base'
3
+
4
+
5
+ describe Blimpy::Livery::Base do
6
+ describe '#rsync_excludes' do
7
+ it { subject.rsync_excludes.should be_instance_of Array }
8
+ end
9
+
10
+ describe '#rsync_command' do
11
+ subject { described_class.new.rsync_command }
12
+
13
+ it { expect(subject.first).to eql('rsync') }
14
+ it { should include('--exclude=.git') }
15
+ end
16
+
17
+ describe '#livery_root' do
18
+ it { expect(subject.livery_root).to eql(Dir.pwd) }
19
+ end
20
+
21
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ require 'blimpy/livery/cwd'
4
+
5
+ describe Blimpy::Livery::CWD do
6
+
7
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ require 'blimpy/livery/puppet'
4
+
5
+ describe Blimpy::Livery::Puppet do
6
+ context 'class methods' do
7
+ subject { described_class }
8
+
9
+ it { should respond_to :configure }
10
+ describe '#configure' do
11
+ it 'should return an instance of the Puppet livery' do
12
+ result = subject.configure { |p| }
13
+ expect(result).to be_instance_of described_class
14
+ end
15
+
16
+ it 'should raise a nice error if no configuration specified' do
17
+ expect {
18
+ subject.configure
19
+ }.to raise_error(Blimpy::InvalidLiveryException)
20
+ end
21
+
22
+ it 'should yield an instance of the Puppet livery' do
23
+ yielded = nil
24
+ subject.configure { |p| yielded = p }
25
+ expect(yielded).to be_instance_of described_class
26
+ end
27
+ end
28
+ end
29
+
30
+ it { should respond_to :module_path= }
31
+ it { should respond_to :manifest_path= }
32
+ it { should respond_to :options= }
33
+ end
@@ -25,4 +25,58 @@ describe Blimpy do
25
25
  end
26
26
  end
27
27
  end
28
+
29
+ describe '#load_file' do
30
+ context 'no contents' do
31
+ let(:content) { '' }
32
+
33
+ it 'should raise InvalidBlimpFileError' do
34
+ expect {
35
+ subject.load_file(content)
36
+ }.to raise_error(Blimpy::InvalidBlimpFileError)
37
+ end
38
+
39
+ end
40
+
41
+ context 'invalid content' do
42
+ let(:content) do
43
+ """
44
+ this is totally invalid Ruby
45
+ """
46
+ end
47
+
48
+ it 'should raise InvalidBlimpFileError' do
49
+ expect {
50
+ subject.load_file(content)
51
+ }.to raise_error(Blimpy::InvalidBlimpFileError)
52
+ end
53
+ end
54
+
55
+ context 'valid content' do
56
+ let(:content) do
57
+ """
58
+ Blimpy.fleet do |fleet|
59
+ fleet.add(:aws) do |ship|
60
+ ship.image_id = 'ami-349b495d'
61
+ ship.livery = 'rails'
62
+ ship.group = 'Simple'
63
+ ship.region = 'us-west-1'
64
+ ship.name = 'Rails App Server'
65
+ end
66
+ end
67
+ """
68
+ end
69
+
70
+ it 'should create the appropriate Fleet object' do
71
+ result = subject.load_file(content)
72
+ result.should be_instance_of Blimpy::Fleet
73
+ result.ships.should be_instance_of Array
74
+ result.ships.size.should == 1
75
+
76
+ ship = result.ships.first
77
+ ship.group.should == 'Simple'
78
+ ship.name.should == 'Rails App Server'
79
+ end
80
+ end
81
+ end
28
82
  end
@@ -1,3 +1,6 @@
1
+ require 'rubygems'
2
+ require 'ruby-debug'
3
+
1
4
  $:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
2
5
 
3
6
  require 'blimpy'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blimpy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-20 00:00:00.000000000Z
12
+ date: 2012-08-25 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog
16
- requirement: &7880740 !ruby/object:Gem::Requirement
16
+ requirement: &6595860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *7880740
24
+ version_requirements: *6595860
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thor
27
- requirement: &7879300 !ruby/object:Gem::Requirement
27
+ requirement: &6592700 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *7879300
35
+ version_requirements: *6592700
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: minitar
38
- requirement: &7878680 !ruby/object:Gem::Requirement
38
+ requirement: &6573460 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *7878680
46
+ version_requirements: *6573460
47
47
  description: Blimpy is a tool for managing a fleet of machines in the CLOUD!
48
48
  email:
49
49
  - tyler@monkeypox.org
@@ -59,15 +59,18 @@ files:
59
59
  - Rakefile
60
60
  - bin/blimpy
61
61
  - blimpy.gemspec
62
+ - cucumber.yml
62
63
  - features/cli/init.feature
63
64
  - features/cli/provision.feature
64
65
  - features/cli/scp.feature
65
66
  - features/cli/ssh.feature
66
67
  - features/cli/start.feature
67
68
  - features/cli/status.feature
69
+ - features/cli/version.feature
68
70
  - features/liveries.feature
69
71
  - features/openstack.feature
70
72
  - features/step_definitions/cli_steps.rb
73
+ - features/step_definitions/liveries_steps.rb
71
74
  - features/support/env.rb
72
75
  - features/support/hooks.rb
73
76
  - lib/blimpy.rb
@@ -76,21 +79,25 @@ files:
76
79
  - lib/blimpy/boxes/aws.rb
77
80
  - lib/blimpy/boxes/openstack.rb
78
81
  - lib/blimpy/cli.rb
79
- - lib/blimpy/engine.rb
80
82
  - lib/blimpy/fleet.rb
81
83
  - lib/blimpy/helpers/state.rb
82
84
  - lib/blimpy/keys.rb
83
85
  - lib/blimpy/livery.rb
86
+ - lib/blimpy/livery/base.rb
87
+ - lib/blimpy/livery/cwd.rb
88
+ - lib/blimpy/livery/puppet.rb
84
89
  - lib/blimpy/securitygroups.rb
85
90
  - lib/blimpy/version.rb
86
91
  - scripts/puppet.sh
87
92
  - spec/blimpy/box_spec.rb
88
93
  - spec/blimpy/boxes/aws_spec.rb
89
94
  - spec/blimpy/boxes/openstack_spec.rb
90
- - spec/blimpy/engine_spec.rb
91
95
  - spec/blimpy/fleet_spec.rb
92
96
  - spec/blimpy/helpers/state_spec.rb
93
97
  - spec/blimpy/keys_spec.rb
98
+ - spec/blimpy/livery/base_spec.rb
99
+ - spec/blimpy/livery/cwd_spec.rb
100
+ - spec/blimpy/livery/puppet_spec.rb
94
101
  - spec/blimpy/livery_spec.rb
95
102
  - spec/blimpy/securitygroups_spec.rb
96
103
  - spec/blimpy_spec.rb
@@ -109,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
116
  version: '0'
110
117
  segments:
111
118
  - 0
112
- hash: 1569587934174396261
119
+ hash: 932416498555668498
113
120
  required_rubygems_version: !ruby/object:Gem::Requirement
114
121
  none: false
115
122
  requirements:
@@ -118,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
125
  version: '0'
119
126
  segments:
120
127
  - 0
121
- hash: 1569587934174396261
128
+ hash: 932416498555668498
122
129
  requirements: []
123
130
  rubyforge_project:
124
131
  rubygems_version: 1.8.10
@@ -132,18 +139,22 @@ test_files:
132
139
  - features/cli/ssh.feature
133
140
  - features/cli/start.feature
134
141
  - features/cli/status.feature
142
+ - features/cli/version.feature
135
143
  - features/liveries.feature
136
144
  - features/openstack.feature
137
145
  - features/step_definitions/cli_steps.rb
146
+ - features/step_definitions/liveries_steps.rb
138
147
  - features/support/env.rb
139
148
  - features/support/hooks.rb
140
149
  - spec/blimpy/box_spec.rb
141
150
  - spec/blimpy/boxes/aws_spec.rb
142
151
  - spec/blimpy/boxes/openstack_spec.rb
143
- - spec/blimpy/engine_spec.rb
144
152
  - spec/blimpy/fleet_spec.rb
145
153
  - spec/blimpy/helpers/state_spec.rb
146
154
  - spec/blimpy/keys_spec.rb
155
+ - spec/blimpy/livery/base_spec.rb
156
+ - spec/blimpy/livery/cwd_spec.rb
157
+ - spec/blimpy/livery/puppet_spec.rb
147
158
  - spec/blimpy/livery_spec.rb
148
159
  - spec/blimpy/securitygroups_spec.rb
149
160
  - spec/blimpy_spec.rb
@@ -1,30 +0,0 @@
1
-
2
- require 'rubygems'
3
- require 'fog/core'
4
- require 'fog/compute'
5
-
6
- module Blimpy
7
- class Engine
8
- attr_reader :fleet
9
-
10
- def initialize
11
- @fleet = nil
12
- end
13
-
14
- def load_file(file_content)
15
- if file_content.nil? || file_content.empty?
16
- raise InvalidBlimpFileError, 'File appears empty'
17
- end
18
-
19
- begin
20
- @fleet = eval(file_content)
21
- if @fleet and !(@fleet.instance_of? Blimpy::Fleet)
22
- raise Exception, 'File does not create a Fleet'
23
- end
24
- rescue Exception => e
25
- raise InvalidBlimpFileError, e.to_s
26
- end
27
- @fleet
28
- end
29
- end
30
- end
@@ -1,57 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Blimpy::Engine do
4
- describe '#load_file' do
5
- context 'no contents' do
6
- let(:content) { '' }
7
-
8
- it 'should raise InvalidBlimpFileError' do
9
- expect {
10
- subject.load_file(content)
11
- }.to raise_error(Blimpy::InvalidBlimpFileError)
12
- end
13
-
14
- end
15
-
16
- context 'invalid content' do
17
- let(:content) do
18
- """
19
- this is totally invalid Ruby
20
- """
21
- end
22
-
23
- it 'should raise InvalidBlimpFileError' do
24
- expect {
25
- subject.load_file(content)
26
- }.to raise_error(Blimpy::InvalidBlimpFileError)
27
- end
28
- end
29
-
30
- context 'valid content' do
31
- let(:content) do
32
- """
33
- Blimpy.fleet do |fleet|
34
- fleet.add(:aws) do |ship|
35
- ship.image_id = 'ami-349b495d'
36
- ship.livery = 'rails'
37
- ship.group = 'Simple'
38
- ship.region = 'us-west-1'
39
- ship.name = 'Rails App Server'
40
- end
41
- end
42
- """
43
- end
44
-
45
- it 'should create the appropriate Fleet object' do
46
- result = subject.load_file(content)
47
- result.should be_instance_of Blimpy::Fleet
48
- result.ships.should be_instance_of Array
49
- result.ships.size.should == 1
50
-
51
- ship = result.ships.first
52
- ship.group.should == 'Simple'
53
- ship.name.should == 'Rails App Server'
54
- end
55
- end
56
- end
57
- end