Class: Bosh::Director::Models::Instance
- Defined in:
- lib/bosh/director/models/instance.rb
Instance Method Summary collapse
- #latest_rendered_templates_archive ⇒ Object
- #persistent_disk ⇒ Object
- #persistent_disk_cid ⇒ Object
- #stale_rendered_templates_archives ⇒ Object
- #validate ⇒ Object
Instance Method Details
#latest_rendered_templates_archive ⇒ Object
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_disk ⇒ Object
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_cid ⇒ Object
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_archives ⇒ Object
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 |
#validate ⇒ Object
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 |