Class: Dcmgr::Models::VolumeSnapshot
- Inherits:
-
AccountResource
- Object
- Sequel::Model
- BaseNew
- AccountResource
- Dcmgr::Models::VolumeSnapshot
- Defined in:
- lib/dcmgr/models/volume_snapshot.rb
Defined Under Namespace
Classes: RequestError
Constant Summary collapse
- STATE_TYPE_REGISTERING =
"registering"
- STATE_TYPE_CREATING =
"creating"
- STATE_TYPE_AVAILABLE =
"available"
- STATE_TYPE_FAILED =
"failed"
- STATE_TYPE_DELETING =
"deleting"
- STATE_TYPE_DELETED =
"deleted"
Constants inherited from BaseNew
Class Method Summary collapse
Instance Method Summary collapse
-
#create_volume(account_id) ⇒ Object
create volume inherite from this snapshot for the account.
- #origin_volume ⇒ Object
-
#to_api_document ⇒ Object
Hash data for API response.
Methods inherited from AccountResource
Methods inherited from BaseNew
Proxy, dataset, install_data, install_data_hooks, lock!, unlock!
Class Method Details
.delete_snapshot(account_id, uuid) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/dcmgr/models/volume_snapshot.rb', line 51 def self.delete_snapshot(account_id, uuid) vs = self.dataset.where(:account_id => account_id).where(:uuid => uuid.split('-').last).first if vs.state.to_sym != :available raise RequestError, "invalid delete request" end vs.state = :deleting vs.save_changes end |
Instance Method Details
#create_volume(account_id) ⇒ Object
create volume inherite from this snapshot for the account. limitation: inherit volume is created on same storage_pool.
43 44 45 |
# File 'lib/dcmgr/models/volume_snapshot.rb', line 43 def create_volume(account_id) storage_pool.create_volume(account_id, self.size, self.canonical_uuid) end |
#origin_volume ⇒ Object
47 48 49 |
# File 'lib/dcmgr/models/volume_snapshot.rb', line 47 def origin_volume Volume[origin_volume_id] end |
#to_api_document ⇒ Object
Hash data for API response.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dcmgr/models/volume_snapshot.rb', line 30 def to_api_document h = { :id => self.canonical_uuid, :uuid => self.canonical_uuid, :state => self.state, :size => self.size, :origin_volume_id => self.origin_volume_id, :created_at => self.created_at, } end |