Sha256: 3d5e27dbe66ba4f3c778999e1cc5183a973290d9bf08eeb932180ae17663f870
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
require 'json' module Uricp::Strategy class RbdSnap include Uricp::Strategy::Common include Uricp::Strategy::CacheCommon include Methadone::SH 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 def command "rbd snap create --id #{rbd_id} '#{rbd_upload_snapshot(from)}' && " \ "rbd snap protect --id #{rbd_id} '#{rbd_upload_snapshot(from)}' && " \ end def proposal @proposed_options = options.dup @proposed_options['rbd_snapshot'] = rbd_upload_snapshot(from) @proposed_options['from_uri'] = rbd_uri(@proposed_options['rbd_snapshot']) if options['rbd_cache_target'] @proposed_options['to_uri'] = options['rbd_cache_target'] @proposed_options['rbd_cache_target'] = to end self end def rbd_upload_snapshot(uri) "#{rbd_image_spec(uri)}@#{rbd_snapshot_name}" end def snap_in_progress? return false if dry_run? result = false sh "rbd snap ls --id #{rbd_id} --format json #{rbd_image_spec(from)}" do |stdout| result = JSON.parse(stdout).any? { |x| x['name'] == rbd_snapshot_name } end result end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
uricp-0.0.20 | lib/uricp/strategy/rbd_snap.rb |