uricp 0.0.15 → 0.0.16
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 +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile.lock +1 -8
- data/Jenkinsfile +27 -0
- data/Rakefile +19 -36
- data/bionic/Dockerfile +2 -2
- data/centos7/Dockerfile +2 -2
- data/features/step_definitions/orbit_steps.rb +11 -4
- data/lib/segment_upload.rb +20 -22
- data/lib/uricp.rb +3 -3
- data/lib/uricp/curl_primitives.rb +31 -33
- data/lib/uricp/orbit_auth.rb +23 -27
- data/lib/uricp/segmenter.rb +12 -16
- data/lib/uricp/strategy/cache_common.rb +11 -11
- data/lib/uricp/strategy/cached_get.rb +14 -20
- data/lib/uricp/strategy/cleaner.rb +2 -8
- data/lib/uricp/strategy/common.rb +25 -18
- data/lib/uricp/strategy/local_convert.rb +9 -16
- data/lib/uricp/strategy/local_link.rb +10 -8
- data/lib/uricp/strategy/piped_cache.rb +7 -13
- data/lib/uricp/strategy/piped_cache_convert.rb +14 -18
- data/lib/uricp/strategy/piped_compress.rb +3 -8
- data/lib/uricp/strategy/piped_decompress.rb +7 -11
- data/lib/uricp/strategy/piped_local_compress.rb +0 -4
- data/lib/uricp/strategy/piped_local_decompress.rb +10 -16
- data/lib/uricp/strategy/piped_local_get.rb +0 -5
- data/lib/uricp/strategy/piped_local_put.rb +3 -9
- data/lib/uricp/strategy/piped_rbd_get.rb +44 -0
- data/lib/uricp/strategy/piped_remote_get.rb +20 -20
- data/lib/uricp/strategy/rbd_remote_put.rb +36 -0
- data/lib/uricp/strategy/rbd_sweeper.rb +22 -0
- data/lib/uricp/strategy/remote_put.rb +11 -17
- data/lib/uricp/strategy/segmented_remote_put.rb +16 -28
- data/lib/uricp/strategy/sweeper.rb +2 -8
- data/lib/uricp/uri_strategy.rb +14 -13
- data/lib/uricp/version.rb +2 -2
- data/trusty/Dockerfile +2 -2
- data/uricp.gemspec +0 -1
- data/xenial/Dockerfile +2 -2
- metadata +7 -20
- data/spec/something_spec.rb +0 -5
@@ -1,30 +1,25 @@
|
|
1
1
|
module Uricp::Strategy
|
2
|
-
|
3
2
|
class PipedCompress
|
4
|
-
|
5
3
|
include Uricp::Strategy::Common
|
6
4
|
|
7
|
-
|
8
5
|
def appropriate?
|
9
6
|
case from.scheme
|
10
7
|
when 'pipe'
|
11
|
-
|
8
|
+
return proposal if compression_required?
|
12
9
|
end
|
13
10
|
debug "#{self.class.name}: not appropriate"
|
14
11
|
false
|
15
12
|
end
|
16
13
|
|
17
14
|
def command
|
18
|
-
|
15
|
+
'lz4 |'
|
19
16
|
end
|
20
17
|
|
21
18
|
def proposal
|
22
19
|
@proposed_options = options.dup
|
23
20
|
@proposed_options.delete('compress')
|
24
|
-
@proposed_options['encoding']='lz4'
|
21
|
+
@proposed_options['encoding'] = 'lz4'
|
25
22
|
self
|
26
23
|
end
|
27
|
-
|
28
24
|
end
|
29
|
-
|
30
25
|
end
|
@@ -1,35 +1,31 @@
|
|
1
1
|
module Uricp::Strategy
|
2
|
-
|
3
2
|
class PipedDecompress
|
4
|
-
|
5
3
|
include Uricp::Strategy::Common
|
6
4
|
|
7
5
|
def appropriate?
|
8
6
|
case from.scheme
|
9
7
|
when 'pipe'
|
10
|
-
|
8
|
+
return proposal if lz4_source?
|
11
9
|
end
|
12
10
|
debug "#{self.class.name}: not appropriate"
|
13
11
|
false
|
14
12
|
end
|
15
13
|
|
16
14
|
def command
|
17
|
-
|
15
|
+
'lz4 -d |'
|
18
16
|
end
|
19
17
|
|
20
18
|
def proposal
|
21
19
|
@proposed_options = options.dup
|
22
20
|
@proposed_options.delete('source-format')
|
23
21
|
if @proposed_options['target-format']
|
24
|
-
|
25
|
-
if @proposed_options['source-format'] == @proposed_options['target-format']
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
@proposed_options['source-format'] = :raw
|
23
|
+
if @proposed_options['source-format'] == @proposed_options['target-format']
|
24
|
+
@proposed_options.delete('source-format')
|
25
|
+
@proposed_options.delete('target-format')
|
26
|
+
end
|
29
27
|
end
|
30
28
|
self
|
31
29
|
end
|
32
|
-
|
33
30
|
end
|
34
|
-
|
35
31
|
end
|
@@ -1,19 +1,15 @@
|
|
1
1
|
module Uricp::Strategy
|
2
|
-
|
3
2
|
class PipedLocalDecompress
|
4
|
-
|
5
3
|
include Uricp::Strategy::Common
|
6
4
|
|
7
5
|
def appropriate?
|
8
6
|
case from.scheme
|
9
7
|
when 'pipe'
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
8
|
+
if raw_target? && lz4_source? && to.scheme == 'file'
|
9
|
+
return proposal if always_write_sparse?
|
10
|
+
|
11
|
+
debug "#{self.class.name}: using safe sparse expansion via stream"
|
12
|
+
end
|
17
13
|
end
|
18
14
|
debug "#{self.class.name}: not appropriate"
|
19
15
|
false
|
@@ -27,16 +23,14 @@ module Uricp::Strategy
|
|
27
23
|
@proposed_options = options.dup
|
28
24
|
@proposed_options.delete('source-format')
|
29
25
|
if @proposed_options['target-format']
|
30
|
-
|
31
|
-
if @proposed_options['source-format'] == @proposed_options['target-format']
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
@proposed_options['source-format'] = :raw
|
27
|
+
if @proposed_options['source-format'] == @proposed_options['target-format']
|
28
|
+
@proposed_options.delete('source-format')
|
29
|
+
@proposed_options.delete('target-format')
|
30
|
+
end
|
35
31
|
end
|
36
32
|
@proposed_options['from_uri'] = @proposed_options['to_uri']
|
37
33
|
self
|
38
34
|
end
|
39
|
-
|
40
35
|
end
|
41
|
-
|
42
36
|
end
|
@@ -1,14 +1,11 @@
|
|
1
1
|
module Uricp::Strategy
|
2
|
-
|
3
2
|
class PipedLocalPut
|
4
|
-
|
5
3
|
include Uricp::Strategy::Common
|
6
4
|
|
7
5
|
def appropriate?
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
6
|
+
return proposal if to.scheme == 'file' &&
|
7
|
+
from.scheme == 'pipe'
|
8
|
+
|
12
9
|
debug "#{self.class.name}: not appropriate"
|
13
10
|
false
|
14
11
|
end
|
@@ -22,8 +19,5 @@ module Uricp::Strategy
|
|
22
19
|
@proposed_options['from_uri'] = @proposed_options['to_uri']
|
23
20
|
self
|
24
21
|
end
|
25
|
-
|
26
22
|
end
|
27
|
-
|
28
23
|
end
|
29
|
-
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'json'
|
2
|
+
module Uricp::Strategy
|
3
|
+
class PipedRbdGet
|
4
|
+
include Uricp::Strategy::Common
|
5
|
+
include Methadone::SH
|
6
|
+
|
7
|
+
def appropriate?
|
8
|
+
case from.scheme
|
9
|
+
when 'rbd'
|
10
|
+
return proposal unless sequence_complete? || snap_in_progress?
|
11
|
+
end
|
12
|
+
debug "#{self.class.name}: not appropriate"
|
13
|
+
false
|
14
|
+
end
|
15
|
+
|
16
|
+
def command
|
17
|
+
"rbd snap create --id #{rbd_id} '#{rbd_snap_target(from)}' && " \
|
18
|
+
"rbd export --no-progress --id #{rbd_id} '#{rbd_snap_target(from)}' - |"
|
19
|
+
end
|
20
|
+
|
21
|
+
def proposal
|
22
|
+
@proposed_options = options.dup
|
23
|
+
@proposed_options['rbd_snapshot'] = rbd_snap_target(from)
|
24
|
+
@proposed_options['from_uri'] = PIPE_URI
|
25
|
+
@proposed_options.delete('cache')
|
26
|
+
@proposed_options.delete('cache_name')
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
RBD_SNAPSHOT = 'uricp_snap'.freeze
|
31
|
+
|
32
|
+
def rbd_snap_target(uri)
|
33
|
+
"#{rbd_target(uri)}@#{RBD_SNAPSHOT}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def snap_in_progress?
|
37
|
+
return false if dry_run?
|
38
|
+
|
39
|
+
sh "rbd snap ls --id #{rbd_id} --format json #{rbd_target(from)}" do |stdout|
|
40
|
+
JSON.parse(stdout).any? { |x| x['name'] == RBD_SNAPSHOT }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'open-uri'
|
2
2
|
module Uricp::Strategy
|
3
|
-
|
4
3
|
class PipedRemoteGet
|
5
|
-
|
6
4
|
include Uricp::Strategy::Common
|
7
5
|
|
8
6
|
def appropriate?
|
@@ -10,33 +8,35 @@ module Uricp::Strategy
|
|
10
8
|
when 'http', 'https'
|
11
9
|
return proposal unless sequence_complete?
|
12
10
|
else
|
13
|
-
|
14
|
-
|
11
|
+
debug "#{self.class.name}: not appropriate"
|
12
|
+
false
|
15
13
|
end
|
16
14
|
end
|
17
15
|
|
18
|
-
alias
|
16
|
+
alias command curl_download_to_pipe
|
19
17
|
|
20
18
|
def proposal
|
21
19
|
@proposed_options = options.dup
|
22
20
|
@proposed_options['from_uri'] = PIPE_URI
|
23
21
|
if conversion_required?
|
24
22
|
@proposed_options['source-format'] = format_peek
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
if @proposed_options['source-format'] == @proposed_options['target-format']
|
24
|
+
@proposed_options.delete('source-format')
|
25
|
+
@proposed_options.delete('target-format')
|
26
|
+
end
|
29
27
|
end
|
30
28
|
if options['max-cache'] &&
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
size_peek.to_i > options['max-cache'].to_i
|
30
|
+
@proposed_options.delete('cache')
|
31
|
+
@proposed_options.delete('cache_name')
|
32
|
+
@proposed_options.delete('max-cache')
|
35
33
|
end
|
36
34
|
self
|
37
35
|
end
|
38
36
|
|
39
37
|
def format_peek
|
38
|
+
return options['target-format'] || 'raw' if dry_run?
|
39
|
+
|
40
40
|
options['from_uri'].open(headers) do |u|
|
41
41
|
encoding(u)
|
42
42
|
end
|
@@ -48,14 +48,16 @@ module Uricp::Strategy
|
|
48
48
|
raise
|
49
49
|
end
|
50
50
|
rescue SocketError => e
|
51
|
-
raise SocketError, options['from_uri'].to_s+
|
51
|
+
raise SocketError, options['from_uri'].to_s + ' inaccessible: ' + e.message
|
52
52
|
end
|
53
53
|
|
54
54
|
def size_peek
|
55
|
-
|
55
|
+
return options['max-cache'] if dry_run?
|
56
|
+
|
57
|
+
size_headers = headers
|
56
58
|
size_headers['Range'] = 'bytes=0-0'
|
57
59
|
options['from_uri'].open(headers) do |u|
|
58
|
-
|
60
|
+
match = %r{bytes\s+(\d+)-(\d+)/(\d+|\*)}i.match(u.meta['content-range'])
|
59
61
|
match && match[3].to_i
|
60
62
|
end
|
61
63
|
rescue OpenURI::HTTPError => e
|
@@ -66,15 +68,13 @@ module Uricp::Strategy
|
|
66
68
|
raise
|
67
69
|
end
|
68
70
|
rescue SocketError => e
|
69
|
-
raise SocketError, options['from_uri'].to_s+
|
71
|
+
raise SocketError, options['from_uri'].to_s + ' inaccessible: ' + e.message
|
70
72
|
end
|
71
73
|
|
72
74
|
def headers
|
73
|
-
headers={'Range' => 'bytes=0-7'}
|
75
|
+
headers = { 'Range' => 'bytes=0-7' }
|
74
76
|
headers['X-Auth-Token'] = options['authenticator'].call if http_authentication?
|
75
77
|
headers
|
76
78
|
end
|
77
|
-
|
78
79
|
end
|
79
|
-
|
80
80
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Uricp::Strategy
|
2
|
+
class RbdRemotePut
|
3
|
+
include Uricp::Strategy::Common
|
4
|
+
|
5
|
+
def appropriate?
|
6
|
+
if compression_required? || conversion_required?
|
7
|
+
debug "#{self.class.name}: not ready to upload"
|
8
|
+
return false
|
9
|
+
end
|
10
|
+
case from.scheme
|
11
|
+
when 'pipe', 'file'
|
12
|
+
return proposal if to.scheme == 'rbd'
|
13
|
+
end
|
14
|
+
debug "#{self.class.name}: not appropriate"
|
15
|
+
false
|
16
|
+
end
|
17
|
+
|
18
|
+
def command
|
19
|
+
"rbd import --no-progress --id #{rbd_id} #{data_source} '#{rbd_target(to)}';"
|
20
|
+
end
|
21
|
+
|
22
|
+
def proposal
|
23
|
+
@proposed_options = options.dup
|
24
|
+
@proposed_options['from_uri'] = to
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
def data_source
|
29
|
+
if from.scheme == 'pipe'
|
30
|
+
'-'
|
31
|
+
else
|
32
|
+
"'#{from.path}'"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Uricp::Strategy
|
2
|
+
class RbdSweeper
|
3
|
+
include Uricp::Strategy::Common
|
4
|
+
|
5
|
+
def appropriate?
|
6
|
+
return proposal if options['rbd_snapshot'] && sequence_complete?
|
7
|
+
|
8
|
+
debug "#{self.class.name}: not appropriate"
|
9
|
+
false
|
10
|
+
end
|
11
|
+
|
12
|
+
def command
|
13
|
+
"rbd snap rm --id #{rbd_id} '#{options['rbd_snapshot']}';"
|
14
|
+
end
|
15
|
+
|
16
|
+
def proposal
|
17
|
+
@proposed_options = options.dup
|
18
|
+
@proposed_options.delete('rbd_snapshot')
|
19
|
+
self
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,26 +1,22 @@
|
|
1
1
|
module Uricp::Strategy
|
2
|
-
|
3
2
|
class RemotePut
|
4
|
-
|
5
3
|
include Uricp::Strategy::Common
|
6
4
|
|
7
5
|
def appropriate?
|
8
6
|
if compression_required? || conversion_required?
|
9
7
|
debug "#{self.class.name}: not ready to upload"
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
22
|
-
debug "#{self.class.name}: not appropriate"
|
8
|
+
return false
|
9
|
+
end
|
10
|
+
case to.scheme
|
11
|
+
when 'http', 'https'
|
12
|
+
case from.scheme
|
13
|
+
when 'file', 'pipe'
|
14
|
+
return proposal if http_authentication?
|
15
|
+
|
16
|
+
unsupported_transfer
|
17
|
+
end
|
23
18
|
end
|
19
|
+
debug "#{self.class.name}: not appropriate"
|
24
20
|
false
|
25
21
|
end
|
26
22
|
|
@@ -41,7 +37,5 @@ module Uricp::Strategy
|
|
41
37
|
from.path
|
42
38
|
end
|
43
39
|
end
|
44
|
-
|
45
40
|
end
|
46
|
-
|
47
41
|
end
|
@@ -1,35 +1,29 @@
|
|
1
1
|
module Uricp::Strategy
|
2
|
-
|
3
2
|
class SegmentedRemotePut
|
4
|
-
|
5
3
|
include Uricp::Strategy::Common
|
6
4
|
|
7
5
|
def appropriate?
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
when 'file', 'pipe'
|
16
|
-
if http_authentication?
|
17
|
-
return proposal
|
18
|
-
else
|
19
|
-
unsupported_transfer
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
debug "#{self.class.name}: not appropriate"
|
24
|
-
end
|
25
|
-
else
|
26
|
-
debug "#{self.class.name}: no segmentation requested"
|
6
|
+
unless segmented?
|
7
|
+
debug "#{self.class.name}: not appropriate"
|
8
|
+
return false
|
9
|
+
end
|
10
|
+
if compression_required? || conversion_required?
|
11
|
+
debug "#{self.class.name}: not ready to upload"
|
12
|
+
return false
|
27
13
|
end
|
14
|
+
case to.scheme
|
15
|
+
when 'http', 'https'
|
16
|
+
case from.scheme
|
17
|
+
when 'file', 'pipe'
|
18
|
+
return proposal if http_authentication?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
unsupported_transfer
|
28
22
|
false
|
29
23
|
end
|
30
24
|
|
31
25
|
def command
|
32
|
-
"segment_upload --segment-size '#{options['segment-size']}' #{source_details} #{to
|
26
|
+
"segment_upload --segment-size '#{options['segment-size']}' #{source_details} #{to};"
|
33
27
|
end
|
34
28
|
|
35
29
|
def proposal
|
@@ -42,11 +36,5 @@ module Uricp::Strategy
|
|
42
36
|
def source_details
|
43
37
|
"--from #{from.path}" unless from.scheme == 'pipe'
|
44
38
|
end
|
45
|
-
|
46
|
-
def segmented?
|
47
|
-
options['segment-size']
|
48
|
-
end
|
49
|
-
|
50
39
|
end
|
51
|
-
|
52
40
|
end
|