storcs 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f3dad4d085753517c22a3026d8a0d8a44959dbe5
4
+ data.tar.gz: 190d894f84584c5d151084256e2554f0fbef7fe3
5
+ SHA512:
6
+ metadata.gz: e4ebfb6321245cf8b17af2731c9da161c4806f169e6f26afaaeec735b9d40ad70ea6238bdfce144f921ff93204cbe5291524b43bc13b92f35f6b5a9bafec5486
7
+ data.tar.gz: 1d6781e41e887180006a4c8885a584feda51e817647b474a06e9ec412d30d7ed9e34a1122b00e61592287679886c20ee0328e25ea24c5eb72861e2209638ce1c
data/.gitignore CHANGED
@@ -3,3 +3,4 @@ tmp/*
3
3
  *.gem
4
4
  .bundle
5
5
  .rvmrc
6
+ Gemfile.lock
@@ -0,0 +1,9 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.0
7
+ - ruby-head
8
+ - rbx-2
9
+ - jruby
data/Gemfile CHANGED
@@ -2,3 +2,6 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in storcs.gemspec
4
4
  gemspec
5
+
6
+ # for CI on Travis
7
+ gem 'rake'
@@ -1,5 +1,7 @@
1
1
  h1. Storcs
2
2
 
3
+ "!https://secure.travis-ci.org/jbbarth/storcs.png!":http://travis-ci.org/jbbarth/storcs
4
+
3
5
  h2. Description
4
6
 
5
7
  Storcs (STORage Calculation Service) is a gem designed to help you manage centralized storages in a datacenter. It's especially appropriate for having a unique visibility on heterogeneous datacenters where many SAN or NAS devices are used. It currently reports the following elements :
@@ -18,7 +20,11 @@ For the moment, it has only been tested on the following devices :
18
20
 
19
21
  h2. Installation
20
22
 
21
- Build the gem and install it:
23
+ Install the stable version from rubygems.org:
24
+
25
+ bc. gem install storcs
26
+
27
+ Build the gem and install it from source:
22
28
 
23
29
  bc. gem build storcs.gemspec
24
30
  gem install storcs-*.gem
data/Rakefile CHANGED
@@ -1,2 +1,9 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
+ require 'rspec/core/rake_task'
4
+
5
+ desc "Run specs"
6
+ RSpec::Core::RakeTask.new
7
+
8
+ desc 'Default: run specs.'
9
+ task :default => :spec
@@ -0,0 +1 @@
1
+ require 'core_ext/float/rounding'
@@ -0,0 +1,20 @@
1
+ # copied from https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/float/rounding.rb
2
+ class Float
3
+ alias precisionless_round round
4
+ private :precisionless_round
5
+
6
+ # Rounds the float with the specified precision.
7
+ #
8
+ # x = 1.337
9
+ # x.round # => 1
10
+ # x.round(1) # => 1.3
11
+ # x.round(2) # => 1.34
12
+ def round(precision = nil)
13
+ if precision
14
+ magnitude = 10.0 ** precision
15
+ (self * magnitude).round / magnitude
16
+ else
17
+ precisionless_round
18
+ end
19
+ end
20
+ end
@@ -1,3 +1,4 @@
1
+ require 'core_ext/float'
1
2
  require 'storcs/summable_sizes'
2
3
  require 'storcs/device'
3
4
  require 'storcs/parsers'
@@ -2,6 +2,7 @@ require 'storcs/parsers/utils'
2
2
  require 'storcs/parsers/df_nas'
3
3
  require 'storcs/parsers/ibm'
4
4
  require 'storcs/parsers/equalogic'
5
+ require 'storcs/parsers/nss'
5
6
 
6
7
  module Storcs
7
8
  module Parsers
@@ -0,0 +1,39 @@
1
+ module Storcs::Parsers
2
+ class Nss
3
+ include Storcs::Parsers::Utils
4
+
5
+ attr_accessor :device
6
+
7
+ def initialize(name,file)
8
+ @device = Storcs::Device.new(name)
9
+ @lines = File.readlines(file)
10
+ parse!(@lines)
11
+ end
12
+
13
+ def parse!(content)
14
+ @device.children = pools
15
+ end
16
+
17
+ def pools
18
+ return @pools if @pools
19
+ @pools = []
20
+
21
+ current_allocated = nil
22
+ @lines.each do |line|
23
+ if line =~ /^Total (Available|Allocated) Space in "([^"]*)" \(ID: \d+\): (.* MB)/
24
+ case $1
25
+ when 'Allocated'
26
+ current_allocated = parse_size($3)
27
+ when 'Available'
28
+ current_available = parse_size($3)
29
+ @pools << Storcs::Device.new($2)
30
+ @pools.last.real_size = current_allocated + current_available
31
+ @pools.last.real_used = current_allocated
32
+ current_allocated = nil
33
+ end
34
+ end
35
+ end
36
+ @pools
37
+ end
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module Storcs
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,54 @@
1
+
2
+ IPStor Server: nss-test
3
+
4
+
5
+ ****** Storage Pool [SAN]: pool-a (ID: 2) ******
6
+
7
+ Allocated Physical Devices:
8
+
9
+ Device Name ACSL First Sector Last Sector Size(MB)
10
+ -------------------------------------------------------------------------------
11
+ VMware:Virtual disk.000 0:0:2:0 14336 20479 3
12
+ VMware:Virtual disk.000 0:0:2:0 20480 2117631 1024
13
+ VMware:Virtual disk.000 0:0:2:0 2117632 2123775 3
14
+ VMware:Virtual disk.000 0:0:2:0 2123776 4220927 1024
15
+
16
+ Total Allocated Space in "pool-a" (ID: 2): 2,054 MB
17
+
18
+ Available Physical Devices:
19
+
20
+ Device Name ACSL First Sector Last Sector Size(MB)
21
+ -------------------------------------------------------------------------------
22
+ VMware:Virtual disk.000 0:0:2:0 4220928 16777215 6131
23
+
24
+ Total Available Space in "pool-a" (ID: 2): 6,131 MB
25
+
26
+
27
+ ****** Storage Pool [SAN]: pool-b (ID: 3) ******
28
+
29
+ Allocated Physical Devices:
30
+
31
+ Device Name ACSL First Sector Last Sector Size(MB)
32
+ -------------------------------------------------------------------------------
33
+ VMware:Virtual disk.000 0:0:3:0 14336 20479 3
34
+ VMware:Virtual disk.000 0:0:3:0 20480 2117631 1024
35
+
36
+ Total Allocated Space in "pool-b" (ID: 3): 1,027 MB
37
+
38
+ Available Physical Devices:
39
+
40
+ Device Name ACSL First Sector Last Sector Size(MB)
41
+ -------------------------------------------------------------------------------
42
+ VMware:Virtual disk.000 0:0:3:0 2117632 16777215 7158
43
+
44
+ Total Available Space in "pool-b" (ID: 3): 7,158 MB
45
+
46
+
47
+ ****** Physical Devices not in storage pool ******
48
+
49
+ Total Allocated Space not in Storage Pool: 0 MB
50
+
51
+ Total Available Space not in Storage Pool: 0 MB
52
+
53
+ Command: getpdevinfo executed successfully.
54
+
@@ -0,0 +1,22 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Storcs::Parsers::Nss do
4
+
5
+ it "parses the output of a 'iscli getpdevinfo -L'" do
6
+ parsed = Storcs::Parsers::Nss.new("NSS", "spec/data/nss.txt")
7
+
8
+ device = parsed.device
9
+
10
+ device.size.should == 17165189
11
+ device.used.should == 3230663
12
+ device.free.should == 13934526
13
+
14
+ device.children.size.should == 2
15
+
16
+ pool_a = device.children.first
17
+ pool_a.name.should == "pool-a"
18
+ pool_a.size.should == 8582594
19
+ pool_a.used.should == 2153775
20
+ pool_a.free.should == 6428819
21
+ end
22
+ end
@@ -44,5 +44,14 @@ describe Storcs::Parsers::Utils do
44
44
  parse_size(k).should == v.round
45
45
  end
46
46
  end
47
+
48
+ it "knows everything about scientific notation" do
49
+ to_test = {
50
+ "3.1234E+011" => 3.1234*10**11,
51
+ }
52
+ to_test.each do |k,v|
53
+ parse_size(k).should == v.round
54
+ end
55
+ end
47
56
  end
48
57
  end
@@ -1,3 +1,12 @@
1
1
  $:.unshift File.expand_path("../../lib", __FILE__)
2
2
  require 'storcs'
3
3
  require 'rspec'
4
+ require 'rspec/collection_matchers'
5
+
6
+ #explicitly enable "should" syntax in rspec 3.x
7
+ #see: https://www.relishapp.com/rspec/rspec-expectations/docs/syntax-configuration#disable-should-syntax
8
+ RSpec.configure do |config|
9
+ config.expect_with :rspec do |c|
10
+ c.syntax = [:should, :expect]
11
+ end
12
+ end
@@ -12,7 +12,8 @@ Gem::Specification.new do |s|
12
12
  s.summary = %q{Storage-related calculations}
13
13
  s.description = %q{Storage-related calculations. Helps you manage your storage devices such as SAN, NAS, etc. in your CMDB}
14
14
 
15
- s.add_development_dependency "rspec"
15
+ s.add_development_dependency "rspec", "~> 3.0.0"
16
+ s.add_development_dependency "rspec-collection_matchers"
16
17
 
17
18
  s.rubyforge_project = "storcs"
18
19
 
metadata CHANGED
@@ -1,49 +1,58 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: storcs
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 2
9
- version: 0.0.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Jean-Baptiste Barth
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2011-03-29 00:00:00 +02:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2014-06-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.0
20
+ type: :development
22
21
  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"
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec-collection_matchers
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
31
34
  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
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Storage-related calculations. Helps you manage your storage devices such
42
+ as SAN, NAS, etc. in your CMDB
43
+ email:
35
44
  - jeanbaptiste.barth@gmail.com
36
45
  executables: []
37
-
38
46
  extensions: []
39
-
40
47
  extra_rdoc_files: []
41
-
42
- files:
48
+ files:
43
49
  - .gitignore
50
+ - .travis.yml
44
51
  - Gemfile
45
52
  - README.textile
46
53
  - Rakefile
54
+ - lib/core_ext/float.rb
55
+ - lib/core_ext/float/rounding.rb
47
56
  - lib/storcs.rb
48
57
  - lib/storcs/device.rb
49
58
  - lib/storcs/formatter.rb
@@ -51,6 +60,7 @@ files:
51
60
  - lib/storcs/parsers/df_nas.rb
52
61
  - lib/storcs/parsers/equalogic.rb
53
62
  - lib/storcs/parsers/ibm.rb
63
+ - lib/storcs/parsers/nss.rb
54
64
  - lib/storcs/parsers/utils.rb
55
65
  - lib/storcs/summable_sizes.rb
56
66
  - lib/storcs/version.rb
@@ -58,45 +68,50 @@ files:
58
68
  - spec/data/equalogic_PS5000XV.txt
59
69
  - spec/data/ibm_DS3400.txt
60
70
  - spec/data/ibm_DS4500.txt
71
+ - spec/data/nss.txt
61
72
  - spec/device_spec.rb
62
73
  - spec/formatter_spec.rb
63
74
  - spec/parsers/df_nas_spec.rb
64
75
  - spec/parsers/equalogic_spec.rb
65
76
  - spec/parsers/ibm_spec.rb
77
+ - spec/parsers/nss_spec.rb
66
78
  - spec/parsers/utils_spec.rb
67
79
  - spec/spec_helper.rb
68
80
  - storcs.gemspec
69
- has_rdoc: true
70
81
  homepage: http://github.com/jbbarth/storcs
71
82
  licenses: []
72
-
83
+ metadata: {}
73
84
  post_install_message:
74
85
  rdoc_options: []
75
-
76
- require_paths:
86
+ require_paths:
77
87
  - lib
78
- required_ruby_version: !ruby/object:Gem::Requirement
79
- none: false
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- segments:
84
- - 0
85
- version: "0"
86
- required_rubygems_version: !ruby/object:Gem::Requirement
87
- none: false
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- segments:
92
- - 0
93
- version: "0"
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
94
98
  requirements: []
95
-
96
99
  rubyforge_project: storcs
97
- rubygems_version: 1.3.7
100
+ rubygems_version: 2.2.2
98
101
  signing_key:
99
- specification_version: 3
102
+ specification_version: 4
100
103
  summary: Storage-related calculations
101
- test_files: []
102
-
104
+ test_files:
105
+ - spec/data/df_nas.txt
106
+ - spec/data/equalogic_PS5000XV.txt
107
+ - spec/data/ibm_DS3400.txt
108
+ - spec/data/ibm_DS4500.txt
109
+ - spec/data/nss.txt
110
+ - spec/device_spec.rb
111
+ - spec/formatter_spec.rb
112
+ - spec/parsers/df_nas_spec.rb
113
+ - spec/parsers/equalogic_spec.rb
114
+ - spec/parsers/ibm_spec.rb
115
+ - spec/parsers/nss_spec.rb
116
+ - spec/parsers/utils_spec.rb
117
+ - spec/spec_helper.rb