blimpy 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,16 +12,18 @@ module Blimpy
12
12
  DEFAULT_IMAGE_ID = 'ami-ec0b86dc'
13
13
 
14
14
  attr_reader :allowed_regions, :region
15
- attr_accessor :image_id, :livery, :group
15
+ attr_accessor :image_id, :livery, :group, :server
16
16
  attr_accessor :name, :tags, :fleet_id, :username
17
17
 
18
- def self.from_instance_id(an_id, data)
19
- region = data['region'] || DEFAULT_REGION
18
+ def self.fog_server_for_instance(id, blimpdata)
19
+ region = blimpdata['region'] || DEFAULT_REGION
20
20
  fog = Fog::Compute.new(:provider => 'AWS', :region => region)
21
- server = fog.servers.get(an_id)
22
- if server.nil?
23
- return nil
24
- end
21
+ fog.servers.get(id)
22
+ end
23
+
24
+ def self.from_instance_id(an_id, data)
25
+ server = self.fog_server_for_instance(an_id, data)
26
+ return if server.nil?
25
27
  box = self.new(server)
26
28
  box.name = data['name']
27
29
  box
@@ -16,13 +16,33 @@ module Blimpy
16
16
  end
17
17
  end
18
18
 
19
+ def load_engine
20
+ engine = Blimpy::Engine.new
21
+ engine.load_file(File.open(BLIMPFILE).read)
22
+ engine
23
+ end
24
+
25
+
19
26
  def box_by_name(name)
20
- fleet = Blimpy::Fleet.new
27
+ engine = load_engine
21
28
  box = nil
22
- fleet.members.each do |instance_id, data|
23
- box_name = data['name']
24
- next unless box_name == name
25
- box = Blimpy::Box.from_instance_id(instance_id, data)
29
+ id = nil
30
+ data = nil
31
+ engine.fleet.members.each do |instance_id, instance_data|
32
+ next unless instance_data['name'] == name
33
+ id = instance_id
34
+ data = instance_data
35
+ break
36
+ end
37
+
38
+ if id.nil?
39
+ return nil
40
+ end
41
+
42
+ engine.fleet.ships.each do |ship|
43
+ next unless ship.name == name
44
+ ship.server = Blimpy::Box.fog_server_for_instance(id, data)
45
+ box = ship
26
46
  end
27
47
  box
28
48
  end
@@ -32,8 +52,7 @@ module Blimpy
32
52
  method_options :"dry-run" => :boolean
33
53
  def start
34
54
  ensure_blimpfile
35
- engine = Blimpy::Engine.new
36
- engine.load_file(File.open(BLIMPFILE).read)
55
+ engine = load_engine
37
56
  puts 'Up, up and away!'
38
57
 
39
58
  if options[:'dry-run']
@@ -115,5 +134,16 @@ end
115
134
  box.wait_for_sshd
116
135
  box.scp_file(filename)
117
136
  end
137
+
138
+ desc 'provision BLIMP_NAME', 'Run the livery again'
139
+ def provision(name=nil)
140
+ ensure_blimpfile
141
+ box = box_by_name(name)
142
+ if box.nil?
143
+ puts "Could not find a blimp named \"#{name}\""
144
+ exit 1
145
+ end
146
+ box.bootstrap
147
+ end
118
148
  end
119
149
  end
@@ -4,10 +4,10 @@ module Blimpy
4
4
  class Fleet
5
5
  include Blimpy::Helpers::State
6
6
 
7
- attr_reader :hosts, :id
7
+ attr_reader :ships, :id
8
8
 
9
9
  def initialize
10
- @hosts = []
10
+ @ships = []
11
11
  @id = Time.now.utc.to_i
12
12
  end
13
13
 
@@ -17,7 +17,7 @@ module Blimpy
17
17
  end
18
18
  box = Blimpy::Box.new
19
19
  box.fleet_id = @id
20
- @hosts << box
20
+ @ships << box
21
21
  block.call(box)
22
22
  end
23
23
 
@@ -53,18 +53,18 @@ module Blimpy
53
53
  return resume(instances)
54
54
  end
55
55
 
56
- # Make sure all our hosts are valid first!
57
- @hosts.each do |host|
56
+ # Make sure all our ships are valid first!
57
+ @ships.each do |host|
58
58
  host.validate!
59
59
  end
60
60
 
61
61
  puts '>> Starting:'
62
- @hosts.each do |host|
62
+ @ships.each do |host|
63
63
  puts "..#{host.name}"
64
64
  host.start
65
65
  end
66
66
 
67
- @hosts.each do |host|
67
+ @ships.each do |host|
68
68
  print ">> #{host.name} "
69
69
  host.wait_for_state('running') { print '.' }
70
70
  print ".. online at: #{host.dns_name}"
@@ -1,3 +1,3 @@
1
1
  module Blimpy
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Blimpy::Engine do
4
-
5
4
  describe '#load_file' do
6
5
  context 'no contents' do
7
6
  let(:content) { '' }
@@ -32,12 +31,12 @@ describe Blimpy::Engine do
32
31
  let(:content) do
33
32
  """
34
33
  Blimpy.fleet do |fleet|
35
- fleet.add do |host|
36
- host.image_id = 'ami-349b495d'
37
- host.livery = 'rails'
38
- host.group = 'Simple'
39
- host.region = 'us-west-1'
40
- host.name = 'Rails App Server'
34
+ fleet.add 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'
41
40
  end
42
41
  end
43
42
  """
@@ -46,12 +45,12 @@ describe Blimpy::Engine do
46
45
  it 'should create the appropriate Fleet object' do
47
46
  result = subject.load_file(content)
48
47
  result.should be_instance_of Blimpy::Fleet
49
- result.hosts.should be_instance_of Array
50
- result.hosts.size.should == 1
48
+ result.ships.should be_instance_of Array
49
+ result.ships.size.should == 1
51
50
 
52
- host = result.hosts.first
53
- host.group.should == 'Simple'
54
- host.name.should == 'Rails App Server'
51
+ ship = result.ships.first
52
+ ship.group.should == 'Simple'
53
+ ship.name.should == 'Rails App Server'
55
54
  end
56
55
  end
57
56
  end
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Blimpy::Fleet do
4
- describe '#hosts' do
4
+ describe '#ships' do
5
5
  it 'should be an Array' do
6
- subject.hosts.should be_instance_of Array
7
- subject.hosts.size.should == 0
6
+ subject.ships.should be_instance_of Array
7
+ subject.ships.size.should == 0
8
8
  end
9
9
  end
10
10
 
@@ -31,7 +31,7 @@ describe Blimpy::Fleet do
31
31
 
32
32
  it 'should add the box the fleet' do
33
33
  @box.should_not be nil
34
- subject.hosts.should include(@box)
34
+ subject.ships.should include(@box)
35
35
  end
36
36
  end
37
37
  end
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.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-29 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog
16
- requirement: &6248380 !ruby/object:Gem::Requirement
16
+ requirement: &5775980 !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: *6248380
24
+ version_requirements: *5775980
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thor
27
- requirement: &6247840 !ruby/object:Gem::Requirement
27
+ requirement: &5775440 !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: *6247840
35
+ version_requirements: *5775440
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: minitar
38
- requirement: &6247360 !ruby/object:Gem::Requirement
38
+ requirement: &5774900 !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: *6247360
46
+ version_requirements: *5774900
47
47
  description: Blimpy is a tool for managing a fleet of machines in the CLOUD!
48
48
  email:
49
49
  - tyler@monkeypox.org