uricp 0.0.27 → 0.0.30

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2bdc788caae911b8877f44865af0a39419c96148ca47ee2536b04d2de1630fc1
4
- data.tar.gz: 0f2ae7d75bb93abc8f3eff7437eb82552fa39ef7c9ddfadd7f197f775071519d
3
+ metadata.gz: a10697c8ebadc4cb158670335272b8b4b4681aac70182c95a6dd2b842587d61a
4
+ data.tar.gz: a07ca44d72030583442c8e572754aa164498fc8dce625dfde001e107a02b3533
5
5
  SHA512:
6
- metadata.gz: 77528ea35b99174312d1bdf1aa73ec5d9e53aa1c432dfde4cf9c720c35c093746f5289a3e558c46dff05a39d5efb1a248ec71b6ae6d66192f3e52c420d5ccde1
7
- data.tar.gz: 97fc3ada66b80f66374b46d03302f37459d937d31ab5c15ecb3f4ab4f0dd3856031f168ba2f804a199d18e7df31227bc6145d94e263e75c687fa6f73f2306a1c
6
+ metadata.gz: 35a87e4afe346283df0838e50c8a57b28893e7841582917ef11ee0eee76b20a0f52941616e78cef35c3b7d8d0ab2db5978d5c4cd338054e36bafabee50d12a82
7
+ data.tar.gz: fd3c6fda3b1624519abd26dd6bc8a54bda4d615ec098d1fb37cf279ab12640c643323b499f25e1fc811d9a2400fea59c55c4a2f1bcbe8c9ba90c629b73fb1775
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- uricp (0.0.27)
4
+ uricp (0.0.30)
5
5
  childprocess (~> 1.0)
6
6
  filesize (= 0.0.2)
7
7
  methadone (~> 2.0.2)
@@ -3,11 +3,11 @@ MAINTAINER support@brightbox.co.uk
3
3
 
4
4
  RUN echo "gem: --no-ri --no-rdoc" >> "$HOME/.gemrc"
5
5
  RUN dnf -y install dnf-plugins-core
6
- RUN dnf config-manager --add-repo https://repo.almalinux.org/almalinux/8.4/devel/almalinux-devel.repo
6
+ RUN dnf config-manager --add-repo https://repo.almalinux.org/almalinux/8/devel/almalinux-devel.repo
7
+ RUN echo "8-stream" > /etc/dnf/vars/stream
7
8
  RUN dnf -y update
8
9
  RUN dnf config-manager --set-enabled powertools,devel
9
10
  RUN dnf -y group install "Development Tools"
10
- RUN dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
11
11
  RUN dnf -y install https://www.rdoproject.org/repos/rdo-release.el8.rpm
12
12
  RUN dnf -y install \
13
13
  git \
@@ -32,7 +32,7 @@ Feature: Manipulate file images in ceph
32
32
  """
33
33
  And the output should contain:
34
34
  """
35
- rbd clone --id libvirt 'servers/freedos.qcow2@base' 'servers/srv-testy'
35
+ rbd clone --id libvirt 'servers/freedos.qcow2@base' 'servers/srv-testy' || { [ $? -eq 22 ] && rbd create --id libvirt -s 0 'servers/srv-testy'; };
36
36
  """
37
37
 
38
38
  Scenario: HTTP URI from file cache via unpopulated rbd cache
@@ -246,3 +246,55 @@ Feature: Manipulate file images in ceph
246
246
  """
247
247
  rbd snap protect --id libvirt 'servers/img-testy@base'
248
248
  """
249
+
250
+ Scenario: RBD export and upload to HTTPS
251
+ Given a correctly initialised cache at "/tmp/uricp"
252
+ When I successfully run `uricp --dry-run --auth-token 'd75945e3b9159f1f14e91b2022bc53ea10481ed15e4a' --target-format 'raw' --compress --segment-size '1073741824B' --cache '/var/cache/domtrix' rbd:/servers/vol-yd63x https://orbit.gb1s.brightbox.com/v1/acc-8tgbq/images/img-cfwe0`
253
+ And the output should contain:
254
+ """
255
+ rbd snap create --id libvirt 'servers/vol-yd63x@uricp_snap'
256
+ """
257
+ And the output should contain:
258
+ """
259
+ rbd snap protect --id libvirt 'servers/vol-yd63x@uricp_snap'
260
+ """
261
+ And the output should not contain:
262
+ """
263
+ rbd snap unprotect --id libvirt 'servers/vol-yd63x@uricp_snap'
264
+ """
265
+ And the output should not contain:
266
+ """
267
+ rbd snap rm --id libvirt 'servers/vol-yd63x@uricp_snap'
268
+ """
269
+ And the output should not contain:
270
+ """
271
+ rbd export --no-progress --id libvirt 'servers/vol-yd63x@uricp_snap' -
272
+ """
273
+ And the output should contain:
274
+ """
275
+ rbd clone --id libvirt 'servers/vol-yd63x@uricp_snap' 'servers/img-cfwe0'
276
+ """
277
+ And the output should contain:
278
+ """
279
+ rbd export --no-progress --id libvirt 'servers/img-cfwe0@base' -
280
+ """
281
+ And the output should contain:
282
+ """
283
+ rbd snap create --id libvirt 'servers/img-cfwe0@base'
284
+ """
285
+ And the output should contain:
286
+ """
287
+ rbd snap protect --id libvirt 'servers/img-cfwe0@base'
288
+ """
289
+ And the output should contain:
290
+ """
291
+ rbd export --no-progress --id libvirt 'servers/img-cfwe0@base' -
292
+ """
293
+ And the output should contain:
294
+ """
295
+ lz4
296
+ """
297
+ And the output should contain:
298
+ """
299
+ segment_upload --segment-size '1073741824.00 B' https://orbit.gb1s.brightbox.com/v1/acc-8tgbq/images/img-cfwe0
300
+ """
@@ -6,6 +6,8 @@ module Uricp::Strategy
6
6
  include Uricp::CurlPrimitives
7
7
  include Methadone::SH
8
8
 
9
+ VOL_REGEX = /^(srv|vol)-.....$/
10
+
9
11
  def initialize(options)
10
12
  @options = options
11
13
  debug "#{self.class.name}: options are #{options.inspect}"
@@ -168,7 +170,7 @@ module Uricp::Strategy
168
170
  def rbd_cache_image_exists?(target)
169
171
  command = "rbd status --id #{rbd_id} --format json #{target} 2>/dev/null"
170
172
  if dry_run?
171
- if options['dry-cache'] == :partial_rbd && options['cache_name'] !~ /srv-...../
173
+ if options['dry-cache'] == :partial_rbd && options['cache_name'] !~ VOL_REGEX
172
174
  command = 'exit 0'
173
175
  else
174
176
  command = 'exit 2'
@@ -180,15 +182,23 @@ module Uricp::Strategy
180
182
  false
181
183
  end
182
184
 
183
- def in_rbd_cache(target)
185
+ def snap_check(target, name)
184
186
  result = false
185
- if dry_run?
186
- result = options['dry-cache'] == :rbd && options['cache_name'] !~ /srv-...../
187
- else
188
- sh "rbd snap ls --id #{rbd_id} --format json #{target} 2>/dev/null" do |stdout|
189
- result = JSON.parse(stdout).any? { |x| x['name'] == rbd_base_name }
190
- end
187
+ sh "rbd snap ls --id #{rbd_id} --format json #{target} 2>/dev/null" do |stdout|
188
+ result = JSON.parse(stdout).any? { |x| x['name'] == name }
191
189
  end
190
+ result
191
+ rescue Methadone::FailedCommandError
192
+ false
193
+ end
194
+
195
+ def in_rbd_cache(target)
196
+ result =
197
+ if dry_run?
198
+ options['dry-cache'] == :rbd && options['cache_name'] !~ VOL_REGEX
199
+ else
200
+ snap_check(target, rbd_base_name)
201
+ end
192
202
  result && rbd_clone_snapshot(target)
193
203
  end
194
204
  end
@@ -10,8 +10,10 @@ module Uricp::Strategy
10
10
  without_active_cache do
11
11
  if from.scheme == 'rbd' &&
12
12
  rbd_snapshot_spec?(from) &&
13
- to.scheme != 'rbd'
14
- return proposal unless sequence_complete?
13
+ to.scheme != 'rbd' &&
14
+ (!conversion_required? || raw_target?) &&
15
+ !sequence_complete?
16
+ return proposal
15
17
  end
16
18
  end
17
19
  debug "#{self.class.name}: not appropriate"
@@ -25,6 +27,7 @@ module Uricp::Strategy
25
27
  def proposal
26
28
  @proposed_options = options.dup
27
29
  @proposed_options['from_uri'] = PIPE_URI
30
+ @proposed_options.delete('target-format')
28
31
  self
29
32
  end
30
33
  end
@@ -17,8 +17,8 @@ module Uricp::Strategy
17
17
 
18
18
  def command
19
19
  "rbd clone --id #{rbd_id} '#{rbd_image_spec(from)}' "\
20
- "'#{rbd_image_spec(to)}' || [ $? -eq 22 ] && "\
21
- "rbd create --id #{rbd_id} -s 0 '#{rbd_image_spec(to)}';"
20
+ "'#{rbd_image_spec(to)}' || { [ $? -eq 22 ] && "\
21
+ "rbd create --id #{rbd_id} -s 0 '#{rbd_image_spec(to)}'; };"
22
22
  end
23
23
 
24
24
  def proposal
@@ -47,12 +47,7 @@ module Uricp::Strategy
47
47
 
48
48
  def snap_in_progress?
49
49
  return false if dry_run?
50
-
51
- result = false
52
- sh "rbd snap ls --id #{rbd_id} --format json #{rbd_image_spec(from)} 2>/dev/null" do |stdout|
53
- result = JSON.parse(stdout).any? { |x| x['name'] == rbd_snapshot_name }
54
- end
55
- result
50
+ snap_check(rbd_image_spec(from), rbd_snapshot_name)
56
51
  end
57
52
  end
58
53
  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.27'
4
+ VERSION = '0.0.30'
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.27
4
+ version: 0.0.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil Wilson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-15 00:00:00.000000000 Z
11
+ date: 2022-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aruba