Class: Bosh::Deployer::InstanceManager::Aws
- Inherits:
-
Object
- Object
- Bosh::Deployer::InstanceManager::Aws
- Defined in:
- lib/bosh/deployer/instance_manager/aws.rb
Instance Method Summary collapse
- #check_dependencies ⇒ Object
- #discover_bosh_ip ⇒ Object
- #disk_model ⇒ Object
-
#disk_size(cid) ⇒ Integer
Size in MiB.
-
#initialize(instance_manager, logger) ⇒ Aws
constructor
A new instance of Aws.
- #persistent_disk_changed? ⇒ Boolean
- #remote_tunnel ⇒ Object
- #service_ip ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #update_spec(spec) ⇒ Object
Constructor Details
#initialize(instance_manager, logger) ⇒ Aws
Returns a new instance of Aws.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 8 def initialize(instance_manager, logger) @instance_manager = instance_manager @logger = logger properties = Config.['properties'] @registry = Registry.new( properties['registry']['endpoint'], 'aws', properties['aws'], instance_manager, logger, ) ssh_key, ssh_port, ssh_user, ssh_wait = ssh_properties(properties) ssh_server = SshServer.new(ssh_user, ssh_key, ssh_port, logger) @remote_tunnel = RemoteTunnel.new(ssh_server, ssh_wait, logger) end |
Instance Method Details
#check_dependencies ⇒ Object
52 53 54 |
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 52 def check_dependencies # nothing to check, move on... end |
#discover_bosh_ip ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 65 def discover_bosh_ip if instance_manager.state.vm_cid # choose elastic IP over public, as any agent connecting to the # deployed micro bosh will be cut off from the public IP when # we re-deploy micro bosh instance = instance_manager.cloud.ec2.instances[instance_manager.state.vm_cid] if instance.has_elastic_ip? ip = instance.elastic_ip.public_ip else ip = instance.public_ip_address end if ip && ip != instance_manager.bosh_ip instance_manager.bosh_ip = ip logger.info("discovered bosh ip=#{instance_manager.bosh_ip}") end end instance_manager.bosh_ip end |
#disk_model ⇒ Object
31 32 33 |
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 31 def disk_model nil end |
#disk_size(cid) ⇒ Integer
Returns size in MiB.
91 92 93 94 |
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 91 def disk_size(cid) # AWS stores disk size in GiB but the CPI uses MiB instance_manager.cloud.ec2.volumes[cid].size * 1024 end |
#persistent_disk_changed? ⇒ Boolean
96 97 98 99 100 101 102 103 |
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 96 def persistent_disk_changed? # since AWS stores disk size in GiB and the CPI uses MiB there # is a risk of conversion errors which lead to an unnecessary # disk migration, so we need to do a double conversion # here to avoid that requested = (Config.resources['persistent_disk'] / 1024.0).ceil * 1024 requested != disk_size(instance_manager.state.disk_cid) end |
#remote_tunnel ⇒ Object
27 28 29 |
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 27 def remote_tunnel @remote_tunnel.create(instance_manager.bosh_ip, registry.port) end |
#service_ip ⇒ Object
86 87 88 |
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 86 def service_ip instance_manager.cloud.ec2.instances[instance_manager.state.vm_cid].private_ip_address end |
#start ⇒ Object
56 57 58 |
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 56 def start registry.start end |
#stop ⇒ Object
60 61 62 63 |
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 60 def stop registry.stop instance_manager.save_state end |
#update_spec(spec) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 35 def update_spec(spec) properties = spec.properties # pick from micro_bosh.yml the aws settings in # `apply_spec` section (apply_spec.properties.aws), # and if it doesn't exist, use the bosh deployer # aws properties (cloud.properties.aws) properties['aws'] = Config.spec_properties['aws'] || Config.['properties']['aws'].dup properties['aws']['registry'] = Config.['properties']['registry'] properties['aws']['stemcell'] = Config.['properties']['stemcell'] spec.delete('networks') end |