blimpy 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,6 +26,20 @@ Feature: Start a VM or cluster of VMs in the cloud
26
26
  Up, up and away!
27
27
  """
28
28
 
29
+ Scenario: Start with an invalid Blimpfile
30
+ Given I have the Blimpfile:
31
+ """
32
+ Blimpy.fleet do |f|
33
+ f.bork
34
+ end
35
+ """
36
+ When I run `blimpy start`
37
+ Then the exit status should be 1
38
+ And the output should contain:
39
+ """
40
+ The Blimpfile is invalid!
41
+ """
42
+
29
43
  @slow @destroy
30
44
  Scenario: start with a functional Blimpfile
31
45
  Given I have the Blimpfile:
@@ -1,7 +1,6 @@
1
1
  Before do
2
2
  @cwd = Dir.pwd
3
3
  @tempdir = TempDir.create(:basename => 'blimpy_test')
4
- puts "Using tempdir: #{@tempdir}"
5
4
  Dir.chdir(@tempdir)
6
5
  @dirs = [@tempdir]
7
6
  end
@@ -188,19 +188,14 @@ module Blimpy
188
188
  @exec_commands = use_exec
189
189
  end
190
190
 
191
+ def fog
192
+ raise NotImplementedError, '#fog should be implemented by cloud-specific subclasses'
193
+ end
194
+
191
195
  private
192
196
 
193
197
  def create_host
194
- tags = @tags.merge({:Name => @name, :CreatedBy => 'Blimpy', :BlimpyFleetId => @fleet_id})
195
- if @fog.nil?
196
- @fog = Fog::Compute.new(:provider => 'AWS', :region => @region)
197
- end
198
-
199
- Blimpy::Keys.import_key(@fog)
200
- @fog.servers.create(:image_id => @image_id,
201
- :key_name => Blimpy::Keys.key_name,
202
- :groups => [@group],
203
- :tags => tags)
198
+ raise NotImplementedError, '#create_host should be implemented by a cloud-specific subclass'
204
199
  end
205
200
  end
206
201
  end
@@ -23,9 +23,31 @@ module Blimpy::Boxes
23
23
  end
24
24
 
25
25
  def validate!
26
- if Fog::Compute[:aws].security_groups.get(@group).nil?
27
- raise Blimpy::BoxValidationError
26
+ if @region.nil?
27
+ raise Blimpy::BoxValidationError, "Cannot spin up machine without a set region"
28
28
  end
29
+
30
+ if fog.security_groups.get(@group).nil?
31
+ raise Blimpy::BoxValidationError, "The security group '#{@group}' does not exist in #{@region}"
32
+ end
33
+ end
34
+
35
+ def fog
36
+ @fog ||= begin
37
+ Fog::Compute.new(:provider => 'AWS', :region => @region)
38
+ end
39
+ end
40
+
41
+ private
42
+
43
+ def create_host
44
+ tags = @tags.merge({:Name => @name, :CreatedBy => 'Blimpy', :BlimpyFleetId => @fleet_id})
45
+
46
+ Blimpy::Keys.import_key(fog)
47
+ fog.servers.create(:image_id => @image_id,
48
+ :key_name => Blimpy::Keys.key_name,
49
+ :groups => [@group],
50
+ :tags => tags)
29
51
  end
30
52
  end
31
53
  end
@@ -62,7 +62,13 @@ module Blimpy
62
62
  method_options :"dry-run" => :boolean
63
63
  def start
64
64
  ensure_blimpfile
65
- engine = load_engine
65
+ begin
66
+ engine = load_engine
67
+ rescue Blimpy::InvalidBlimpFileError => e
68
+ puts "The Blimpfile is invalid!"
69
+ exit 1
70
+ end
71
+
66
72
  puts 'Up, up and away!'
67
73
 
68
74
  if options[:'dry-run']
@@ -111,7 +117,7 @@ module Blimpy
111
117
  # Blimpfile created on #{Time.now}
112
118
 
113
119
  Blimpy.fleet do |fleet|
114
- fleet.add do |ship|
120
+ fleet.add(:aws) do |ship|
115
121
  ship.name = 'Excelsior'
116
122
  ship.group = 'default'
117
123
  end
@@ -1,3 +1,3 @@
1
1
  module Blimpy
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -28,6 +28,23 @@ describe Blimpy::Box do
28
28
  end
29
29
  end
30
30
 
31
+ describe '#create_host' do
32
+ it 'should raise a NotImplementedError' do
33
+ # lol private
34
+ expect {
35
+ subject.send(:create_host)
36
+ }.to raise_error(NotImplementedError)
37
+ end
38
+ end
39
+
40
+ describe '#fog' do
41
+ it 'should raise NotImplementedError' do
42
+ expect {
43
+ subject.fog.should be_nil
44
+ }.to raise_error(NotImplementedError)
45
+ end
46
+ end
47
+
31
48
  context 'with a mocked server' do
32
49
  let(:server_id) { 'id-0xdeadbeef' }
33
50
  let(:server) do
@@ -42,15 +42,23 @@ describe Blimpy::Boxes::AWS do
42
42
  group.stub(:name).and_return('MockedGroup')
43
43
  group
44
44
  end
45
- let(:groups) { double('Fog::Compute::AWS::SecurityGroups') }
45
+ let (:fog) { mock('Fog::Compute::AWS') }
46
46
 
47
47
  before :each do
48
- Fog::Compute.stub_chain(:[], :security_groups).and_return(groups)
48
+ subject.stub(:fog).and_return(fog)
49
+ end
50
+
51
+ it 'should raise if no region has been set' do
52
+ expect {
53
+ # This may be a silly test
54
+ subject.instance_variable_set(:@region, nil)
55
+ subject.validate!
56
+ }.to raise_error(Blimpy::BoxValidationError)
49
57
  end
50
58
 
51
59
  context 'with invalid settings' do
52
60
  it 'should raise with a bad security group' do
53
- groups.should_receive(:get).and_return(nil)
61
+ fog.stub_chain(:security_groups, :get).and_return(nil)
54
62
  expect {
55
63
  subject.validate!
56
64
  }.to raise_error(Blimpy::BoxValidationError)
@@ -59,7 +67,7 @@ describe Blimpy::Boxes::AWS do
59
67
 
60
68
  context 'with valid settings' do
61
69
  it 'should validate with a good security group' do
62
- groups.should_receive(:get).with('MockedGroup').and_return(security_group)
70
+ fog.stub_chain(:security_groups, :get).with('MockedGroup').and_return(security_group)
63
71
  expect {
64
72
  subject.group = 'MockedGroup'
65
73
  subject.validate!
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.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-05-19 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog
16
- requirement: &9308320 !ruby/object:Gem::Requirement
16
+ requirement: &13915520 !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: *9308320
24
+ version_requirements: *13915520
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thor
27
- requirement: &9307780 !ruby/object:Gem::Requirement
27
+ requirement: &13914980 !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: *9307780
35
+ version_requirements: *13914980
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: minitar
38
- requirement: &9307240 !ruby/object:Gem::Requirement
38
+ requirement: &13914440 !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: *9307240
46
+ version_requirements: *13914440
47
47
  description: Blimpy is a tool for managing a fleet of machines in the CLOUD!
48
48
  email:
49
49
  - tyler@monkeypox.org