Class: Dcmgr::Models::VolumeSnapshot
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"
- RECENT_TERMED_PERIOD =
(60 * 15)
Constants inherited
from BaseNew
BaseNew::LOCK_TABLES_KEY
Class Method Summary
collapse
Instance Method Summary
collapse
#account
Methods inherited from BaseNew
Proxy, dataset, default_row_lock_mode=, install_data, install_data_hooks, lock!, #to_hash, unlock!, #with_timestamps?
Class Method Details
.delete_snapshot(account_id, uuid) ⇒ Object
68
69
70
71
72
73
74
75
|
# File 'lib/dcmgr/models/volume_snapshot.rb', line 68
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
|
.store_local?(destination) ⇒ Boolean
90
91
92
|
# File 'lib/dcmgr/models/volume_snapshot.rb', line 90
def self.store_local?(destination)
destination.nil?
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_node.
46
47
48
|
# File 'lib/dcmgr/models/volume_snapshot.rb', line 46
def create_volume(account_id)
storage_node.create_volume(account_id, self.size, self.canonical_uuid)
end
|
#delete ⇒ Object
override Sequel::Model#delete not to delete rows but to set delete flags.
79
80
81
82
83
|
# File 'lib/dcmgr/models/volume_snapshot.rb', line 79
def delete
self.state = :deleted if self.state != :deleted
self.deleted_at ||= Time.now
self.save
end
|
#destination ⇒ Object
64
65
66
|
# File 'lib/dcmgr/models/volume_snapshot.rb', line 64
def destination
self.destination_key.split('@')[0]
end
|
#display_name ⇒ Object
50
51
52
53
54
|
# File 'lib/dcmgr/models/volume_snapshot.rb', line 50
def display_name
repository_config = Dcmgr::StorageService.snapshot_repository_config
repository = repository_config[self.destination]
repository['display_name']
end
|
#origin_volume ⇒ Object
56
57
58
|
# File 'lib/dcmgr/models/volume_snapshot.rb', line 56
def origin_volume
Volume[origin_volume_id]
end
|
#snapshot_filename ⇒ Object
60
61
62
|
# File 'lib/dcmgr/models/volume_snapshot.rb', line 60
def snapshot_filename
"#{self.canonical_uuid}.snap"
end
|
#to_api_document ⇒ Object
Hash data for API response.
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/dcmgr/models/volume_snapshot.rb', line 29
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,
:destination_id => self.destination,
:destination_name => self.display_name,
:backing_store => self.storage_node.storage_type,
:created_at => self.created_at,
:deleted_at => self.deleted_at,
}
end
|
#update_destination_key(account_id, destination_key) ⇒ Object
85
86
87
88
|
# File 'lib/dcmgr/models/volume_snapshot.rb', line 85
def update_destination_key(account_id, destination_key)
self.destination_key = destination_key
self.save_changes
end
|