thinp_xml 0.0.2 → 0.0.3

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWY0MTQ0ZmY5YTQ0MmQwNTE4Mjg1YWE3ZWU3MzhhZmFmODFiNDk3ZA==
4
+ OTc1YTFmYjhkNjI2ZDI4MjU2ZGZlZTU1MTFkZTVjZTFkNTM4NzAzNw==
5
5
  data.tar.gz: !binary |-
6
- NzUxMmVmMzU0YTIwZTViYmRkNjI5NzRkNzkzZjUxZGVlMjQ4NjRjMQ==
6
+ NzE5ZWY2N2EyYmJiMjA5MDYwOTcwMjczZjg0YzJjNDZiNWZlZTEyMw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OTAxNWM1Yzk0NzQ1YzFmMDhlY2I4ZDVlMzE3NTA5ZDMwNjhlYWExMTA2MmI0
10
- NzJjMGJhYjg1YjhkYjNhYTJhYjZjOTg3ZWNhYjY2Mjk3M2NmNTY5MGNlMzMx
11
- ZDNiYmZmNmQyOGI5NTcxY2Q2NWRlOGJkMDkxZGU4M2JlNWJmNjI=
9
+ ZGM4Y2I3Y2U3ZGM5N2JjMWUyNjAyZjA0M2YxZjQ4NGYzMDBkZGI3NTMzNGMx
10
+ YzdkYjU5MGFjOGMwMmQ0NGFjZDc5YzIxODY3M2QwOTYwNzdkY2RkYTJhODk2
11
+ MzQzMzNkMTU1NmQxMjZjYTMyYjRmZmI1NTRlMmI0MzBhZjBlY2E=
12
12
  data.tar.gz: !binary |-
13
- ZDM1Yzc0MDlhZDI3MzY1YzQ2MThkM2VhZGFiNThiZjYyZmI1ODY4NWE5NTYx
14
- MzlmMzViNDg2Yjg4NDljYTRlNDFhY2M0MmRmM2U0NTQ3YTI5NzRmMzE1M2Fl
15
- YjAxY2U0NzNhYTY3MDA2MjMyODMxOTI4NWE1N2E0ODM5MGMwN2Y=
13
+ OGY5ZjExZmEyNTQwMDdmZDFjYmJjODljYzUxODIwZDA1NDE4NTQ4YjJhODJm
14
+ ZjkzNDJhNjU2YjJlOTBhMTBjZTVkZGVhOTEzYTg2YmY5ZTRmMjM1NDY1ZDgy
15
+ N2Q5YjY0Y2I4MDBhNTc0MmU3N2QyNGZjOTQ1NDk3YjhjMzE4YzY=
@@ -4,7 +4,7 @@ Feature: I can create new metadata
4
4
  When I thinp_xml create
5
5
  Then the stdout should contain:
6
6
  """
7
- <superblock uuid="" time="0" transaction="1" data_block_size="128" nr_data_blocks="100">
7
+ <superblock uuid="" time="0" transaction="1" data_block_size="128" nr_data_blocks="0">
8
8
  </superblock>
9
9
  """
10
10
 
@@ -12,7 +12,7 @@ Feature: I can create new metadata
12
12
  When I thinp_xml create --uuid 'one two three'
13
13
  Then the stdout should contain:
14
14
  """
15
- <superblock uuid="one two three" time="0" transaction="1" data_block_size="128" nr_data_blocks="100">
15
+ <superblock uuid="one two three" time="0" transaction="1" data_block_size="128" nr_data_blocks="0">
16
16
  </superblock>
17
17
  """
18
18
 
@@ -20,7 +20,7 @@ Feature: I can create new metadata
20
20
  When I thinp_xml create --nr-thins 3
21
21
  Then the stdout should contain:
22
22
  """
23
- <superblock uuid="" time="0" transaction="1" data_block_size="128" nr_data_blocks="100">
23
+ <superblock uuid="" time="0" transaction="1" data_block_size="128" nr_data_blocks="0">
24
24
  <device dev_id="0" mapped_blocks="0" transaction="0" creation_time="0" snap_time="0">
25
25
  </device>
26
26
  <device dev_id="1" mapped_blocks="0" transaction="0" creation_time="0" snap_time="0">
@@ -34,7 +34,7 @@ Feature: I can create new metadata
34
34
  When I thinp_xml create --nr-thins 1 --nr-mappings 67
35
35
  Then the stdout should contain:
36
36
  """
37
- <superblock uuid="" time="0" transaction="1" data_block_size="128" nr_data_blocks="100">
37
+ <superblock uuid="" time="0" transaction="1" data_block_size="128" nr_data_blocks="67">
38
38
  <device dev_id="0" mapped_blocks="67" transaction="0" creation_time="0" snap_time="0">
39
39
  <range_mapping origin_begin="0" data_begin="0" length="67" time="1"/>
40
40
  </device>
@@ -52,6 +52,3 @@ Feature: I can create new metadata
52
52
  Scenario: A uniform distribution can be given for nr mappings
53
53
  When I thinp_xml create --nr-thins 1 --nr-mappings uniform[40..100]
54
54
  Then it should pass
55
-
56
-
57
-
@@ -15,13 +15,15 @@ module ThinpXML
15
15
  def generate
16
16
  nr_thins = @nr_thins.to_i
17
17
 
18
- superblock = Superblock.new(@uuid, 0, 1, 128, 100)
18
+ mapping_counts = (0..nr_thins - 1).map {|n| @nr_mappings.to_i}
19
+ nr_data_blocks = mapping_counts.inject(0) {|n, tot| n + tot}
20
+ superblock = Superblock.new(@uuid, 0, 1, 128, nr_data_blocks)
19
21
 
20
22
  devices = Array.new
21
23
  offset = 0
22
24
  0.upto(nr_thins - 1) do |dev|
23
25
  mappings = Array.new
24
- nr_mappings = @nr_mappings.to_i
26
+ nr_mappings = mapping_counts[dev]
25
27
 
26
28
  if nr_mappings > 0
27
29
  mappings << Mapping.new(0, offset, nr_mappings, 1)
@@ -1,3 +1,3 @@
1
1
  module ThinpXml
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/spec/builder_spec.rb CHANGED
@@ -90,6 +90,14 @@ describe "ThinpXML::Builder" do
90
90
 
91
91
  md.devices[0].should have(1).mappings
92
92
  end
93
+
94
+ it "should be used to calculate the nr data blocks" do
95
+ @b.nr_thins = 2
96
+ @b.nr_mappings = 117
97
+ md = @b.generate
98
+
99
+ md.superblock.nr_data_blocks.should == 234
100
+ end
93
101
  end
94
102
  end
95
103
 
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.2
4
+ version: 0.0.3
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-04 00:00:00.000000000 Z
11
+ date: 2013-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ejt_command_line