ruby-ipmitool 0.4.1 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/ruby-ipmitool.rb +12 -9
  2. metadata +9 -8
@@ -29,10 +29,10 @@ class Ipmitool
29
29
 
30
30
  #Instantiates a new Ipmitool object. Takes a hash containing :host, :user, and :password.
31
31
  #
32
- #Ex: Ipmitool.new(:host => '192.168.1.1', :user => 'username', :password => 'password')
32
+ #Ex: Ipmitool.new(:host => '192.168.1.1', :user => 'username', :password => 'password', :optional => {})
33
33
  def initialize(conn = {})
34
34
  conn[:check_host] ||= true
35
- raise ArgumentError, "Wrong number of arguments" if conn.count != 4
35
+ raise ArgumentError, "Wrong number of arguments" if conn.count < 4
36
36
  raise ArgumentError, "Host is required" if conn[:host].nil?
37
37
  raise ArgumentError, "User is required" if conn[:user].nil?
38
38
  raise ArgumentError, "Password is required" if conn[:password].nil?
@@ -48,12 +48,8 @@ class Ipmitool
48
48
  #Run a ping check to see if the host is responding
49
49
  def check_host
50
50
  result = `ping -q -c 2 #{@conn[:host]}`
51
- if ($?.exitstatus == 0) do
52
- pingable = true
53
- else
54
- pingable = false
55
- end
56
- pingable
51
+ # return true or false if exit status is 0
52
+ $?.exitstatus == 0
57
53
  end
58
54
 
59
55
  #Read sensor data from ipmitool and return a hash containing the value
@@ -182,7 +178,14 @@ class Ipmitool
182
178
 
183
179
  private
184
180
  def run_command(command, *args)
185
- `#{@conn[:binary]} -H #{@conn[:host]} -U #{@conn[:user]} -P #{@conn[:password]} #{command} #{args unless args.nil?}`.downcase!
181
+ optional = []
182
+ if @conn[:optional]
183
+ @conn[:optional].each { |key, value|
184
+ optional << "-#{key} #{value}"
185
+ }
186
+ end
187
+
188
+ `#{@conn[:binary]} #{optional.join(" ")} -H #{@conn[:host]} -U #{@conn[:user]} -P #{@conn[:password]} #{command} #{args unless args.nil?}`.downcase!
186
189
  end
187
190
 
188
191
  def split_output(array, delimiter)
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-ipmitool
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 443364408258612160
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
9
- - 1
10
- version: 0.4.1
8
+ - 5
9
+ version: "0.5"
11
10
  platform: ruby
12
11
  authors:
13
12
  - Eugene Howe
@@ -15,7 +14,8 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-06-28 00:00:00 Z
17
+ date: 2011-10-31 00:00:00 -04:00
18
+ default_executable:
19
19
  dependencies: []
20
20
 
21
21
  description: Wraps most functionality of ipmitool including user, sensor, channel, and chassis functions
@@ -28,6 +28,7 @@ extra_rdoc_files: []
28
28
 
29
29
  files:
30
30
  - lib/ruby-ipmitool.rb
31
+ has_rdoc: true
31
32
  homepage:
32
33
  licenses: []
33
34
 
@@ -41,7 +42,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
41
42
  requirements:
42
43
  - - ">="
43
44
  - !ruby/object:Gem::Version
44
- hash: 3
45
+ hash: 2002549777813010636
45
46
  segments:
46
47
  - 0
47
48
  version: "0"
@@ -50,14 +51,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
51
  requirements:
51
52
  - - ">="
52
53
  - !ruby/object:Gem::Version
53
- hash: 3
54
+ hash: 2002549777813010636
54
55
  segments:
55
56
  - 0
56
57
  version: "0"
57
58
  requirements: []
58
59
 
59
60
  rubyforge_project:
60
- rubygems_version: 1.7.2
61
+ rubygems_version: 1.5.2
61
62
  signing_key:
62
63
  specification_version: 3
63
64
  summary: Wrapper for the linux ipmitool command