bosh-bootstrap 0.10.2 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -0
- data/.travis.yml +0 -1
- data/ChangeLog.md +23 -4
- data/Gemfile +5 -2
- data/Guardfile +2 -0
- data/README.md +209 -197
- data/TODO.md +55 -0
- data/bosh-bootstrap.gemspec +5 -12
- data/lib/bosh/cli/commands/bootstrap.rb +42 -0
- data/lib/bosh-bootstrap/cli/commands/delete.rb +26 -0
- data/lib/bosh-bootstrap/cli/commands/deploy.rb +89 -0
- data/lib/bosh-bootstrap/cli/commands/ssh.rb +32 -0
- data/lib/bosh-bootstrap/cli/helpers/bundle.rb +12 -0
- data/lib/bosh-bootstrap/cli/helpers/interactions.rb +15 -0
- data/lib/bosh-bootstrap/cli/helpers/settings.rb +61 -0
- data/lib/bosh-bootstrap/cli/helpers.rb +11 -0
- data/lib/bosh-bootstrap/key_pair.rb +21 -0
- data/lib/bosh-bootstrap/microbosh.rb +74 -0
- data/lib/bosh-bootstrap/microbosh_providers/aws.rb +104 -0
- data/lib/bosh-bootstrap/microbosh_providers/base.rb +50 -0
- data/lib/bosh-bootstrap/microbosh_providers/openstack.rb +61 -0
- data/lib/bosh-bootstrap/microbosh_providers/vsphere.rb +78 -0
- data/lib/bosh-bootstrap/microbosh_providers.rb +11 -0
- data/lib/bosh-bootstrap/network.rb +33 -0
- data/lib/bosh-bootstrap/network_providers/aws.rb +28 -0
- data/lib/bosh-bootstrap/network_providers/dummy.rb +10 -0
- data/lib/bosh-bootstrap/network_providers/openstack.rb +28 -0
- data/lib/bosh-bootstrap/network_providers.rb +11 -0
- data/lib/bosh-bootstrap/version.rb +1 -1
- data/lib/bosh-bootstrap.rb +3 -4
- data/spec/assets/microbosh_yml/micro_bosh.aws_ec2.yml +37 -0
- data/spec/assets/microbosh_yml/micro_bosh.aws_vpc.yml +39 -0
- data/spec/assets/microbosh_yml/micro_bosh.openstack.yml +30 -0
- data/spec/assets/microbosh_yml/micro_bosh.vsphere.yml +34 -0
- data/spec/integration/aws/aws_ec2_basic_spec.rb +39 -0
- data/spec/integration/aws/aws_helpers.rb +8 -61
- data/spec/spec_helper.rb +8 -3
- data/spec/support/capture_stdout.rb +18 -0
- data/spec/unit/cli/bootstrap_spec.rb +41 -0
- data/spec/unit/commands/delete_spec.rb +20 -0
- data/spec/unit/commands/deploy_spec.rb +64 -0
- data/spec/unit/commands/ssh_spec.rb +19 -0
- data/spec/unit/key_pair_spec.rb +13 -0
- data/spec/unit/microbosh_providers/aws_spec.rb +68 -0
- data/spec/unit/microbosh_providers/openstack_spec.rb +27 -0
- data/spec/unit/microbosh_providers/vsphere_spec.rb +42 -0
- data/spec/unit/microbosh_spec.rb +27 -0
- data/spec/unit/network_providers/aws_spec.rb +29 -0
- data/spec/unit/network_providers/openstack_spec.rb +29 -0
- data/spec/unit/network_spec.rb +17 -0
- metadata +71 -235
- data/CleanupCi.md +0 -8
- data/bin/bosh-bootstrap +0 -8
- data/docs/README.md +0 -3
- data/docs/devstack-openstack-tutorial.md +0 -215
- data/lib/bosh/providers/README.md +0 -5
- data/lib/bosh/providers/aws.rb +0 -258
- data/lib/bosh/providers/base_provider.rb +0 -48
- data/lib/bosh/providers/openstack.rb +0 -79
- data/lib/bosh/providers.rb +0 -21
- data/lib/bosh-bootstrap/cli.rb +0 -1347
- data/lib/bosh-bootstrap/commander/README.md +0 -47
- data/lib/bosh-bootstrap/commander/command.rb +0 -25
- data/lib/bosh-bootstrap/commander/commands.rb +0 -80
- data/lib/bosh-bootstrap/commander/local_server.rb +0 -68
- data/lib/bosh-bootstrap/commander/remote_script_command.rb +0 -51
- data/lib/bosh-bootstrap/commander/remote_server.rb +0 -137
- data/lib/bosh-bootstrap/commander/upload_command.rb +0 -17
- data/lib/bosh-bootstrap/commander.rb +0 -9
- data/lib/bosh-bootstrap/helpers/fog_setup.rb +0 -50
- data/lib/bosh-bootstrap/helpers/settings.rb +0 -99
- data/lib/bosh-bootstrap/helpers/settings_setter.rb +0 -41
- data/lib/bosh-bootstrap/helpers.rb +0 -3
- data/lib/bosh-bootstrap/stages/stage_micro_bosh_delete/bosh_micro_delete +0 -19
- data/lib/bosh-bootstrap/stages/stage_micro_bosh_delete.rb +0 -90
- data/lib/bosh-bootstrap/stages/stage_micro_bosh_deploy/bosh_micro_deploy +0 -79
- data/lib/bosh-bootstrap/stages/stage_micro_bosh_deploy/install_key_pair_for_user +0 -23
- data/lib/bosh-bootstrap/stages/stage_micro_bosh_deploy.rb +0 -146
- data/lib/bosh-bootstrap/stages/stage_micro_bosh_download/download_micro_bosh_stemcell +0 -93
- data/lib/bosh-bootstrap/stages/stage_micro_bosh_download.rb +0 -139
- data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/configure_git +0 -25
- data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/create_vcap_user +0 -79
- data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_base_packages +0 -30
- data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_bosh +0 -11
- data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_bosh_plugins +0 -25
- data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_hub +0 -26
- data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_ruby +0 -30
- data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_useful_gems +0 -29
- data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/validate_bosh_deployer +0 -18
- data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm.rb +0 -69
- data/lib/bosh-bootstrap/stages/stage_salted_password/convert_salted_password +0 -11
- data/lib/bosh-bootstrap/stages/stage_salted_password.rb +0 -51
- data/lib/bosh-bootstrap/stages/stage_setup_new_bosh/setup_bosh_user +0 -29
- data/lib/bosh-bootstrap/stages/stage_setup_new_bosh.rb +0 -51
- data/lib/bosh-bootstrap/stages/stage_validate_inception_vm/validate_ubuntu +0 -6
- data/lib/bosh-bootstrap/stages/stage_validate_inception_vm.rb +0 -39
- data/lib/bosh-bootstrap/stages.rb +0 -10
- data/spec/assets/bosh/public_stemcells/aws_micro.out +0 -7
- data/spec/assets/micro_bosh_yml/micro_bosh.aws_ec2.yml +0 -35
- data/spec/assets/micro_bosh_yml/micro_bosh.aws_vpc.yml +0 -37
- data/spec/integration/aws/aws_basic_spec.rb +0 -39
- data/spec/integration/aws/aws_edge_prebuilt_ami_spec.rb +0 -46
- data/spec/integration/aws/aws_edge_prebuilt_spec.rb +0 -46
- data/spec/integration/aws/aws_edge_spec.rb +0 -45
- data/spec/unit/aws_spec.rb +0 -177
- data/spec/unit/bosh/providers/aws_spec.rb +0 -174
- data/spec/unit/cli_spec.rb +0 -134
- data/spec/unit/cli_ssh_spec.rb +0 -95
- data/spec/unit/cli_upgrade_inception_spec.rb +0 -29
- data/spec/unit/settings_setter_spec.rb +0 -29
- data/vendor/cache/POpen4-0.1.4.gem +0 -0
- data/vendor/cache/Platform-0.4.0.gem +0 -0
- data/vendor/cache/activesupport-3.2.8.gem +0 -0
- data/vendor/cache/awesome_print-1.1.0.gem +0 -0
- data/vendor/cache/aws-s3-0.6.3.gem +0 -0
- data/vendor/cache/blobstore_client-0.4.0.gem +0 -0
- data/vendor/cache/bosh_cli-1.0.3.gem +0 -0
- data/vendor/cache/bosh_common-0.5.4.gem +0 -0
- data/vendor/cache/builder-3.2.0.gem +0 -0
- data/vendor/cache/coderay-1.0.8.gem +0 -0
- data/vendor/cache/diff-lcs-1.1.3.gem +0 -0
- data/vendor/cache/escape-0.0.4.gem +0 -0
- data/vendor/cache/excon-0.20.1.gem +0 -0
- data/vendor/cache/fog-1.8.0.gem +0 -0
- data/vendor/cache/formatador-0.2.4.gem +0 -0
- data/vendor/cache/guard-1.6.2.gem +0 -0
- data/vendor/cache/guard-rspec-2.4.0.gem +0 -0
- data/vendor/cache/highline-1.6.18.gem +0 -0
- data/vendor/cache/httpclient-2.2.4.gem +0 -0
- data/vendor/cache/i18n-0.6.1.gem +0 -0
- data/vendor/cache/json_pure-1.6.8.gem +0 -0
- data/vendor/cache/listen-0.7.2.gem +0 -0
- data/vendor/cache/log4r-1.1.10.gem +0 -0
- data/vendor/cache/lumberjack-1.0.2.gem +0 -0
- data/vendor/cache/method_source-0.8.1.gem +0 -0
- data/vendor/cache/mime-types-1.22.gem +0 -0
- data/vendor/cache/multi_json-1.1.0.gem +0 -0
- data/vendor/cache/net-scp-1.0.4.gem +0 -0
- data/vendor/cache/net-ssh-2.2.2.gem +0 -0
- data/vendor/cache/net-ssh-gateway-1.1.0.gem +0 -0
- data/vendor/cache/netaddr-1.5.0.gem +0 -0
- data/vendor/cache/nokogiri-1.5.9.gem +0 -0
- data/vendor/cache/open4-1.3.0.gem +0 -0
- data/vendor/cache/progressbar-0.9.2.gem +0 -0
- data/vendor/cache/pry-0.9.11.4-java.gem +0 -0
- data/vendor/cache/pry-0.9.11.4.gem +0 -0
- data/vendor/cache/rake-10.0.3.gem +0 -0
- data/vendor/cache/rb-fsevent-0.9.3.gem +0 -0
- data/vendor/cache/redcard-1.0.0.gem +0 -0
- data/vendor/cache/rspec-2.12.0.gem +0 -0
- data/vendor/cache/rspec-core-2.12.2.gem +0 -0
- data/vendor/cache/rspec-expectations-2.12.1.gem +0 -0
- data/vendor/cache/rspec-mocks-2.12.2.gem +0 -0
- data/vendor/cache/ruby-atmos-pure-1.0.5.gem +0 -0
- data/vendor/cache/ruby-hmac-0.4.0.gem +0 -0
- data/vendor/cache/settingslogic-2.0.9.gem +0 -0
- data/vendor/cache/slop-3.4.3.gem +0 -0
- data/vendor/cache/spoon-0.0.1.gem +0 -0
- data/vendor/cache/terminal-table-1.4.5.gem +0 -0
- data/vendor/cache/thor-0.17.0.gem +0 -0
- data/vendor/cache/uuidtools-2.1.3.gem +0 -0
- data/vendor/cache/xml-simple-1.1.2.gem +0 -0
@@ -0,0 +1,61 @@
|
|
1
|
+
require "bosh-bootstrap/microbosh_providers/base"
|
2
|
+
|
3
|
+
module Bosh::Bootstrap::MicroboshProviders
|
4
|
+
class OpenStack < Base
|
5
|
+
def to_hash
|
6
|
+
super.merge({
|
7
|
+
"network"=>network_configuration,
|
8
|
+
"resources"=>
|
9
|
+
{"persistent_disk"=>persistent_disk,
|
10
|
+
"cloud_properties"=>resources_cloud_properties},
|
11
|
+
"cloud"=>
|
12
|
+
{"plugin"=>"openstack",
|
13
|
+
"properties"=>
|
14
|
+
{"openstack"=>cloud_properties}},
|
15
|
+
})
|
16
|
+
end
|
17
|
+
|
18
|
+
def persistent_disk
|
19
|
+
settings.bosh.persistent_disk
|
20
|
+
end
|
21
|
+
|
22
|
+
def resources_cloud_properties
|
23
|
+
{"instance_type"=>"m1.medium"}
|
24
|
+
end
|
25
|
+
|
26
|
+
# network:
|
27
|
+
# name: default
|
28
|
+
# type: dynamic
|
29
|
+
# label: private
|
30
|
+
# ip: 1.2.3.4
|
31
|
+
def network_configuration
|
32
|
+
{"name"=>"default",
|
33
|
+
"type"=>"dynamic",
|
34
|
+
"label"=>"private",
|
35
|
+
"ip"=>public_ip
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def cloud_properties
|
40
|
+
{
|
41
|
+
"auth_url"=>settings.provider.credentials.openstack_auth_url,
|
42
|
+
"username"=>settings.provider.credentials.openstack_username,
|
43
|
+
"api_key"=> settings.provider.credentials.openstack_api_key,
|
44
|
+
"tenant"=> settings.provider.credentials.openstack_tenant,
|
45
|
+
"default_security_groups"=>security_groups,
|
46
|
+
"default_key_name"=>microbosh_name,
|
47
|
+
"private_key"=>private_key_path}
|
48
|
+
end
|
49
|
+
|
50
|
+
def security_groups
|
51
|
+
["ssh",
|
52
|
+
"bosh_agent_http",
|
53
|
+
"bosh_nats_server",
|
54
|
+
"bosh_blobstore",
|
55
|
+
"bosh_director",
|
56
|
+
"bosh_registry"]
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
Bosh::Bootstrap::MicroboshProviders.register_provider("openstack", Bosh::Bootstrap::MicroboshProviders::OpenStack)
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require "bosh-bootstrap/microbosh_providers/base"
|
2
|
+
|
3
|
+
module Bosh::Bootstrap::MicroboshProviders
|
4
|
+
class VSphere < Base
|
5
|
+
def to_hash
|
6
|
+
super.merge({
|
7
|
+
"network" => network_configuration,
|
8
|
+
"cloud"=>
|
9
|
+
{"plugin"=>"vsphere",
|
10
|
+
"properties"=>{
|
11
|
+
"agent"=>{"ntp"=>ntps},
|
12
|
+
"vcenters"=>[vcenter_configuration]
|
13
|
+
}}})
|
14
|
+
end
|
15
|
+
|
16
|
+
# network:
|
17
|
+
# ip: 172.23.194.100
|
18
|
+
# netmask: 255.255.254.0
|
19
|
+
# gateway: 172.23.194.1
|
20
|
+
# dns:
|
21
|
+
# - 172.22.22.153
|
22
|
+
# - 172.22.22.154
|
23
|
+
# cloud_properties:
|
24
|
+
# name: VLAN2194
|
25
|
+
def network_configuration
|
26
|
+
dns = settings.provider.network.dns
|
27
|
+
dns = dns.split(",") if dns.is_a?(String)
|
28
|
+
{
|
29
|
+
"ip"=>public_ip,
|
30
|
+
"netmask"=>settings.provider.network.netmask,
|
31
|
+
"gateway"=>settings.provider.network.gateway,
|
32
|
+
"dns"=>dns,
|
33
|
+
"cloud_properties"=>{
|
34
|
+
"name"=>settings.provider.network.name
|
35
|
+
}
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def ntps
|
40
|
+
settings.provider.npt
|
41
|
+
end
|
42
|
+
|
43
|
+
# vcenters:
|
44
|
+
# - host: HOST
|
45
|
+
# user: dev\cloudfoundry-auth
|
46
|
+
# password: TempP@ss
|
47
|
+
# datacenters:
|
48
|
+
# - name: LAS01
|
49
|
+
# vm_folder: BOSH_VMs
|
50
|
+
# template_folder: BOSH_Templates
|
51
|
+
# disk_path: BOSH_Deployer
|
52
|
+
# datastore_pattern: las01-.*
|
53
|
+
# persistent_datastore_pattern: las01-.*
|
54
|
+
# allow_mixed_datastores: true
|
55
|
+
# clusters:
|
56
|
+
# - CLUSTER01
|
57
|
+
def vcenter_configuration
|
58
|
+
clusters = settings.provider.datacenter.clusters
|
59
|
+
clusters = clusters.split(",") if clusters.is_a?(String)
|
60
|
+
{
|
61
|
+
"host"=>settings.provider.credentials.host,
|
62
|
+
"user"=>settings.provider.credentials.user,
|
63
|
+
"password"=>settings.provider.credentials.password,
|
64
|
+
"datacenters"=>[{
|
65
|
+
"name"=>settings.provider.datacenter.name,
|
66
|
+
"vm_folder"=>settings.provider.datacenter.vm_folder,
|
67
|
+
"template_folder"=>settings.provider.datacenter.template_folder,
|
68
|
+
"disk_path"=>settings.provider.datacenter.disk_path,
|
69
|
+
"datastore_pattern"=>settings.provider.datacenter.datastore_pattern,
|
70
|
+
"persistent_datastore_pattern"=>settings.provider.datacenter.persistent_datastore_pattern,
|
71
|
+
"allow_mixed_datastores"=>settings.provider.datacenter.allow_mixed_datastores,
|
72
|
+
"clusters"=>clusters
|
73
|
+
}]
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
Bosh::Bootstrap::MicroboshProviders.register_provider("vsphere", Bosh::Bootstrap::MicroboshProviders::VSphere)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Bosh::Bootstrap::MicroboshProviders
|
2
|
+
extend self
|
3
|
+
def register_provider(provider_name, provider_klass)
|
4
|
+
@providers ||= {}
|
5
|
+
@providers[provider_name] = provider_klass
|
6
|
+
end
|
7
|
+
|
8
|
+
def provider_class(provider_name)
|
9
|
+
@providers[provider_name]
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "bosh-bootstrap/network_providers"
|
2
|
+
require "bosh-bootstrap/network_providers/dummy"
|
3
|
+
|
4
|
+
class Bosh::Bootstrap::Network
|
5
|
+
|
6
|
+
attr_reader :provider_name
|
7
|
+
attr_reader :provider_client
|
8
|
+
|
9
|
+
def initialize(provider_name, provider_client)
|
10
|
+
@provider_name = provider_name
|
11
|
+
@provider_client = provider_client
|
12
|
+
end
|
13
|
+
|
14
|
+
def deploy
|
15
|
+
network_provider.perform
|
16
|
+
end
|
17
|
+
|
18
|
+
# Attempt to load and instantiate a NetworkProviders class
|
19
|
+
# Else return NetworkProviders::Dummy which does nothing
|
20
|
+
def network_provider
|
21
|
+
@network_provider ||= begin
|
22
|
+
begin
|
23
|
+
require "bosh-bootstrap/network_providers/#{provider_name}"
|
24
|
+
klass = Bosh::Bootstrap::NetworkProviders.provider_class(provider_name)
|
25
|
+
rescue LoadError
|
26
|
+
klass = Bosh::Bootstrap::NetworkProviders.provider_class("dummy")
|
27
|
+
end
|
28
|
+
klass.new(provider_client)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Bosh::Bootstrap::NetworkProviders
|
2
|
+
class AWS
|
3
|
+
attr_reader :provider_client
|
4
|
+
|
5
|
+
def initialize(provider_client)
|
6
|
+
@provider_client = provider_client
|
7
|
+
end
|
8
|
+
|
9
|
+
def perform
|
10
|
+
security_groups.each do |name, ports|
|
11
|
+
provider_client.create_security_group(name.to_s, name.to_s, ports: ports)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
def security_groups
|
17
|
+
{
|
18
|
+
ssh: 22,
|
19
|
+
bosh_nats_server: 4222,
|
20
|
+
bosh_agent_http: 6868,
|
21
|
+
bosh_blobstore: 25250,
|
22
|
+
bosh_director: 25555,
|
23
|
+
bosh_registry: 25777
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
Bosh::Bootstrap::NetworkProviders.register_provider("aws", Bosh::Bootstrap::NetworkProviders::AWS)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Bosh::Bootstrap::NetworkProviders
|
2
|
+
class OpenStack
|
3
|
+
attr_reader :provider_client
|
4
|
+
|
5
|
+
def initialize(provider_client)
|
6
|
+
@provider_client = provider_client
|
7
|
+
end
|
8
|
+
|
9
|
+
def perform
|
10
|
+
security_groups.each do |name, ports|
|
11
|
+
provider_client.create_security_group(name.to_s, name.to_s, ports)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
def security_groups
|
17
|
+
{
|
18
|
+
ssh: 22,
|
19
|
+
bosh_nats_server: 4222,
|
20
|
+
bosh_agent_http: 6868,
|
21
|
+
bosh_blobstore: 25250,
|
22
|
+
bosh_director: 25555,
|
23
|
+
bosh_registry: 25777
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
Bosh::Bootstrap::NetworkProviders.register_provider("openstack", Bosh::Bootstrap::NetworkProviders::OpenStack)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Bosh::Bootstrap::NetworkProviders
|
2
|
+
extend self
|
3
|
+
def register_provider(provider_name, provider_klass)
|
4
|
+
@providers ||= {}
|
5
|
+
@providers[provider_name] = provider_klass
|
6
|
+
end
|
7
|
+
|
8
|
+
def provider_class(provider_name)
|
9
|
+
@providers[provider_name]
|
10
|
+
end
|
11
|
+
end
|
data/lib/bosh-bootstrap.rb
CHANGED
@@ -8,7 +8,6 @@ module Bosh
|
|
8
8
|
end
|
9
9
|
|
10
10
|
require "bosh-bootstrap/version"
|
11
|
-
require "bosh-bootstrap/
|
12
|
-
require "bosh-bootstrap/
|
13
|
-
|
14
|
-
require "bosh/providers"
|
11
|
+
require "bosh-bootstrap/network"
|
12
|
+
require "bosh-bootstrap/key_pair"
|
13
|
+
require "bosh-bootstrap/microbosh"
|
@@ -0,0 +1,37 @@
|
|
1
|
+
---
|
2
|
+
name: test-bosh
|
3
|
+
logging:
|
4
|
+
level: DEBUG
|
5
|
+
network:
|
6
|
+
type: dynamic
|
7
|
+
vip: 1.2.3.4
|
8
|
+
resources:
|
9
|
+
persistent_disk: 16384
|
10
|
+
cloud_properties:
|
11
|
+
instance_type: m1.medium
|
12
|
+
cloud:
|
13
|
+
plugin: aws
|
14
|
+
properties:
|
15
|
+
aws:
|
16
|
+
access_key_id: ACCESS
|
17
|
+
secret_access_key: SECRET
|
18
|
+
region: us-west-2
|
19
|
+
ec2_endpoint: ec2.us-west-2.amazonaws.com
|
20
|
+
default_security_groups:
|
21
|
+
- ssh
|
22
|
+
- bosh_agent_http
|
23
|
+
- bosh_nats_server
|
24
|
+
- bosh_blobstore
|
25
|
+
- bosh_director
|
26
|
+
- bosh_registry
|
27
|
+
default_key_name: test-bosh
|
28
|
+
ec2_private_key: ~/.microbosh/ssh/test-bosh
|
29
|
+
apply_spec:
|
30
|
+
agent:
|
31
|
+
blobstore:
|
32
|
+
address: 1.2.3.4
|
33
|
+
nats:
|
34
|
+
address: 1.2.3.4
|
35
|
+
properties:
|
36
|
+
aws_registry:
|
37
|
+
address: 1.2.3.4
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
name: test-bosh
|
3
|
+
logging:
|
4
|
+
level: DEBUG
|
5
|
+
network:
|
6
|
+
type: dynamic
|
7
|
+
vip: 1.2.3.4
|
8
|
+
cloud_properties:
|
9
|
+
subnet: $SUBNET_ID$
|
10
|
+
resources:
|
11
|
+
persistent_disk: 16384
|
12
|
+
cloud_properties:
|
13
|
+
instance_type: m1.medium
|
14
|
+
cloud:
|
15
|
+
plugin: aws
|
16
|
+
properties:
|
17
|
+
aws:
|
18
|
+
access_key_id: ACCESS
|
19
|
+
secret_access_key: SECRET
|
20
|
+
region: us-west-2
|
21
|
+
ec2_endpoint: ec2.us-west-2.amazonaws.com
|
22
|
+
default_security_groups:
|
23
|
+
- ssh
|
24
|
+
- bosh_agent_http
|
25
|
+
- bosh_nats_server
|
26
|
+
- bosh_blobstore
|
27
|
+
- bosh_director
|
28
|
+
- bosh_registry
|
29
|
+
default_key_name: test-bosh
|
30
|
+
ec2_private_key: ~/.microbosh/ssh/test-bosh
|
31
|
+
apply_spec:
|
32
|
+
agent:
|
33
|
+
blobstore:
|
34
|
+
address: 1.2.3.4
|
35
|
+
nats:
|
36
|
+
address: 1.2.3.4
|
37
|
+
properties:
|
38
|
+
aws_registry:
|
39
|
+
address: 1.2.3.4
|
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
name: test-bosh
|
3
|
+
logging:
|
4
|
+
level: DEBUG
|
5
|
+
network:
|
6
|
+
name: default
|
7
|
+
type: dynamic
|
8
|
+
label: private
|
9
|
+
ip: 1.2.3.4
|
10
|
+
resources:
|
11
|
+
persistent_disk: 4096
|
12
|
+
cloud_properties:
|
13
|
+
instance_type: m1.medium
|
14
|
+
cloud:
|
15
|
+
plugin: openstack
|
16
|
+
properties:
|
17
|
+
openstack:
|
18
|
+
auth_url: http://10.0.0.2:5000/v2.0/tokens
|
19
|
+
username: USER
|
20
|
+
api_key: PASSWORD
|
21
|
+
tenant: TENANT
|
22
|
+
default_security_groups:
|
23
|
+
- ssh
|
24
|
+
- bosh_agent_http
|
25
|
+
- bosh_nats_server
|
26
|
+
- bosh_blobstore
|
27
|
+
- bosh_director
|
28
|
+
- bosh_registry
|
29
|
+
default_key_name: test-bosh
|
30
|
+
private_key: ~/.microbosh/ssh/test-bosh
|
@@ -0,0 +1,34 @@
|
|
1
|
+
---
|
2
|
+
name: test-bosh
|
3
|
+
logging:
|
4
|
+
level: DEBUG
|
5
|
+
network:
|
6
|
+
ip: 172.23.194.100
|
7
|
+
netmask: 255.255.254.0
|
8
|
+
gateway: 172.23.194.1
|
9
|
+
dns:
|
10
|
+
- 172.22.22.153
|
11
|
+
- 172.22.22.154
|
12
|
+
cloud_properties:
|
13
|
+
name: VLAN2194
|
14
|
+
cloud:
|
15
|
+
plugin: vsphere
|
16
|
+
properties:
|
17
|
+
agent:
|
18
|
+
ntp:
|
19
|
+
- ntp01.las01.emcatmos.com
|
20
|
+
- ntp02.las01.emcatmos.com
|
21
|
+
vcenters:
|
22
|
+
- host: HOST
|
23
|
+
user: user
|
24
|
+
password: TempP@ss
|
25
|
+
datacenters:
|
26
|
+
- name: LAS01
|
27
|
+
vm_folder: BOSH_VMs
|
28
|
+
template_folder: BOSH_Templates
|
29
|
+
disk_path: BOSH_Deployer
|
30
|
+
datastore_pattern: las01-.*
|
31
|
+
persistent_datastore_pattern: las01-.*
|
32
|
+
allow_mixed_datastores: true
|
33
|
+
clusters:
|
34
|
+
- CLUSTER01
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.expand_path("../aws_helpers", __FILE__)
|
2
|
+
describe "AWS deployment using gems and publish stemcells" do
|
3
|
+
include Bosh::Bootstrap::Cli::Helpers::Settings
|
4
|
+
include AwsHelpers
|
5
|
+
|
6
|
+
let(:cli) do
|
7
|
+
cli = Bosh::Cli::Command::Bootstrap.new(nil)
|
8
|
+
cli.add_option(:non_interactive, true)
|
9
|
+
cli.add_option(:cache_dir, @cache_dir)
|
10
|
+
cli
|
11
|
+
end
|
12
|
+
|
13
|
+
# after { destroy_test_constructs }
|
14
|
+
|
15
|
+
it "creates an EC2 inception/microbosh with the associated resources" do
|
16
|
+
# TODO remove this when finished initial development
|
17
|
+
require "fog"
|
18
|
+
Fog.mock!
|
19
|
+
|
20
|
+
setup_home_dir
|
21
|
+
create_manifest
|
22
|
+
cli.deploy
|
23
|
+
|
24
|
+
# creates ~/.microbosh/settings.yml
|
25
|
+
# creates ~/.microbosh/Gemfile
|
26
|
+
# creates ~/.microbosh/ssh/microbosh-test-bosh
|
27
|
+
# creates ~/.microbosh/deployments/test-bosh/micro_bosh.yml
|
28
|
+
|
29
|
+
# creates a server with a specific tagged name
|
30
|
+
# server has a 16G volume attached (plus a root volume)
|
31
|
+
# IP was provisioned
|
32
|
+
# IP was attached to server
|
33
|
+
end
|
34
|
+
|
35
|
+
it "EC2 microbosh from latest AMI"
|
36
|
+
it "EC2 microbosh from latest stemcell"
|
37
|
+
it "EC2 microbosh from source"
|
38
|
+
|
39
|
+
end
|
@@ -1,78 +1,25 @@
|
|
1
1
|
module AwsHelpers
|
2
|
-
def fog_credentials
|
3
|
-
@fog_credentials ||= begin
|
4
|
-
access_key = ENV['AWS_ACCESS_KEY_ID']
|
5
|
-
secret_key = ENV["AWS_SECRET_ACCESS_KEY"]
|
6
|
-
unless access_key && secret_key
|
7
|
-
raise "Please provided $AWS_ACCESS_KEY_ID and $AWS_SECRET_ACCESS_KEY"
|
8
|
-
end
|
9
|
-
credentials = {
|
10
|
-
:provider => 'AWS',
|
11
|
-
:aws_access_key_id => access_key,
|
12
|
-
:aws_secret_access_key => secret_key
|
13
|
-
}
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
2
|
def keep_after_test?
|
18
3
|
ENV['KEEP_AFTER_TEST']
|
19
4
|
end
|
20
5
|
|
21
|
-
def fog
|
22
|
-
@fog ||= connection = Fog::Compute.new(fog_credentials.merge(:region => aws_region))
|
23
|
-
end
|
24
|
-
|
25
|
-
def cmd
|
26
|
-
@cmd ||= Bosh::Bootstrap::Cli.new
|
27
|
-
end
|
28
|
-
|
29
|
-
def provider
|
30
|
-
cmd.provider
|
31
|
-
end
|
32
|
-
|
33
|
-
# used by +SettingsSetter+ to access the settings
|
34
|
-
def settings
|
35
|
-
cmd.settings
|
36
|
-
end
|
37
|
-
|
38
|
-
def prepare_aws(spec_name, aws_region)
|
39
|
-
setup_home_dir
|
40
|
-
@cmd = nil
|
41
|
-
@fog = nil
|
42
|
-
@bosh_name = "aws-#{spec_name}-#{aws_region}-#{unique_number}"
|
43
|
-
create_manifest
|
44
|
-
destroy_test_constructs(bosh_name)
|
45
|
-
end
|
46
|
-
|
47
6
|
def unique_number
|
48
7
|
ENV['UNIQUE_NUMBER'] || Random.rand(100000)
|
49
8
|
end
|
50
9
|
|
51
10
|
def create_manifest(options = {})
|
52
|
-
setting "
|
53
|
-
setting "
|
54
|
-
setting "
|
55
|
-
setting "
|
56
|
-
setting "bosh_username", "testuser"
|
57
|
-
setting "bosh_password", "testpass"
|
58
|
-
setting "fog_credentials", fog_credentials.stringify_keys
|
59
|
-
setting "bosh.salted_password", "pepper"
|
60
|
-
setting "bosh.persistent_disk", 16384
|
61
|
-
setting "git.name", "Dr Nic Williams"
|
62
|
-
setting "git.email", "drnicwilliams@gmail.com"
|
11
|
+
setting "provider.name", "aws"
|
12
|
+
setting "provider.region", "us-east-1"
|
13
|
+
setting "provider.credentials.aws_access_key_id", ENV['AWS_ACCESS_KEY_ID']
|
14
|
+
setting "provider.credentials.aws_secret_access_key", ENV['AWS_SECRET_ACCESS_KEY']
|
63
15
|
options.each { |key, value| setting(key, value) }
|
64
|
-
|
16
|
+
unless settings.exists?("provider.credentials.aws_secret_access_key")
|
17
|
+
raise "Please provided $AWS_ACCESS_KEY_ID and $AWS_SECRET_ACCESS_KEY"
|
18
|
+
end
|
65
19
|
end
|
66
20
|
|
67
|
-
def destroy_test_constructs
|
21
|
+
def destroy_test_constructs
|
68
22
|
puts "Destroying everything created by previous tests..."
|
69
|
-
# destroy servers using inception-vm SG
|
70
|
-
provider.delete_security_group_and_servers("#{bosh_name}-inception-vm")
|
71
|
-
provider.delete_security_group_and_servers(bosh_name)
|
72
|
-
|
73
|
-
# TODO delete "inception" key pair? Why isn't it named for the bosh/inception VM?
|
74
|
-
provider.delete_key_pair(bosh_name)
|
75
|
-
|
76
23
|
provider.cleanup_unused_ip_addresses
|
77
24
|
end
|
78
25
|
|
data/spec/spec_helper.rb
CHANGED
@@ -9,14 +9,19 @@ Bundler.setup(:default, :test)
|
|
9
9
|
$:.unshift(File.expand_path("../../lib", __FILE__))
|
10
10
|
|
11
11
|
require "rspec/core"
|
12
|
-
require "bosh
|
13
|
-
require "bosh
|
14
|
-
require "bosh-bootstrap/cli"
|
12
|
+
require "cli" # bosh CLI
|
13
|
+
require "bosh/cli/commands/bootstrap" # "bosh bootstrap COMMAND" commands added to bosh CLI
|
14
|
+
require "bosh-bootstrap/cli/helpers"
|
15
15
|
|
16
16
|
# for the #sh helper
|
17
17
|
require "rake"
|
18
18
|
require "rake/file_utils"
|
19
19
|
|
20
|
+
# load all files in spec/support/* (but not lower down)
|
21
|
+
Dir[File.dirname(__FILE__) + '/support/*'].each do |path|
|
22
|
+
require path unless File.directory?(path)
|
23
|
+
end
|
24
|
+
|
20
25
|
def spec_asset(filename)
|
21
26
|
File.expand_path("../assets/#{filename}", __FILE__)
|
22
27
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module StdoutCapture
|
2
|
+
# Captures stdout within the block
|
3
|
+
# Usage:
|
4
|
+
#
|
5
|
+
# out = capture_stdout do
|
6
|
+
# puts "this will not be shown"
|
7
|
+
# end
|
8
|
+
# out.should == "this will not be shown"
|
9
|
+
def capture_stdout(&block)
|
10
|
+
out = StringIO.new
|
11
|
+
$stdout = out
|
12
|
+
yield
|
13
|
+
out.rewind
|
14
|
+
return out.read
|
15
|
+
ensure
|
16
|
+
$stdout = STDOUT
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# Copyright (c) 2012-2013 Stark & Wayne, LLC
|
2
|
+
|
3
|
+
require "bosh-bootstrap/cli/commands/deploy"
|
4
|
+
require "bosh-bootstrap/cli/commands/delete"
|
5
|
+
require "bosh-bootstrap/cli/commands/ssh"
|
6
|
+
describe Bosh::Cli::Command::Bootstrap do
|
7
|
+
include FileUtils
|
8
|
+
|
9
|
+
before do
|
10
|
+
FileUtils.mkdir_p(@stemcells_dir = File.join(Dir.mktmpdir, "stemcells"))
|
11
|
+
FileUtils.mkdir_p(@cache_dir = File.join(Dir.mktmpdir, "cache"))
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:cli) do
|
15
|
+
cli = Bosh::Cli::Command::Bootstrap.new(nil)
|
16
|
+
cli.add_option(:non_interactive, true)
|
17
|
+
cli.add_option(:cache_dir, @cache_dir)
|
18
|
+
cli
|
19
|
+
end
|
20
|
+
|
21
|
+
it "runs deploy command" do
|
22
|
+
cmd = double(Bosh::Bootstrap::Cli::Commands::Deploy)
|
23
|
+
cmd.should_receive(:perform)
|
24
|
+
Bosh::Bootstrap::Cli::Commands::Deploy.stub(:new).and_return(cmd)
|
25
|
+
cli.deploy
|
26
|
+
end
|
27
|
+
|
28
|
+
it "runs delete command" do
|
29
|
+
cmd = double(Bosh::Bootstrap::Cli::Commands::Delete)
|
30
|
+
cmd.should_receive(:perform)
|
31
|
+
Bosh::Bootstrap::Cli::Commands::Delete.stub(:new).and_return(cmd)
|
32
|
+
cli.delete
|
33
|
+
end
|
34
|
+
|
35
|
+
it "runs ssh command" do
|
36
|
+
cmd = double(Bosh::Bootstrap::Cli::Commands::SSH)
|
37
|
+
cmd.should_receive(:perform)
|
38
|
+
Bosh::Bootstrap::Cli::Commands::SSH.stub(:new).and_return(cmd)
|
39
|
+
cli.ssh
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Copyright (c) 2012-2013 Stark & Wayne, LLC
|
2
|
+
|
3
|
+
require "bosh-bootstrap/cli/commands/delete"
|
4
|
+
|
5
|
+
describe Bosh::Bootstrap::Cli::Commands::Delete do
|
6
|
+
include StdoutCapture
|
7
|
+
include Bosh::Bootstrap::Cli::Helpers
|
8
|
+
|
9
|
+
let(:settings_dir) { File.expand_path("~/.microbosh") }
|
10
|
+
|
11
|
+
subject { Bosh::Bootstrap::Cli::Commands::Delete.new }
|
12
|
+
|
13
|
+
it "deletes microbosh VM" do
|
14
|
+
setting "bosh.name", "test-bosh"
|
15
|
+
mkdir_p(File.join(settings_dir, "deployments"))
|
16
|
+
subject.should_receive(:sh).with("bundle exec bosh -n micro deployment test-bosh")
|
17
|
+
subject.should_receive(:sh).with("bundle exec bosh -n micro delete")
|
18
|
+
subject.perform
|
19
|
+
end
|
20
|
+
end
|