Sha256: 867a081c5ff1263c8fa6ea8365098e3c822e793ba6a141d176492d3f1a9a9864
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
require 'json' module Uricp::Strategy class PipedRbdGet include Uricp::Strategy::Common include Methadone::SH def appropriate? case from.scheme when 'rbd' return proposal unless sequence_complete? || snap_in_progress? end debug "#{self.class.name}: not appropriate" false end def command "rbd snap create --id #{rbd_id} '#{rbd_snap_target(from)}' && " \ "rbd export --no-progress --id #{rbd_id} '#{rbd_snap_target(from)}' - |" end 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_SNAPSHOT = 'uricp_snap'.freeze def rbd_snap_target(uri) "#{rbd_target(uri)}@#{RBD_SNAPSHOT}" end def snap_in_progress? return false if dry_run? sh "rbd snap ls --id #{rbd_id} --format json #{rbd_target(from)}" do |stdout| JSON.parse(stdout).any? { |x| x['name'] == RBD_SNAPSHOT } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
uricp-0.0.16 | lib/uricp/strategy/piped_rbd_get.rb |