bosh-bootstrap 0.10.2 → 0.11.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.
Files changed (162) hide show
  1. data/.rspec +1 -0
  2. data/.travis.yml +0 -1
  3. data/ChangeLog.md +23 -4
  4. data/Gemfile +5 -2
  5. data/Guardfile +2 -0
  6. data/README.md +209 -197
  7. data/TODO.md +55 -0
  8. data/bosh-bootstrap.gemspec +5 -12
  9. data/lib/bosh/cli/commands/bootstrap.rb +42 -0
  10. data/lib/bosh-bootstrap/cli/commands/delete.rb +26 -0
  11. data/lib/bosh-bootstrap/cli/commands/deploy.rb +89 -0
  12. data/lib/bosh-bootstrap/cli/commands/ssh.rb +32 -0
  13. data/lib/bosh-bootstrap/cli/helpers/bundle.rb +12 -0
  14. data/lib/bosh-bootstrap/cli/helpers/interactions.rb +15 -0
  15. data/lib/bosh-bootstrap/cli/helpers/settings.rb +61 -0
  16. data/lib/bosh-bootstrap/cli/helpers.rb +11 -0
  17. data/lib/bosh-bootstrap/key_pair.rb +21 -0
  18. data/lib/bosh-bootstrap/microbosh.rb +74 -0
  19. data/lib/bosh-bootstrap/microbosh_providers/aws.rb +104 -0
  20. data/lib/bosh-bootstrap/microbosh_providers/base.rb +50 -0
  21. data/lib/bosh-bootstrap/microbosh_providers/openstack.rb +61 -0
  22. data/lib/bosh-bootstrap/microbosh_providers/vsphere.rb +78 -0
  23. data/lib/bosh-bootstrap/microbosh_providers.rb +11 -0
  24. data/lib/bosh-bootstrap/network.rb +33 -0
  25. data/lib/bosh-bootstrap/network_providers/aws.rb +28 -0
  26. data/lib/bosh-bootstrap/network_providers/dummy.rb +10 -0
  27. data/lib/bosh-bootstrap/network_providers/openstack.rb +28 -0
  28. data/lib/bosh-bootstrap/network_providers.rb +11 -0
  29. data/lib/bosh-bootstrap/version.rb +1 -1
  30. data/lib/bosh-bootstrap.rb +3 -4
  31. data/spec/assets/microbosh_yml/micro_bosh.aws_ec2.yml +37 -0
  32. data/spec/assets/microbosh_yml/micro_bosh.aws_vpc.yml +39 -0
  33. data/spec/assets/microbosh_yml/micro_bosh.openstack.yml +30 -0
  34. data/spec/assets/microbosh_yml/micro_bosh.vsphere.yml +34 -0
  35. data/spec/integration/aws/aws_ec2_basic_spec.rb +39 -0
  36. data/spec/integration/aws/aws_helpers.rb +8 -61
  37. data/spec/spec_helper.rb +8 -3
  38. data/spec/support/capture_stdout.rb +18 -0
  39. data/spec/unit/cli/bootstrap_spec.rb +41 -0
  40. data/spec/unit/commands/delete_spec.rb +20 -0
  41. data/spec/unit/commands/deploy_spec.rb +64 -0
  42. data/spec/unit/commands/ssh_spec.rb +19 -0
  43. data/spec/unit/key_pair_spec.rb +13 -0
  44. data/spec/unit/microbosh_providers/aws_spec.rb +68 -0
  45. data/spec/unit/microbosh_providers/openstack_spec.rb +27 -0
  46. data/spec/unit/microbosh_providers/vsphere_spec.rb +42 -0
  47. data/spec/unit/microbosh_spec.rb +27 -0
  48. data/spec/unit/network_providers/aws_spec.rb +29 -0
  49. data/spec/unit/network_providers/openstack_spec.rb +29 -0
  50. data/spec/unit/network_spec.rb +17 -0
  51. metadata +71 -235
  52. data/CleanupCi.md +0 -8
  53. data/bin/bosh-bootstrap +0 -8
  54. data/docs/README.md +0 -3
  55. data/docs/devstack-openstack-tutorial.md +0 -215
  56. data/lib/bosh/providers/README.md +0 -5
  57. data/lib/bosh/providers/aws.rb +0 -258
  58. data/lib/bosh/providers/base_provider.rb +0 -48
  59. data/lib/bosh/providers/openstack.rb +0 -79
  60. data/lib/bosh/providers.rb +0 -21
  61. data/lib/bosh-bootstrap/cli.rb +0 -1347
  62. data/lib/bosh-bootstrap/commander/README.md +0 -47
  63. data/lib/bosh-bootstrap/commander/command.rb +0 -25
  64. data/lib/bosh-bootstrap/commander/commands.rb +0 -80
  65. data/lib/bosh-bootstrap/commander/local_server.rb +0 -68
  66. data/lib/bosh-bootstrap/commander/remote_script_command.rb +0 -51
  67. data/lib/bosh-bootstrap/commander/remote_server.rb +0 -137
  68. data/lib/bosh-bootstrap/commander/upload_command.rb +0 -17
  69. data/lib/bosh-bootstrap/commander.rb +0 -9
  70. data/lib/bosh-bootstrap/helpers/fog_setup.rb +0 -50
  71. data/lib/bosh-bootstrap/helpers/settings.rb +0 -99
  72. data/lib/bosh-bootstrap/helpers/settings_setter.rb +0 -41
  73. data/lib/bosh-bootstrap/helpers.rb +0 -3
  74. data/lib/bosh-bootstrap/stages/stage_micro_bosh_delete/bosh_micro_delete +0 -19
  75. data/lib/bosh-bootstrap/stages/stage_micro_bosh_delete.rb +0 -90
  76. data/lib/bosh-bootstrap/stages/stage_micro_bosh_deploy/bosh_micro_deploy +0 -79
  77. data/lib/bosh-bootstrap/stages/stage_micro_bosh_deploy/install_key_pair_for_user +0 -23
  78. data/lib/bosh-bootstrap/stages/stage_micro_bosh_deploy.rb +0 -146
  79. data/lib/bosh-bootstrap/stages/stage_micro_bosh_download/download_micro_bosh_stemcell +0 -93
  80. data/lib/bosh-bootstrap/stages/stage_micro_bosh_download.rb +0 -139
  81. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/configure_git +0 -25
  82. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/create_vcap_user +0 -79
  83. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_base_packages +0 -30
  84. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_bosh +0 -11
  85. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_bosh_plugins +0 -25
  86. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_hub +0 -26
  87. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_ruby +0 -30
  88. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_useful_gems +0 -29
  89. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/validate_bosh_deployer +0 -18
  90. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm.rb +0 -69
  91. data/lib/bosh-bootstrap/stages/stage_salted_password/convert_salted_password +0 -11
  92. data/lib/bosh-bootstrap/stages/stage_salted_password.rb +0 -51
  93. data/lib/bosh-bootstrap/stages/stage_setup_new_bosh/setup_bosh_user +0 -29
  94. data/lib/bosh-bootstrap/stages/stage_setup_new_bosh.rb +0 -51
  95. data/lib/bosh-bootstrap/stages/stage_validate_inception_vm/validate_ubuntu +0 -6
  96. data/lib/bosh-bootstrap/stages/stage_validate_inception_vm.rb +0 -39
  97. data/lib/bosh-bootstrap/stages.rb +0 -10
  98. data/spec/assets/bosh/public_stemcells/aws_micro.out +0 -7
  99. data/spec/assets/micro_bosh_yml/micro_bosh.aws_ec2.yml +0 -35
  100. data/spec/assets/micro_bosh_yml/micro_bosh.aws_vpc.yml +0 -37
  101. data/spec/integration/aws/aws_basic_spec.rb +0 -39
  102. data/spec/integration/aws/aws_edge_prebuilt_ami_spec.rb +0 -46
  103. data/spec/integration/aws/aws_edge_prebuilt_spec.rb +0 -46
  104. data/spec/integration/aws/aws_edge_spec.rb +0 -45
  105. data/spec/unit/aws_spec.rb +0 -177
  106. data/spec/unit/bosh/providers/aws_spec.rb +0 -174
  107. data/spec/unit/cli_spec.rb +0 -134
  108. data/spec/unit/cli_ssh_spec.rb +0 -95
  109. data/spec/unit/cli_upgrade_inception_spec.rb +0 -29
  110. data/spec/unit/settings_setter_spec.rb +0 -29
  111. data/vendor/cache/POpen4-0.1.4.gem +0 -0
  112. data/vendor/cache/Platform-0.4.0.gem +0 -0
  113. data/vendor/cache/activesupport-3.2.8.gem +0 -0
  114. data/vendor/cache/awesome_print-1.1.0.gem +0 -0
  115. data/vendor/cache/aws-s3-0.6.3.gem +0 -0
  116. data/vendor/cache/blobstore_client-0.4.0.gem +0 -0
  117. data/vendor/cache/bosh_cli-1.0.3.gem +0 -0
  118. data/vendor/cache/bosh_common-0.5.4.gem +0 -0
  119. data/vendor/cache/builder-3.2.0.gem +0 -0
  120. data/vendor/cache/coderay-1.0.8.gem +0 -0
  121. data/vendor/cache/diff-lcs-1.1.3.gem +0 -0
  122. data/vendor/cache/escape-0.0.4.gem +0 -0
  123. data/vendor/cache/excon-0.20.1.gem +0 -0
  124. data/vendor/cache/fog-1.8.0.gem +0 -0
  125. data/vendor/cache/formatador-0.2.4.gem +0 -0
  126. data/vendor/cache/guard-1.6.2.gem +0 -0
  127. data/vendor/cache/guard-rspec-2.4.0.gem +0 -0
  128. data/vendor/cache/highline-1.6.18.gem +0 -0
  129. data/vendor/cache/httpclient-2.2.4.gem +0 -0
  130. data/vendor/cache/i18n-0.6.1.gem +0 -0
  131. data/vendor/cache/json_pure-1.6.8.gem +0 -0
  132. data/vendor/cache/listen-0.7.2.gem +0 -0
  133. data/vendor/cache/log4r-1.1.10.gem +0 -0
  134. data/vendor/cache/lumberjack-1.0.2.gem +0 -0
  135. data/vendor/cache/method_source-0.8.1.gem +0 -0
  136. data/vendor/cache/mime-types-1.22.gem +0 -0
  137. data/vendor/cache/multi_json-1.1.0.gem +0 -0
  138. data/vendor/cache/net-scp-1.0.4.gem +0 -0
  139. data/vendor/cache/net-ssh-2.2.2.gem +0 -0
  140. data/vendor/cache/net-ssh-gateway-1.1.0.gem +0 -0
  141. data/vendor/cache/netaddr-1.5.0.gem +0 -0
  142. data/vendor/cache/nokogiri-1.5.9.gem +0 -0
  143. data/vendor/cache/open4-1.3.0.gem +0 -0
  144. data/vendor/cache/progressbar-0.9.2.gem +0 -0
  145. data/vendor/cache/pry-0.9.11.4-java.gem +0 -0
  146. data/vendor/cache/pry-0.9.11.4.gem +0 -0
  147. data/vendor/cache/rake-10.0.3.gem +0 -0
  148. data/vendor/cache/rb-fsevent-0.9.3.gem +0 -0
  149. data/vendor/cache/redcard-1.0.0.gem +0 -0
  150. data/vendor/cache/rspec-2.12.0.gem +0 -0
  151. data/vendor/cache/rspec-core-2.12.2.gem +0 -0
  152. data/vendor/cache/rspec-expectations-2.12.1.gem +0 -0
  153. data/vendor/cache/rspec-mocks-2.12.2.gem +0 -0
  154. data/vendor/cache/ruby-atmos-pure-1.0.5.gem +0 -0
  155. data/vendor/cache/ruby-hmac-0.4.0.gem +0 -0
  156. data/vendor/cache/settingslogic-2.0.9.gem +0 -0
  157. data/vendor/cache/slop-3.4.3.gem +0 -0
  158. data/vendor/cache/spoon-0.0.1.gem +0 -0
  159. data/vendor/cache/terminal-table-1.4.5.gem +0 -0
  160. data/vendor/cache/thor-0.17.0.gem +0 -0
  161. data/vendor/cache/uuidtools-2.1.3.gem +0 -0
  162. data/vendor/cache/xml-simple-1.1.2.gem +0 -0
@@ -1,45 +0,0 @@
1
- require File.expand_path("../../../spec_helper", __FILE__)
2
- require File.expand_path("../aws_helpers", __FILE__)
3
-
4
- require "active_support/core_ext/hash/keys"
5
-
6
- describe "AWS deployment using Bosh edge from source" do
7
- include FileUtils
8
- include Bosh::Bootstrap::Helpers::SettingsSetter
9
- include AwsHelpers
10
-
11
- attr_reader :bosh_name
12
-
13
- before { prepare_aws("bosh-edge", aws_region) }
14
- # after { destroy_test_constructs(bosh_name) unless keep_after_test? }
15
-
16
- def aws_region
17
- ENV['AWS_REGION'] || "us-west-2"
18
- end
19
-
20
- it "creates an EC2 inception/microbosh with the associated resources" do
21
- create_manifest("edge" => true)
22
-
23
- manifest_file = home_file(".bosh_bootstrap", "manifest.yml")
24
- File.should be_exists(manifest_file)
25
-
26
- cmd.deploy
27
-
28
- ip_adresses = fog.addresses
29
- public_ips = ip_adresses.map(&:public_ip)
30
-
31
- inception_vms = provider.servers_with_sg("#{bosh_name}-inception-vm")
32
- inception_vms.size.should == 1
33
-
34
- # TODO inception VM is not getting its IP address bound correctly
35
- # https://github.com/StarkAndWayne/bosh-bootstrap/issues/174
36
- # public_ips.include?(inception_vms.first.public_ip_address).should be_true
37
-
38
- micrboshes = provider.servers_with_sg(bosh_name)
39
- micrboshes.size.should == 1
40
- public_ips.include?(micrboshes.first.public_ip_address).should be_true
41
-
42
- # TODO - microbosh stemcell in /var/vcap/store/stemcells
43
- end
44
-
45
- end
@@ -1,177 +0,0 @@
1
- require File.expand_path("../../spec_helper", __FILE__)
2
-
3
- require "active_support/core_ext/hash/keys"
4
-
5
- describe "AWS deployment" do
6
- include FileUtils
7
- include Bosh::Bootstrap::Helpers::SettingsSetter
8
-
9
- before do
10
- Fog.mock!
11
- Fog::Mock.reset
12
- @cmd = Bosh::Bootstrap::Cli.new
13
- @fog_credentials = {
14
- :provider => 'AWS',
15
- :aws_secret_access_key => 'XXX',
16
- :aws_access_key_id => 'YYY'
17
- }
18
-
19
- @region = "us-west-2"
20
- setting "bosh_provider", "aws"
21
- setting "region_code", @region
22
- setting "bosh_name", "test-bosh"
23
- setting "inception.create_new", true
24
- setting "bosh_username", "testuser"
25
- setting "bosh_password", "testpass"
26
- setting "fog_credentials", @fog_credentials.stringify_keys
27
- setting "bosh.salted_password", "pepper"
28
- setting "bosh.persistent_disk", 16384
29
- setting "git.name", "Dr Nic Williams"
30
- setting "git.email", "drnicwilliams@gmail.com"
31
- end
32
-
33
- # used by +SettingsSetter+ to access the settings
34
- def settings
35
- @cmd.settings
36
- end
37
-
38
- def fog
39
- @fog ||= connection = Fog::Compute.new(@fog_credentials.merge(:region => @region))
40
- end
41
-
42
- def expected_manifest_content(filename, public_ip, subnet_id = nil)
43
- file = File.read(filename)
44
- file.gsub!('$MICROBOSH_IP$', public_ip)
45
- file.gsub!('$SUBNET_ID$', subnet_id) if subnet_id
46
- YAML.load(file)
47
- end
48
-
49
- xit "creates a VPC inception/microbosh with the associated resources" do
50
- # create a VPC
51
- # create a BOSH subnet 10.10.0.0/24
52
- # create BOSH security group
53
- # create INCEPTION security group allowing only 22
54
- # create NATS security group, allowing only 4222
55
- # create DHCP options with 2 nameserver (1 amazon for public resolves, 1 for private resolves (.bosh)?)
56
- # create Internet Gateway, attach to VPC
57
- # create default route (0.0.0.0/0) to IG
58
-
59
- # create inception VM (attaching elastic IP, sg of [BOSH, INCEPTION]) in BOSH subnet at 10.10.0.5
60
- # create MB VM from inception VM (sg of [BOSH, NATS]) in BOSH subnet at 10.10.0.6
61
-
62
- setting "use_vpc", true # TODO include in cli.rb
63
-
64
- @cmd.should_receive(:provision_and_mount_volume)
65
- @cmd.stub(:run_server).and_return(true)
66
- @cmd.stub(:sleep)
67
- @cmd.should_receive(:deploy_stage_8_setup_new_bosh)
68
- @cmd.deploy
69
-
70
- fog.addresses.should have(1).item # assigned to inception VM
71
- inception_ip_address = fog.addresses.first
72
-
73
- fog.vpcs.should have(1).item
74
- vpc = fog.vpcs.first
75
- vpc.cidr_block.should == "10.0.0.0/16"
76
-
77
- fog.servers.should have(1).item
78
- inception = fog.servers.first
79
- inception_ip_address.domain.should == "vpc"
80
-
81
- # TODO - fix fog so we can test public_ip_address
82
- # inception.public_ip_address.should == inception_ip_address.public_ip
83
-
84
- # TODO - fix fog so we can test private_ip_address
85
- # inception.private_ip_address.should == "10.0.0.5"
86
-
87
- fog.security_groups.should have(3).item
88
-
89
- fog.internet_gateways.should have(1).item
90
- ig = fog.internet_gateways.first
91
-
92
- fog.subnets.should have(1).item
93
- subnet = fog.subnets.first
94
- subnet.vpc_id.should == vpc.id
95
- subnet.cidr_block.should == "10.0.0.0/24"
96
-
97
- # fog.route_tables.should have(1).item
98
- # a IG that is assigned to the VPN
99
- # a subnet (contains the inception VM; is included in micro_bosh_yml)
100
-
101
- # TODO - fix fog so we can test private_ip_address
102
- # settings["inception"]["ip_address"].should == "10.0.0.5"
103
-
104
- inception_server = fog.servers.first
105
- inception_server.dns_name.should == settings["inception"]["host"]
106
- inception_server.groups.should == [settings["inception"]["security_group"]]
107
-
108
- public_ip = settings["bosh"]["ip_address"]
109
- public_ip.should == "10.0.0.6"
110
-
111
- manifest_path = spec_asset("micro_bosh_yml/micro_bosh.aws_ec2.yml")
112
- YAML.load(@cmd.micro_bosh_yml).should == expected_manifest_content(manifest_path, public_ip, subnet.subnet_id)
113
- end
114
-
115
- it "creates an EC2 inception/microbosh with the associated resources" do
116
- setting "use_vpc", false
117
-
118
- @cmd.should_receive(:provision_and_mount_volume)
119
- @cmd.stub(:run_server).and_return(true)
120
- @cmd.stub(:sleep)
121
- @cmd.should_receive(:deploy_stage_8_setup_new_bosh)
122
- @cmd.deploy
123
- @settings = nil # reload settings file
124
-
125
- # TODO we are temporarily using prebuilt stemcells by default for AWS
126
- settings["micro_bosh_stemcell_type"].should == "edge-prebuilt"
127
-
128
- fog.addresses.should have(2).item
129
- inception_ip_address = fog.addresses.first
130
- inception_ip_address.domain.should == "standard"
131
-
132
- inception_kp = fog.key_pairs.find { |kp| kp.name == "inception" }
133
- inception_kp.should_not be_nil
134
-
135
- inception_kp = fog.key_pairs.find { |kp| kp.name == "fog_default" }
136
- inception_kp.should be_nil
137
-
138
- fog.key_pairs.should have(2).item
139
-
140
- settings["inception"].should_not be_nil
141
- settings["inception"]["key_pair"].should_not be_nil
142
- settings["inception"]["key_pair"]["name"].should_not be_nil
143
- settings["inception"]["key_pair"]["private_key"].should_not be_nil
144
- settings["inception"]["local_private_key_path"].should == File.join(ENV['HOME'], ".bosh_bootstrap", "ssh", "inception")
145
- File.should_not be_world_readable(settings["inception"]["local_private_key_path"])
146
-
147
- fog.vpcs.should have(0).item
148
- fog.servers.should have(1).item
149
- fog.security_groups.should have(3).item
150
-
151
- inception_server = fog.servers.first
152
- inception_server.dns_name.should == settings["inception"]["host"]
153
- inception_server.groups.should == [settings["inception"]["security_group"]]
154
-
155
- public_ip = settings["bosh"]["ip_address"]
156
- manifest_path = spec_asset("micro_bosh_yml/micro_bosh.aws_ec2.yml")
157
- YAML.load(@cmd.micro_bosh_yml).should == expected_manifest_content(manifest_path, public_ip)
158
- end
159
-
160
- it "uses pre-built gems and AMIs for us-east-1 created from jenkins" do
161
- @cmd.should_receive(:provision_and_mount_volume)
162
- @cmd.stub(:run_server).and_return(true)
163
- @cmd.stub(:sleep)
164
- @cmd.should_receive(:deploy_stage_8_setup_new_bosh)
165
- @cmd.should_receive(:latest_prebuilt_microbosh_ami).and_return("ami-123456")
166
-
167
- setting "edge-prebuilt", true
168
- @cmd.deploy
169
-
170
- settings["micro_bosh_stemcell_type"].should == "ami"
171
- settings["micro_bosh_stemcell_name"].should == "ami-123456"
172
-
173
- public_ip = settings["bosh"]["ip_address"]
174
- manifest_path = spec_asset("micro_bosh_yml/micro_bosh.aws_ec2.yml")
175
- YAML.load(@cmd.micro_bosh_yml).should == expected_manifest_content(manifest_path, public_ip)
176
- end
177
- end
@@ -1,174 +0,0 @@
1
- # Copyright (c) 2012-2013 Stark & Wayne, LLC
2
-
3
- require File.expand_path("../../../../spec_helper", __FILE__)
4
-
5
- # Specs for the aws provider
6
- describe Bosh::Providers do
7
- include FileUtils
8
-
9
- describe "AWS" do
10
- before do
11
- Fog.mock!
12
- @fog_compute = Fog::Compute.new(
13
- :provider => 'AWS',
14
- :aws_access_key_id => 'MOCK_AWS_ACCESS_KEY_ID',
15
- :aws_secret_access_key => 'MOCK_AWS_SECRET_ACCESS_KEY')
16
- @aws_provider = Bosh::Providers.for_bosh_provider_name("aws", @fog_compute)
17
- end
18
-
19
- describe "create security group" do
20
- it "should open a single TCP port on a security group" do
21
- ports = { ssh: 22 }
22
- @aws_provider.create_security_group("sg1-name", "sg1-desc", ports)
23
- created_sg = @fog_compute.security_groups.get("sg1-name")
24
- created_sg.name.should == "sg1-name"
25
- created_sg.description.should == "sg1-desc"
26
- created_sg.ip_permissions.should == [
27
- {
28
- "ipProtocol"=>"tcp",
29
- "fromPort"=>22,
30
- "toPort"=>22,
31
- "groups"=>[],
32
- "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
33
- }
34
- ]
35
- end
36
- it "should open a range of TCP ports" do
37
- ports = { ssh: (22..30) }
38
- @aws_provider.create_security_group("sg-range-name", "sg-range-desc", ports)
39
- created_sg = @fog_compute.security_groups.get("sg-range-name")
40
- created_sg.ip_permissions.should == [
41
- {
42
- "ipProtocol"=>"tcp",
43
- "fromPort"=>22,
44
- "toPort"=>30,
45
- "groups"=>[],
46
- "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
47
- }
48
- ]
49
- end
50
- it "should open a range of UDP ports" do
51
- ports = { ssh: { protocol: "udp", ports: (60000..600050) } }
52
- @aws_provider.create_security_group("sg-range-udp-name", "sg-range-udp-name", ports)
53
- created_sg = @fog_compute.security_groups.get("sg-range-udp-name")
54
- created_sg.ip_permissions.should == [
55
- {
56
- "ipProtocol"=>"udp",
57
- "fromPort"=>60000,
58
- "toPort"=>600050,
59
- "groups"=>[],
60
- "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
61
- }
62
- ]
63
- end
64
- it "should open a range of ICMP ports" do
65
- ports = { ping: { protocol: "icmp", ports: (3..4) } }
66
- @aws_provider.create_security_group("sg-range-icmp-name", "sg-range-icmp-name", ports)
67
- created_sg = @fog_compute.security_groups.get("sg-range-icmp-name")
68
- created_sg.ip_permissions.should == [
69
- {
70
- "ipProtocol"=>"icmp",
71
- "fromPort"=>3,
72
- "toPort"=>4,
73
- "groups"=>[],
74
- "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
75
- }
76
- ]
77
- end
78
- it "should open not open ports if they are already open" do
79
- @aws_provider.create_security_group("sg2", "", { ssh: { protocol: "udp", ports: (60000..600050) } })
80
- @aws_provider.create_security_group("sg2", "", { ssh: { protocol: "udp", ports: (60010..600040) } })
81
- @aws_provider.create_security_group("sg2", "", { ssh: { protocol: "udp", ports: (60000..600050) } })
82
- created_sg = @fog_compute.security_groups.get("sg2")
83
- created_sg.ip_permissions.should == [
84
- {
85
- "ipProtocol"=>"udp",
86
- "fromPort"=>60000,
87
- "toPort"=>600050,
88
- "groups"=>[],
89
- "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
90
- }
91
- ]
92
- end
93
- it "should open ports even if they are already open for a different protocol" do
94
- @aws_provider.create_security_group("sg3", "", { ssh: { protocol: "udp", ports: (60000..600050) } })
95
- @aws_provider.create_security_group("sg3", "", { ssh: { protocol: "tcp", ports: (60000..600050) } })
96
- created_sg = @fog_compute.security_groups.get("sg3")
97
- created_sg.ip_permissions.should == [
98
- {
99
- "ipProtocol"=>"udp",
100
- "fromPort"=>60000,
101
- "toPort"=>600050,
102
- "groups"=>[],
103
- "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
104
- },
105
- {
106
- "ipProtocol"=>"tcp",
107
- "fromPort"=>60000,
108
- "toPort"=>600050,
109
- "groups"=>[],
110
- "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
111
- }
112
- ]
113
- end
114
- it "should open ports even if they are already open for a different ip_range" do
115
- default_ports = {
116
- all_internal_tcp: { protocol: "tcp", ip_range: "1.1.1.1/32", ports: (0..65535) }
117
- }
118
- @aws_provider.create_security_group("sg6", "sg6", default_ports)
119
- @aws_provider.create_security_group("sg6", "sg6", { mosh: { protocol: "tcp", ports: (15..30) } })
120
- created_sg = @fog_compute.security_groups.get("sg6")
121
- created_sg.ip_permissions.should == [
122
- {
123
- "ipProtocol"=>"tcp",
124
- "fromPort"=>0,
125
- "toPort"=>65535,
126
- "groups"=>[],
127
- "ipRanges"=>[ { "cidrIp"=>"1.1.1.1/32" } ]
128
- },
129
- {
130
- "ipProtocol"=>"tcp",
131
- "fromPort"=>15,
132
- "toPort"=>30,
133
- "groups"=>[],
134
- "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
135
- }
136
- ]
137
- end
138
- it "should open ports on the default sg" do
139
- @aws_provider.create_security_group("default", "default", { mosh: { protocol: "tcp", ports: (15..30) } })
140
- created_sg = @fog_compute.security_groups.get("default")
141
- expected_rule = {
142
- "ipProtocol"=>"tcp",
143
- "fromPort"=>15,
144
- "toPort"=>30,
145
- "groups"=>[],
146
- "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
147
- }
148
- created_sg.ip_permissions.should include expected_rule
149
- end
150
- #AWS allows overlapping port ranges, and it makes it easier to see the separate "rules" that were added
151
- it "should create overlapping port ranges" do
152
- @aws_provider.create_security_group("sg4", "", { ssh: { protocol: "udp", ports: (10..20) } })
153
- @aws_provider.create_security_group("sg4", "", { ssh: { protocol: "udp", ports: (15..30) } })
154
- created_sg = @fog_compute.security_groups.get("sg4")
155
- created_sg.ip_permissions.should == [
156
- {
157
- "ipProtocol"=>"udp",
158
- "fromPort"=>10,
159
- "toPort"=>20,
160
- "groups"=>[],
161
- "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
162
- },
163
- {
164
- "ipProtocol"=>"udp",
165
- "fromPort"=>15,
166
- "toPort"=>30,
167
- "groups"=>[],
168
- "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
169
- }
170
- ]
171
- end
172
- end
173
- end
174
- end
@@ -1,134 +0,0 @@
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
- @cmd = Bosh::Bootstrap::Cli.new
11
- setting "git.name", "Dr Nic Williams"
12
- setting "git.email", "drnicwilliams@gmail.com"
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_salted_password
24
- deploy_stage_6_download_micro_bosh
25
- deploy_stage_7_deploy_micro_bosh
26
- deploy_stage_8_setup_new_bosh
27
- ]
28
- stage_methods.each do |method|
29
- unless method =~ /#{stage}/
30
- @cmd.should_receive(method.to_sym)
31
- end
32
- end
33
- end
34
-
35
- # used by +SettingsSetter+ to access the settings
36
- def settings
37
- @cmd.settings
38
- end
39
-
40
- describe "deploy" do
41
- it "goes through stages" do
42
- @cmd.should_receive(:deploy_stage_1_choose_infrastructure_provider)
43
- @cmd.should_receive(:deploy_stage_2_bosh_configuration)
44
- @cmd.should_receive(:deploy_stage_3_create_allocate_inception_vm)
45
- @cmd.should_receive(:deploy_stage_4_prepare_inception_vm)
46
- @cmd.should_receive(:deploy_stage_5_salted_password)
47
- @cmd.should_receive(:deploy_stage_6_download_micro_bosh)
48
- @cmd.should_receive(:deploy_stage_7_deploy_micro_bosh)
49
- @cmd.should_receive(:deploy_stage_8_setup_new_bosh)
50
- @cmd.deploy
51
- end
52
-
53
- it "stage 3 - create inception VM" do
54
- testing_stage(3)
55
- setting "inception.username", "ubuntu"
56
- setting "inception.key_pair.private_key", "INCEPTION_PRIVATE_KEY"
57
- setting "inception.key_pair.public_key", "INCEPTION_PUBLIC_KEY"
58
- setting "inception.key_pair.name", "inception"
59
- setting "fog_credentials.provider", "AWS"
60
- @cmd.should_receive(:run_server).and_return(true)
61
- @cmd.deploy
62
- end
63
-
64
- it "stage 4 - prepare inception VM" do
65
- testing_stage(4)
66
- @cmd.should_receive(:recreate_local_ssh_keys_for_inception_vm)
67
- setting "inception.username", "ubuntu"
68
- setting "bosh.password", "UNSALTED"
69
- @cmd.should_receive(:run_server).and_return(true)
70
- @cmd.deploy
71
- end
72
-
73
- it "stage 7 - deploy microbosh" do
74
- testing_stage(7)
75
- @cmd.should_receive(:recreate_local_ssh_keys_for_inception_vm)
76
- setting "bosh_provider", "aws"
77
- setting "micro_bosh_stemcell_name", "micro-bosh-stemcell-aws-0.8.1.tgz"
78
- setting "bosh_username", "drnic"
79
- setting "bosh_password", "password"
80
- setting "bosh.salted_password", "SALTED"
81
- setting "bosh.ip_address", "1.2.3.4"
82
- setting "bosh.persistent_disk", 16384
83
- setting "bosh_resources_cloud_properties", {}
84
- setting "bosh_cloud_properties", {}
85
- setting "bosh_key_pair.private_key", "PRIVATE_KEY"
86
- setting "bosh_key_pair.name", "KEYNAME"
87
- @cmd.should_receive(:run_server).and_return(true)
88
- @cmd.deploy
89
- end
90
-
91
- it "stage 8 - sets up new microbosh" do
92
- testing_stage(8)
93
- setting "bosh_name", "microbosh-aws-us-east-1"
94
- setting "bosh_username", "drnic"
95
- setting "bosh_password", "password"
96
- setting "bosh.ip_address", "1.2.3.4"
97
- @cmd.should_receive(:sleep)
98
- @cmd.should_receive(:run_server).and_return(true)
99
- @cmd.should_receive(:sh).with("bosh -u drnic -p password target 1.2.3.4")
100
- @cmd.should_receive(:sh).with("bosh login drnic password")
101
- @cmd.deploy
102
- end
103
- end
104
-
105
- describe "micro_bosh_stemcell_name" do
106
- # The +bosh_stemcells_cmd+ has an output that looks like:
107
- # +-----------------------------------+--------------------+
108
- # | Name | Tags |
109
- # +-----------------------------------+--------------------+
110
- # | micro-bosh-stemcell-aws-0.6.4.tgz | aws, micro, stable |
111
- # | micro-bosh-stemcell-aws-0.7.0.tgz | aws, micro, test |
112
- # | micro-bosh-stemcell-aws-0.8.1.tgz | aws, micro, test |
113
- # +-----------------------------------+--------------------+
114
- #
115
- # So to get the latest version for the filter tags,
116
- # get the Name field, reverse sort, and return the first item
117
- it "should return the latest stable stemcell by default for AWS" do
118
- @cmd.settings["bosh_provider"] = "aws"
119
- @cmd.settings["fog_credentials"] = {}
120
- @cmd.settings["fog_credentials"]["provider"] = "aws"
121
- @cmd.should_receive(:known_stable_micro_bosh_stemcell_version).and_return("0.8.1")
122
- @cmd.micro_bosh_stemcell_name.should == "micro-bosh-stemcell-aws-0.8.1.tgz"
123
- end
124
-
125
- it "should return the latest stable stemcell by default for OpenStack" do
126
- @cmd.settings["bosh_provider"] = "openstack"
127
- @cmd.settings["fog_credentials"] = {}
128
- @cmd.settings["fog_credentials"]["provider"] = "OpenStack"
129
- @cmd.should_receive(:known_stable_micro_bosh_stemcell_version).and_return("0.8.1")
130
- @cmd.micro_bosh_stemcell_name.should == "micro-bosh-stemcell-openstack-kvm-0.8.1.tgz"
131
- end
132
- end
133
-
134
- end
@@ -1,95 +0,0 @@
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
- # * mosh
9
- describe Bosh::Bootstrap do
10
- include FileUtils
11
- include Bosh::Bootstrap::Helpers::SettingsSetter
12
-
13
- before do
14
- @cmd = Bosh::Bootstrap::Cli.new
15
- end
16
-
17
- # used by +SettingsSetter+ to access the settings
18
- def settings
19
- @cmd.settings
20
- end
21
-
22
- describe "ssh" do
23
- before do
24
- setting "inception.host", "5.5.5.5"
25
- setting "inception.key_pair.private_key", "PRIVATE"
26
- setting "inception.key_pair.public_key", "PUBLIC"
27
- @private_key_path = File.join(ENV['HOME'], ".bosh_bootstrap", "ssh", "inception")
28
- end
29
-
30
- describe "normal" do
31
- it "launches ssh session" do
32
- @cmd.should_receive(:exit)
33
- @cmd.should_receive(:system).
34
- with("ssh -i #{@private_key_path} vcap@5.5.5.5")
35
- @cmd.ssh
36
- end
37
- it "runs ssh command" do
38
- @cmd.should_receive(:exit)
39
- @cmd.should_receive(:system).
40
- with("ssh -i #{@private_key_path} vcap@5.5.5.5 'some command'")
41
- @cmd.ssh("some command")
42
- end
43
- end
44
-
45
- describe "tmux" do
46
- it "launches ssh session" do
47
- @cmd.should_receive(:exit)
48
- @cmd.should_receive(:system).
49
- with("ssh -i #{@private_key_path} vcap@5.5.5.5 -t 'tmux attach || tmux new-session'")
50
- @cmd.tmux
51
- end
52
- end
53
-
54
- describe "mosh" do
55
- before do
56
- @cmd.settings['bosh_provider'] = 'aws'
57
- Fog.mock!
58
- fog_compute = Fog::Compute.new(
59
- :provider => 'AWS',
60
- :aws_access_key_id => 'MOCK_AWS_ACCESS_KEY_ID',
61
- :aws_secret_access_key => 'MOCK_AWS_SECRET_ACCESS_KEY')
62
- @cmd.stub!(:provider).and_return(Bosh::Providers.for_bosh_provider_name('aws', fog_compute))
63
- @cmd.stub!(:fog_compute).and_return(fog_compute)
64
- @cmd.fog_compute.stub!(:servers).and_return(double(:get => double(:groups => ['default'])))
65
- end
66
- after do
67
- Fog.unmock!
68
- end
69
- it "should check whether mosh is installed" do
70
- @cmd.should_receive(:system).
71
- with("mosh --version")
72
- @cmd.stub!(:exit)
73
- @cmd.ensure_mosh_installed
74
- end
75
- it "launches mosh session" do
76
- @cmd.stub!(:ensure_mosh_installed).and_return(true)
77
- @cmd.should_receive(:exit)
78
- @cmd.should_receive(:system).
79
- with("mosh vcap@5.5.5.5")
80
- @cmd.mosh
81
- end
82
- it "should ensure that the mosh ports are opened" do
83
- expected_ports = {
84
- mosh: {
85
- protocol: "udp",
86
- ports: (60000..60050)
87
- }
88
- }
89
- @cmd.provider.stub!(:create_security_group)
90
- .with('default','not used', expected_ports)
91
- @cmd.ensure_security_group_allows_mosh
92
- end
93
- end
94
- end
95
- end
@@ -1,29 +0,0 @@
1
- # Copyright (c) 2012-2013 Stark & Wayne, LLC
2
-
3
- require File.expand_path("../../spec_helper", __FILE__)
4
-
5
- # Specs for 'upgrade' command
6
- describe Bosh::Bootstrap do
7
- include FileUtils
8
- include Bosh::Bootstrap::Helpers::SettingsSetter
9
-
10
- # used by +SettingsSetter+ to access the settings
11
- def settings
12
- @cmd.settings
13
- end
14
-
15
- before do
16
- @cmd = Bosh::Bootstrap::Cli.new
17
- end
18
-
19
- it "runs 'upgrade' command on an existing inception VM" do
20
- setting "inception.prepared", true
21
- setting "inception.username", "ubuntu"
22
- setting "git.name", "Dr Nic Williams"
23
- setting "git.email", "drnicwilliams@gmail.com"
24
- setting "bosh.password", "UNSALTED"
25
- setting "bosh.salted_password", "SALTED"
26
- @cmd.should_receive(:run_server).and_return(true)
27
- @cmd.upgrade_inception
28
- end
29
- end
@@ -1,29 +0,0 @@
1
- # Copyright (c) 2012-2013 Stark & Wayne, LLC
2
-
3
- require File.expand_path("../../spec_helper", __FILE__)
4
-
5
- describe Bosh::Bootstrap::Helpers::SettingsSetter do
6
- include Bosh::Bootstrap::Helpers::SettingsSetter
7
-
8
- attr_reader :settings
9
- before do
10
- @settings = {}
11
- end
12
-
13
- def save_settings!
14
- end
15
-
16
- it "with_setting 'a'" do
17
- with_setting "a" do |setting|
18
- setting['value'] = "abc"
19
- end
20
- settings["a"]["value"].should == "abc"
21
- end
22
-
23
- it "with_setting 'a.b.c'" do
24
- with_setting "a.b.c" do |setting|
25
- setting['value'] = "abc"
26
- end
27
- settings["a"]["b"]["c"]["value"].should == "abc"
28
- end
29
- end
Binary file