Class: Bosh::Director::VmData
Overview
A class for storing VMs and their associated data so that they can be accessed and deleted easily.
Instance Attribute Summary collapse
- #agent ⇒ Object
- #agent_id ⇒ Object readonly
- #network_settings ⇒ Object readonly
- #reservation ⇒ Object readonly
-
#stemcell ⇒ Object
readonly
@attr The Stemcell this VM is running.
- #vm ⇒ Object readonly
Instance Method Summary collapse
- #in_use? ⇒ Boolean
-
#initialize(reservation, vm, stemcell, network_settings) ⇒ VmData
constructor
Initializes a VmData.
-
#mark_in_use ⇒ Boolean
Marks that this VM is being used.
-
#release ⇒ Object
Releases the current VM to be reused.
Constructor Details
#initialize(reservation, vm, stemcell, network_settings) ⇒ VmData
Initializes a VmData.
29 30 31 32 33 34 35 36 37 |
# File 'lib/bosh/director/vm_data.rb', line 29 def initialize(reservation, vm, stemcell, network_settings) @reservation = reservation @vm = vm @stemcell = stemcell @network_settings = network_settings @agent_id = vm.agent_id @being_used = false @being_used_mutex = Mutex.new end |
Instance Attribute Details
#agent ⇒ Object
22 23 24 |
# File 'lib/bosh/director/vm_data.rb', line 22 def agent @agent end |
#agent_id ⇒ Object (readonly)
19 20 21 |
# File 'lib/bosh/director/vm_data.rb', line 19 def agent_id @agent_id end |
#network_settings ⇒ Object (readonly)
16 17 18 |
# File 'lib/bosh/director/vm_data.rb', line 16 def network_settings @network_settings end |
#reservation ⇒ Object (readonly)
7 8 9 |
# File 'lib/bosh/director/vm_data.rb', line 7 def reservation @reservation end |
#stemcell ⇒ Object (readonly)
@attr The Stemcell this VM is running.
13 14 15 |
# File 'lib/bosh/director/vm_data.rb', line 13 def stemcell @stemcell end |
#vm ⇒ Object (readonly)
10 11 12 |
# File 'lib/bosh/director/vm_data.rb', line 10 def vm @vm end |
Instance Method Details
#in_use? ⇒ Boolean
59 60 61 |
# File 'lib/bosh/director/vm_data.rb', line 59 def in_use? @being_used end |
#mark_in_use ⇒ Boolean
Marks that this VM is being used.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/bosh/director/vm_data.rb', line 41 def mark_in_use @being_used_mutex.synchronize do if @being_used return false else @being_used = true return true end end end |
#release ⇒ Object
Releases the current VM to be reused.
53 54 55 56 57 |
# File 'lib/bosh/director/vm_data.rb', line 53 def release @being_used_mutex.synchronize do @being_used = false end end |