1 2 3 4 5 6 7 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 44
|
require 'fog/openstack/volume/models/snapshot'
module Fog
module OpenStack
class Volume
class V3
class Snapshot < Fog::OpenStack::Volume::Snapshot
identity :id
attribute :name
attribute :status
attribute :description
attribute :metadata
attribute :force
attribute :size
def save
requires :name
data = if id.nil?
service.create_snapshot(attributes[:volume_id], name, description, force)
else
service.update_snapshot(id, attributes.reject { |k, _v| k == :id })
end
merge_attributes(data.body['snapshot'])
true
end
def create
requires :name
# volume_id, name, description, force=false
response = service.create_snapshot(attributes[:volume_id],
attributes[:name],
attributes[:description],
attributes[:force])
merge_attributes(response.body['snapshot'])
self
end
end
end
end
end
end
|