Class: Dcmgr::Stm::VolumeContext
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Dcmgr::Stm::VolumeContext
- Defined in:
- lib/dcmgr/stm/volume_context.rb
Instance Attribute Summary collapse
-
#stm ⇒ Object
readonly
Returns the value of attribute stm.
Instance Method Summary collapse
-
#initialize(volume_id = nil) ⇒ VolumeContext
constructor
A new instance of VolumeContext.
- #on_attach ⇒ Object
- #on_delete ⇒ Object
- #on_detach ⇒ Object
- #state ⇒ Object
- #to_hash(hash = {}) ⇒ Object
Constructor Details
#initialize(volume_id = nil) ⇒ VolumeContext
Returns a new instance of VolumeContext.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/dcmgr/stm/volume_context.rb', line 8 def initialize(volume_id=nil) super({:volume_id => volume_id, :export_path => nil, :transport_information => nil, :instance_id => nil, :host_device_name => nil, :guest_device_name => nil, :deleted_at => nil, :attached_at => nil, :detached_at => nil, }) @stm = Statemachine.build { startstate :registering superstate :volume_condition do trans :registering, :on_create, :creating trans :creating, :on_register, :available trans :available, :on_attach, :attaching trans :attaching, :on_attach, :attached trans :attached, :on_detach, :detaching trans :detaching, :on_detach, :available event :on_fail, :failed event :on_deregister, :deregistering end trans :failed, :on_create, :creating trans :failed, :on_register, :available trans :failed, :on_fail, :failed trans :failed, :on_deregister, :deleting trans :failed, :on_delete, :deleted trans :deregistering, :on_delete, :deleting trans :deleting, :on_delete, :deleted trans :deleted, :on_delete, :deleted } @stm.context = self end |
Instance Attribute Details
#stm ⇒ Object (readonly)
Returns the value of attribute stm.
6 7 8 |
# File 'lib/dcmgr/stm/volume_context.rb', line 6 def stm @stm end |
Instance Method Details
#on_attach ⇒ Object
57 58 59 |
# File 'lib/dcmgr/stm/volume_context.rb', line 57 def on_attach self.attached_at = Time.now end |
#on_delete ⇒ Object
53 54 55 |
# File 'lib/dcmgr/stm/volume_context.rb', line 53 def on_delete self.deleted_at = Time.now end |
#on_detach ⇒ Object
61 62 63 |
# File 'lib/dcmgr/stm/volume_context.rb', line 61 def on_detach self.detached_at = Time.now end |
#state ⇒ Object
45 46 47 |
# File 'lib/dcmgr/stm/volume_context.rb', line 45 def state @stm.state end |
#to_hash(hash = {}) ⇒ Object
49 50 51 |
# File 'lib/dcmgr/stm/volume_context.rb', line 49 def to_hash(hash={}) @table.dup.merge({:state=>@stm.state}).merge(hash) end |