Sha256: ad45ac404100765aa0fb3ea7a8801a60a75a8c1bab692f9f2f5d7f4fc887c639
Contents?: true
Size: 1.64 KB
Versions: 4
Compression:
Stored size: 1.64 KB
Contents
# frozen_string_literal: true 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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
uricp-0.0.28 | lib/uricp/strategy/rbd_snap.rb |
uricp-0.0.27 | lib/uricp/strategy/rbd_snap.rb |
uricp-0.0.26 | lib/uricp/strategy/rbd_snap.rb |
uricp-0.0.25 | lib/uricp/strategy/rbd_snap.rb |