Class: Bosh::Bootstrap::MicroboshProviders::AWS
- Defined in:
- lib/bosh-bootstrap/microbosh_providers/aws.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#fog_compute, #manifest_path, #settings
Instance Method Summary collapse
- #aws_region ⇒ Object
- #cloud_properties ⇒ Object
- #discover_if_stemcell_image_already_uploaded ⇒ Object
-
#find_ami_for_stemcell(name, version) ⇒ String
Usage: find_ami_for_stemcell(“bosh-aws-xen-ubuntu-trusty-go_agent”, “2732”).
-
#latest_stemcell ⇒ Object
If us-east-1 region, then return light stemcell.
-
#light_stemcell? ⇒ Boolean
only us-east-1 has light stemcells published.
- #network_configuration ⇒ Object
-
#owned_images ⇒ Hash
[{“deviceName”=>“/dev/sda”, “snapshotId”=>“snap-56c7089e”, “volumeSize”=>2, “deleteOnTermination”=>“true”, “virtualName”=>“ephemeral0”], “productCodes”=>[], “stateReason”=>{}, “tagSet”=>2732”, “imageId”=>“ami-c19ed3f1”, “imageLocation”=>“357913607455/BOSH-64a71269-18a2-450b-9e61-713ed70fa62a”, “imageState”=>“available”, “imageOwnerId”=>“357913607455”, “isPublic”=>false, “architecture”=>“x86_64”, “imageType”=>“machine”, “kernelId”=>“aki-94e26fa4”, “name”=>“BOSH-64a71269-18a2-450b-9e61-713ed70fa62a”, “description”=>“bosh-aws-xen-ubuntu-trusty-go_agent 2732”, “rootDeviceType”=>“ebs”, “rootDeviceName”=>“/dev/sda1”, “virtualizationType”=>“paravirtual”, “hypervisor”=>“xen”}.
- #persistent_disk ⇒ Object
- #resources_cloud_properties ⇒ Object
- #security_groups ⇒ Object
- #to_hash ⇒ Object
- #vpc? ⇒ Boolean
-
#vpc_dns(ip_address) ⇒ Object
Note: this should work for all /16 vpcs and may run into issues with other blocks.
Methods inherited from Base
#create_microbosh_yml, #default_spec, #download_stemcell, #initialize, #jenkins_bucket, #microbosh_name, #ntp_servers, #private_key_path, #proxy, #proxy?, #public_ip, #public_ip?, #recent_stemcells, #salted_password, #stemcell_dir, #stemcell_path
Constructor Details
This class inherits a constructor from Bosh::Bootstrap::MicroboshProviders::Base
Instance Method Details
#aws_region ⇒ Object
88 89 90 |
# File 'lib/bosh-bootstrap/microbosh_providers/aws.rb', line 88 def aws_region settings.provider.region end |
#cloud_properties ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/bosh-bootstrap/microbosh_providers/aws.rb', line 66 def cloud_properties {"access_key_id"=>settings.provider.credentials.aws_access_key_id, "secret_access_key"=>settings.provider.credentials.aws_secret_access_key, "region"=>settings.provider.region, "ec2_endpoint"=>"ec2.#{settings.provider.region}.amazonaws.com", "default_security_groups"=>security_groups, "default_key_name"=>microbosh_name, "ec2_private_key"=>private_key_path} end |
#discover_if_stemcell_image_already_uploaded ⇒ Object
154 155 156 |
# File 'lib/bosh-bootstrap/microbosh_providers/aws.rb', line 154 def discover_if_stemcell_image_already_uploaded find_ami_for_stemcell(latest_stemcell.stemcell_name, latest_stemcell.version) end |
#find_ami_for_stemcell(name, version) ⇒ String
Usage: find_ami_for_stemcell(“bosh-aws-xen-ubuntu-trusty-go_agent”, “2732”)
147 148 149 150 151 152 |
# File 'lib/bosh-bootstrap/microbosh_providers/aws.rb', line 147 def find_ami_for_stemcell(name, version) image = owned_images.find do |image| image["description"] == "#{name} #{version}" end image["imageId"] if image end |
#latest_stemcell ⇒ Object
If us-east-1 region, then return light stemcell
94 95 96 97 98 99 100 101 |
# File 'lib/bosh-bootstrap/microbosh_providers/aws.rb', line 94 def latest_stemcell @latest_stemcell ||= begin trusty_stemcells = recent_stemcells.select do |s| s.name =~ /aws/ && s.name =~ /trusty/ && s.name =~ /^light/ end trusty_stemcells.sort {|s1, s2| s2.version <=> s1.version}.first end end |
#light_stemcell? ⇒ Boolean
only us-east-1 has light stemcells published
104 105 106 |
# File 'lib/bosh-bootstrap/microbosh_providers/aws.rb', line 104 def light_stemcell? aws_region == "us-east-1" end |
#network_configuration ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/bosh-bootstrap/microbosh_providers/aws.rb', line 38 def network_configuration if vpc? { "type" =>"manual", "ip" => public_ip, "dns" => [vpc_dns(public_ip)], "cloud_properties" => { "subnet" => settings.address.subnet_id } } else { "type"=>"dynamic", "vip"=>public_ip } end end |
#owned_images ⇒ Hash
[{"deviceName"=>"/dev/sda",
"snapshotId"=>"snap-56c7089e",
"volumeSize"=>2,
"deleteOnTermination"=>"true",
"virtualName"=>"ephemeral0"],
“productCodes”=>[], “stateReason”=>{}, “tagSet”=>{“Name”=>“bosh-aws-xen-ubuntu-trusty-go_agent 2732”}, “imageId”=>“ami-c19ed3f1”, “imageLocation”=>“357913607455/BOSH-64a71269-18a2-450b-9e61-713ed70fa62a”, “imageState”=>“available”, “imageOwnerId”=>“357913607455”, “isPublic”=>false, “architecture”=>“x86_64”, “imageType”=>“machine”, “kernelId”=>“aki-94e26fa4”, “name”=>“BOSH-64a71269-18a2-450b-9e61-713ed70fa62a”, “description”=>“bosh-aws-xen-ubuntu-trusty-go_agent 2732”, “rootDeviceType”=>“ebs”, “rootDeviceName”=>“/dev/sda1”, “virtualizationType”=>“paravirtual”, “hypervisor”=>“xen”}
140 141 142 143 |
# File 'lib/bosh-bootstrap/microbosh_providers/aws.rb', line 140 def owned_images my_images_raw = fog_compute.describe_images('Owner' => 'self') my_images_raw.body["imagesSet"] end |
#persistent_disk ⇒ Object
57 58 59 |
# File 'lib/bosh-bootstrap/microbosh_providers/aws.rb', line 57 def persistent_disk settings.bosh.persistent_disk end |
#resources_cloud_properties ⇒ Object
61 62 63 64 |
# File 'lib/bosh-bootstrap/microbosh_providers/aws.rb', line 61 def resources_cloud_properties {"instance_type"=>"m3.medium", "ephemeral_disk"=>{"size" => 163840, "type" => "gp2"}} end |
#security_groups ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/bosh-bootstrap/microbosh_providers/aws.rb', line 76 def security_groups sg_suffix="" if vpc? sg_suffix="-#{settings.address.vpc_id}" end [ "ssh#{sg_suffix}", "dns-server#{sg_suffix}", "bosh#{sg_suffix}" ] end |
#to_hash ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/bosh-bootstrap/microbosh_providers/aws.rb', line 6 def to_hash data = super.deep_merge({ "network"=>network_configuration, "resources"=> {"persistent_disk"=>persistent_disk, "cloud_properties"=>resources_cloud_properties}, "cloud"=> {"plugin"=>"aws", "properties"=> {"aws"=>cloud_properties}}, "apply_spec"=> {"agent"=> {"blobstore"=>{"address"=>public_ip}, "nats"=>{"address"=>public_ip}}, "properties"=> {"aws_registry"=>{"address"=>public_ip}, "hm"=>{"resurrector_enabled" => true}}}, }) if az = settings.exists?("provider.az") data["resources"]["cloud_properties"]["availability_zone"] = az end if vpc? dns = settings.exists?("recursor") ? settings.recursor : vpc_dns(public_ip) 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 |
#vpc? ⇒ Boolean
108 109 110 |
# File 'lib/bosh-bootstrap/microbosh_providers/aws.rb', line 108 def vpc? settings.address["subnet_id"] end |
#vpc_dns(ip_address) ⇒ Object
Note: this should work for all /16 vpcs and may run into issues with other blocks
112 113 114 |
# File 'lib/bosh-bootstrap/microbosh_providers/aws.rb', line 112 def vpc_dns(ip_address) ip_address.gsub(/^(\d+)\.(\d+)\..*/, '\1.\2.0.2') end |