storcs 0.0.1
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.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/README.textile +47 -0
- data/Rakefile +2 -0
- data/lib/storcs.rb +3 -0
- data/lib/storcs/device.rb +36 -0
- data/lib/storcs/formatter.rb +14 -0
- data/lib/storcs/parsers.rb +10 -0
- data/lib/storcs/parsers/df_nas.rb +20 -0
- data/lib/storcs/parsers/equalogic.rb +43 -0
- data/lib/storcs/parsers/ibm.rb +58 -0
- data/lib/storcs/parsers/utils.rb +25 -0
- data/lib/storcs/version.rb +3 -0
- data/spec/data/df_nas.txt +2 -0
- data/spec/data/equalogic_PS5000XV.txt +0 -0
- data/spec/data/ibm_DS3400.txt +869 -0
- data/spec/data/ibm_DS4500.txt +7976 -0
- data/spec/device_spec.rb +29 -0
- data/spec/formatter_spec.rb +13 -0
- data/spec/parsers/df_nas_spec.rb +12 -0
- data/spec/parsers/equalogic_spec.rb +28 -0
- data/spec/parsers/ibm_spec.rb +63 -0
- data/spec/parsers/utils_spec.rb +48 -0
- data/spec/spec_helper.rb +3 -0
- data/storcs.gemspec +23 -0
- metadata +101 -0
data/spec/device_spec.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path('../spec_helper',__FILE__)
|
2
|
+
|
3
|
+
describe Storcs::Device do
|
4
|
+
before(:each) do
|
5
|
+
@bay = Storcs::Device.new("bay1")
|
6
|
+
@array1 = Storcs::Device.new("array1"); @array1.real_size = 10; @array1.real_used = 8
|
7
|
+
@array2 = Storcs::Device.new("array2"); @array2.real_size = 10; @array2.real_used = 3
|
8
|
+
@bay.children << @array1
|
9
|
+
@bay.children << @array2
|
10
|
+
end
|
11
|
+
|
12
|
+
it "creates a new device" do
|
13
|
+
@bay.should_not be_nil
|
14
|
+
@bay.name.should == "bay1"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "has basic (nested) methods" do
|
18
|
+
@array1.used.should == 8
|
19
|
+
@array1.size.should == 10
|
20
|
+
@bay.used.should == 11
|
21
|
+
@bay.size.should == 20
|
22
|
+
@bay.free.should == 9
|
23
|
+
end
|
24
|
+
|
25
|
+
it "calculates the percent used and free" do
|
26
|
+
@bay.percent_used.should == 55
|
27
|
+
@bay.percent_free.should == 45
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
describe Storcs::Formatter do
|
2
|
+
include Storcs::Formatter
|
3
|
+
it "formats sizes in bytes" do
|
4
|
+
{ 1 => "1.0bytes",
|
5
|
+
1024 => "1.0Kb",
|
6
|
+
12345 => "12.1Kb",
|
7
|
+
825388561334 => "768.7Gb",
|
8
|
+
12285713148014 => "11.2Tb"
|
9
|
+
}.each do |raw,formatted|
|
10
|
+
pretty_size(raw).should == formatted
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Storcs::Parsers::DfNas do
|
4
|
+
it "parses a df -k output" do
|
5
|
+
parsed = Storcs::Parsers::DfNas.new('nas','spec/data/df_nas.txt')
|
6
|
+
parsed.device.should_not be_nil
|
7
|
+
parsed.device.name.should == 'nas'
|
8
|
+
parsed.device.used.should == 612376576
|
9
|
+
parsed.device.size.should == 814572544
|
10
|
+
parsed.device.free.should == 202195968
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Storcs::Parsers::Equalogic do
|
4
|
+
it "parses the output of a 'show' command inside the console" do
|
5
|
+
parsed = Storcs::Parsers::Equalogic.new('ps5000','spec/data/equalogic_PS5000XV.txt')
|
6
|
+
bay = parsed.device
|
7
|
+
bay.should_not be_nil
|
8
|
+
bay.name.should == "ps5000"
|
9
|
+
bay.size.should == 4020012968837
|
10
|
+
bay.used.should == 3972897177600
|
11
|
+
bay.free.should == 47115791237
|
12
|
+
end
|
13
|
+
|
14
|
+
it "divides the bay into a set of logical volumes" do
|
15
|
+
device = Storcs::Parsers::Equalogic.new('ps5000','spec/data/equalogic_PS5000XV.txt').device
|
16
|
+
device.children.first.should be_a Storcs::Device
|
17
|
+
device.children.should have_exactly(11).items
|
18
|
+
first = device.children.first
|
19
|
+
first.should be_a Storcs::Device
|
20
|
+
first.name.should == "g01-app01"
|
21
|
+
first.size.should == 858993459200
|
22
|
+
first.used.should == first.size
|
23
|
+
free = device.children.last
|
24
|
+
free.name.should == "free"
|
25
|
+
free.size.should == 47115791237
|
26
|
+
free.used.should == 0
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Storcs::Parsers::Ibm do
|
4
|
+
models = {"DS4500" => { :num_arrays => 15, :num_sections => 11,
|
5
|
+
:bay_size => 12285713148014, :bay_used => 11460324586680, :bay_free => 825388561334,
|
6
|
+
:first_array_name => "ARRAY 1", :first_array_raid => "5", :first_array_ld_num => 17,
|
7
|
+
:ld_name => "array1_LUN0_app01_5G", :ld_size => 5368709120,
|
8
|
+
:array_size => 1316496596795, :array_used => 655826473713 },
|
9
|
+
"DS3400" => { :num_arrays => 1, :num_sections => 9,
|
10
|
+
:bay_size => 2395702692938, :bay_used => 2395702692938, :bay_free => 0,
|
11
|
+
:first_array_name => "ARRAY 1", :first_array_raid => "5", :first_array_ld_num => 2,
|
12
|
+
:ld_name => "SAN01_LUN1", :ld_size => 1099511627776,
|
13
|
+
:array_size => 2395702692938, :array_used => 2395702692938 }
|
14
|
+
}
|
15
|
+
|
16
|
+
models.keys.each do |model|
|
17
|
+
|
18
|
+
context "for a #{model}" do
|
19
|
+
before(:each) do
|
20
|
+
@parsed = Storcs::Parsers::Ibm.new(model,"spec/data/ibm_#{model}.txt")
|
21
|
+
@expected = models[model]
|
22
|
+
end
|
23
|
+
|
24
|
+
it "parses the output of a 'SMcli X.X.X.X 'show storagesubsystem profile;' for a #{model}" do
|
25
|
+
bay = @parsed.device
|
26
|
+
bay.should_not be_nil
|
27
|
+
bay.name.should == model
|
28
|
+
bay.children.should have_exactly(@expected[:num_arrays]).items
|
29
|
+
bay.size.should == @expected[:bay_size]
|
30
|
+
bay.used.should == @expected[:bay_used]
|
31
|
+
bay.free.should == @expected[:bay_free]
|
32
|
+
end
|
33
|
+
|
34
|
+
it "divides a profile file into small sections" do
|
35
|
+
sections = @parsed.sections
|
36
|
+
sections.should be_a Hash
|
37
|
+
sections.keys.length.should == @expected[:num_sections]
|
38
|
+
sections[:arrays].should be_an Array
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns a list of arrays with name+raid type" do
|
42
|
+
first = @parsed.arrays.first
|
43
|
+
first.should be_a Storcs::Device
|
44
|
+
first.name.should == @expected[:first_array_name]
|
45
|
+
first.raid.should == @expected[:first_array_raid]
|
46
|
+
end
|
47
|
+
|
48
|
+
it "divides each array into a set of logical volumes" do
|
49
|
+
array = @parsed.arrays.first
|
50
|
+
array.should be_a Storcs::Device
|
51
|
+
array.children.should have_exactly(@expected[:first_array_ld_num]).items
|
52
|
+
first = array.children.first
|
53
|
+
first.should be_a Storcs::Device
|
54
|
+
first.name.should == @expected[:ld_name]
|
55
|
+
first.size.should == @expected[:ld_size]
|
56
|
+
first.used.should == first.size
|
57
|
+
array.size.should == @expected[:array_size]
|
58
|
+
array.used.should == @expected[:array_used]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
describe Storcs::Parsers::Utils do
|
2
|
+
include Storcs::Parsers::Utils
|
3
|
+
|
4
|
+
describe "#parse_size" do
|
5
|
+
it "parses size units correctly" do
|
6
|
+
to_test = {
|
7
|
+
"577" => 577,
|
8
|
+
"1 KB" => 1024,
|
9
|
+
"1 MB" => 1024**2,
|
10
|
+
"1 GB" => 1024**3,
|
11
|
+
"1 TB" => 1024**4,
|
12
|
+
"1 PB" => 1024**5,
|
13
|
+
"2.501 GB" => 2.501*1024**3,
|
14
|
+
"112.641 GB" => 112.641*1024**3
|
15
|
+
}
|
16
|
+
to_test.each do |k,v|
|
17
|
+
parse_size(k).should == v.round
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "interprets comas as dots inside the number" do
|
22
|
+
to_test = {
|
23
|
+
"37,39 GB" => 37.39*1024**3,
|
24
|
+
"22,284 GB" => 22.284*1024**3,
|
25
|
+
"235,079 GB" => 235.079*1024**3
|
26
|
+
}
|
27
|
+
to_test.each do |k,v|
|
28
|
+
parse_size(k).should == v.round
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it "prioritize the values inside parentesis if numbers and ignores comas inside" do
|
33
|
+
to_test = {
|
34
|
+
"56,234 GB (143453 Bytes)" => 143453,
|
35
|
+
"10 000 KB (blah Bytes)" => 10240000,
|
36
|
+
"10 000 KB (43 242 Bytes)" => 43242,
|
37
|
+
"953,572 GB (1 023 890 138 112 Bytes)" => 1023890138112,
|
38
|
+
"9,329 GB (10 016 522 240 Bytes)" => 10016522240,
|
39
|
+
"11,293 GB (12 125 732 864 Bytes)" => 12125732864,
|
40
|
+
"203.597 GB (218,610,794,496 Bytes)" => 218610794496,
|
41
|
+
"5 GB (5,368,709,120 Bytes)" => 5368709120
|
42
|
+
}
|
43
|
+
to_test.each do |k,v|
|
44
|
+
parse_size(k).should == v.round
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/storcs.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "storcs/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "storcs"
|
7
|
+
s.version = Storcs::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Jean-Baptiste Barth"]
|
10
|
+
s.email = ["jeanbaptiste.barth@gmail.com"]
|
11
|
+
s.homepage = "http://github.com/jbbarth/storcs"
|
12
|
+
s.summary = %q{Storage-related calculations}
|
13
|
+
s.description = %q{Storage-related calculations. Helps you manage your storage devices such as SAN, NAS, etc. in your CMDB}
|
14
|
+
|
15
|
+
s.add_development_dependency "rspec"
|
16
|
+
|
17
|
+
s.rubyforge_project = "storcs"
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
|
+
s.require_paths = ["lib"]
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: storcs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Jean-Baptiste Barth
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-01-06 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :development
|
32
|
+
version_requirements: *id001
|
33
|
+
description: Storage-related calculations. Helps you manage your storage devices such as SAN, NAS, etc. in your CMDB
|
34
|
+
email:
|
35
|
+
- jeanbaptiste.barth@gmail.com
|
36
|
+
executables: []
|
37
|
+
|
38
|
+
extensions: []
|
39
|
+
|
40
|
+
extra_rdoc_files: []
|
41
|
+
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- Gemfile
|
45
|
+
- README.textile
|
46
|
+
- Rakefile
|
47
|
+
- lib/storcs.rb
|
48
|
+
- lib/storcs/device.rb
|
49
|
+
- lib/storcs/formatter.rb
|
50
|
+
- lib/storcs/parsers.rb
|
51
|
+
- lib/storcs/parsers/df_nas.rb
|
52
|
+
- lib/storcs/parsers/equalogic.rb
|
53
|
+
- lib/storcs/parsers/ibm.rb
|
54
|
+
- lib/storcs/parsers/utils.rb
|
55
|
+
- lib/storcs/version.rb
|
56
|
+
- spec/data/df_nas.txt
|
57
|
+
- spec/data/equalogic_PS5000XV.txt
|
58
|
+
- spec/data/ibm_DS3400.txt
|
59
|
+
- spec/data/ibm_DS4500.txt
|
60
|
+
- spec/device_spec.rb
|
61
|
+
- spec/formatter_spec.rb
|
62
|
+
- spec/parsers/df_nas_spec.rb
|
63
|
+
- spec/parsers/equalogic_spec.rb
|
64
|
+
- spec/parsers/ibm_spec.rb
|
65
|
+
- spec/parsers/utils_spec.rb
|
66
|
+
- spec/spec_helper.rb
|
67
|
+
- storcs.gemspec
|
68
|
+
has_rdoc: true
|
69
|
+
homepage: http://github.com/jbbarth/storcs
|
70
|
+
licenses: []
|
71
|
+
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
version: "0"
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
version: "0"
|
93
|
+
requirements: []
|
94
|
+
|
95
|
+
rubyforge_project: storcs
|
96
|
+
rubygems_version: 1.3.7
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: Storage-related calculations
|
100
|
+
test_files: []
|
101
|
+
|