blimpy 0.6.6 → 0.6.7

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.
data/Gemfile CHANGED
@@ -11,9 +11,5 @@ group :development do
11
11
  gem 'aruba'
12
12
  gem 'tempdir'
13
13
  gem 'pry'
14
- if RUBY_VERSION > '1.9'
15
- gem 'ruby-debug19', :require => 'ruby-debug'
16
- else
17
- gem 'ruby-debug'
18
- end
14
+ gem 'debugger' unless RUBY_VERSION =~ /1.8.+/
19
15
  end
data/README.md CHANGED
@@ -47,6 +47,9 @@ Here's an example Blimpfile:
47
47
  ship.group = 'Simple' # [Optional] The name of the desired Security Group
48
48
  ship.region = 'us-west-1' # [Optional] defaults to us-west-2
49
49
  ship.username = 'ubuntu' # [Optional] SSH username, defaults to "ubuntu" for AWS machines
50
+ ship.flavor = 'm1.small' # [Optional] defaults to t1.micro
51
+ ship.tags = {:mytag => 'somevalue'} # [Optional]
52
+ ship.provision_on_start = false # [Optional] defaults to true
50
53
  end
51
54
  end
52
55
  ```
data/bin/blimpy CHANGED
@@ -10,12 +10,12 @@ rescue NameError
10
10
  # I don't think we have YAML::ENGINE until Ruby 1.9
11
11
  end
12
12
 
13
- begin
14
- require 'blimpy/cli'
15
- rescue LoadError
16
- $:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/')
17
- require 'blimpy/cli'
18
- end
13
+ $:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/')
14
+ require 'blimpy/cli'
15
+
16
+ # allow monkey-patching of Blimpy by the project (mainly to add more commands)
17
+ blimprc = File.join(Dir.pwd,"Blimprc")
18
+ Blimpy.load_file File.open(blimprc).read if File.exists? blimprc
19
19
 
20
20
  Blimpy::CLI.start
21
21
  exit 0
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'aruba/cucumber'
3
3
  require 'fileutils'
4
- require 'ruby-debug'
4
+ require 'ruby-debug' unless RUBY_VERSION =~ /1.8.+/
5
5
  require 'temp_dir'
6
6
 
7
7
 
@@ -13,8 +13,8 @@ module Blimpy
13
13
  attr_reader :allowed_regions, :region
14
14
  attr_accessor :image_id, :flavor, :group, :ports
15
15
  attr_accessor :dns, :internal_dns
16
- attr_accessor :name, :tags, :fleet_id, :username, :livery
17
-
16
+ attr_accessor :name, :tags, :fleet_id, :username, :ssh_port, :livery
17
+ attr_accessor :provision_on_start
18
18
 
19
19
  def self.from_instance_id(an_id, data)
20
20
  return if data[:type].nil?
@@ -33,6 +33,7 @@ module Blimpy
33
33
  end
34
34
 
35
35
  def initialize(server=nil)
36
+ @provision_on_start = true
36
37
  @livery = nil
37
38
  @group = nil
38
39
  @name = 'Unnamed Box'
@@ -126,7 +127,7 @@ module Blimpy
126
127
  end
127
128
 
128
129
  def serializable_attributes
129
- [:type, :name, :region, :dns, :internal_dns]
130
+ [:type, :name, :region, :dns, :internal_dns, :flavor, :tags]
130
131
  end
131
132
 
132
133
  def immutable_attributes
@@ -161,7 +162,6 @@ module Blimpy
161
162
  end
162
163
  end
163
164
 
164
-
165
165
  def with_data(ship_id, data)
166
166
  data.each do |key, value|
167
167
  next if immutable_attributes.include? key.to_sym
@@ -197,15 +197,15 @@ module Blimpy
197
197
  end
198
198
  end
199
199
 
200
+ def ssh_commands(*args)
201
+ ['ssh', '-o', 'PasswordAuthentication=no',
202
+ '-o', 'StrictHostKeyChecking=no',
203
+ '-p', (ssh_port||22).to_s,
204
+ '-l', username, dns, *args]
205
+ end
206
+
200
207
  def ssh_into(*args)
201
- # Support using #ssh_into within our own code as well to pass arguments
202
- # to the ssh(1) binary
203
- if args.empty?
204
- args = ARGV[2 .. -1]
205
- end
206
- run_command('ssh', '-o', 'PasswordAuthentication=no',
207
- '-o', 'StrictHostKeyChecking=no',
208
- '-l', username, dns, *args)
208
+ run_command(*ssh_commands(*args))
209
209
  end
210
210
 
211
211
  def scp_file(filename, directory='', *args)
@@ -214,6 +214,11 @@ module Blimpy
214
214
  filename, "#{username}@#{dns}:#{directory}", *args)
215
215
  end
216
216
 
217
+ def scp_files(directory, files)
218
+ filename = File.expand_path(filename)
219
+ run_command(*['scp', '-o', 'StrictHostKeyChecking=no']+files+["#{username}@#{dns}:#{directory}"])
220
+ end
221
+
217
222
  def bootstrap_livery
218
223
  if @livery.kind_of? Symbol
219
224
  raise Blimpy::InvalidLiveryException, 'Symbol liveries are unsupported!'
@@ -233,18 +238,34 @@ module Blimpy
233
238
  # after sshd(8) comes online
234
239
  @exec_commands = false
235
240
 
241
+ $stdout.sync = true
242
+ need_nl = false
243
+
236
244
  until @ssh_connected
237
245
  # Run the `true` command and exit
238
246
  @ssh_connected = ssh_into('-q', 'true')
247
+ # if SSH is killed, don't repeat
248
+ if $?.signaled?
249
+ if $?.termsig==2
250
+ # if Ctrl+C, report what we were doing
251
+ puts "Failed to connect. To try it yourself:\n#{ssh_commands('-v','true').join(' ')}"
252
+ end
253
+ raise Exception, "ssh was killed: #{$?}"
254
+ end
239
255
 
240
256
  unless @ssh_connected
257
+ if !need_nl
258
+ p = ssh_port.nil? ? "" : ":#{ssh_port}"
259
+ print ">> Connecting #{username}@#{name}#{p}"
260
+ end
241
261
  if (Time.now.to_i - start) < 60
242
262
  print '.'
263
+ need_nl = true
243
264
  sleep 1
244
265
  end
245
266
  end
246
267
  end
247
- puts
268
+ puts if need_nl
248
269
  @exec_commands = use_exec
249
270
  end
250
271
 
@@ -1,5 +1,6 @@
1
1
  require 'blimpy/box'
2
2
  require 'blimpy/boxes'
3
+ require 'fog/aws'
3
4
 
4
5
  module Blimpy::Boxes
5
6
  class AWS < Blimpy::Box
@@ -1,5 +1,6 @@
1
1
  require 'blimpy/box'
2
2
  require 'blimpy/boxes'
3
+ require 'fog/openstack'
3
4
 
4
5
  module Blimpy::Boxes
5
6
  class OpenStack < Blimpy::Box
@@ -62,6 +62,7 @@ module Blimpy
62
62
  fleet = load_blimpfile
63
63
  rescue Blimpy::InvalidBlimpFileError => e
64
64
  puts "The Blimpfile is invalid!"
65
+ puts e.to_s
65
66
  exit 1
66
67
  end
67
68
 
@@ -73,6 +74,32 @@ module Blimpy
73
74
  fleet.start
74
75
  end
75
76
 
77
+ desc 'show', 'Show blimp details for running blimps'
78
+ method_options :tags => :boolean
79
+ def show
80
+ ensure_blimpfile
81
+ blimps = current_blimps
82
+ unless blimps
83
+ puts 'No currently running VMs'
84
+ exit 0
85
+ end
86
+
87
+ tags_option = options[:tags]
88
+ blimps.each do |blimp, data|
89
+ if tags_option
90
+ tags = nil
91
+ data[:tags].each do |k,v|
92
+ if tags.nil?
93
+ tags = "#{k}=#{v}"
94
+ elsif
95
+ tags = "#{tags},#{k}=#{v}"
96
+ end
97
+ end
98
+ puts "#{data[:name]} #{data[:internal_dns]} #{tags}"
99
+ end
100
+ end
101
+ end
102
+
76
103
  desc 'status', 'Show running blimps'
77
104
  def status
78
105
  ensure_blimpfile
@@ -85,7 +112,7 @@ module Blimpy
85
112
  blimps.each do |blimp, data|
86
113
  instance_id = File.basename(blimp)
87
114
  instance_id = instance_id.split('.blimp').first
88
- puts "#{data[:name]} (#{instance_id}) is: online at #{data[:dns]}"
115
+ puts "#{data[:name]} (#{instance_id}) is: online at #{data[:dns]} (#{data[:internal_dns]} internally)"
89
116
  end
90
117
  end
91
118
 
@@ -143,7 +170,7 @@ end
143
170
  end
144
171
 
145
172
  box.wait_for_sshd
146
- box.ssh_into
173
+ box.ssh_into *args
147
174
  end
148
175
 
149
176
  desc 'scp BLIMP_NAME FILE_NAME', 'Securely copy FILE_NAME into the blimp'
@@ -124,8 +124,10 @@ module Blimpy
124
124
  print "\n"
125
125
  puts ">> #{host.name} online at: #{host.dns}"
126
126
  host.online!
127
- host.bootstrap
128
- puts
127
+ if host.provision_on_start
128
+ host.bootstrap
129
+ puts
130
+ end
129
131
  end
130
132
 
131
133
  save!
@@ -22,7 +22,7 @@ module Blimpy
22
22
  run_sudo = ''
23
23
  end
24
24
 
25
- box.ssh_into("cd #{dir_name} && #{run_sudo} ./#{script}")
25
+ box.ssh_into("cd #{dir_name} && #{run_sudo} BLIMPY_SHIPNAME=#{box.name} ./#{script}")
26
26
  end
27
27
 
28
28
  def bootstrap_script
@@ -1,3 +1,3 @@
1
1
  module Blimpy
2
- VERSION = "0.6.6"
2
+ VERSION = "0.6.7"
3
3
  end
@@ -51,12 +51,14 @@ else
51
51
  Ubuntu) export PATH=/var/lib/gems/1.8/bin:/usr/local/bin:$PATH
52
52
  which puppet > /dev/null 2>&1
53
53
  if [ $? -ne 0 ]; then
54
+ # CODENAME is 'precise', 'oneiric', etc.
55
+ CODENAME=`lsb_release -c | awk '{print $2}'`
56
+ REPO_DEB="puppetlabs-release-${CODENAME}.deb"
57
+ wget --quiet http://apt.puppetlabs.com/${REPO_DEB} || Fatal "Could not retrieve http://apt.puppetlabs.com/${REPO_DEB}"
58
+ dpkg -i ${REPO_DEB} || Fatal "Could not install Puppet repo source '${REPO_DEB}'"
59
+ rm -f ${REPO_DEB}
54
60
  apt-get update
55
- apt-get install -y ruby1.8 \
56
- ruby1.8-dev \
57
- libopenssl-ruby1.8 \
58
- rubygems
59
- gem install puppet --version "~> 2.7" --no-ri --no-rdoc
61
+ apt-get -qqy install puppet-common=2.7.* puppet=2.7.* hiera=1.1.* hiera-puppet=1.0* || Fatal "Could not install Puppet"
60
62
  fi
61
63
  ;;
62
64
  *) Fatal "Unsupported Linux flavor: $LINUXFLAVOR"
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.6.6
4
+ version: 0.6.7
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-12-19 00:00:00.000000000Z
12
+ date: 2013-05-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog
16
- requirement: &23419180 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *23419180
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: thor
27
- requirement: &23418760 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *23418760
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: minitar
38
- requirement: &23418300 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,7 +53,12 @@ dependencies:
43
53
  version: '0'
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *23418300
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  description: Blimpy is a tool for managing a fleet of machines in the CLOUD!
48
63
  email:
49
64
  - tyler@monkeypox.org
@@ -117,7 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
132
  version: '0'
118
133
  segments:
119
134
  - 0
120
- hash: 728683722124113180
135
+ hash: 4596383241046326596
121
136
  required_rubygems_version: !ruby/object:Gem::Requirement
122
137
  none: false
123
138
  requirements:
@@ -126,10 +141,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
141
  version: '0'
127
142
  segments:
128
143
  - 0
129
- hash: 728683722124113180
144
+ hash: 4596383241046326596
130
145
  requirements: []
131
146
  rubyforge_project:
132
- rubygems_version: 1.8.10
147
+ rubygems_version: 1.8.25
133
148
  signing_key:
134
149
  specification_version: 3
135
150
  summary: Ruby + CLOUD = Blimpy