lib/dcmgr/node_modules/sta_collector.rb in wakame-vdc-dcmgr-10.12.0 vs lib/dcmgr/node_modules/sta_collector.rb in wakame-vdc-dcmgr-11.06.0
- old
+ new
@@ -2,10 +2,11 @@
require 'isono'
module Dcmgr
module NodeModules
class StaCollector < Isono::NodeModules::Base
+ include Dcmgr::Logger
initialize_hook do
app = Isono::Rack::ObjectMethod.new(myinstance)
rpc = Isono::NodeModules::RpcChannel.new(node)
rpc.register_endpoint('sta-collector', Isono::Rack.build do
@@ -19,52 +20,28 @@
terminate_hook do
end
def get_volume(volume_id)
- Models::Volume.lock!
v = Dcmgr::Models::Volume[volume_id]
v.merge_pool_data
end
def get_snapshot(snapshot_id)
- Models::VolumeSnapshot.lock!
vs = Dcmgr::Models::VolumeSnapshot[snapshot_id]
vs.to_hash
end
- 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
+ def update_volume(volume_id, data)
+ v = Dcmgr::Models::Volume[volume_id]
+ v.set(data).save
# do not respond model object.
nil
end
- def update_snapshot(data)
- Models::VolumeSnapshot.lock!
- vs = Dcmgr::Models::VolumeSnapshot[data[:snapshot_id]]
- vs.set_fields(data, [:state]).save
+ def update_snapshot(snapshot_id, data)
+ vs = Dcmgr::Models::VolumeSnapshot[snapshot_id]
+ vs.set(data).save
# do not respond model object.
nil
end
end
end