Class: Bosh::Director::VmMetadataUpdater

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/vm_metadata_updater.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cloud, director_metadata, logger) ⇒ VmMetadataUpdater

Returns a new instance of VmMetadataUpdater.



7
8
9
10
11
# File 'lib/bosh/director/vm_metadata_updater.rb', line 7

def initialize(cloud, , logger)
  @cloud = cloud
  @director_metadata = 
  @logger = logger
end

Class Method Details

.buildObject



3
4
5
# File 'lib/bosh/director/vm_metadata_updater.rb', line 3

def self.build
  new(Config.cloud, {director: Config.name}, Config.logger)
end

Instance Method Details

#update(vm, metadata) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bosh/director/vm_metadata_updater.rb', line 13

def update(vm, )
  if @cloud.respond_to?(:set_vm_metadata)
     = .merge(@director_metadata)
    [:deployment] = vm.deployment.name

    if vm.instance
      [:job] = vm.instance.job
      [:index] = vm.instance.index.to_s
    end

    @cloud.(vm.cid, )
  end
rescue Bosh::Clouds::NotImplemented => e
  @logger.debug(e.inspect)
end