Skip to content
This repository has been archived by the owner on Nov 29, 2017. It is now read-only.

Commit

Permalink
Merge pull request #310 from cloudfoundry-community/add_proxy
Browse files Browse the repository at this point in the history
add support for proxy in setting.yml
  • Loading branch information
cweibel committed Apr 28, 2015
2 parents d607576 + 112b7a1 commit 8a1b53a
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/bosh-bootstrap/microbosh_providers/aws.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def to_hash
data["apply_spec"]["properties"]["dns"] = {}
data["apply_spec"]["properties"]["dns"]["recursor"] = dns
end
if proxy?
data["apply_spec"]["properties"]["director"] = {"env" => proxy}
end
data
end

Expand Down
8 changes: 8 additions & 0 deletions lib/bosh-bootstrap/microbosh_providers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ def private_key_path
settings.key_pair.path
end

def proxy
settings.proxy.to_hash
end

def proxy?
settings.exists?("proxy")
end

def jenkins_bucket
"bosh-jenkins-artifacts"
end
Expand Down
6 changes: 5 additions & 1 deletion lib/bosh-bootstrap/microbosh_providers/openstack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Bosh::Bootstrap::MicroboshProviders
class OpenStack < Base

def to_hash
super.deep_merge({
data = super.deep_merge({
"network"=>network_configuration,
"resources"=>
{"persistent_disk"=>persistent_disk,
Expand All @@ -23,6 +23,10 @@ def to_hash
"hm"=>{"resurrector_enabled" => true},
"ntp"=>["0.north-america.pool.ntp.org","1.north-america.pool.ntp.org"]}}
})
if proxy?
data["apply_spec"]["properties"]["director"]["env"] = proxy
end
data
end

# For Nova/Floating IP:
Expand Down
49 changes: 49 additions & 0 deletions spec/assets/microbosh_yml/micro_bosh.aws_vpc_proxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
name: test-bosh
logging:
level: DEBUG
network:
type: manual
ip: 1.2.3.4
dns:
- 1.2.0.2
cloud_properties:
subnet: subnet-123456
resources:
persistent_disk: 32768
cloud_properties:
instance_type: m3.medium
ephemeral_disk:
size: 163840
type: gp2
cloud:
plugin: aws
properties:
aws:
access_key_id: ACCESS
secret_access_key: SECRET
region: us-west-2
ec2_endpoint: ec2.us-west-2.amazonaws.com
default_security_groups:
- ssh-vpc-123456
- dns-server-vpc-123456
- bosh-vpc-123456
default_key_name: test-bosh
ec2_private_key: ~/.microbosh/ssh/test-bosh
apply_spec:
agent:
blobstore:
address: 1.2.3.4
nats:
address: 1.2.3.4
properties:
hm:
resurrector_enabled: true
aws_registry:
address: 1.2.3.4
dns:
recursor: 1.2.0.2
director:
env:
http_proxy: http://192.168.1.100:8080
https_proxy: https://192.168.1.100:8080
49 changes: 49 additions & 0 deletions spec/assets/microbosh_yml/micro_bosh.openstack.with_proxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
name: test-bosh
logging:
level: DEBUG
network:
type: dynamic
vip: 1.2.3.4
cloud_properties:
net_id: 7b8788eb-b49e-4424-9065-75a6b07094ea
resources:
persistent_disk: 32768
cloud_properties:
instance_type: m1.medium
cloud:
plugin: openstack
properties:
openstack:
auth_url: http://10.0.0.2:5000/v2.0/tokens
username: USER
api_key: PASSWORD
tenant: TENANT
region: REGION
default_security_groups:
- ssh
- dns-server
- bosh
default_key_name: test-bosh
state_timeout: 300
private_key: ~/.microbosh/ssh/test-bosh
connection_options:
ssl_verify_peer: false
boot_from_volume: false
apply_spec:
agent:
blobstore:
address: 1.2.3.4
nats:
address: 1.2.3.4
properties:
director:
max_threads: 3
env:
http_proxy: http://192.168.1.100:8080
https_proxy: https://192.168.1.100:8080
hm:
resurrector_enabled: true
ntp:
- 0.north-america.pool.ntp.org
- 1.north-america.pool.ntp.org
23 changes: 23 additions & 0 deletions spec/unit/microbosh_providers/aws_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,5 +207,28 @@
expect(File).to be_exists(microbosh_yml)
yaml_files_match(microbosh_yml, spec_asset("microbosh_yml/micro_bosh.aws_vpc_recursor.yml"))
end

it "adds proxy if present" do
setting "provider.name", "aws"
setting "provider.region", "us-west-2"
setting "provider.credentials.aws_access_key_id", "ACCESS"
setting "provider.credentials.aws_secret_access_key", "SECRET"
setting "address.ip", "1.2.3.4"
setting "address.vpc_id", "vpc-123456"
setting "address.subnet_id", "subnet-123456"
setting "key_pair.path", "~/.microbosh/ssh/test-bosh"
setting "bosh.name", "test-bosh"
setting "bosh.salted_password", "salted_password"
setting "bosh.persistent_disk", 32768
setting "proxy.http_proxy", "http://192.168.1.100:8080"
setting "proxy.https_proxy", "https://192.168.1.100:8080"


subject = Bosh::Bootstrap::MicroboshProviders::AWS.new(microbosh_yml, settings, fog_compute)

subject.create_microbosh_yml(settings)
expect(File).to be_exists(microbosh_yml)
yaml_files_match(microbosh_yml, spec_asset("microbosh_yml/micro_bosh.aws_vpc_proxy.yml"))
end
end
end
24 changes: 24 additions & 0 deletions spec/unit/microbosh_providers/openstack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,30 @@
yaml_files_match(microbosh_yml, spec_asset("microbosh_yml/micro_bosh.openstack.with_recursor.yml"))
end

it "adds proxy if present" do
setting "provider.name", "openstack"
setting "provider.credentials.openstack_auth_url", "http://10.0.0.2:5000/v2.0/tokens"
setting "provider.credentials.openstack_username", "USER"
setting "provider.credentials.openstack_api_key", "PASSWORD"
setting "provider.credentials.openstack_tenant", "TENANT"
setting "provider.credentials.openstack_region", "REGION"
setting "address.subnet_id", "7b8788eb-b49e-4424-9065-75a6b07094ea"
setting "address.pool_name", "INTERNET"
setting "address.ip", "1.2.3.4" # network.vip
setting "key_pair.path", "~/.microbosh/ssh/test-bosh"
setting "bosh.name", "test-bosh"
setting "bosh.salted_password", "salted_password"
setting "bosh.persistent_disk", 32768
setting "proxy.http_proxy", "http://192.168.1.100:8080"
setting "proxy.https_proxy", "https://192.168.1.100:8080"

subject = Bosh::Bootstrap::MicroboshProviders::OpenStack.new(microbosh_yml, settings, fog_compute)

subject.create_microbosh_yml(settings)
expect(File).to be_exists(microbosh_yml)
yaml_files_match(microbosh_yml, spec_asset("microbosh_yml/micro_bosh.openstack.with_proxy.yml"))
end

it "adds state_timeout if provided" do
setting "provider.name", "openstack"
setting "provider.credentials.openstack_auth_url", "http://10.0.0.2:5000/v2.0/tokens"
Expand Down

0 comments on commit 8a1b53a

Please sign in to comment.