Sha256: 439d3898953b83712df0153d3e8d826ff6a1ace2f827b97366f585a2c5cbe06f
Contents?: true
Size: 1.61 KB
Versions: 1
Compression:
Stored size: 1.61 KB
Contents
require 'json' module Uricp::Strategy class RbdSnap include Uricp::Strategy::Common include Uricp::Strategy::CacheCommon 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['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 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)} 2>/dev/null" 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.24 | lib/uricp/strategy/rbd_snap.rb |