uricp 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -28,6 +28,14 @@ Feature: Authenticated download of images from orbit
|
|
28
28
|
And a file named "/tmp/uricp/cache/img-qcow2" should exist
|
29
29
|
And the file named "/tmp/uricp/cache/img-qcow2" should have a file format of "qcow2v3"
|
30
30
|
|
31
|
+
Scenario: zero download convert to qcow2, cache
|
32
|
+
Given a correctly initialised cache at "/tmp/uricp"
|
33
|
+
When I retrieve "img-zeroy" with options "--target-format=qcow2 --cache=/tmp/uricp" from container "test" into "file:///tmp/uricp/srv-testz"
|
34
|
+
Then a file named "/tmp/uricp/srv-testz" should exist
|
35
|
+
And the file named "/tmp/uricp/srv-testz" should have a file format of "qcow2"
|
36
|
+
And a 0 byte file named "/tmp/uricp/cache/img-zeroy" should exist
|
37
|
+
And the file named "/tmp/uricp/cache/img-zeroy" should have a file format of "raw"
|
38
|
+
|
31
39
|
Scenario: qcow download convert to raw, cache
|
32
40
|
Given a correctly initialised cache at "/tmp/uricp"
|
33
41
|
When I retrieve "img-qcow2" with options "--target-format=raw --cache=/tmp/uricp" from container "test" into "file:///tmp/uricp/srv-test4"
|
@@ -23,8 +23,14 @@ def create_download_file(filetype, name, container)
|
|
23
23
|
tempfile = '/tmp/fred55322'
|
24
24
|
FileUtils.rm_f(Dir.glob(tempfile+'*'))
|
25
25
|
format = 'raw'
|
26
|
-
|
27
|
-
|
26
|
+
size = '1G'
|
27
|
+
case filetype
|
28
|
+
when 'qcow2'
|
29
|
+
format = 'qcow2'
|
30
|
+
when 'zero'
|
31
|
+
size = '0'
|
32
|
+
end
|
33
|
+
cmd = "qemu-img create -q -f #{format} #{tempfile} #{size}"
|
28
34
|
system(unescape(cmd))
|
29
35
|
cmd = "cat #{tempfile}"
|
30
36
|
if filetype == 'lz4'
|
@@ -32,6 +38,7 @@ def create_download_file(filetype, name, container)
|
|
32
38
|
end
|
33
39
|
cmd += "| curl --silent --fail -T - -H 'X-Auth-Token: #{@current_auth_token}' #{upload_url} "
|
34
40
|
system(unescape(cmd))
|
41
|
+
FileUtils.rm_f(Dir.glob(tempfile+'*'))
|
35
42
|
end
|
36
43
|
|
37
44
|
def create_container(name)
|
@@ -180,6 +187,7 @@ Before('@orbitdownloads') do
|
|
180
187
|
create_container('test')
|
181
188
|
create_download_file('qcow2', 'img-qcow2', 'test')
|
182
189
|
create_download_file('lz4', 'img-lz4cy', 'test')
|
190
|
+
create_download_file('zero', 'img-zeroy', 'test')
|
183
191
|
$orbit_setup = true
|
184
192
|
end
|
185
193
|
end
|
@@ -2,7 +2,7 @@ Then(/^the file named "(.*?)" should have a file format of "(.*?)"$/) do |filena
|
|
2
2
|
case format
|
3
3
|
when 'lz4'
|
4
4
|
assert_exact_output([0x184D2204].pack('V'),
|
5
|
-
File.open(filename, 'rb') {|f| f.read(4) })
|
5
|
+
File.open(filename, 'rb') {|f| f.read(4) }.to_s)
|
6
6
|
when 'qcow2v3', 'qcow3'
|
7
7
|
steps %{
|
8
8
|
When I successfully run `qemu-img info #{filename}`
|
@@ -11,7 +11,7 @@ Then(/^the file named "(.*?)" should have a file format of "(.*?)"$/) do |filena
|
|
11
11
|
}
|
12
12
|
else
|
13
13
|
assert_no_partial_output([0x184D2204].pack('V'),
|
14
|
-
File.open(filename, 'rb') {|f| f.read(4) })
|
14
|
+
File.open(filename, 'rb') {|f| f.read(4) }.to_s)
|
15
15
|
steps(%{
|
16
16
|
When I successfully run `qemu-img info #{filename}`
|
17
17
|
Then the output from "qemu-img info #{filename}" should contain "file format: #{format}"
|
@@ -21,8 +21,7 @@ module Uricp::Strategy
|
|
21
21
|
@proposed_options = options.dup
|
22
22
|
@proposed_options['from_uri'] = PIPE_URI
|
23
23
|
if options['target-format']
|
24
|
-
@proposed_options['source-format'] =
|
25
|
-
options['from_uri'].open(headers) { |u| encoding(u) }
|
24
|
+
@proposed_options['source-format'] = format_peek
|
26
25
|
if @proposed_options['source-format'] == @proposed_options['target-format']
|
27
26
|
@proposed_options.delete('source-format')
|
28
27
|
@proposed_options.delete('target-format')
|
@@ -31,6 +30,17 @@ module Uricp::Strategy
|
|
31
30
|
self
|
32
31
|
end
|
33
32
|
|
33
|
+
def format_peek
|
34
|
+
options['from_uri'].open(headers) { |u| encoding(u) }
|
35
|
+
rescue OpenURI::HTTPError => e
|
36
|
+
case e.io.status[0]
|
37
|
+
when '416'
|
38
|
+
'raw'
|
39
|
+
else
|
40
|
+
raise
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
34
44
|
def headers
|
35
45
|
headers={'Range' => 'bytes=0-7'}
|
36
46
|
headers['X-Auth-Token'] = options['auth-token'] if http_authentication?
|
data/lib/uricp/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-03-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|