class Uricp::Strategy::PipedRbdGet
Constants
- RBD_SNAPSHOT
Public Instance Methods
appropriate?()
click to toggle source
# File lib/uricp/strategy/piped_rbd_get.rb, line 7 def appropriate? case from.scheme when 'rbd' return proposal unless sequence_complete? || snap_in_progress? end debug "#{self.class.name}: not appropriate" false end
command()
click to toggle source
# File lib/uricp/strategy/piped_rbd_get.rb, line 16 def command "rbd snap create --id #{rbd_id} '#{rbd_snap_target(from)}' && " \ "rbd export --no-progress --id #{rbd_id} '#{rbd_snap_target(from)}' - |" end
proposal()
click to toggle source
# File lib/uricp/strategy/piped_rbd_get.rb, line 21 def proposal @proposed_options = options.dup @proposed_options['rbd_snapshot'] = rbd_snap_target(from) @proposed_options['from_uri'] = PIPE_URI @proposed_options.delete('cache') @proposed_options.delete('cache_name') self end
rbd_snap_target(uri)
click to toggle source
# File lib/uricp/strategy/piped_rbd_get.rb, line 32 def rbd_snap_target(uri) "#{rbd_target(uri)}@#{RBD_SNAPSHOT}" end
snap_in_progress?()
click to toggle source
# File lib/uricp/strategy/piped_rbd_get.rb, line 36 def snap_in_progress? return false if dry_run? result = false sh "rbd snap ls --id #{rbd_id} --format json #{rbd_target(from)}" do |stdout| result = JSON.parse(stdout).any? { |x| x['name'] == RBD_SNAPSHOT } end result end