Class: Dcmgr::NodeModules::StaCollector

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

Instance Method Summary collapse

Methods included from Logger

create, default_logdev, included

Instance Method Details

#get_available_volumes(sta_node_id) ⇒ Object

collect all volume instances on the sta node.



25
26
27
28
29
30
31
# File 'lib/dcmgr/node_modules/sta_collector.rb', line 25

def get_available_volumes(sta_node_id)
  stnode = Models::StorageNode.filter(:node_id=>sta_node_id).first || raise("Unknown sta node ID: #{sta_node_id}")
  v = stnode.volumes_dataset.lives.all
  v.map { |volume|
    volume.merge_pool_data
  }
end

#get_snapshot(snapshot_id) ⇒ Object



38
39
40
41
# File 'lib/dcmgr/node_modules/sta_collector.rb', line 38

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

#get_volume(volume_id) ⇒ Object



33
34
35
36
# File 'lib/dcmgr/node_modules/sta_collector.rb', line 33

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

#update_snapshot(snapshot_id, data) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/dcmgr/node_modules/sta_collector.rb', line 56

def update_snapshot(snapshot_id, data)
  vs = Dcmgr::Models::VolumeSnapshot[snapshot_id]
  vs.set(data).save
  if data[:state] == :deleted
    # VolumeSnapshot#destroy do not really delete row.
    # just for chain react destroy hooks in the associated models.
    vs.destroy
  end
  # do not respond model object.
  nil
end

#update_volume(volume_id, data) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/dcmgr/node_modules/sta_collector.rb', line 43

def update_volume(volume_id, data)
  v = Dcmgr::Models::Volume[volume_id]
  v.set(data).save
  if data[:state] == :deleted
    # Volume#destroy do not really delete row.
    # just for chain react destroy hooks in the associated models.
    v.destroy
  end

  # do not respond model object.
  nil
end