uricp 0.0.22 → 0.0.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/bin/uricp +2 -2
- data/features/rbd_access.feature +34 -4
- data/lib/uricp/strategy/cache_common.rb +1 -1
- data/lib/uricp/strategy/common.rb +16 -1
- data/lib/uricp/strategy/piped_cache.rb +4 -2
- data/lib/uricp/strategy/rbd_cache_clone.rb +1 -2
- data/lib/uricp/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f12b0071b707cd164565e756677d620c77aa4433161b28b4e2aed90e764f2e68
|
4
|
+
data.tar.gz: 2a226104ffad1d51b15e6a9ea015d94e058ff7728e66d3f0c708092e1764205b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 420a3273588f2fde0d78b12250be89b0c07fc0f82d9e4101c427780f871f021bba870ff88b14d5adf3dd9ed0c599a944474137040e8ea2f07aaadd326fa6eccc
|
7
|
+
data.tar.gz: 6cba1806fed37f14d5dad8402061f639f9d6e32df79caf66bd06c2bbabcbd68d460b71710ba76f676967301a1b878129b8b92bd7796f697f8159cc9a65da3c89
|
data/Gemfile.lock
CHANGED
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("--
|
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
|
data/features/rbd_access.feature
CHANGED
@@ -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
|
-
|
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
|
"""
|
@@ -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
|
-
|
28
|
-
|
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
|
-
|
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
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.
|
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-
|
11
|
+
date: 2021-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|