poweriq_client 0.1.1 → 0.2.0
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/README.rdoc +68 -5
- data/bin/poweriq_client +50 -3
- data/lib/poweriq_client/compatibility.rb +20 -0
- data/lib/poweriq_client/configuration.rb +4 -3
- data/lib/poweriq_client/resource/aisle.rb +7 -0
- data/lib/poweriq_client/resource/asset_strip.rb +7 -0
- data/lib/poweriq_client/resource/circuit_breaker_reading.rb +7 -0
- data/lib/poweriq_client/resource/circuit_breaker_readings_rollup.rb +7 -0
- data/lib/poweriq_client/resource/data_center.rb +7 -0
- data/lib/poweriq_client/resource/device.rb +7 -0
- data/lib/poweriq_client/resource/event.rb +7 -0
- data/lib/poweriq_client/resource/floor.rb +7 -0
- data/lib/poweriq_client/resource/job.rb +7 -0
- data/lib/poweriq_client/resource/job_message.rb +7 -0
- data/lib/poweriq_client/resource/line_reading.rb +7 -0
- data/lib/poweriq_client/resource/line_readings_rollup.rb +7 -0
- data/lib/poweriq_client/resource/outlet.rb +1 -2
- data/lib/poweriq_client/resource/outlet_reading.rb +7 -0
- data/lib/poweriq_client/resource/outlet_readings_rollup.rb +7 -0
- data/lib/poweriq_client/resource/pdu.rb +7 -0
- data/lib/poweriq_client/resource/rack.rb +7 -0
- data/lib/poweriq_client/resource/rack_unit.rb +7 -0
- data/lib/poweriq_client/resource/room.rb +7 -0
- data/lib/poweriq_client/resource/row.rb +7 -0
- data/lib/poweriq_client/resource/sensor.rb +7 -0
- data/lib/poweriq_client/resource/sensor_reading.rb +7 -0
- data/lib/poweriq_client/resource/sensor_readings_rollup.rb +7 -0
- data/lib/poweriq_client/resource.rb +23 -1
- data/lib/poweriq_client/version.rb +2 -2
- data/lib/poweriq_client.rb +1 -0
- data/poweriq_client.gemspec +25 -2
- metadata +26 -3
data/README.rdoc
CHANGED
@@ -1,8 +1,72 @@
|
|
1
|
-
=
|
1
|
+
= Power IQ Client
|
2
2
|
|
3
|
-
Power IQ Rest API client for Power IQ 3.1
|
3
|
+
Power IQ Rest API client for Power IQ 3.1. For a complete list of resources, routes, and methods available
|
4
|
+
see the online Power IQ documentation (http://www.raritan.com/support/power-iq).
|
4
5
|
|
5
|
-
==
|
6
|
+
== Installation
|
7
|
+
|
8
|
+
% gem install poweriq_client
|
9
|
+
|
10
|
+
== Console
|
11
|
+
|
12
|
+
The Power IQ client comes with a interactive console. To run the console:
|
13
|
+
|
14
|
+
% poweriq_client
|
15
|
+
|
16
|
+
==== Console Options
|
17
|
+
|
18
|
+
Usage: poweriq_client [options]
|
19
|
+
-l, --less-typing Put resource objects in global namespace
|
20
|
+
(ie PowerIQ::Resource::Outlet becomes Outlet)
|
21
|
+
-c, --check-compatibility Check client compatibility with server
|
22
|
+
-u, --user [USER] User name for authentication
|
23
|
+
-p, --password [PASSWORD] Password for authentication
|
24
|
+
-s, --server [HOST] Host name or IP of Power IQ
|
25
|
+
|
26
|
+
==== Console Configuration
|
27
|
+
|
28
|
+
Create a file named .poweriq_client in your home directory. The contents of the file
|
29
|
+
should look similiar to below, adjusted to your Power IQ server:
|
30
|
+
|
31
|
+
default:
|
32
|
+
host: vm163
|
33
|
+
user: admin
|
34
|
+
password: raritan
|
35
|
+
|
36
|
+
If you do not use a configuration file, or through the command line options above, you'll
|
37
|
+
need to provide the configuration manually:
|
38
|
+
|
39
|
+
% poweriq_client
|
40
|
+
>> PowerIQ::Configuration.configure("user"=>"foo","password"=>"bar","host"=>"vm150")
|
41
|
+
|
42
|
+
==== Console Examples
|
43
|
+
|
44
|
+
Retrieve all outlets:
|
45
|
+
>> outlets_resource = PowerIQ::Resource::Outlet.new
|
46
|
+
https://vm163/api/v2/outlets
|
47
|
+
>> outlets_resource.get
|
48
|
+
|
49
|
+
Retrieve one outlet:
|
50
|
+
>> outlet_resource = PowerIQ::Resource::Outlet.new('/381')
|
51
|
+
https://vm163/api/v2/outlets/381
|
52
|
+
>> outlet = outlet_resource.get
|
53
|
+
|
54
|
+
Update an outlet:
|
55
|
+
>> outlet_resource = PowerIQ::Resource::Outlet.new('/381')
|
56
|
+
https://vm163/api/v2/outlets/381
|
57
|
+
>> outlet = outlet_resource.get
|
58
|
+
>> outlet['outlet']['outlet_name'] = "New Name"
|
59
|
+
>> outlet_resource.put outlet.to_json
|
60
|
+
|
61
|
+
== Development
|
62
|
+
|
63
|
+
The Power IQ rest client uses the rest-client gem, with some
|
64
|
+
modifications to make it easier to query Power IQ resources.
|
65
|
+
For now you'll need to view the source code for more details,
|
66
|
+
however the usage is essentially the same as you see in the
|
67
|
+
interactive console examples above.
|
68
|
+
|
69
|
+
== Contributing to Power IQ Client
|
6
70
|
|
7
71
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
72
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
@@ -14,6 +78,5 @@ Power IQ Rest API client for Power IQ 3.1
|
|
14
78
|
|
15
79
|
== Copyright
|
16
80
|
|
17
|
-
Copyright (c) 2011
|
81
|
+
Copyright (c) 2011 Raritan, INC. See LICENSE.txt for
|
18
82
|
further details.
|
19
|
-
|
data/bin/poweriq_client
CHANGED
@@ -3,18 +3,65 @@
|
|
3
3
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
4
4
|
|
5
5
|
require 'rubygems'
|
6
|
+
require 'optparse'
|
6
7
|
require 'poweriq_client'
|
7
8
|
require 'irb'
|
8
9
|
require 'irb/completion'
|
9
10
|
|
11
|
+
options = {}
|
12
|
+
OptionParser.new do |opts|
|
13
|
+
opts.banner = "Usage: poweriq_client [options]"
|
14
|
+
opts.on("-l", "--less-typing", "Put resource objects in global namespace","(ie PowerIQ::Resource::Outlet becomes Outlet)") do |l|
|
15
|
+
options[:less_typing] = l
|
16
|
+
end
|
17
|
+
opts.on("-c", "--check-compatibility", "Check client compatibility with server") do |c|
|
18
|
+
options[:check_compatability] = c
|
19
|
+
end
|
20
|
+
opts.on("-u", "--user [USER]", "User name for authentication") do |u|
|
21
|
+
options[:user] = u
|
22
|
+
end
|
23
|
+
opts.on("-p", "--password [PASSWORD]", "Password for authentication") do |p|
|
24
|
+
options[:password] = p
|
25
|
+
end
|
26
|
+
opts.on("-s", "--server [HOST]", "Host name or IP of Power IQ") do |h|
|
27
|
+
options[:host] = h
|
28
|
+
end
|
29
|
+
end.parse!
|
30
|
+
|
10
31
|
if File.exists? ".irbrc"
|
11
32
|
ENV['IRBRC'] = ".irbrc"
|
12
33
|
end
|
13
|
-
|
14
|
-
|
15
|
-
|
34
|
+
unless(options[:user] || options[:password] || options[:host])
|
35
|
+
begin
|
36
|
+
PowerIQ::Configuration.load_configuration("default")
|
37
|
+
rescue
|
38
|
+
end
|
39
|
+
else
|
40
|
+
PowerIQ::Configuration.configure(options)
|
41
|
+
end
|
42
|
+
|
43
|
+
def less_typing
|
44
|
+
resources = Dir.entries(File.join(File.dirname(__FILE__), '..', 'lib','poweriq_client','resource')).select { |x| x=~%r{\.rb$} }
|
45
|
+
resources.each { |r| load File.join(File.dirname(__FILE__), '..', 'lib','poweriq_client','resource',r) }
|
46
|
+
classes = ObjectSpace.each_object(Class).map { |x| x.to_s}.select { |x| x=~/PowerIQ::Resource/ }.reject { |x| x=~/Base$/ }
|
47
|
+
classes.each { |c|
|
48
|
+
Object.const_set(c.demodulize,c.constantize)
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
def check_compatability
|
53
|
+
client_version = PowerIQ::Compatibility.client_version
|
54
|
+
server_version = PowerIQ::Compatibility.server_version
|
55
|
+
unless(PowerIQ::Compatibility.compatible?)
|
56
|
+
raise Error.new("This client (#{client_version}) is not supported by your version of Power IQ (#{server_version})")
|
57
|
+
else
|
58
|
+
puts "This client (#{client_version}) is supported by your version of Power IQ (#{server_version})"
|
59
|
+
end
|
16
60
|
end
|
17
61
|
|
62
|
+
check_compatability if(options[:check_compatability])
|
63
|
+
less_typing if(options[:less_typing])
|
64
|
+
|
18
65
|
ARGV.clear
|
19
66
|
IRB.start
|
20
67
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module PowerIQ
|
2
|
+
module Compatibility
|
3
|
+
API_COMPATIBILITY = %r{^3.1.*?}
|
4
|
+
@@system_info = nil
|
5
|
+
class << self
|
6
|
+
def compatible?
|
7
|
+
!!self.system_info['system_info']['poweriq_version'].match(API_COMPATIBILITY)
|
8
|
+
end
|
9
|
+
def server_version
|
10
|
+
self.system_info['system_info']['poweriq_version']
|
11
|
+
end
|
12
|
+
def client_version
|
13
|
+
PowerIQ::Version::STRING
|
14
|
+
end
|
15
|
+
def system_info
|
16
|
+
@@system_info ||= PowerIQ::Resource::SystemInfo.new.get
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -10,9 +10,10 @@ module PowerIQ
|
|
10
10
|
end
|
11
11
|
def configure(options=nil,&block)
|
12
12
|
unless(options.nil?)
|
13
|
-
|
14
|
-
self.
|
15
|
-
self.
|
13
|
+
options.symbolize_keys!
|
14
|
+
self.user = options[:user]
|
15
|
+
self.password = options[:password]
|
16
|
+
self.host = options[:host]
|
16
17
|
end
|
17
18
|
if(block_given?)
|
18
19
|
yield self
|
@@ -1,7 +1,29 @@
|
|
1
1
|
module PowerIQ
|
2
2
|
module Resource
|
3
3
|
autoload :Base, 'poweriq_client/resource/base'
|
4
|
-
autoload :
|
4
|
+
autoload :Aisle, 'poweriq_client/resource/aisle'
|
5
|
+
autoload :AssetStrip, 'poweriq_client/resource/asset_strip'
|
6
|
+
autoload :CircuitBreakerReading, 'poweriq_client/resource/circuit_breaker_reading'
|
7
|
+
autoload :CircuitBreakerReadingsRollup, 'poweriq_client/resource/circuit_breaker_readings_rollup'
|
8
|
+
autoload :DataCenter, 'poweriq_client/resource/data_center'
|
9
|
+
autoload :Device, 'poweriq_client/resource/device'
|
10
|
+
autoload :Event, 'poweriq_client/resource/event'
|
11
|
+
autoload :Floor, 'poweriq_client/resource/floor'
|
12
|
+
autoload :Job, 'poweriq_client/resource/job'
|
13
|
+
autoload :JobMessage, 'poweriq_client/resource/job_message'
|
14
|
+
autoload :LineReading, 'poweriq_client/resource/line_reading'
|
15
|
+
autoload :LineReadingsRollup, 'poweriq_client/resource/line_readings_rollup'
|
5
16
|
autoload :Outlet, 'poweriq_client/resource/outlet'
|
17
|
+
autoload :OutletReading, 'poweriq_client/resource/outlet_reading'
|
18
|
+
autoload :OutletReadingsRollup, 'poweriq_client/resource/outlet_readings_rollup'
|
19
|
+
autoload :Pdu, 'poweriq_client/resource/pdu'
|
20
|
+
autoload :Rack, 'poweriq_client/resource/rack'
|
21
|
+
autoload :RackUnit, 'poweriq_client/resource/rack_unit'
|
22
|
+
autoload :Room, 'poweriq_client/resource/room'
|
23
|
+
autoload :Row, 'poweriq_client/resource/row'
|
24
|
+
autoload :Sensor, 'poweriq_client/resource/sensor'
|
25
|
+
autoload :SensorReading, 'poweriq_client/resource/sensor_reading'
|
26
|
+
autoload :SensorReadingsRollup, 'poweriq_client/resource/sensor_readings_rollup'
|
27
|
+
autoload :SystemInfo, 'poweriq_client/resource/system_info'
|
6
28
|
end
|
7
29
|
end
|
data/lib/poweriq_client.rb
CHANGED
data/poweriq_client.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{poweriq_client}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Trent Albright}]
|
12
|
-
s.date = %q{2011-11-
|
12
|
+
s.date = %q{2011-11-03}
|
13
13
|
s.description = %q{Power IQ Rest API client for Power IQ 3.1}
|
14
14
|
s.email = %q{trent.albright@raritan.com}
|
15
15
|
s.executables = [%q{poweriq_client}]
|
@@ -28,10 +28,33 @@ Gem::Specification.new do |s|
|
|
28
28
|
"Rakefile",
|
29
29
|
"bin/poweriq_client",
|
30
30
|
"lib/poweriq_client.rb",
|
31
|
+
"lib/poweriq_client/compatibility.rb",
|
31
32
|
"lib/poweriq_client/configuration.rb",
|
32
33
|
"lib/poweriq_client/resource.rb",
|
34
|
+
"lib/poweriq_client/resource/aisle.rb",
|
35
|
+
"lib/poweriq_client/resource/asset_strip.rb",
|
33
36
|
"lib/poweriq_client/resource/base.rb",
|
37
|
+
"lib/poweriq_client/resource/circuit_breaker_reading.rb",
|
38
|
+
"lib/poweriq_client/resource/circuit_breaker_readings_rollup.rb",
|
39
|
+
"lib/poweriq_client/resource/data_center.rb",
|
40
|
+
"lib/poweriq_client/resource/device.rb",
|
41
|
+
"lib/poweriq_client/resource/event.rb",
|
42
|
+
"lib/poweriq_client/resource/floor.rb",
|
43
|
+
"lib/poweriq_client/resource/job.rb",
|
44
|
+
"lib/poweriq_client/resource/job_message.rb",
|
45
|
+
"lib/poweriq_client/resource/line_reading.rb",
|
46
|
+
"lib/poweriq_client/resource/line_readings_rollup.rb",
|
34
47
|
"lib/poweriq_client/resource/outlet.rb",
|
48
|
+
"lib/poweriq_client/resource/outlet_reading.rb",
|
49
|
+
"lib/poweriq_client/resource/outlet_readings_rollup.rb",
|
50
|
+
"lib/poweriq_client/resource/pdu.rb",
|
51
|
+
"lib/poweriq_client/resource/rack.rb",
|
52
|
+
"lib/poweriq_client/resource/rack_unit.rb",
|
53
|
+
"lib/poweriq_client/resource/room.rb",
|
54
|
+
"lib/poweriq_client/resource/row.rb",
|
55
|
+
"lib/poweriq_client/resource/sensor.rb",
|
56
|
+
"lib/poweriq_client/resource/sensor_reading.rb",
|
57
|
+
"lib/poweriq_client/resource/sensor_readings_rollup.rb",
|
35
58
|
"lib/poweriq_client/resource/system_info.rb",
|
36
59
|
"lib/poweriq_client/version.rb",
|
37
60
|
"poweriq_client.gemspec",
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: poweriq_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Trent Albright
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-11-
|
13
|
+
date: 2011-11-03 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
@@ -120,10 +120,33 @@ files:
|
|
120
120
|
- Rakefile
|
121
121
|
- bin/poweriq_client
|
122
122
|
- lib/poweriq_client.rb
|
123
|
+
- lib/poweriq_client/compatibility.rb
|
123
124
|
- lib/poweriq_client/configuration.rb
|
124
125
|
- lib/poweriq_client/resource.rb
|
126
|
+
- lib/poweriq_client/resource/aisle.rb
|
127
|
+
- lib/poweriq_client/resource/asset_strip.rb
|
125
128
|
- lib/poweriq_client/resource/base.rb
|
129
|
+
- lib/poweriq_client/resource/circuit_breaker_reading.rb
|
130
|
+
- lib/poweriq_client/resource/circuit_breaker_readings_rollup.rb
|
131
|
+
- lib/poweriq_client/resource/data_center.rb
|
132
|
+
- lib/poweriq_client/resource/device.rb
|
133
|
+
- lib/poweriq_client/resource/event.rb
|
134
|
+
- lib/poweriq_client/resource/floor.rb
|
135
|
+
- lib/poweriq_client/resource/job.rb
|
136
|
+
- lib/poweriq_client/resource/job_message.rb
|
137
|
+
- lib/poweriq_client/resource/line_reading.rb
|
138
|
+
- lib/poweriq_client/resource/line_readings_rollup.rb
|
126
139
|
- lib/poweriq_client/resource/outlet.rb
|
140
|
+
- lib/poweriq_client/resource/outlet_reading.rb
|
141
|
+
- lib/poweriq_client/resource/outlet_readings_rollup.rb
|
142
|
+
- lib/poweriq_client/resource/pdu.rb
|
143
|
+
- lib/poweriq_client/resource/rack.rb
|
144
|
+
- lib/poweriq_client/resource/rack_unit.rb
|
145
|
+
- lib/poweriq_client/resource/room.rb
|
146
|
+
- lib/poweriq_client/resource/row.rb
|
147
|
+
- lib/poweriq_client/resource/sensor.rb
|
148
|
+
- lib/poweriq_client/resource/sensor_reading.rb
|
149
|
+
- lib/poweriq_client/resource/sensor_readings_rollup.rb
|
127
150
|
- lib/poweriq_client/resource/system_info.rb
|
128
151
|
- lib/poweriq_client/version.rb
|
129
152
|
- poweriq_client.gemspec
|
@@ -142,7 +165,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
165
|
requirements:
|
143
166
|
- - ">="
|
144
167
|
- !ruby/object:Gem::Version
|
145
|
-
hash: -
|
168
|
+
hash: -4058341116595240085
|
146
169
|
segments:
|
147
170
|
- 0
|
148
171
|
version: "0"
|