Class: Dcmgr::NodeModules::StaCollector

Inherits:
Isono::NodeModules::Base
  • Object
show all
Defined in:
lib/dcmgr/node_modules/sta_collector.rb

Instance Method Summary collapse

Instance Method Details

#get_snapshot(snapshot_id) ⇒ Object



29
30
31
32
33
# File 'lib/dcmgr/node_modules/sta_collector.rb', line 29

def get_snapshot(snapshot_id)
  Models::VolumeSnapshot.lock!
  vs = Dcmgr::Models::VolumeSnapshot[snapshot_id]
  vs.to_hash
end

#get_volume(volume_id) ⇒ Object



23
24
25
26
27
# File 'lib/dcmgr/node_modules/sta_collector.rb', line 23

def get_volume(volume_id)
  Models::Volume.lock!
  v = Dcmgr::Models::Volume[volume_id]
  v.merge_pool_data
end

#update_snapshot(data) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/dcmgr/node_modules/sta_collector.rb', line 63

def update_snapshot(data)
  Models::VolumeSnapshot.lock!
  vs = Dcmgr::Models::VolumeSnapshot[data[:snapshot_id]]
  vs.set_fields(data, [:state]).save
  # do not respond model object.
  nil
end

#update_volume(data) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/dcmgr/node_modules/sta_collector.rb', line 35

def update_volume(data)
  Models::Volume.lock!
  v = Dcmgr::Models::Volume[data[:volume_id]]

  column = case data[:state]
           when :creating
             [:state, :export_path]
           when :available
             if !data[:transport_information].nil?
               [:state, :transport_information]
             else
               [:state, :host_device_name, :instance_id, :detached_at]
             end
           when :attaching
             [:state, :host_device_name]
           when :attached
             [:state, :guest_device_name, :attached_at]
           when :detaching
             [:state, :guest_device_name]
           else
             [:state]
           end

  v.set_fields(data, column).save
  # do not respond model object.
  nil
end