Class: Uricp::Strategy::RbdSnap
- Inherits:
-
Object
- Object
- Uricp::Strategy::RbdSnap
show all
- Includes:
- CacheCommon, Common
- Defined in:
- lib/uricp/strategy/rbd_snap.rb
Constant Summary
Constants included
from Common
Common::DRY_SNAP, Common::PIPE_URI
Instance Attribute Summary
Attributes included from Common
#proposed_options
#options
Instance Method Summary
collapse
#cache_exists?, #cache_file, #cache_name, #cache_root, #in_cache?, #temp_cache_file, #temp_cache_uri, #validate_cache!, #with_active_cache, #without_active_cache
Methods included from Common
#all_local_files?, #always_write_sparse?, #compression_required?, #conversion_required?, #dry_run?, #encoding, #file_source?, #format_change?, #get_temp_filename, #in_rbd_cache, #in_rbd_cache?, #initialize, #lz4?, #lz4_source?, #not_in_rbd_cache?, #proposed_path, #qcow2?, #raw_target?, #rbd_base_name, #rbd_cache_image_exists?, #rbd_cache_image_spec, #rbd_cache_name, #rbd_cache_upload_available?, #rbd_clone_snapshot, #rbd_id, #rbd_image_spec, #rbd_sequence_complete?, #rbd_snapshot_name, #rbd_snapshot_spec?, #rbd_uri, #segmented?, #sequence_complete?, #supported_source?, #temp_uri, #unsupported_transfer
#authentication, #curl_command, #curl_download_to_pipe, #curl_manifest, #curl_upload_from, #from, #from=, #http_authentication?, #to, #to=
Instance Method Details
#appropriate? ⇒ Boolean
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/uricp/strategy/rbd_snap.rb', line 7
def appropriate?
without_active_cache do
if from.scheme == 'rbd' &&
options['rbd_snapshot'].nil? &&
!rbd_snapshot_spec?(from) &&
(rbd_cache_name.nil? ||
!from.path.include?(rbd_cache_name))
if snap_in_progress?
debug "#{self.class.name}: detected snapshot in progress"
else
return proposal unless sequence_complete?
end
end
end
debug "#{self.class.name}: not appropriate"
false
end
|
#command ⇒ Object
25
26
27
28
|
# File 'lib/uricp/strategy/rbd_snap.rb', line 25
def command
"rbd snap create --id #{rbd_id} '#{rbd_upload_snapshot(from)}';" \
"rbd snap protect --id #{rbd_id} '#{rbd_upload_snapshot(from)}';" \
end
|
#proposal ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/uricp/strategy/rbd_snap.rb', line 30
def proposal
@proposed_options = options.dup
@proposed_options['from_uri'] = rbd_uri(rbd_upload_snapshot(from))
if options['rbd_cache_target']
@proposed_options['to_uri'] = options['rbd_cache_target']
@proposed_options['rbd_cache_target'] = to
else
@proposed_options['rbd_snapshot'] = rbd_upload_snapshot(from) unless to.scheme == 'rbd'
end
self
end
|
#rbd_upload_snapshot(uri) ⇒ Object
42
43
44
|
# File 'lib/uricp/strategy/rbd_snap.rb', line 42
def rbd_upload_snapshot(uri)
"#{rbd_image_spec(uri)}@#{rbd_snapshot_name}"
end
|
#snap_in_progress? ⇒ Boolean
46
47
48
49
50
51
52
53
54
|
# File 'lib/uricp/strategy/rbd_snap.rb', line 46
def snap_in_progress?
return false if dry_run?
result = false
sh "rbd snap ls --id #{rbd_id} --format json #{rbd_image_spec(from)} 2>/dev/null" do |stdout|
result = JSON.parse(stdout).any? { |x| x['name'] == rbd_snapshot_name }
end
result
end
|