Class: Bosh::Deployer::InstanceManager::Openstack
- Inherits:
-
Object
- Object
- Bosh::Deployer::InstanceManager::Openstack
- Defined in:
- lib/bosh/deployer/instance_manager/openstack.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) ⇒ Openstack
constructor
A new instance of Openstack.
- #persistent_disk_changed? ⇒ Boolean
- #remote_tunnel ⇒ Object
- #service_ip ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #update_spec(spec) ⇒ Object
Constructor Details
#initialize(instance_manager, logger) ⇒ Openstack
Returns a new instance of Openstack.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bosh/deployer/instance_manager/openstack.rb', line 8 def initialize(instance_manager, logger) @instance_manager = instance_manager @logger = logger properties = Config.['properties'] @registry = Registry.new( properties['registry']['endpoint'], 'openstack', properties['openstack'], 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
47 48 49 |
# File 'lib/bosh/deployer/instance_manager/openstack.rb', line 47 def check_dependencies # nothing to check, move on... end |
#discover_bosh_ip ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/bosh/deployer/instance_manager/openstack.rb', line 60 def discover_bosh_ip if instance_manager.state.vm_cid floating_ip = instance_manager.cloud.openstack.servers. get(instance_manager.state.vm_cid).floating_ip_address ip = floating_ip || service_ip if 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
30 31 32 |
# File 'lib/bosh/deployer/instance_manager/openstack.rb', line 30 def disk_model nil end |
#disk_size(cid) ⇒ Integer
Returns size in MiB.
81 82 83 84 |
# File 'lib/bosh/deployer/instance_manager/openstack.rb', line 81 def disk_size(cid) # OpenStack stores disk size in GiB but we work with MiB instance_manager.cloud.openstack.volumes.get(cid).size * 1024 end |
#persistent_disk_changed? ⇒ Boolean
86 87 88 89 90 91 92 93 |
# File 'lib/bosh/deployer/instance_manager/openstack.rb', line 86 def persistent_disk_changed? # since OpenStack stores disk size in GiB and we use 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
26 27 28 |
# File 'lib/bosh/deployer/instance_manager/openstack.rb', line 26 def remote_tunnel @remote_tunnel.create(instance_manager.bosh_ip, registry.port) end |
#service_ip ⇒ Object
75 76 77 78 |
# File 'lib/bosh/deployer/instance_manager/openstack.rb', line 75 def service_ip instance_manager.cloud.openstack.servers. get(instance_manager.state.vm_cid).private_ip_address end |
#start ⇒ Object
51 52 53 |
# File 'lib/bosh/deployer/instance_manager/openstack.rb', line 51 def start registry.start end |
#stop ⇒ Object
55 56 57 58 |
# File 'lib/bosh/deployer/instance_manager/openstack.rb', line 55 def stop registry.stop instance_manager.save_state end |
#update_spec(spec) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bosh/deployer/instance_manager/openstack.rb', line 34 def update_spec(spec) properties = spec.properties properties['openstack'] = Config.spec_properties['openstack'] || Config.['properties']['openstack'].dup properties['openstack']['registry'] = Config.['properties']['registry'] properties['openstack']['stemcell'] = Config.['properties']['stemcell'] spec.delete('networks') end |