Class: SnapshotsController

Inherits:
ApplicationController show all
Includes:
Util
Defined in:
app/controllers/snapshots_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/snapshots_controller.rb', line 8

def create
  volume_ids = params[:ids]
  response = []
  volume_ids.each do |volume_id|
    data = {
      :volume_id => volume_id
    }
    response << DcmgrResource::VolumeSnapshot.create(data)
  end
  render :json => response
end

#destroyObject



20
21
22
23
24
25
26
27
# File 'app/controllers/snapshots_controller.rb', line 20

def destroy
  snapshot_ids = params[:ids]
  response = []
  snapshot_ids.each do |snapshot_id|
    response << DcmgrResource::VolumeSnapshot.delete(snapshot_id)
  end
  render :json => response
end

#indexObject



5
6
# File 'app/controllers/snapshots_controller.rb', line 5

def index
end

#listObject



29
30
31
32
33
34
35
36
# File 'app/controllers/snapshots_controller.rb', line 29

def list
  data = {
    :start => params[:start].to_i - 1,
    :limit => params[:limit]
  }
  snapshots = DcmgrResource::VolumeSnapshot.list(data)
  respond_with(snapshots[0], :to => [:json])
end

#showObject



38
39
40
41
42
# File 'app/controllers/snapshots_controller.rb', line 38

def show
  snapshot_id = params[:id]
  detail = DcmgrResource::VolumeSnapshot.show(snapshot_id)
  respond_with(detail,:to => [:json])
end

#totalObject



44
45
46
47
# File 'app/controllers/snapshots_controller.rb', line 44

def total
 total_resource = DcmgrResource::VolumeSnapshot.total_resource
 render :json => total_resource
end