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!, unlock!, #with_timestamps?
Class Method Details
.delete_snapshot(account_id, uuid) ⇒ Object
78
79
80
81
82
83
84
85
|
# File 'lib/dcmgr/models/volume_snapshot.rb', line 78
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
92
93
94
|
# File 'lib/dcmgr/models/volume_snapshot.rb', line 92
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_pool.
56
57
58
|
# File 'lib/dcmgr/models/volume_snapshot.rb', line 56
def create_volume(account_id)
storage_pool.create_volume(account_id, self.size, self.canonical_uuid)
end
|
#destination ⇒ Object
74
75
76
|
# File 'lib/dcmgr/models/volume_snapshot.rb', line 74
def destination
self.destination_key.split('@')[0]
end
|
#display_name ⇒ Object
60
61
62
63
64
|
# File 'lib/dcmgr/models/volume_snapshot.rb', line 60
def display_name
repository_config = Dcmgr::StorageService.snapshot_repository_config
repository = repository_config[self.destination]
repository['display_name']
end
|
#origin_volume ⇒ Object
66
67
68
|
# File 'lib/dcmgr/models/volume_snapshot.rb', line 66
def origin_volume
Volume[origin_volume_id]
end
|
#snapshot_filename ⇒ Object
70
71
72
|
# File 'lib/dcmgr/models/volume_snapshot.rb', line 70
def snapshot_filename
"#{self.canonical_uuid}.zsnap"
end
|
#to_api_document ⇒ Object
Hash data for API response.
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/dcmgr/models/volume_snapshot.rb', line 40
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,
:created_at => self.created_at,
:deleted_at => self.deleted_at,
}
end
|
#update_destination_key(account_id, destination_key) ⇒ Object
87
88
89
90
|
# File 'lib/dcmgr/models/volume_snapshot.rb', line 87
def update_destination_key(account_id, destination_key)
self.destination_key = destination_key
self.save_changes
end
|