Class: Bosh::Director::Models::Instance

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

Instance Method Summary collapse

Instance Method Details

#latest_rendered_templates_archiveObject



27
28
29
# File 'lib/bosh/director/models/instance.rb', line 27

def latest_rendered_templates_archive
  rendered_templates_archives_dataset.order(:created_at).last
end

#persistent_diskObject



16
17
18
19
# File 'lib/bosh/director/models/instance.rb', line 16

def persistent_disk
  # Currently we support only 1 persistent disk.
  self.persistent_disks.find { |disk| disk.active }
end

#persistent_disk_cidObject



21
22
23
24
25
# File 'lib/bosh/director/models/instance.rb', line 21

def persistent_disk_cid
  disk = persistent_disk
  return disk.disk_cid if disk
  nil
end

#stale_rendered_templates_archivesObject



31
32
33
34
35
36
37
38
# File 'lib/bosh/director/models/instance.rb', line 31

def stale_rendered_templates_archives
  stale_archives = rendered_templates_archives_dataset
  if latest = latest_rendered_templates_archive
    stale_archives.exclude(id: latest.id)
  else
    stale_archives
  end
end

#validateObject



8
9
10
11
12
13
14
# File 'lib/bosh/director/models/instance.rb', line 8

def validate
  validates_presence [:deployment_id, :job, :index, :state]
  validates_unique [:deployment_id, :job, :index]
  validates_unique [:vm_id] if vm_id
  validates_integer :index
  validates_includes ["started", "stopped", "detached"], :state
end