bosh-bootstrap 0.13.2 → 0.14.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.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MTk4NzJmZDdmNjEzMmEzZjQ5YmE1ZjFjNTc4NjZkZDVkOGZkYWQyZQ==
5
- data.tar.gz: !binary |-
6
- NzljOTRmMTU5MzgzMGRlMmE3YWE2MTdiMGFjYWYwNzliYzk1YzU4NQ==
2
+ SHA1:
3
+ metadata.gz: b5ea6f814d89322a4ce8eecc1e9e56d6a8c77578
4
+ data.tar.gz: a9808b7ddf7eed80eca2fdb9cdf5f973bd14916e
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- OGMzN2FkOTc5YjFjNTY0NDMwZWIxZmU3NTU1MjM2NWEzOWU2MWYwZGYxMmNi
10
- ZjY4NWMzZmM5MGQzM2NlMjAzODQxZjBkNDBmMTIxOGI3NzY4YTNiMjEzNWM3
11
- Mzk3MWIxZDVhZmNjODZjYTMzM2Q4ZDQzNWU0NmQ0ZjIyZWRmYzY=
12
- data.tar.gz: !binary |-
13
- MDQ0NmYzMDU4MmM3Mzg5YzFhNTFkMzlmNzI4MmY5M2JiMGMwMjhmMWY1ODc4
14
- NjhjMjJiNWZmMDViYzM0MGU5YmM3Y2Y5YTg2ZjZhNTFjMThmMGI0ZWYxNzg4
15
- ZDExYzIyYTA0ODY2ZDkxYzZiZjYxNjAxNTlkMDNjY2UyZDY3YzA=
6
+ metadata.gz: 91325833e973b0ca5dbf52d9d5b7090bd7bc2c982169e0c15eab750b3da66b968898ab303cfbfc9a5c03c294c0303786a2aa66c0f8c7466444a0c21c508af53f
7
+ data.tar.gz: a3e81665b3fcaf6617520af632c2311a5dbcaec9eb27ed3de125964dcdaa33c5c61bfeb683338d31f3f39fbad3a6b33608136796dc57e0b0123eb4432693f88b
data/ChangeLog.md CHANGED
@@ -8,6 +8,12 @@ gem install bosh-bootstrap
8
8
  bosh-bootstrap deploy
9
9
  ```
10
10
 
11
+ v0.14
12
+
13
+ - default target directory is current director, rather than `~/.microbosh`
14
+ - [aws] VPC support - detects if VPCs available and allows selection, then select of subset, then creates security groups into the VPC
15
+ - [aws] Using m3.medium instead of m1.medium
16
+
11
17
  v0.13
12
18
  -----
13
19
 
@@ -22,10 +22,12 @@ EOS
22
22
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
23
23
  gem.require_paths = ["lib"]
24
24
 
25
- gem.add_dependency "cyoi", "~> 0.10"
25
+ gem.add_dependency "cyoi", "~> 0.11"
26
26
  gem.add_dependency "fog", "~> 1.11"
27
27
  gem.add_dependency "readwritesettings", "~> 3.0"
28
28
  gem.add_dependency "thor", "~> 0.18"
29
+ gem.add_dependency "httpclient", '=2.4.0'
30
+
29
31
  gem.add_dependency "redcard"
30
32
  gem.add_dependency "rbvmomi"
31
33
  gem.add_development_dependency "rake"
@@ -42,7 +42,7 @@ class Bosh::Bootstrap::Cli::Commands::Deploy
42
42
  reload_settings!
43
43
 
44
44
  # TODO why passing provider_client rather than a Cyoi::Cli::Network object?
45
- network = Bosh::Bootstrap::Network.new(settings.provider.name, cyoi_provider_client)
45
+ network = Bosh::Bootstrap::Network.new(settings.provider.name, cyoi_provider_client, settings)
46
46
  network.deploy
47
47
  end
48
48
 
@@ -59,14 +59,14 @@ class Bosh::Bootstrap::Cli::Commands::Deploy
59
59
  # download if stemcell
60
60
  def select_public_image_or_download_stemcell
61
61
  print "Determining stemcell image/file to use... "
62
- stemcell = microbosh_provider.stemcell
63
- while (stemcell || "").size == 0
62
+ stemcell_path = microbosh_provider.stemcell_path
63
+ while (stemcell_path || "").size == 0
64
64
  puts "failed. Retrying..."
65
65
  print "Determining stemcell image/file to use... "
66
- stemcell = microbosh_provider.stemcell
66
+ stemcell_path = microbosh_provider.stemcell_path
67
67
  end
68
- settings.set("bosh.stemcell", stemcell)
69
- puts settings.bosh.stemcell
68
+ settings.set("bosh.stemcell_path", stemcell_path)
69
+ puts settings.bosh.stemcell_path
70
70
  end
71
71
 
72
72
  def perform_microbosh_deploy
@@ -7,10 +7,10 @@ module Bosh::Bootstrap::Cli::Helpers::Settings
7
7
  # The base directory for holding the manifest settings file
8
8
  # and private keys
9
9
  #
10
- # Defaults to ~/.bosh_inception; and can be overridden with either:
10
+ # Defaults to current directory; and can be overridden:
11
11
  # * $SETTINGS - to a folder (supported method)
12
12
  def settings_dir
13
- @settings_dir ||= File.expand_path(ENV["SETTINGS"] || "~/.microbosh")
13
+ @settings_dir ||= File.expand_path(ENV["SETTINGS"] || ".")
14
14
  end
15
15
 
16
16
  def settings_dir=(settings_dir)
@@ -40,7 +40,7 @@ class Bosh::Bootstrap::Microbosh
40
40
  chdir(base_path) do
41
41
  setup_gems
42
42
  create_microbosh_yml(settings)
43
- deploy_or_update(settings.bosh.name, settings.bosh.stemcell)
43
+ deploy_or_update(settings.bosh.name, settings.bosh.stemcell_path)
44
44
  end
45
45
  end
46
46
 
@@ -52,7 +52,6 @@ class Bosh::Bootstrap::Microbosh
52
52
  f << <<-RUBY
53
53
  source 'https://rubygems.org'
54
54
 
55
- gem "bosh-bootstrap", path: "#{gempath}"
56
55
  gem "bosh_cli_plugin_micro"
57
56
  RUBY
58
57
  end
@@ -70,4 +69,4 @@ gem "bosh_cli_plugin_micro"
70
69
  bundle "exec bosh -n micro deploy --update-if-exists", stemcell
71
70
  end
72
71
  end
73
- end
72
+ end
@@ -2,18 +2,6 @@ require "bosh-bootstrap/microbosh_providers/base"
2
2
 
3
3
  module Bosh::Bootstrap::MicroboshProviders
4
4
  class AWS < Base
5
- # if us-east-1 -> ami
6
- # if not running in target aws region -> error "Must either use us-east-1 or run 'bosh bootstrap deploy' within target AWS region"
7
- # else download stemcell & return path
8
- def stemcell
9
- unless settings.exists?("bosh.stemcell")
10
- if ami_region?
11
- fetch_ami
12
- else
13
- download_stemcell
14
- end
15
- end
16
- end
17
5
 
18
6
  def to_hash
19
7
  data = super.merge({
@@ -41,7 +29,7 @@ module Bosh::Bootstrap::MicroboshProviders
41
29
  end
42
30
 
43
31
  def resources_cloud_properties
44
- {"instance_type"=>"m1.medium"}
32
+ {"instance_type"=>"m3.medium"}
45
33
  end
46
34
 
47
35
  def cloud_properties
@@ -64,22 +52,28 @@ module Bosh::Bootstrap::MicroboshProviders
64
52
  settings.provider.region
65
53
  end
66
54
 
67
- # only us-east-1 has AMIs published currently
68
- def ami_region?
69
- aws_region == "us-east-1"
70
- end
71
-
72
- def fetch_ami
73
- Net::HTTP.get("#{jenkins_bucket}.s3.amazonaws.com", ami_uri_path(aws_region)).strip
55
+ # @return Bosh::Cli::PublicStemcell latest stemcell for aws/trusty
56
+ # If us-east-1 region, then return light stemcell
57
+ def latest_stemcell
58
+ @latest_stemcell ||= begin
59
+ trusty_stemcells = if light_stemcell?
60
+ recent_stemcells.select do |s|
61
+ s.name =~ /aws/ && s.name =~ /trusty/ && s.name =~ /^light/
62
+ end
63
+ else
64
+ recent_stemcells.select do |s|
65
+ s.name =~ /aws/ && s.name =~ /trusty/ && s.name =~ /^bosh/
66
+ end
67
+ end
68
+ trusty_stemcells.sort {|s1, s2| s2.version <=> s1.version}.first
69
+ end
74
70
  end
75
71
 
76
- def ami_uri_path(region)
77
- "/last_successful-bosh-stemcell-aws_ami_#{region}"
72
+ # only us-east-1 has light stemcells published
73
+ def light_stemcell?
74
+ aws_region == "us-east-1"
78
75
  end
79
76
 
80
- def stemcell_uri
81
- "http://bosh-jenkins-artifacts.s3.amazonaws.com/bosh-stemcell/aws/bosh-stemcell-latest-aws-xen-ubuntu.tgz"
82
- end
83
77
  end
84
78
  end
85
79
  Bosh::Bootstrap::MicroboshProviders.register_provider("aws", Bosh::Bootstrap::MicroboshProviders::AWS)
@@ -1,4 +1,5 @@
1
1
  require "bosh-bootstrap/microbosh_providers"
2
+ require "bosh-bootstrap/public_stemcells"
2
3
 
3
4
  # for the #sh helper
4
5
  require "rake"
@@ -56,13 +57,26 @@ class Bosh::Bootstrap::MicroboshProviders::Base
56
57
  "bosh-jenkins-artifacts"
57
58
  end
58
59
 
60
+ def stemcell_path
61
+ unless settings.exists?("bosh.stemcell_path")
62
+ download_stemcell
63
+ end
64
+ end
65
+
66
+ def recent_stemcells
67
+ @recent_stemcells ||= begin
68
+ public_stemcells = Bosh::Bootstrap::PublicStemcells.new
69
+ public_stemcells.recent
70
+ end
71
+ end
72
+
59
73
  # downloads latest stemcell & returns path
60
74
  def download_stemcell
61
75
  mkdir_p(stemcell_dir)
62
76
  chdir(stemcell_dir) do
63
- stemcell_path = File.expand_path(File.basename(stemcell_uri))
77
+ stemcell_path = File.expand_path(latest_stemcell.name)
64
78
  unless File.exists?(stemcell_path)
65
- sh "curl -O '#{stemcell_uri}'"
79
+ sh "curl -O '#{latest_stemcell.url}'"
66
80
  end
67
81
  return stemcell_path
68
82
  end
@@ -2,11 +2,6 @@ require "bosh-bootstrap/microbosh_providers/base"
2
2
 
3
3
  module Bosh::Bootstrap::MicroboshProviders
4
4
  class OpenStack < Base
5
- def stemcell
6
- unless settings.exists?("bosh.stemcell")
7
- download_stemcell
8
- end
9
- end
10
5
 
11
6
  def to_hash
12
7
  super.merge({
@@ -126,9 +121,16 @@ module Bosh::Bootstrap::MicroboshProviders
126
121
  !!(settings.provider["options"] && settings.provider.options.boot_from_volume)
127
122
  end
128
123
 
129
- def stemcell_uri
130
- "http://bosh-jenkins-artifacts.s3.amazonaws.com/bosh-stemcell/openstack/bosh-stemcell-latest-openstack-kvm-ubuntu.tgz"
124
+ # @return Bosh::Cli::PublicStemcell latest stemcell for openstack/trusty
125
+ def latest_stemcell
126
+ @latest_stemcell ||= begin
127
+ trusty_stemcells = recent_stemcells.select do |s|
128
+ s.name =~ /openstack/ && s.name =~ /trusty/
129
+ end
130
+ trusty_stemcells.sort {|s1, s2| s2.version <=> s1.version}.first
131
+ end
131
132
  end
133
+
132
134
  end
133
135
  end
134
136
  Bosh::Bootstrap::MicroboshProviders.register_provider("openstack", Bosh::Bootstrap::MicroboshProviders::OpenStack)
@@ -100,9 +100,16 @@ module Bosh::Bootstrap::MicroboshProviders
100
100
  }
101
101
  end
102
102
 
103
- def stemcell_uri
104
- "http://#{jenkins_bucket}.s3.amazonaws.com/bosh-stemcell/vsphere/bosh-stemcell-latest-vsphere-esxi-ubuntu.tgz"
103
+ # @return Bosh::Cli::PublicStemcell latest stemcell for vsphere/trusty
104
+ def latest_stemcell
105
+ @latest_stemcell ||= begin
106
+ trusty_stemcells = recent_stemcells.select do |s|
107
+ s.name =~ /vsphere/ && s.name =~ /trusty/
108
+ end
109
+ trusty_stemcells.sort {|s1, s2| s2.version <=> s1.version}.first
110
+ end
105
111
  end
112
+
106
113
  end
107
114
  end
108
115
  Bosh::Bootstrap::MicroboshProviders.register_provider("vsphere", Bosh::Bootstrap::MicroboshProviders::VSphere)
@@ -5,14 +5,16 @@ class Bosh::Bootstrap::Network
5
5
 
6
6
  attr_reader :provider_name
7
7
  attr_reader :cyoi_provider_client
8
+ attr_reader :settings
8
9
 
9
- def initialize(provider_name, cyoi_provider_client)
10
+ def initialize(provider_name, cyoi_provider_client, settings)
10
11
  @provider_name = provider_name
11
12
  @cyoi_provider_client = cyoi_provider_client
13
+ @settings = settings
12
14
  end
13
15
 
14
16
  def deploy
15
- network_provider.perform
17
+ network_provider.perform(settings)
16
18
  end
17
19
 
18
20
  # Attempt to load and instantiate a NetworkProviders class
@@ -6,9 +6,13 @@ module Bosh::Bootstrap::NetworkProviders
6
6
  @cyoi_provider_client = cyoi_provider_client
7
7
  end
8
8
 
9
- def perform
9
+ def perform(settings)
10
+ attributes = {}
11
+ if vpc_id = settings.exists?("address.vpc_id")
12
+ attributes[:vpc_id] = vpc_id
13
+ end
10
14
  security_groups.each do |name, ports|
11
- cyoi_provider_client.create_security_group(name.to_s, name.to_s, ports: ports)
15
+ cyoi_provider_client.create_security_group(name.to_s, name.to_s, {ports: ports}, attributes)
12
16
  end
13
17
  end
14
18
 
@@ -3,7 +3,7 @@ module Bosh::Bootstrap::NetworkProviders
3
3
  def initialize(cyoi_provider_client)
4
4
  end
5
5
 
6
- def perform
6
+ def perform(settings)
7
7
  end
8
8
  end
9
9
  end
@@ -6,7 +6,7 @@ module Bosh::Bootstrap::NetworkProviders
6
6
  @cyoi_provider_client = cyoi_provider_client
7
7
  end
8
8
 
9
- def perform
9
+ def perform(settings)
10
10
  cyoi_provider_client.create_security_group("ssh", "ssh", 22)
11
11
  cyoi_provider_client.create_security_group("dns_server", "dns_server", protocol: "udp", ports: (53..53) )
12
12
  cyoi_provider_client.create_security_group("bosh", "bosh", [4222, 6868, 25250, 25555, 25777] )
@@ -0,0 +1,33 @@
1
+ module Bosh::Bootstrap
2
+ class PublicStemcell
3
+ attr_reader :size
4
+
5
+ def initialize(key, size)
6
+ @key = key
7
+ @size = size
8
+
9
+ @parsed_version = key.scan(/[\d]*_?[\d]+/).first
10
+ end
11
+
12
+ def name
13
+ File.basename(@key)
14
+ end
15
+
16
+ def version
17
+ @parsed_version.gsub('_', '.').to_f
18
+ end
19
+
20
+ def variety
21
+ name.gsub(/(.tgz)|(bosh-stemcell-)|(#{@parsed_version})/, '').split('-').reject { |c| c.empty? }.join('-')
22
+ end
23
+
24
+ def url
25
+ "#{PublicStemcells::PUBLIC_STEMCELLS_BASE_URL}/#{@key}"
26
+ end
27
+
28
+ def legacy?
29
+ @key.include?('legacy')
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,66 @@
1
+ require 'httpclient'
2
+ require 'rexml/document'
3
+
4
+ require 'bosh-bootstrap/public_stemcell'
5
+
6
+ module Bosh::Bootstrap
7
+ class PublicStemcells
8
+ PUBLIC_STEMCELLS_BASE_URL = 'https://bosh-jenkins-artifacts.s3.amazonaws.com'
9
+
10
+ def has_stemcell?(stemcell_filename)
11
+ all.any? { |stemcell| stemcell.name == stemcell_filename }
12
+ end
13
+
14
+ def find(stemcell_filename)
15
+ all.detect { |stemcell| stemcell.name == stemcell_filename }
16
+ end
17
+
18
+ def all
19
+ response = self.class.http_client.get(PUBLIC_STEMCELLS_BASE_URL, {'prefix' => 'bosh-stemcell'})
20
+ doc = REXML::Document.new(response.body)
21
+ stemcells_tags = parse_document(doc)
22
+ stemcells = parse_stemcells(stemcells_tags)
23
+
24
+ while is_truncated(doc)
25
+ response = self.class.http_client.get(PUBLIC_STEMCELLS_BASE_URL, {
26
+ 'prefix' => 'bosh-stemcell',
27
+ 'marker' => stemcells_tags.last.get_text('Key').value
28
+ })
29
+
30
+ doc = REXML::Document.new(response.body)
31
+ stemcells_tags = parse_document(doc)
32
+ stemcells += parse_stemcells(stemcells_tags)
33
+ end
34
+
35
+ stemcells
36
+ end
37
+
38
+ def recent
39
+ stemcell_varietes = all.reject(&:legacy?).group_by(&:variety).values
40
+ stemcell_varietes.map { |stemcells| stemcells.sort_by(&:version).last }
41
+ end
42
+
43
+ private
44
+
45
+ def parse_document(doc)
46
+ REXML::XPath.match(doc, "/ListBucketResult/Contents[Key[text()[not(contains(.,'latest'))]]]")
47
+ end
48
+
49
+ def parse_stemcells(stemcell_tags)
50
+ stemcell_tags.map do |stemcell_tag|
51
+ stemcell_key = stemcell_tag.get_text('Key').value
52
+ stemcell_size = Integer(stemcell_tag.get_text('Size').value)
53
+
54
+ PublicStemcell.new(stemcell_key, stemcell_size)
55
+ end
56
+ end
57
+
58
+ def is_truncated(doc)
59
+ REXML::XPath.match(doc, "/ListBucketResult/IsTruncated").first.get_text == 'true'
60
+ end
61
+
62
+ def self.http_client
63
+ @http_client ||= HTTPClient.new
64
+ end
65
+ end
66
+ end
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Bootstrap
3
- VERSION = "0.13.2"
3
+ VERSION = "0.14.0"
4
4
  end
5
5
  end
@@ -12,12 +12,14 @@ describe "AWS deployment using gems and publish stemcells" do
12
12
 
13
13
  # after { destroy_test_constructs }
14
14
 
15
- it "creates an EC2 inception/microbosh with the associated resources" do
15
+ xit "creates an EC2 inception/microbosh with the associated resources" do
16
16
  # TODO remove this when finished initial development
17
17
  require "fog"
18
18
  Fog.mock!
19
19
 
20
20
  setup_home_dir
21
+ puts `pwd`
22
+ puts `tree`
21
23
  create_manifest
22
24
  cli.deploy
23
25
 
data/spec/spec_helper.rb CHANGED
@@ -39,21 +39,40 @@ def yaml_files_match(filename, expected_filename)
39
39
  end
40
40
 
41
41
  def setup_home_dir
42
- home_dir = File.expand_path("../../tmp/home", __FILE__)
43
42
  FileUtils.rm_rf(home_dir)
44
43
  FileUtils.mkdir_p(home_dir)
45
44
  ENV['HOME'] = home_dir
46
45
  end
47
46
 
47
+ def setup_work_dir
48
+ FileUtils.mkdir_p(work_dir)
49
+ FileUtils.chdir(work_dir)
50
+ end
51
+
52
+ def work_dir
53
+ File.join(home_dir, "workspace/deployments/microbosh")
54
+ end
55
+
56
+ def home_dir
57
+ File.expand_path("../../tmp/home", __FILE__)
58
+ end
59
+
48
60
  # returns the file path to a file
49
61
  # in the fake $HOME folder
50
62
  def home_file(*path)
51
63
  File.join(ENV['HOME'], *path)
52
64
  end
53
65
 
66
+ # returns the file path to a file
67
+ # in the fake ~/workspace/deployments/microbosh folder
68
+ def work_file(*path)
69
+ File.join(work_dir, *path)
70
+ end
71
+
54
72
  RSpec.configure do |c|
55
73
  c.before(:each) do
56
74
  setup_home_dir
75
+ setup_work_dir
57
76
  end
58
77
 
59
78
  c.color = true
@@ -6,8 +6,6 @@ describe Bosh::Bootstrap::Cli::Commands::Delete do
6
6
  include StdoutCapture
7
7
  include Bosh::Bootstrap::Cli::Helpers
8
8
 
9
- let(:settings_dir) { File.expand_path("~/.microbosh") }
10
-
11
9
  subject { Bosh::Bootstrap::Cli::Commands::Delete.new }
12
10
 
13
11
  it "deletes microbosh VM" do
@@ -17,4 +15,4 @@ describe Bosh::Bootstrap::Cli::Commands::Delete do
17
15
  subject.should_receive(:sh).with("bundle exec bosh -n micro delete")
18
16
  subject.perform
19
17
  end
20
- end
18
+ end
@@ -7,7 +7,7 @@ describe Bosh::Bootstrap::Cli::Commands::Deploy do
7
7
  include StdoutCapture
8
8
  include Bosh::Bootstrap::Cli::Helpers
9
9
 
10
- let(:settings_dir) { File.expand_path("~/.microbosh") }
10
+ let(:settings_dir) { work_dir }
11
11
 
12
12
  before do
13
13
  FileUtils.mkdir_p(@stemcells_dir = File.join(Dir.mktmpdir, "stemcells"))
@@ -45,8 +45,8 @@ describe Bosh::Bootstrap::Cli::Commands::Deploy do
45
45
 
46
46
  # microbosh_provider & select_public_image_or_download_stemcell
47
47
  microbosh_provider = instance_double("Bosh::Bootstrap::MicroboshProviders::AWS")
48
- expect(microbosh_provider).to receive(:stemcell).exactly(1).times.and_return("")
49
- expect(microbosh_provider).to receive(:stemcell).exactly(1).times.and_return("ami-123456")
48
+ expect(microbosh_provider).to receive(:stemcell_path).exactly(1).times.and_return("")
49
+ expect(microbosh_provider).to receive(:stemcell_path).exactly(1).times.and_return("ami-123456")
50
50
  expect(cmd).to receive(:microbosh_provider).and_return(microbosh_provider).exactly(3).times
51
51
 
52
52
  # setup_keypair
@@ -91,8 +91,8 @@ describe Bosh::Bootstrap::Cli::Commands::Deploy do
91
91
 
92
92
  # microbosh_provider & select_public_image_or_download_stemcell
93
93
  microbosh_provider = instance_double("Bosh::Bootstrap::MicroboshProviders::OpenStack")
94
- expect(microbosh_provider).to receive(:stemcell).exactly(1).times.and_return("")
95
- expect(microbosh_provider).to receive(:stemcell).exactly(1).times.and_return("openstack.tgz")
94
+ expect(microbosh_provider).to receive(:stemcell_path).exactly(1).times.and_return("")
95
+ expect(microbosh_provider).to receive(:stemcell_path).exactly(1).times.and_return("openstack.tgz")
96
96
  expect(cmd).to receive(:microbosh_provider).and_return(microbosh_provider).exactly(3).times
97
97
 
98
98
  # setup_keypair
@@ -6,15 +6,15 @@ describe Bosh::Bootstrap::Cli::Commands::SSH do
6
6
  include StdoutCapture
7
7
  include Bosh::Bootstrap::Cli::Helpers
8
8
 
9
- let(:settings_dir) { File.expand_path("~/.microbosh") }
9
+ let(:settings_dir) { work_dir }
10
10
 
11
11
  subject { Bosh::Bootstrap::Cli::Commands::SSH.new }
12
12
 
13
13
  it "runs ssh" do
14
14
  setting "address.ip", "1.2.3.4"
15
15
  setting "key_pair.path", "/path/to/private/key"
16
- subject.should_receive(:setup_keypair)
17
- subject.should_receive(:sh).with("ssh -i /path/to/private/key vcap@1.2.3.4")
16
+ expect(subject).to receive(:setup_keypair)
17
+ expect(subject).to receive(:sh).with("ssh -i /path/to/private/key vcap@1.2.3.4")
18
18
  subject.perform
19
19
  end
20
- end
20
+ end
@@ -3,13 +3,12 @@ require "bosh-bootstrap/key_pair"
3
3
  describe Bosh::Bootstrap::KeyPair do
4
4
  include Bosh::Bootstrap::Cli::Helpers::Settings
5
5
 
6
- subject { Bosh::Bootstrap::KeyPair.new(settings_dir, "keyname", "PRIVATE") }
6
+ subject { Bosh::Bootstrap::KeyPair.new(work_dir, "keyname", "PRIVATE") }
7
7
 
8
8
  it "creates local private key file" do
9
- setup_home_dir
10
- expect(File.exists?(home_file(".microbosh", "ssh", "keyname"))).to eq false
9
+ expect(File.exists?(work_file("ssh", "keyname"))).to eq false
11
10
  subject.execute!
12
- keyfile = home_file(".microbosh", "ssh", "keyname")
11
+ keyfile = work_file("ssh", "keyname")
13
12
  expect(File.read(keyfile)).to eq "PRIVATE"
14
13
  end
15
14
  end
@@ -5,10 +5,9 @@ require "bosh-bootstrap/microbosh_providers/aws"
5
5
  describe Bosh::Bootstrap::MicroboshProviders::AWS do
6
6
  include Bosh::Bootstrap::Cli::Helpers::Settings
7
7
 
8
- let(:microbosh_yml) { File.expand_path("~/.microbosh/deployments/micro_bosh.yml")}
9
- let(:aws_jenkins_bucket) { "bosh-jenkins-artifacts" }
10
- let(:latest_ami_uri) { "http://#{aws_jenkins_bucket}.s3.amazonaws.com/last_successful-bosh-stemcell-aws_ami_us-east-1" }
11
- let(:latest_stemcell_uri) { "http://bosh-jenkins-artifacts.s3.amazonaws.com/bosh-stemcell/aws/bosh-stemcell-latest-aws-xen-ubuntu.tgz" }
8
+ let(:microbosh_yml) { File.expand_path("~/.microbosh/deployments/micro_bosh.yml") }
9
+ let(:artifacts_base) { "https://bosh-jenkins-artifacts.s3.amazonaws.com" }
10
+ let(:http_client) { instance_double("HTTPClient") }
12
11
 
13
12
  it "creates micro_bosh.yml manifest" do
14
13
  setting "provider.name", "aws"
@@ -24,7 +23,7 @@ describe Bosh::Bootstrap::MicroboshProviders::AWS do
24
23
  subject = Bosh::Bootstrap::MicroboshProviders::AWS.new(microbosh_yml, settings)
25
24
 
26
25
  subject.create_microbosh_yml(settings)
27
- File.should be_exists(microbosh_yml)
26
+ expect(File).to be_exists(microbosh_yml)
28
27
  yaml_files_match(microbosh_yml, spec_asset("microbosh_yml/micro_bosh.aws_ec2.yml"))
29
28
  end
30
29
 
@@ -43,7 +42,7 @@ describe Bosh::Bootstrap::MicroboshProviders::AWS do
43
42
  subject = Bosh::Bootstrap::MicroboshProviders::AWS.new(microbosh_yml, settings)
44
43
 
45
44
  subject.create_microbosh_yml(settings)
46
- File.should be_exists(microbosh_yml)
45
+ expect(File).to be_exists(microbosh_yml)
47
46
  yaml_files_match(microbosh_yml, spec_asset("microbosh_yml/micro_bosh.aws_ec2.us-west-2a.yml"))
48
47
  end
49
48
 
@@ -52,24 +51,52 @@ describe Bosh::Bootstrap::MicroboshProviders::AWS do
52
51
  setting "provider.name", "aws"
53
52
  end
54
53
 
55
- it "is an AMI if us-east-1 target region" do
56
- setting "provider.region", "us-east-1"
57
- FakeWeb.register_uri(:get, latest_ami_uri, body: "ami-234567")
58
-
59
- subject = Bosh::Bootstrap::MicroboshProviders::AWS.new(microbosh_yml, settings)
60
- subject.stemcell.should == "ami-234567"
54
+ before(:each) do
55
+ body = <<-XML
56
+ <?xml version="1.0" encoding="UTF-8"?>
57
+ <ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
58
+ <Name>bosh-jenkins-artifacts</Name>
59
+ <Prefix>bosh-stemcell</Prefix>
60
+ <Marker/>
61
+ <MaxKeys>1000</MaxKeys>
62
+ <IsTruncated>false</IsTruncated>
63
+ <Contents>
64
+ <Key>bosh-stemcell/aws/bosh-stemcell-2719-aws-xen-centos-go_agent.tgz</Key>
65
+ <LastModified>2014-09-22T04:59:16.000Z</LastModified>
66
+ <ETag>"7621366406eeb0a9d88242a664206cc3"</ETag>
67
+ <Size>557556059</Size>
68
+ <StorageClass>STANDARD</StorageClass>
69
+ </Contents>
70
+ <Contents>
71
+ <Key>bosh-stemcell/aws/bosh-stemcell-2719-aws-xen-ubuntu-trusty-go_agent.tgz</Key>
72
+ <LastModified>2014-09-22T04:59:16.000Z</LastModified>
73
+ <ETag>"18cb27adc889e71c97e39b1c57f85027"</ETag>
74
+ <Size>467288141</Size>
75
+ <StorageClass>STANDARD</StorageClass>
76
+ </Contents>
77
+ <Contents>
78
+ <Key>bosh-stemcell/aws/light-bosh-stemcell-2719-aws-xen-ubuntu-trusty-go_agent.tgz</Key>
79
+ <LastModified>2014-09-22T04:59:16.000Z</LastModified>
80
+ <ETag>"18cb27adc889e71c97e39b1c57f85027"</ETag>
81
+ <Size>467288141</Size>
82
+ <StorageClass>STANDARD</StorageClass>
83
+ </Contents>
84
+ </ListBucketResult>
85
+ XML
86
+ expect(Bosh::Bootstrap::PublicStemcells).to receive(:http_client).and_return(http_client)
87
+ expect(http_client).to receive(:get).
88
+ with(artifacts_base, {'prefix' => 'bosh-stemcell'}).
89
+ and_return(OpenStruct.new(body: body))
61
90
  end
62
91
 
63
- it "retries to get AMI if initially fails" do
92
+ it "light stemcell if us-east-1 target region" do
64
93
  setting "provider.region", "us-east-1"
65
- FakeWeb.register_uri(:get, latest_ami_uri, [
66
- { status: 404 },
67
- { body: "ami-234567"}
68
- ])
69
94
 
70
95
  subject = Bosh::Bootstrap::MicroboshProviders::AWS.new(microbosh_yml, settings)
71
- subject.stemcell.should == ""
72
- subject.stemcell.should == "ami-234567"
96
+
97
+ latest_stemcell_uri = "#{artifacts_base}/bosh-stemcell/aws/light-bosh-stemcell-2719-aws-xen-ubuntu-trusty-go_agent.tgz"
98
+ expect(subject).to receive(:sh).with("curl -O '#{latest_stemcell_uri}'")
99
+ expect(subject.stemcell_path).to match /light-bosh-stemcell-2719-aws-xen-ubuntu-trusty-go_agent.tgz$/
73
100
  end
74
101
 
75
102
  xit "errors if AMI not available and not running within target region" do
@@ -78,10 +105,15 @@ describe Bosh::Bootstrap::MicroboshProviders::AWS do
78
105
 
79
106
  it "downloads latest stemcell and returns path if running in target AWS region" do
80
107
  setting "provider.region", "us-west-2"
81
-
108
+
82
109
  subject = Bosh::Bootstrap::MicroboshProviders::AWS.new(microbosh_yml, settings)
83
- subject.stub(:sh).with("curl -O '#{latest_stemcell_uri}'")
84
- subject.stemcell.should =~ %r{deployments/bosh-stemcell-latest-aws-xen-ubuntu.tgz$}
110
+
111
+ latest_stemcell_uri = "#{artifacts_base}/bosh-stemcell/aws/bosh-stemcell-2719-aws-xen-ubuntu-trusty-go_agent.tgz"
112
+
113
+ expect(subject).to receive(:sh).with("curl -O '#{latest_stemcell_uri}'")
114
+ stemcell_path = subject.stemcell_path
115
+ expect(stemcell_path).to match /bosh-stemcell-2719-aws-xen-ubuntu-trusty-go_agent.tgz$/
116
+ expect(stemcell_path).to_not match /light-bosh-stemcell-2719-aws-xen-ubuntu-trusty-go_agent.tgz$/
85
117
  end
86
118
  end
87
119
  end
@@ -3,18 +3,18 @@ require "readwritesettings"
3
3
  describe Bosh::Bootstrap::Microbosh do
4
4
  include Bosh::Bootstrap::Cli::Helpers::Settings
5
5
 
6
- let(:path_or_ami) { "/path/to/stemcell.tgz" }
7
- let(:base_path) { File.expand_path("~/.microbosh") }
6
+ let(:stemcell_path) { "/path/to/stemcell.tgz" }
7
+ let(:base_path) { File.expand_path("/tmp/bootstrap") }
8
8
  let(:settings_dir) { base_path }
9
9
  let(:microbosh_provider) { instance_double("Bosh::Bootstrap::MicroboshProviders::AWS", create_microbosh_yml: {}) }
10
10
  subject { Bosh::Bootstrap::Microbosh.new(base_path, microbosh_provider) }
11
11
 
12
12
  it "deploys new microbosh" do
13
13
  setting "bosh.name", "test-bosh"
14
- setting "bosh.stemcell", path_or_ami
15
- subject.should_receive(:sh).with("bundle install")
16
- subject.should_receive(:sh).with("bundle exec bosh micro deployment test-bosh")
17
- subject.should_receive(:sh).with("bundle exec bosh -n micro deploy --update-if-exists #{path_or_ami}")
14
+ setting "bosh.stemcell_path", stemcell_path
15
+ expect(subject).to receive(:sh).with("bundle install")
16
+ expect(subject).to receive(:sh).with("bundle exec bosh micro deployment test-bosh")
17
+ expect(subject).to receive(:sh).with("bundle exec bosh -n micro deploy --update-if-exists #{stemcell_path}")
18
18
  subject.deploy(settings)
19
19
  end
20
20
 
@@ -13,15 +13,30 @@ describe Bosh::Bootstrap::NetworkProviders::AWS do
13
13
  expect(Bosh::Bootstrap::NetworkProviders.provider_class("aws")).to eq(subject.class)
14
14
  end
15
15
 
16
- it "creates security groups it needs" do
16
+ it "creates EC2 security groups it needs" do
17
17
  expected_groups = [
18
18
  ["ssh", "ssh", ports: 22],
19
19
  ["dns_server", "dns_server", ports: { protocol: "udp", ports: (53..53) }],
20
20
  ["bosh", "bosh", ports: [4222, 6868, 25250, 25555, 25777]]
21
21
  ]
22
22
  expected_groups.each do |security_group_name, description, ports|
23
- expect(cyoi_provider_client).to receive(:create_security_group).with(security_group_name, description, ports)
23
+ expect(cyoi_provider_client).to receive(:create_security_group).with(security_group_name, description, ports, {})
24
24
  end
25
- subject.perform
25
+ subject.perform(settings)
26
26
  end
27
+
28
+ it "creates VPC security groups it needs" do
29
+ setting "address.vpc_id", "vpc-id-1234"
30
+ expected_groups = [
31
+ ["ssh", "ssh", ports: 22],
32
+ ["dns_server", "dns_server", ports: { protocol: "udp", ports: (53..53) }],
33
+ ["bosh", "bosh", ports: [4222, 6868, 25250, 25555, 25777]]
34
+ ]
35
+ expected_groups.each do |security_group_name, description, ports|
36
+ expect(cyoi_provider_client).to receive(:create_security_group).
37
+ with(security_group_name, description, ports, {vpc_id: "vpc-id-1234"})
38
+ end
39
+ subject.perform(settings)
40
+ end
41
+
27
42
  end
@@ -21,6 +21,6 @@ describe Bosh::Bootstrap::NetworkProviders::OpenStack do
21
21
  expected_groups.each do |security_group_name, description, ports|
22
22
  expect(provider_client).to receive(:create_security_group).with(security_group_name, description, ports)
23
23
  end
24
- subject.perform
24
+ subject.perform(settings)
25
25
  end
26
26
  end
@@ -6,13 +6,13 @@ describe Bosh::Bootstrap::Network do
6
6
  let(:aws_cyoi_provider_client) { instance_double("Cyoi::Providers::Clients::AwsProviderClient") }
7
7
 
8
8
  it "uses NetworkProvider if available" do
9
- network = Bosh::Bootstrap::Network.new("aws", aws_cyoi_provider_client)
9
+ network = Bosh::Bootstrap::Network.new("aws", aws_cyoi_provider_client, settings)
10
10
  expect(aws_cyoi_provider_client).to receive(:create_security_group).exactly(3).times
11
11
  network.deploy
12
12
  end
13
13
 
14
14
  it "does nothing if no NetworkProvider for the infrastructure" do
15
- network = Bosh::Bootstrap::Network.new("vsphere", nil)
15
+ network = Bosh::Bootstrap::Network.new("vsphere", nil, settings)
16
16
  network.deploy
17
17
  end
18
18
  end
metadata CHANGED
@@ -1,139 +1,153 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh-bootstrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.2
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dr Nic Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-30 00:00:00.000000000 Z
11
+ date: 2014-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cyoi
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.10'
19
+ version: '0.11'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.10'
26
+ version: '0.11'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: fog
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.11'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.11'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: readwritesettings
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: thor
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0.18'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.18'
69
+ - !ruby/object:Gem::Dependency
70
+ name: httpclient
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 2.4.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 2.4.0
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: redcard
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - ! '>='
87
+ - - ">="
74
88
  - !ruby/object:Gem::Version
75
89
  version: '0'
76
90
  type: :runtime
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - ! '>='
94
+ - - ">="
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rbvmomi
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - ! '>='
101
+ - - ">="
88
102
  - !ruby/object:Gem::Version
89
103
  version: '0'
90
104
  type: :runtime
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - ! '>='
108
+ - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rake
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - ! '>='
115
+ - - ">="
102
116
  - !ruby/object:Gem::Version
103
117
  version: '0'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - ! '>='
122
+ - - ">="
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: rspec-fire
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
- - - ! '>='
129
+ - - ">="
116
130
  - !ruby/object:Gem::Version
117
131
  version: '0'
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
- - - ! '>='
136
+ - - ">="
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: fakeweb
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
- - - ! '>='
143
+ - - ">="
130
144
  - !ruby/object:Gem::Version
131
145
  version: '0'
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
- - - ! '>='
150
+ - - ">="
137
151
  - !ruby/object:Gem::Version
138
152
  version: '0'
139
153
  description: Bootstrap a micro bosh universe from one CLI
@@ -144,9 +158,9 @@ executables:
144
158
  extensions: []
145
159
  extra_rdoc_files: []
146
160
  files:
147
- - .gitignore
148
- - .rspec
149
- - .travis.yml
161
+ - ".gitignore"
162
+ - ".rspec"
163
+ - ".travis.yml"
150
164
  - ChangeLog.md
151
165
  - Gemfile
152
166
  - Guardfile
@@ -177,6 +191,8 @@ files:
177
191
  - lib/bosh-bootstrap/network_providers/aws.rb
178
192
  - lib/bosh-bootstrap/network_providers/dummy.rb
179
193
  - lib/bosh-bootstrap/network_providers/openstack.rb
194
+ - lib/bosh-bootstrap/public_stemcell.rb
195
+ - lib/bosh-bootstrap/public_stemcells.rb
180
196
  - lib/bosh-bootstrap/thor_cli.rb
181
197
  - lib/bosh-bootstrap/version.rb
182
198
  - lib/bosh/cli/commands/bootstrap.rb
@@ -217,17 +233,17 @@ require_paths:
217
233
  - lib
218
234
  required_ruby_version: !ruby/object:Gem::Requirement
219
235
  requirements:
220
- - - ! '>='
236
+ - - ">="
221
237
  - !ruby/object:Gem::Version
222
238
  version: '1.9'
223
239
  required_rubygems_version: !ruby/object:Gem::Requirement
224
240
  requirements:
225
- - - ! '>='
241
+ - - ">="
226
242
  - !ruby/object:Gem::Version
227
243
  version: '0'
228
244
  requirements: []
229
245
  rubyforge_project:
230
- rubygems_version: 2.2.2
246
+ rubygems_version: 2.2.1
231
247
  signing_key:
232
248
  specification_version: 4
233
249
  summary: bosh-bootstrap configures and deploys a microbosh deployed on either AWS