bosh-bootstrap 0.5.1 → 0.6.0

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/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format progress
2
+ --color
data/ChangeLog.md ADDED
@@ -0,0 +1,22 @@
1
+ # Change Log
2
+
3
+ ## v0.6
4
+
5
+ Highlights:
6
+
7
+ * Defaults to downloading latest stemcell (rather than stable, which are getting old now).
8
+ * Installs the Cloud Foundry plugin for BOSH https://github.com/StarkAndWayne/bosh-cloudfoundry
9
+
10
+ Additions:
11
+
12
+ * `tmux` - if you have tmux installed, then you can SSH into inception VM with it (thx @mrdavidlang)
13
+ * started a test suite; its small but growing! (thx @mrdavidlang for getting it started)
14
+
15
+ Bug fixes:
16
+
17
+ * Fog::SSH uses explicit ssh key that was requested to access inception VM
18
+
19
+ Future thoughts:
20
+
21
+ * I hate Settingslogic for read-write settings. It's really only a read-only settings DSL. It puts Ruby classes into the YAML. Probably going to rip it out.
22
+ * I am so sorry I took so long to start writing tests. It always seemed such a hard thing to write tests for. But bosh-cloudfoundry project has had good success with internal tests; so we're migrating those ideas into this project.
data/Gemfile CHANGED
@@ -2,3 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in bosh-bootstrap.gemspec
4
4
  gemspec
5
+
6
+ gem "awesome_print"
7
+ gem "rb-fsevent", "~> 0.9.1"
8
+ gem "guard-rspec"
data/Guardfile ADDED
@@ -0,0 +1,6 @@
1
+ guard 'rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/bosh-bootstrap/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
6
+
data/Rakefile CHANGED
@@ -1 +1,31 @@
1
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __FILE__)
2
+
3
+ require "rubygems"
4
+ require "bundler"
5
+ Bundler.setup(:default, :test, :development)
6
+
1
7
  require "bundler/gem_tasks"
8
+
9
+ require "rake/dsl_definition"
10
+ require "rake"
11
+ require "rspec/core/rake_task"
12
+
13
+
14
+ if defined?(RSpec)
15
+ namespace :spec do
16
+ desc "Run Unit Tests"
17
+ unit_rspec_task = RSpec::Core::RakeTask.new(:unit) do |t|
18
+ t.pattern = "spec/unit/**/*_spec.rb"
19
+ t.rspec_opts = %w(--format progress --color -d)
20
+ end
21
+
22
+ desc "Run Integration Tests"
23
+ functional_rspec_task = RSpec::Core::RakeTask.new(:functional) do |t|
24
+ t.pattern = "spec/functional/**/*_spec.rb"
25
+ t.rspec_opts = %w(--format progress --color)
26
+ end
27
+ end
28
+
29
+ desc "Install dependencies and run tests"
30
+ task :spec => %w(spec:unit spec:functional)
31
+ end
@@ -30,5 +30,6 @@ EOS
30
30
  gem.add_dependency "fog", "~>1.8.0"
31
31
  gem.add_dependency "escape"
32
32
  gem.add_dependency "bosh_cli"
33
- gem.add_development_dependency "bosh_deployer"
33
+ gem.add_development_dependency "rake"
34
+ gem.add_development_dependency "rspec"
34
35
  end
@@ -25,7 +25,8 @@ module Bosh::Bootstrap
25
25
  method_option :"private-key", :type => :string, :desc => "Local passphrase-less private key path"
26
26
  method_option :"upgrade-deps", :type => :boolean, :desc => "Force upgrade dependencies, packages & gems"
27
27
  method_option :"edge-deployer", :type => :boolean, :desc => "Install bosh deployer from git instead of rubygems"
28
- method_option :"latest-stemcell", :type => :boolean, :desc => "Use latest micro-bosh stemcell; possibly not tagged stable"
28
+ method_option :"stable-stemcell", :type => :boolean, :desc => "Use recent stable microbosh stemcell"
29
+ method_option :"latest-stemcell", :type => :boolean, :desc => "Use latest microbosh stemcell; possibly not tagged stable [default]"
29
30
  method_option :"edge-stemcell", :type => :boolean, :desc => "Create custom stemcell from BOSH git source"
30
31
  def deploy
31
32
  load_deploy_options # from method_options above
@@ -61,6 +62,15 @@ module Bosh::Bootstrap
61
62
  run_ssh_command_or_open_tunnel(cmd)
62
63
  end
63
64
 
65
+ desc "tmux", "Open an ssh (with tmux) session to the inception VM [do nothing if local machine is inception VM]"
66
+ long_desc <<-DESC
67
+ Opens a connection using ssh and attaches to the most recent tmux session;
68
+ giving you persistance across disconnects.
69
+ DESC
70
+ def tmux
71
+ run_ssh_command_or_open_tunnel(["-t", "tmux attach || tmux new-session"])
72
+ end
73
+
64
74
  no_tasks do
65
75
  DEFAULT_INCEPTION_VOLUME_SIZE = 32 # Gb
66
76
 
@@ -185,7 +195,7 @@ module Bosh::Bootstrap
185
195
  save_settings!
186
196
 
187
197
  if settings["inception"]["host"]
188
- @server = Commander::RemoteServer.new(settings.inception.host)
198
+ @server = Commander::RemoteServer.new(settings.inception.host, settings.local.private_key_path)
189
199
  confirm "Using inception VM #{settings.inception.username}@#{settings.inception.host}"
190
200
  else
191
201
  @server = Commander::LocalServer.new
@@ -202,9 +212,9 @@ module Bosh::Bootstrap
202
212
  end
203
213
 
204
214
  def deploy_stage_4_prepare_inception_vm
205
- unless settings["inception"]["prepared"] && !settings["upgrade_deps"]
215
+ unless settings["inception"] && settings["inception"]["prepared"] && !settings["upgrade_deps"]
206
216
  header "Stage 4: Preparing the Inception VM"
207
- unless server.run(Bosh::Bootstrap::Stages::StagePrepareInceptionVm.new(settings).commands)
217
+ unless run_server(Bosh::Bootstrap::Stages::StagePrepareInceptionVm.new(settings).commands)
208
218
  error "Failed to complete Stage 4: Preparing the Inception VM"
209
219
  end
210
220
  # Settings are updated by this stage
@@ -219,7 +229,7 @@ module Bosh::Bootstrap
219
229
 
220
230
  def deploy_stage_5_deploy_micro_bosh
221
231
  header "Stage 5: Deploying micro BOSH"
222
- unless server.run(Bosh::Bootstrap::Stages::MicroBoshDeploy.new(settings).commands)
232
+ unless run_server(Bosh::Bootstrap::Stages::MicroBoshDeploy.new(settings).commands)
223
233
  error "Failed to complete Stage 5: Deploying micro BOSH"
224
234
  end
225
235
 
@@ -232,7 +242,7 @@ module Bosh::Bootstrap
232
242
  sleep 5
233
243
 
234
244
  header "Stage 6: Setup bosh"
235
- unless server.run(Bosh::Bootstrap::Stages::SetupNewBosh.new(settings).commands)
245
+ unless run_server(Bosh::Bootstrap::Stages::SetupNewBosh.new(settings).commands)
236
246
  error "Failed to complete Stage 6: Setup bosh"
237
247
  end
238
248
 
@@ -248,7 +258,7 @@ module Bosh::Bootstrap
248
258
  def delete_stage_1_target_inception_vm
249
259
  header "Stage 1: Target inception VM to use to delete micro-bosh"
250
260
  if settings["inception"]["host"]
251
- @server = Commander::RemoteServer.new(settings.inception.host)
261
+ @server = Commander::RemoteServer.new(settings.inception.host, settings.local.private_key_path)
252
262
  confirm "Using inception VM #{settings.inception.username}@#{settings.inception.host}"
253
263
  else
254
264
  @server = Commander::LocalServer.new
@@ -281,7 +291,8 @@ module Bosh::Bootstrap
281
291
  exit "Inception VM has not finished launching; run to complete: #{self.class.banner_base} deploy"
282
292
  end
283
293
  username = 'vcap'
284
- exit system Escape.shell_command(['ssh', "#{username}@#{host}", cmd].compact)
294
+ result = system Escape.shell_command(['ssh', "#{username}@#{host}", cmd].flatten.compact)
295
+ exit result
285
296
 
286
297
  # TODO how to use the specific private_key_path as configured in settings
287
298
  # _, private_key_path = local_ssh_key_paths
@@ -319,16 +330,19 @@ module Bosh::Bootstrap
319
330
  settings["bosh_git_source"] = options[:"edge-deployer"] # use bosh git repo instead of rubygems
320
331
 
321
332
  # determine which micro-bosh stemcell to download/create
322
- if options[:"latest-stemcell"]
333
+ if options[:"stable-stemcell"]
334
+ settings["micro_bosh_stemcell_type"] = "stable"
335
+ settings["micro_bosh_stemcell_name"] = nil # force name to be refetched
336
+ elsif options[:"latest-stemcell"]
323
337
  settings["micro_bosh_stemcell_type"] = "latest"
324
338
  settings["micro_bosh_stemcell_name"] = nil # force name to be refetched
325
339
  elsif options[:"edge-stemcell"]
326
340
  settings["micro_bosh_stemcell_type"] = "custom"
327
341
  settings["micro_bosh_stemcell_name"] = "custom"
328
- else
329
- # may have already been set from previous deploy run
330
- settings["micro_bosh_stemcell_type"] ||= "stable"
331
342
  end
343
+ # may have already been set from previous deploy run
344
+ # default to "latest" for both AWS and OpenStack at the moment (no useful stable stemcells)
345
+ settings["micro_bosh_stemcell_type"] ||= "latest"
332
346
 
333
347
  # once a stemcell is downloaded or created; these fields above should
334
348
  # be uploaded with values such as:
@@ -913,6 +927,10 @@ module Bosh::Bootstrap
913
927
  say "SSH access: ssh -i #{private_key_path} #{settings["inception"]["username"]}@#{settings["inception"]["host"]}"
914
928
  end
915
929
 
930
+ def run_server(server_commands)
931
+ server.run(server_commands)
932
+ end
933
+
916
934
  # Discover/create local passphrase-less SSH keys to allow
917
935
  # communication with Inception VM
918
936
  #
@@ -951,12 +969,10 @@ module Bosh::Bootstrap
951
969
  # for the target provider (aws, vsphere, openstack)
952
970
  def micro_bosh_stemcell_name
953
971
  @micro_bosh_stemcell_name ||= begin
954
- provider = settings.bosh_provider.downcase # aws, vsphere, openstack
955
- stemcell_filter_tags = ['micro', provider]
956
- if openstack?
957
- # FIXME remove this if when openstack has its first stable
958
- else
959
- if settings["micro_bosh_stemcell_type"] == "stable"
972
+ stemcell_filter_tags = ['micro', provider_name]
973
+ if settings["micro_bosh_stemcell_type"] == "stable"
974
+ unless openstack?
975
+ # FIXME remove this if when openstack has its first stable
960
976
  stemcell_filter_tags << "stable" # latest stable micro-bosh stemcell by default
961
977
  end
962
978
  end
@@ -974,7 +990,11 @@ module Bosh::Bootstrap
974
990
  #
975
991
  # So to get the latest version for the filter tags,
976
992
  # get the Name field, reverse sort, and return the first item
977
- `#{bosh_stemcells_cmd} | grep micro | awk '{ print $2 }' | sort -r | head -n 1`.strip
993
+ # Effectively:
994
+ # `#{bosh_stemcells_cmd} | grep micro | awk '{ print $2 }' | sort -r | head -n 1`.strip
995
+ stemcell_output = `#{bosh_stemcells_cmd}`
996
+ say stemcell_output
997
+ stemcell_output.scan(/[\w.-]+\.tgz/).last
978
998
  end
979
999
  end
980
1000
 
@@ -4,11 +4,12 @@ require "tempfile"
4
4
  class Bosh::Bootstrap::Commander::RemoteServer
5
5
 
6
6
  attr_reader :host
7
+ attr_reader :private_key_path
7
8
  attr_reader :default_username
8
9
  attr_reader :logfile
9
10
 
10
- def initialize(host, logfile=STDERR)
11
- @host, @logfile = host, logfile
11
+ def initialize(host, private_key_path, logfile=STDERR)
12
+ @host, @private_key_path, @logfile = host, private_key_path, logfile
12
13
  @default_username = "vcap" # unless overridden by a Command (before vcap exists)
13
14
  end
14
15
 
@@ -51,6 +52,7 @@ class Bosh::Bootstrap::Commander::RemoteServer
51
52
  output =~ /^(.*)\Z/
52
53
  last_line = $1
53
54
  # store output into a settings field, if requested
55
+ # TODO replace this with SettingsSetting#setting(settings_key, last_line.strip)
54
56
  if settings_key
55
57
  settings_key_portions = settings_key.split(".")
56
58
  parent_key_portions, final_key = settings_key_portions[0..-2], settings_key_portions[-1]
@@ -100,7 +102,8 @@ class Bosh::Bootstrap::Commander::RemoteServer
100
102
  "bash -lc 'sudo /usr/bin/env PATH=$PATH #{remote_path}'"
101
103
  ]
102
104
  script_output = ""
103
- results = Fog::SSH.new(host, username).run(commands) do |stdout, stderr|
105
+ keys = [private_key_path] # path to local private key being used
106
+ results = Fog::SSH.new(host, username, keys: keys).run(commands) do |stdout, stderr|
104
107
  [stdout, stderr].flatten.each do |data|
105
108
  logfile << data
106
109
  script_output << data
@@ -1,2 +1,3 @@
1
1
  require "bosh-bootstrap/helpers/settings"
2
+ require "bosh-bootstrap/helpers/settings_setter"
2
3
  require "bosh-bootstrap/helpers/fog_setup"
@@ -0,0 +1,20 @@
1
+ # Copyright (c) 2012-2013 Stark & Wayne, LLC
2
+
3
+ require "settingslogic"
4
+ module Bosh; module Bootstrap; module Helpers; end; end; end
5
+
6
+ # Set a nested setting with "key1.key2.key3" notation
7
+ #
8
+ # Assumes +settings+ contains the settings
9
+ module Bosh::Bootstrap::Helpers::SettingsSetter
10
+ def setting(nested_key, value)
11
+ target_settings_field = settings
12
+ settings_key_portions = nested_key.split(".")
13
+ parent_key_portions, final_key = settings_key_portions[0..-2], settings_key_portions[-1]
14
+ parent_key_portions.each do |key_portion|
15
+ target_settings_field[key_portion] ||= {}
16
+ target_settings_field = target_settings_field[key_portion]
17
+ end
18
+ target_settings_field[final_key] = value
19
+ end
20
+ end
@@ -45,14 +45,16 @@ module Bosh::Bootstrap::Stages
45
45
  if File.exist?(path)
46
46
  script = File.read(path)
47
47
  if variables.keys.size > 0
48
+ env_variables = variables.reject { |var| var.is_a?(Symbol) }
49
+
48
50
  # inject variables into script if its bash script
49
51
  inline_variables = "#!/usr/bin/env bash\n\n"
50
- variables.each { |name, value| inline_variables << "#{name}='#{value}'\n" }
52
+ env_variables.each { |name, value| inline_variables << "#{name}='#{value}'\n" }
51
53
  script.gsub!("#!/usr/bin/env bash", inline_variables)
52
54
 
53
55
  # inject variables into script if its ruby script
54
56
  inline_variables = "#!/usr/bin/env ruby\n\n"
55
- variables.each { |name, value| inline_variables << "ENV['#{name}'] = '#{value}'\n" }
57
+ env_variables.each { |name, value| inline_variables << "ENV['#{name}'] = '#{value}'\n" }
56
58
  script.gsub!("#!/usr/bin/env ruby", inline_variables)
57
59
  end
58
60
  script
@@ -107,7 +107,7 @@ if [[ "${MICRO_BOSH_STEMCELL_NAME}" == "custom" ]]; then
107
107
 
108
108
  cd $BOSH_DIR
109
109
  echo "Creating custom stemcell..."
110
- bundle install --without test development
110
+ bundle install
111
111
  bundle exec rake stemcell:micro[$PROVIDER,$MICRO_BOSH_MANIFEST_PATH,$LATEST_BOSH_RELEASE_PATH]
112
112
 
113
113
  echo "Copying to stemcells folder..."
@@ -18,6 +18,7 @@ module Bosh::Bootstrap::Stages
18
18
  server.install "bosh", script("install_bosh",
19
19
  "UPGRADE" => settings[:upgrade_deps],
20
20
  "INSTALL_BOSH_FROM_SOURCE" => settings["bosh_git_source"] || "")
21
+ server.install "bosh plugins", script("install_bosh_plugins", "UPGRADE" => settings[:upgrade_deps])
21
22
  # use inception VM to generate a salted password (local machine may not have mkpasswd)
22
23
  server.capture_value "salted password", script("convert_salted_password", "PASSWORD" => settings.bosh.password),
23
24
  :settings => settings, :save_output_to_settings_key => "bosh.salted_password"
@@ -39,7 +40,8 @@ module Bosh::Bootstrap::Stages
39
40
  script = File.read(path)
40
41
  if variables.keys.size > 0
41
42
  inline_variables = "#!/usr/bin/env bash\n\n"
42
- variables.each { |name, value| inline_variables << "#{name}=#{value}\n" }
43
+ env_variables = variables.reject { |var| var.is_a?(Symbol) }
44
+ env_variables.each { |name, value| inline_variables << "#{name}=#{value}\n" }
43
45
  script.gsub!("#!/usr/bin/env bash", inline_variables)
44
46
  end
45
47
  script
@@ -32,7 +32,22 @@ if [[ "${INSTALL_BOSH_FROM_SOURCE}X" != "X" ]]; then
32
32
  fi
33
33
 
34
34
  bosh_dir=/var/vcap/store/repos/bosh
35
- for project in common cli deployer aws_registry openstack_registry; do
35
+ projects=(
36
+ bosh_common
37
+ blobstore_client
38
+ bosh_cpi
39
+ ruby_vcloud_sdk
40
+ bosh_vcloud_cpi
41
+ ruby_vim_sdk
42
+ bosh_vsphere_cpi
43
+ bosh_aws_cpi
44
+ agent_client
45
+ bosh_cli
46
+ bosh_aws_registry
47
+ bosh_openstack_registry
48
+ bosh_deployer
49
+ )
50
+ for project in "${projects[@]}"; do
36
51
  cd $bosh_dir/$project/
37
52
  rm -rf pkg
38
53
  bundle install --without=development test
@@ -44,6 +59,9 @@ if [[ "${INSTALL_BOSH_FROM_SOURCE}X" != "X" ]]; then
44
59
 
45
60
  else
46
61
  install_gem bosh_cli
62
+ # TODO remove this when bosh_deployer starts installing aws-sdk 1.8.1.1 or higher
63
+ install_gem httparty
64
+ # end TODO
47
65
  install_gem bosh_deployer
48
66
  fi
49
67
 
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Install bosh-cloudfoundry BOSH CLI plugin
4
+ #
5
+ # Options:
6
+ # * $UPGRADE - re-install or upgrade gems if already installed
7
+
8
+ if [[ $EUID -ne 0 ]]; then
9
+ echo "ERROR: This script must be run as root" 1>&2
10
+ exit 1
11
+ fi
12
+
13
+ # Install a gem if $UPGRADE exists or if gem not already installed
14
+ function install_gem() {
15
+ gem_name=$1
16
+ if [[ ("${UPGRADE}X" != "X") || "$(gem list $gem_name | grep $gem_name)X" == "X" ]]; then
17
+ gem install $gem_name --no-ri --no-rdoc
18
+ else
19
+ echo gem $gem_name already installed
20
+ fi
21
+ }
22
+
23
+ install_gem bosh-cloudfoundry
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Bootstrap
3
- VERSION = "0.5.1"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
File without changes
@@ -0,0 +1,7 @@
1
+ +-----------------------------------+--------------------+
2
+ | Name | Tags |
3
+ +-----------------------------------+--------------------+
4
+ | micro-bosh-stemcell-aws-0.6.4.tgz | aws, micro, stable |
5
+ | micro-bosh-stemcell-aws-0.7.0.tgz | aws, micro, test |
6
+ | micro-bosh-stemcell-aws-0.8.1.tgz | aws, micro, test |
7
+ +-----------------------------------+--------------------+
File without changes
@@ -0,0 +1,39 @@
1
+ # Copyright (c) 2012-2013 Stark & Wayne, LLC
2
+
3
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
4
+
5
+ require "rubygems"
6
+ require "bundler"
7
+ Bundler.setup(:default, :test)
8
+
9
+ $:.unshift(File.expand_path("../../lib", __FILE__))
10
+
11
+ require "rspec/core"
12
+ require "bosh-bootstrap"
13
+ require "bosh-bootstrap/cli"
14
+
15
+ def spec_asset(filename)
16
+ File.expand_path("../assets/#{filename}", __FILE__)
17
+ end
18
+
19
+ def files_match(filename, expected_filename)
20
+ file = File.read(filename)
21
+ expected_file = File.read(expected_filename)
22
+ file.should == expected_file
23
+ end
24
+
25
+ RSpec.configure do |c|
26
+ c.before(:each) do
27
+
28
+ end
29
+
30
+ c.color_enabled = true
31
+ end
32
+
33
+ def get_tmp_file_path(content)
34
+ tmp_file = File.open(File.join(Dir.mktmpdir, "tmp"), "w")
35
+ tmp_file.write(content)
36
+ tmp_file.close
37
+
38
+ tmp_file.path
39
+ end
File without changes
@@ -0,0 +1,117 @@
1
+ # Copyright (c) 2012-2013 Stark & Wayne, LLC
2
+
3
+ require File.expand_path("../../spec_helper", __FILE__)
4
+
5
+ describe Bosh::Bootstrap do
6
+ include FileUtils
7
+ include Bosh::Bootstrap::Helpers::SettingsSetter
8
+
9
+ before do
10
+ ENV['MANIFEST'] = File.expand_path("../../../tmp/test-manifest.yml", __FILE__)
11
+ rm_rf(ENV['MANIFEST'])
12
+ @cmd = Bosh::Bootstrap::Cli.new
13
+ end
14
+
15
+ # stub out all stages except a specific one
16
+ # +stage+ can either be the stage number or name
17
+ def testing_stage(stage)
18
+ stage_methods = %w[
19
+ deploy_stage_1_choose_infrastructure_provider
20
+ deploy_stage_2_bosh_configuration
21
+ deploy_stage_3_create_allocate_inception_vm
22
+ deploy_stage_4_prepare_inception_vm
23
+ deploy_stage_5_deploy_micro_bosh
24
+ deploy_stage_6_setup_new_bosh
25
+ ]
26
+ stage_methods.each do |method|
27
+ unless method =~ /#{stage}/
28
+ @cmd.should_receive(method.to_sym)
29
+ end
30
+ end
31
+ end
32
+
33
+ # used by +SettingsSetter+ to access the settings
34
+ def settings
35
+ @cmd.settings
36
+ end
37
+
38
+ describe "deploy" do
39
+ it "goes through stages" do
40
+ @cmd.should_receive(:deploy_stage_1_choose_infrastructure_provider)
41
+ @cmd.should_receive(:deploy_stage_2_bosh_configuration)
42
+ @cmd.should_receive(:deploy_stage_3_create_allocate_inception_vm)
43
+ @cmd.should_receive(:deploy_stage_4_prepare_inception_vm)
44
+ @cmd.should_receive(:deploy_stage_5_deploy_micro_bosh)
45
+ @cmd.should_receive(:deploy_stage_6_setup_new_bosh)
46
+ @cmd.deploy
47
+ end
48
+
49
+ it "stage 3 - create inception VM"
50
+ # do
51
+ # testing_stage(3)
52
+ # setting "fog_credentials.provider", "AWS"
53
+ # @cmd.should_receive(:run_server).and_return(true)
54
+ # @cmd.deploy
55
+ # end
56
+
57
+ it "stage 4 - prepare inception VM" do
58
+ testing_stage(4)
59
+ setting "inception.username", "ubuntu"
60
+ setting "bosh.password", "UNSALTED"
61
+ @cmd.should_receive(:run_server).and_return(true)
62
+ @cmd.deploy
63
+ end
64
+
65
+ it "stage 5 - download stemcell and deploy microbosh" do
66
+ testing_stage(5)
67
+ setting "bosh_provider", "aws"
68
+ setting "micro_bosh_stemcell_name", "micro-bosh-stemcell-aws-0.8.1.tgz"
69
+ setting "bosh_username", "drnic"
70
+ setting "bosh_password", "password"
71
+ setting "bosh.salted_password", "SALTED"
72
+ setting "bosh.ip_address", "1.2.3.4"
73
+ setting "bosh.persistent_disk", 16384
74
+ setting "bosh_resources_cloud_properties", {}
75
+ setting "bosh_cloud_properties", {}
76
+ setting "bosh_key_pair.private_key", "PRIVATE_KEY"
77
+ setting "bosh_key_pair.name", "KEYNAME"
78
+ @cmd.should_receive(:run_server).and_return(true)
79
+ @cmd.deploy
80
+ end
81
+
82
+ it "stage 6 - sets up new microbosh" do
83
+ testing_stage(6)
84
+ setting "bosh_name", "microbosh-aws-us-east-1"
85
+ setting "bosh_username", "drnic"
86
+ setting "bosh_password", "password"
87
+ setting "bosh.ip_address", "1.2.3.4"
88
+ @cmd.should_receive(:sleep)
89
+ @cmd.should_receive(:run_server).and_return(true)
90
+ @cmd.should_receive(:sh).with("bosh -u drnic -p password target 1.2.3.4")
91
+ @cmd.should_receive(:sh).with("bosh login drnic password")
92
+ @cmd.deploy
93
+ end
94
+ end
95
+
96
+ describe "micro_bosh_stemcell_name" do
97
+ # The +bosh_stemcells_cmd+ has an output that looks like:
98
+ # +-----------------------------------+--------------------+
99
+ # | Name | Tags |
100
+ # +-----------------------------------+--------------------+
101
+ # | micro-bosh-stemcell-aws-0.6.4.tgz | aws, micro, stable |
102
+ # | micro-bosh-stemcell-aws-0.7.0.tgz | aws, micro, test |
103
+ # | micro-bosh-stemcell-aws-0.8.1.tgz | aws, micro, test |
104
+ # +-----------------------------------+--------------------+
105
+ #
106
+ # So to get the latest version for the filter tags,
107
+ # get the Name field, reverse sort, and return the first item
108
+ it "should return the latest stable stemcell by default for AWS" do
109
+ @cmd.settings["bosh_provider"] = "aws"
110
+ @cmd.should_receive(:`).
111
+ with("bosh public stemcells --tags micro,aws").
112
+ and_return(File.read(spec_asset("bosh/public_stemcells/aws_micro.out")))
113
+ @cmd.micro_bosh_stemcell_name.should == "micro-bosh-stemcell-aws-0.8.1.tgz"
114
+ end
115
+ end
116
+
117
+ end
@@ -0,0 +1,47 @@
1
+ # Copyright (c) 2012-2013 Stark & Wayne, LLC
2
+
3
+ require File.expand_path("../../spec_helper", __FILE__)
4
+
5
+ # Specs for 'ssh' related behavior. Includes CLI commands:
6
+ # * ssh
7
+ # * tmux
8
+ describe Bosh::Bootstrap do
9
+ include FileUtils
10
+
11
+ before do
12
+ ENV['MANIFEST'] = File.expand_path("../../../tmp/test-manifest.yml", __FILE__)
13
+ rm_rf(ENV['MANIFEST'])
14
+ @cmd = Bosh::Bootstrap::Cli.new
15
+ end
16
+
17
+ describe "ssh" do
18
+ before do
19
+ @cmd.settings["inception"] = {}
20
+ @cmd.settings["inception"]["host"] = "5.5.5.5"
21
+ end
22
+
23
+ describe "normal" do
24
+ it "launches ssh session" do
25
+ @cmd.should_receive(:exit)
26
+ @cmd.should_receive(:system).
27
+ with("ssh vcap@5.5.5.5")
28
+ @cmd.ssh
29
+ end
30
+ it "runs ssh command" do
31
+ @cmd.should_receive(:exit)
32
+ @cmd.should_receive(:system).
33
+ with("ssh vcap@5.5.5.5 'some command'")
34
+ @cmd.ssh("some command")
35
+ end
36
+ end
37
+
38
+ describe "tmux" do
39
+ it "launches ssh session" do
40
+ @cmd.should_receive(:exit)
41
+ @cmd.should_receive(:system).
42
+ with("ssh vcap@5.5.5.5 -t 'tmux attach || tmux new-session'")
43
+ @cmd.tmux
44
+ end
45
+ end
46
+ end
47
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh-bootstrap
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,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-30 00:00:00.000000000 Z
12
+ date: 2013-02-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -140,7 +140,23 @@ dependencies:
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  - !ruby/object:Gem::Dependency
143
- name: bosh_deployer
143
+ name: rake
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: rspec
144
160
  requirement: !ruby/object:Gem::Requirement
145
161
  none: false
146
162
  requirements:
@@ -164,7 +180,10 @@ extensions: []
164
180
  extra_rdoc_files: []
165
181
  files:
166
182
  - .gitignore
183
+ - .rspec
184
+ - ChangeLog.md
167
185
  - Gemfile
186
+ - Guardfile
168
187
  - LICENSE.txt
169
188
  - README.md
170
189
  - Rakefile
@@ -183,6 +202,7 @@ files:
183
202
  - lib/bosh-bootstrap/helpers.rb
184
203
  - lib/bosh-bootstrap/helpers/fog_setup.rb
185
204
  - lib/bosh-bootstrap/helpers/settings.rb
205
+ - lib/bosh-bootstrap/helpers/settings_setter.rb
186
206
  - lib/bosh-bootstrap/stages.rb
187
207
  - lib/bosh-bootstrap/stages/stage_micro_bosh_delete.rb
188
208
  - lib/bosh-bootstrap/stages/stage_micro_bosh_delete/bosh_micro_delete
@@ -195,6 +215,7 @@ files:
195
215
  - lib/bosh-bootstrap/stages/stage_prepare_inception_vm/create_vcap_user
196
216
  - lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_base_packages
197
217
  - lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_bosh
218
+ - lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_bosh_plugins
198
219
  - lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_ruby
199
220
  - lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_useful_gems
200
221
  - lib/bosh-bootstrap/stages/stage_prepare_inception_vm/validate_bosh_deployer
@@ -209,6 +230,13 @@ files:
209
230
  - lib/bosh/providers/aws.rb
210
231
  - lib/bosh/providers/base_provider.rb
211
232
  - lib/bosh/providers/openstack.rb
233
+ - spec/assets/.gitkeep
234
+ - spec/assets/bosh/public_stemcells/aws_micro.out
235
+ - spec/functional/.gitkeep
236
+ - spec/spec_helper.rb
237
+ - spec/unit/.gitkeep
238
+ - spec/unit/cli_spec.rb
239
+ - spec/unit/cli_ssh_spec.rb
212
240
  homepage: https://github.com/StarkAndWayne/bosh-bootstrap
213
241
  licenses: []
214
242
  post_install_message:
@@ -221,12 +249,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
221
249
  - - ! '>='
222
250
  - !ruby/object:Gem::Version
223
251
  version: '0'
252
+ segments:
253
+ - 0
254
+ hash: 14194851677947465
224
255
  required_rubygems_version: !ruby/object:Gem::Requirement
225
256
  none: false
226
257
  requirements:
227
258
  - - ! '>='
228
259
  - !ruby/object:Gem::Version
229
260
  version: '0'
261
+ segments:
262
+ - 0
263
+ hash: 14194851677947465
230
264
  requirements: []
231
265
  rubyforge_project:
232
266
  rubygems_version: 1.8.24
@@ -235,5 +269,11 @@ specification_version: 3
235
269
  summary: Now very simple to bootstrap a micro BOSH from a single, local CLI. The bootstrapper
236
270
  first creates an inception VM and then uses bosh_deployer (bosh micro deploy) to
237
271
  deploy micro BOSH from an available stemcell.
238
- test_files: []
239
- has_rdoc:
272
+ test_files:
273
+ - spec/assets/.gitkeep
274
+ - spec/assets/bosh/public_stemcells/aws_micro.out
275
+ - spec/functional/.gitkeep
276
+ - spec/spec_helper.rb
277
+ - spec/unit/.gitkeep
278
+ - spec/unit/cli_spec.rb
279
+ - spec/unit/cli_ssh_spec.rb