uricp 0.0.22 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e1b637ff4ba7720c05496e44d43b9dbe71908bb8bf1605e7a64c2ed1497f273
4
- data.tar.gz: 037bd61ab71e9f18bd654779d6fe7049d42124f678737c5703e7a76eef9448df
3
+ metadata.gz: f12b0071b707cd164565e756677d620c77aa4433161b28b4e2aed90e764f2e68
4
+ data.tar.gz: 2a226104ffad1d51b15e6a9ea015d94e058ff7728e66d3f0c708092e1764205b
5
5
  SHA512:
6
- metadata.gz: d71cb3c6211690160d6a57130eff9b6ed3043f497ef9b182f1aefd9dbb378d186c16c7093e637f2ed718867d47f6e6a50059976440ece998f8c313facd701be8
7
- data.tar.gz: d7feeb5ab8fe6b98e6895d442f38c8404fcc12687dcc851485f6e38e640eb31cfe1bb0dfb2e0803d50261594e918e92034f1653f9ece0d457fea15f98cfbbd3a
6
+ metadata.gz: 420a3273588f2fde0d78b12250be89b0c07fc0f82d9e4101c427780f871f021bba870ff88b14d5adf3dd9ed0c599a944474137040e8ea2f07aaadd326fa6eccc
7
+ data.tar.gz: 6cba1806fed37f14d5dad8402061f639f9d6e32df79caf66bd06c2bbabcbd68d460b71710ba76f676967301a1b878129b8b92bd7796f697f8159cc9a65da3c89
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- uricp (0.0.22)
4
+ uricp (0.0.23)
5
5
  childprocess (~> 1.0)
6
6
  filesize (= 0.0.2)
7
7
  methadone (~> 2.0.2)
data/bin/uricp CHANGED
@@ -122,8 +122,8 @@ class App
122
122
  "Compress output")
123
123
  on("--[no-]dry-run",
124
124
  "Show what would be run,", "but don't run the command")
125
- on("--[no-]dry-cache",
126
- "On dry runs assume the cache is populated")
125
+ on("--dry-cache DRY_CACHE",[:rbd, :partial_rbd],
126
+ "On dry runs assume the cache is populated", "[rbd, partial_rbd]")
127
127
  on("--[no-]force",
128
128
  "Always write sparsely")
129
129
  #Arguments
@@ -56,9 +56,21 @@ Feature: Manipulate file images in ceph
56
56
  rbd clone --id libvirt 'servers/freedos.qcow2@base' 'servers/srv-testy'
57
57
  """
58
58
 
59
- Scenario: HTTP URI to rbd via populated caches
59
+ Scenario: HTTP URI to rbd via partial rbd caches
60
60
  Given a correctly initialised cache at "/tmp/uricp"
61
- When I successfully run `uricp --dry-run --dry-cache --target-format=raw --cache=/tmp/uricp http://orbit.brightbox.com/v1/acc-tqs4c/downloads/freedos.qcow2 rbd:///servers/srv-testy`
61
+ When I successfully run `uricp --dry-run --dry-cache=partial_rbd --target-format=raw --cache=/tmp/uricp http://orbit.brightbox.com/v1/acc-tqs4c/downloads/freedos.qcow2 rbd:///servers/srv-testy`
62
+ And the output should not contain:
63
+ """
64
+ snap create
65
+ """
66
+ And the output should contain:
67
+ """
68
+ rbd import --no-progress --id libvirt - 'servers/srv-testy'
69
+ """
70
+
71
+ Scenario: HTTP URI to rbd via populated cache
72
+ Given a correctly initialised cache at "/tmp/uricp"
73
+ When I successfully run `uricp --dry-run --dry-cache=rbd --target-format=raw --cache=/tmp/uricp http://orbit.brightbox.com/v1/acc-tqs4c/downloads/freedos.qcow2 rbd:///servers/srv-testy`
62
74
  And the output should not contain:
63
75
  """
64
76
  snap create
@@ -132,9 +144,18 @@ Feature: Manipulate file images in ceph
132
144
  rbd snap protect --id libvirt 'servers/img-testy@base'
133
145
  """
134
146
 
147
+ Scenario: rbd to rbd - partial cache
148
+ Given a correctly initialised cache at "/tmp/uricp"
149
+ When I run `uricp --dry-run --dry-cache=partial_rbd --cache=/tmp/uricp rbd:///servers/srv-testy rbd:///servers/img-testy`
150
+ Then the exit status should be 70
151
+ And the output should contain:
152
+ """
153
+ Unsupported transfer
154
+ """
155
+
135
156
  Scenario: rbd to rbd - populated cache
136
157
  Given a correctly initialised cache at "/tmp/uricp"
137
- When I successfully run `uricp --dry-run --dry-cache --cache=/tmp/uricp rbd:///servers/img-testy rbd:///servers/srv-testy`
158
+ When I successfully run `uricp --dry-run --dry-cache=rbd --cache=/tmp/uricp rbd:///servers/img-testy rbd:///servers/srv-testy`
138
159
  And the output should not contain:
139
160
  """
140
161
  snap create
@@ -170,7 +191,16 @@ Feature: Manipulate file images in ceph
170
191
 
171
192
  Scenario: RBD export with cacheing - populated cache
172
193
  Given a correctly initialised cache at "/tmp/uricp"
173
- When I run `uricp --dry-run --dry-cache --compress --cache=/tmp/uricp rbd:///servers/srv-testy file:///tmp/img-testy`
194
+ When I run `uricp --dry-run --dry-cache=rbd --compress --cache=/tmp/uricp rbd:///servers/srv-testy file:///tmp/img-testy`
195
+ Then the exit status should be 70
196
+ And the output should contain:
197
+ """
198
+ Unsupported transfer
199
+ """
200
+
201
+ Scenario: RBD export with cacheing - partial cache
202
+ Given a correctly initialised cache at "/tmp/uricp"
203
+ When I run `uricp --dry-run --dry-cache=partial_rbd --compress --cache=/tmp/uricp rbd:///servers/srv-testy file:///tmp/img-testy`
174
204
  Then the exit status should be 70
175
205
  And the output should contain:
176
206
  """
@@ -34,7 +34,7 @@ module Uricp::Strategy
34
34
  end
35
35
 
36
36
  def in_cache?
37
- File.readable?(cache_file) || options['dry-cache']
37
+ File.readable?(cache_file) || options['dry-cache'] == :rbd
38
38
  end
39
39
 
40
40
  def cache_root
@@ -158,10 +158,25 @@ module Uricp::Strategy
158
158
  uri.scheme == 'rbd' && uri.path.include?('@')
159
159
  end
160
160
 
161
+ def rbd_cache_image_exists?(target)
162
+ command = "rbd status --id #{rbd_id} --format json #{target} 2>/dev/null"
163
+ if dry_run?
164
+ if options['dry-cache'] == :partial_rbd && options['cache_name'] !~ /srv-...../
165
+ command = "exit 0"
166
+ else
167
+ command = "exit 2"
168
+ end
169
+ end
170
+ sh!(command)
171
+ true
172
+ rescue Methadone::FailedCommandError
173
+ false
174
+ end
175
+
161
176
  def in_rbd_cache(target)
162
177
  result = false
163
178
  if dry_run?
164
- result = options['dry-cache'] && options['cache_name'] !~ /srv-...../
179
+ result = options['dry-cache'] == :rbd && options['cache_name'] !~ /srv-...../
165
180
  else
166
181
  sh "rbd snap ls --id #{rbd_id} --format json #{target} 2>/dev/null" do |stdout|
167
182
  result = JSON.parse(stdout).any? { |x| x['name'] == rbd_base_name }
@@ -4,6 +4,7 @@ module Uricp::Strategy
4
4
  class PipedCache
5
5
  include Uricp::Strategy::Common
6
6
  include Uricp::Strategy::CacheCommon
7
+ include Methadone::SH
7
8
 
8
9
  def appropriate?
9
10
  with_active_cache do
@@ -24,8 +25,9 @@ module Uricp::Strategy
24
25
  def proposal
25
26
  @proposed_options = options.dup
26
27
  @proposed_options['sweep'] = [temp_cache_file, cache_file]
27
- if to.scheme == 'rbd'
28
- @proposed_options['rbd_cache_name'] = rbd_cache_image_spec(to)
28
+ image_spec_to_check = rbd_cache_image_spec(to)
29
+ if to.scheme == 'rbd' && !rbd_cache_image_exists?(image_spec_to_check)
30
+ @proposed_options['rbd_cache_name'] = image_spec_to_check
29
31
  end
30
32
  @proposed_options.delete('cache')
31
33
  @proposed_options.delete('cache_name')
@@ -15,8 +15,7 @@ module Uricp::Strategy
15
15
  with_active_cache do
16
16
  options['cache_name'] = File.basename(options['to_uri'].path)
17
17
  cache_target = rbd_cache_image_spec(from)
18
- cache_check = in_rbd_cache(rbd_cache_image_spec(from))
19
- if cache_check
18
+ if rbd_cache_image_exists?(cache_target) || in_rbd_cache(cache_target)
20
19
  debug "#{self.class.name}: Unexpected existing cache entry for #{options['to_uri']}"
21
20
  unsupported_transfer
22
21
  end
data/lib/uricp/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uricp
4
- VERSION = '0.0.22'
4
+ VERSION = '0.0.23'
5
5
  DEFAULT_SEGMENT_SIZE = '5 GiB'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uricp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil Wilson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-21 00:00:00.000000000 Z
11
+ date: 2021-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler