thinp_xml 0.0.3 → 0.0.4
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 +8 -8
- data/README.md +2 -2
- data/bin/thinp_xml +3 -1
- data/features/create.feature +8 -0
- data/lib/thinp_xml/builder.rb +3 -2
- data/lib/thinp_xml/version.rb +1 -1
- data/spec/builder_spec.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjEzY2RlNTQwYTJkM2U1YTU0ZmYxYzA4ZjgyMmI3OWM3ZTVlZGZhOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OGM5ZjgwY2FlN2FjYmUyZmJjMDE2MTdmMzQ0YWY4NGQzMDhkNjY5Yg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDQ2YTM1ZDU3ZmU3MzllODJlYWI0OGMzNjI4ZWEyYThmMzUxMDI2MjAyZTAw
|
10
|
+
ODIxZmJlZTNiMzE4NTc5N2RkNDY2MjdiODBmMjk5YzU1NGRjZTM2MDJhZDM4
|
11
|
+
YTViODg4YzdlYmEyODZlOTdlMWQ0MjViNDk0NTBiMmIwNDRiYTk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjEwMDE2ZWE0YTNlNmUyZGUyYTI2YTg4NDA3MGI5ZTJiMDA5ODA1Zjc1ZTQz
|
14
|
+
ZGQ1NjNiMjRlMGNmZDg0MjhlNmJmMzM4NWJlYjc1Yzg2Yjc5YjM1ZTQzNGE2
|
15
|
+
NGUxNTdiNGNhYThlNWE5NzRmMDBmNmFhYzgyYTkyYTE1YWEwMGI=
|
data/README.md
CHANGED
@@ -24,12 +24,12 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
-
$ thinp_xml create --nr-thins 4 --nr-mappings 100
|
27
|
+
$ thinp_xml create --nr-thins 4 --nr-mappings 100 --block-size 512
|
28
28
|
|
29
29
|
When specifying numerical constants you may also give a random number distribution.
|
30
30
|
|
31
31
|
uniform[<begin>..<end inclusive>]
|
32
32
|
|
33
|
-
$ thinp_xml create --nr-thins uniform[4..9] --nr-mappings uniform[1000..10000]
|
33
|
+
$ thinp_xml create --nr-thins uniform[4..9] --nr-mappings uniform[1000..10000] --block-size 1024
|
34
34
|
|
35
35
|
|
data/bin/thinp_xml
CHANGED
@@ -30,13 +30,14 @@ XMLCommandLine = CommandLine::Parser.new do
|
|
30
30
|
value_switch :uuid, :string, '--uuid'
|
31
31
|
value_switch :nr_thins, :int_distribution, '--nr-thins'
|
32
32
|
value_switch :nr_mappings, :int_distribution, '--nr-mappings'
|
33
|
+
value_switch :block_size, :int, '--block-size'
|
33
34
|
|
34
35
|
global do
|
35
36
|
switches :help
|
36
37
|
end
|
37
38
|
|
38
39
|
command :create do
|
39
|
-
switches :uuid, :nr_thins, :nr_mappings
|
40
|
+
switches :uuid, :nr_thins, :nr_mappings, :block_size
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
@@ -60,6 +61,7 @@ class Dispatcher
|
|
60
61
|
b.uuid = opts.fetch(:uuid, '')
|
61
62
|
b.nr_thins = opts.fetch(:nr_thins, 0)
|
62
63
|
b.nr_mappings = opts.fetch(:nr_mappings, 0)
|
64
|
+
b.block_size = opts.fetch(:block_size, 128)
|
63
65
|
md = b.generate
|
64
66
|
write_xml(md, STDOUT)
|
65
67
|
end
|
data/features/create.feature
CHANGED
@@ -16,6 +16,14 @@ Feature: I can create new metadata
|
|
16
16
|
</superblock>
|
17
17
|
"""
|
18
18
|
|
19
|
+
Scenario: Create a valid superblock with specified block size
|
20
|
+
When I thinp_xml create --block-size 512
|
21
|
+
Then the stdout should contain:
|
22
|
+
"""
|
23
|
+
<superblock uuid="" time="0" transaction="1" data_block_size="512" nr_data_blocks="0">
|
24
|
+
</superblock>
|
25
|
+
"""
|
26
|
+
|
19
27
|
Scenario: Take an expression for the number of devices
|
20
28
|
When I thinp_xml create --nr-thins 3
|
21
29
|
Then the stdout should contain:
|
data/lib/thinp_xml/builder.rb
CHANGED
@@ -4,12 +4,13 @@ require 'thinp_xml/metadata'
|
|
4
4
|
|
5
5
|
module ThinpXML
|
6
6
|
class Builder
|
7
|
-
attr_accessor :uuid, :nr_thins, :nr_mappings
|
7
|
+
attr_accessor :uuid, :nr_thins, :nr_mappings, :block_size
|
8
8
|
|
9
9
|
def initialize
|
10
10
|
@uuid = ''
|
11
11
|
@nr_thins = 0
|
12
12
|
@nr_mappings = 0
|
13
|
+
@block_size = 128
|
13
14
|
end
|
14
15
|
|
15
16
|
def generate
|
@@ -17,7 +18,7 @@ module ThinpXML
|
|
17
18
|
|
18
19
|
mapping_counts = (0..nr_thins - 1).map {|n| @nr_mappings.to_i}
|
19
20
|
nr_data_blocks = mapping_counts.inject(0) {|n, tot| n + tot}
|
20
|
-
superblock = Superblock.new(@uuid, 0, 1,
|
21
|
+
superblock = Superblock.new(@uuid, 0, 1, @block_size, nr_data_blocks)
|
21
22
|
|
22
23
|
devices = Array.new
|
23
24
|
offset = 0
|
data/lib/thinp_xml/version.rb
CHANGED
data/spec/builder_spec.rb
CHANGED
@@ -30,6 +30,24 @@ describe "ThinpXML::Builder" do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
describe "block_size" do
|
34
|
+
it "should be 128 by default" do
|
35
|
+
@b.block_size.should == 128
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should reflect any changes" do
|
39
|
+
@b.block_size = 512
|
40
|
+
@b.block_size.should == 512
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should generate the correct block size" do
|
44
|
+
bs = 1024
|
45
|
+
@b.block_size = bs
|
46
|
+
md = @b.generate
|
47
|
+
md.superblock.data_block_size.should == bs
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
33
51
|
describe "nr of thins" do
|
34
52
|
it "zero by default" do
|
35
53
|
@b.nr_thins.should == 0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thinp_xml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Thornber
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ejt_command_line
|