xclarity_client 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile +2 -0
- data/README.md +57 -4
- data/bin/mock_server.ru +1 -1
- data/docs/apib/cabinet.apib +63 -0
- data/docs/apib/canister.apib +69 -0
- data/docs/apib/chassis.apib +65 -1428
- data/docs/apib/cmm.apib +1102 -0
- data/docs/apib/fan.apib +383 -0
- data/docs/apib/fan_mux.apib +13 -0
- data/docs/apib/fan_muxes.apib +245 -0
- data/docs/apib/node.apib +8989 -869
- data/docs/apib/power_supply.apib +519 -0
- data/docs/apib/scalable_complex.apib +91 -0
- data/docs/apib/squisher.rb +26 -0
- data/docs/apib/switches.apib +1596 -0
- data/example/simple.rb +12 -5
- data/lib/xclarity_client.rb +20 -0
- data/lib/xclarity_client/cabinet.rb +14 -0
- data/lib/xclarity_client/cabinet_management.rb +59 -0
- data/lib/xclarity_client/canister.rb +20 -0
- data/lib/xclarity_client/canister_management.rb +60 -0
- data/lib/xclarity_client/chassi.rb +24 -0
- data/lib/xclarity_client/chassi_management.rb +64 -0
- data/lib/xclarity_client/client.rb +77 -1
- data/lib/xclarity_client/cmm.rb +18 -0
- data/lib/xclarity_client/cmm_management.rb +61 -0
- data/lib/xclarity_client/configuration.rb +13 -3
- data/lib/xclarity_client/fan.rb +20 -0
- data/lib/xclarity_client/fan_management.rb +83 -0
- data/lib/xclarity_client/fan_mux.rb +18 -0
- data/lib/xclarity_client/fan_mux_management.rb +82 -0
- data/lib/xclarity_client/node.rb +15 -94
- data/lib/xclarity_client/node_management.rb +62 -0
- data/lib/xclarity_client/power_supply.rb +18 -0
- data/lib/xclarity_client/power_supply_management.rb +89 -0
- data/lib/xclarity_client/scalable_complex.rb +16 -0
- data/lib/xclarity_client/scalable_complex_management.rb +83 -0
- data/lib/xclarity_client/switch.rb +19 -0
- data/lib/xclarity_client/switch_management.rb +59 -0
- data/lib/xclarity_client/version.rb +1 -1
- data/lib/xclarity_client/xclarity_base.rb +26 -1
- data/lib/xclarity_client/xclarity_resource.rb +20 -0
- data/xclarity_client.gemspec +1 -2
- metadata +34 -5
- data/lib/xclarity_client/chassis.rb +0 -7
@@ -0,0 +1,16 @@
|
|
1
|
+
module XClarityClient
|
2
|
+
class ScalableComplex
|
3
|
+
include XClarityClient::Resource
|
4
|
+
|
5
|
+
BASE_URI = '/scalable_complexes'.freeze
|
6
|
+
|
7
|
+
attr_accessor :properties, :_id, :location, :nodeCount, :orphanNodes,
|
8
|
+
:partition, :partitionCount, :uuid, :slots, :complexID
|
9
|
+
|
10
|
+
|
11
|
+
def initialize(attributes)
|
12
|
+
build_resource(attributes)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module XClarityClient
|
4
|
+
class ScalableComplexManagement < XClarityBase
|
5
|
+
|
6
|
+
BASE_URI = '/scalableComplex'.freeze
|
7
|
+
|
8
|
+
def initialize(conf)
|
9
|
+
super(conf, BASE_URI)
|
10
|
+
end
|
11
|
+
|
12
|
+
def population
|
13
|
+
response = connection(BASE_URI)
|
14
|
+
body = JSON.parse(response.body)
|
15
|
+
body = {'complex' => [body]} unless body.has_key? 'complex'
|
16
|
+
body['complex'].map do |scalableComplex|
|
17
|
+
ScalableComplex.new scalableComplex
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_object_scalableComplexes(uuids, includeAttributes, excludeAttributes)
|
22
|
+
|
23
|
+
response = if not includeAttributes.nil?
|
24
|
+
get_object_scalableComplexes_include_attributes(uuids, includeAttributes)
|
25
|
+
elsif not excludeAttributes.nil?
|
26
|
+
get_object_scalableComplexes_exclude_attributes(uuids, excludeAttributes)
|
27
|
+
elsif not uuids.nil?
|
28
|
+
response = connection(BASE_URI + "/" + uuids)
|
29
|
+
body = JSON.parse(response.body)
|
30
|
+
body = {'complex' => [body]} unless body.has_key? 'complex'
|
31
|
+
body['complex'].map do |scalableComplex|
|
32
|
+
ScalableComplex.new scalableComplex
|
33
|
+
end
|
34
|
+
else
|
35
|
+
response = connection(BASE_URI)
|
36
|
+
body = JSON.parse(response.body)
|
37
|
+
body = {'complex' => [body]} unless body.has_key? 'complex'
|
38
|
+
body['complex'].map do |scalableComplex|
|
39
|
+
ScalableComplex.new scalableComplex
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_object_scalableComplexes_exclude_attributes(uuids, attributes)
|
46
|
+
|
47
|
+
if not uuids.nil?
|
48
|
+
response = connection(BASE_URI + "/" + uuids +"?excludeAttributes=" + attributes.join(","))
|
49
|
+
body = JSON.parse(response.body)
|
50
|
+
body = {'complex' => [body]} unless body.has_key? 'complex'
|
51
|
+
body['complex'].map do |scalableComplex|
|
52
|
+
ScalableComplex.new scalableComplex
|
53
|
+
end
|
54
|
+
else
|
55
|
+
response = connection(BASE_URI + "?excludeAttributes=" + attributes.join(","))
|
56
|
+
body = JSON.parse(response.body)
|
57
|
+
body = {'complex' => [body]} unless body.has_key? 'complex'
|
58
|
+
body['complex'].map do |scalableComplex|
|
59
|
+
ScalableComplex.new scalableComplex
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
def get_object_scalableComplexes_include_attributes(uuids, attributes)
|
66
|
+
if not uuids.nil?
|
67
|
+
response = connection(BASE_URI + "/" + uuids + "?includeAttributes=" + attributes.join(","))
|
68
|
+
body = JSON.parse(response.body)
|
69
|
+
body = {'complex' => [body]} unless body.has_key? 'complex'
|
70
|
+
body['complex'].map do |scalableComplex|
|
71
|
+
ScalableComplex.new scalableComplex
|
72
|
+
end
|
73
|
+
else
|
74
|
+
response = connection(BASE_URI + "?includeAttributes=" + attributes.join(","))
|
75
|
+
body = JSON.parse(response.body)
|
76
|
+
body = {'complex' => [body]} unless body.has_key? 'complex'
|
77
|
+
body['complex'].map do |scalableComplex|
|
78
|
+
ScalableComplex.new scalableComplex
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module XClarityClient
|
2
|
+
class Switch
|
3
|
+
include XClarityClient::Resource
|
4
|
+
|
5
|
+
BASE_URI = '/switches'.freeze
|
6
|
+
|
7
|
+
attr_accessor :properties, :_id, :accessState, :applyPending, :attachedNodes, :cmmDisplayName, :cmmHealthState, :entitleSerialNumber, :fans, :firmware, :hostname, :ipInterfaces,
|
8
|
+
:leds, :macAddresses, :machineType, :manufacturer, :manufacturerId, :ports, :productId, :productName, :protectedMode, :serialNumber, :type, :upTime, :uuid, :accessState,
|
9
|
+
:cmmHealthState, :excludedHealthState, :memoryUtilization, :model, :overallHealthState, :panicDump, :powerState, :savePending, :slots, :posID, :stackMode, :stackedMode,
|
10
|
+
:stackRole, :sysObjectID, :temperatureSensors, :userDescription, :vpdID, :contact, :cpuUtilization, :dataHandle, :description, :dnsHostnames, :domainName, :errorFields,
|
11
|
+
:FRU, :fruSerialNumber, :ipv4Addresses, :ipv6Addresses, :ipInterfaces, :manufacturingDate, :name, :resetReason, :uri, :backedBy, :partNumber, :parent, :powerAllocation
|
12
|
+
|
13
|
+
|
14
|
+
def initialize(attributes)
|
15
|
+
build_resource(attributes)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module XClarityClient
|
4
|
+
class SwitchManagement < XClarityBase
|
5
|
+
|
6
|
+
BASE_URI = '/switches'.freeze
|
7
|
+
|
8
|
+
def initialize(conf)
|
9
|
+
super(conf, BASE_URI)
|
10
|
+
end
|
11
|
+
|
12
|
+
def population
|
13
|
+
response = connection(BASE_URI)
|
14
|
+
body = JSON.parse(response.body)
|
15
|
+
body = {'switchList' => [body]} unless body.has_key? 'switchList'
|
16
|
+
body['switchList'].map do |switch|
|
17
|
+
Switch.new switch
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_object_switches(uuids, includeAttributes, excludeAttributes)
|
22
|
+
|
23
|
+
response = if not includeAttributes.nil?
|
24
|
+
get_object_switches_include_attributes(uuids, includeAttributes)
|
25
|
+
elsif not excludeAttributes.nil?
|
26
|
+
get_object_switches_exclude_attributes(uuids, excludeAttributes)
|
27
|
+
elsif not uuids.nil?
|
28
|
+
connection(BASE_URI + "/" + uuids.join(","))
|
29
|
+
else
|
30
|
+
connection(BASE_URI)
|
31
|
+
end
|
32
|
+
|
33
|
+
body = JSON.parse(response.body)
|
34
|
+
body = {'switchList' => [body]} unless body.has_key? 'switchList'
|
35
|
+
body['switchList'].map do |switch|
|
36
|
+
Switch.new switch
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_object_switches_exclude_attributes(uuids, attributes)
|
42
|
+
|
43
|
+
response = if not uuids.nil?
|
44
|
+
connection(BASE_URI + "/#{uuids.join(",")}"+"?excludeAttributes=#{attributes.join(",")}")
|
45
|
+
else
|
46
|
+
connection(BASE_URI + "?excludeAttributes=" + attributes.join(","))
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_object_switches_include_attributes(uuids, attributes)
|
52
|
+
response = if not uuids.nil?
|
53
|
+
connection(BASE_URI + "/" + uuids.join(",") + "?includeAttributes=" + attributes.join(","))
|
54
|
+
else
|
55
|
+
connection(BASE_URI + "?includeAttributes=" + attributes.join(","))
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -1,8 +1,12 @@
|
|
1
1
|
require 'faraday'
|
2
|
+
require 'json'
|
3
|
+
require 'uri'
|
2
4
|
|
3
5
|
module XClarityClient
|
4
6
|
class XClarityBase
|
5
7
|
|
8
|
+
token_auth = '/session'.freeze
|
9
|
+
|
6
10
|
attr_reader :conn
|
7
11
|
|
8
12
|
def initialize(conf, uri)
|
@@ -10,11 +14,20 @@ module XClarityClient
|
|
10
14
|
end
|
11
15
|
|
12
16
|
def connection_builder(conf, uri)
|
17
|
+
|
18
|
+
#Building configuration
|
13
19
|
@conn = Faraday.new(url: conf.host + uri) do |faraday|
|
14
20
|
faraday.request :url_encoded # form-encode POST params
|
15
|
-
faraday.response :logger # log requests to STDOUT
|
21
|
+
# faraday.response :logger # log requests to STDOUT -- This line, should be uncommented if you wanna inspect the URL Request
|
16
22
|
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
23
|
+
faraday.ssl[:verify] = conf.verify_ssl == 'PEER'
|
17
24
|
end
|
25
|
+
|
26
|
+
response = authentication(conf) unless conf.auth_type != 'token'
|
27
|
+
#TODO: What's to do with the response of authentication request?
|
28
|
+
@conn.basic_auth(conf.username, conf.password) if conf.auth_type == 'basic_auth'
|
29
|
+
|
30
|
+
@conn
|
18
31
|
end
|
19
32
|
|
20
33
|
private
|
@@ -22,5 +35,17 @@ module XClarityClient
|
|
22
35
|
def connection(uri = "", options = {})
|
23
36
|
@conn.get(uri)
|
24
37
|
end
|
38
|
+
|
39
|
+
def authentication(conf)
|
40
|
+
response = @conn.post do |request|
|
41
|
+
request.url '/session'
|
42
|
+
request.headers['Content-Type'] = 'application/json'
|
43
|
+
request.body = {:UserId => conf.username,
|
44
|
+
:password => conf.password,
|
45
|
+
:heartBeatEnabled => true,
|
46
|
+
:maxLostHeartBeats => 3,
|
47
|
+
:csrf => conf.csrf_token}.to_json
|
48
|
+
end
|
49
|
+
end
|
25
50
|
end
|
26
51
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module XClarityClient
|
2
|
+
module Resource
|
3
|
+
def build_resource(attributes)
|
4
|
+
attributes.each do |key, value|
|
5
|
+
begin
|
6
|
+
value = value.gsub("\u0000", '') if value.is_a?(String)
|
7
|
+
send("#{key}=", value)
|
8
|
+
rescue
|
9
|
+
$log.warn("UNEXISTING ATTRIBUTES FOR #{self.class}: #{key}") unless defined?(Rails).nil?
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_hash
|
15
|
+
hash = {}
|
16
|
+
instance_variables.each {|var| hash[var.to_s.delete("@")] = instance_variable_get(var) }
|
17
|
+
hash
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/xclarity_client.gemspec
CHANGED
@@ -9,8 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Julian Cheal"]
|
10
10
|
spec.email = ["jcheal@redhat.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{
|
13
|
-
spec.description = %q{Write a longer description or delete this line.}
|
12
|
+
spec.summary = %q{Lenovo XClairty API Client}
|
14
13
|
spec.homepage = "https://github.com/juliancheal/xclarity_client"
|
15
14
|
|
16
15
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xclarity_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Cheal
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,7 +94,7 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.9.2
|
97
|
-
description:
|
97
|
+
description:
|
98
98
|
email:
|
99
99
|
- jcheal@redhat.com
|
100
100
|
executables: []
|
@@ -113,17 +113,46 @@ files:
|
|
113
113
|
- bin/mock_server.ru
|
114
114
|
- bin/setup
|
115
115
|
- docs/apib/aicc.apib
|
116
|
+
- docs/apib/cabinet.apib
|
117
|
+
- docs/apib/canister.apib
|
116
118
|
- docs/apib/chassis.apib
|
119
|
+
- docs/apib/cmm.apib
|
120
|
+
- docs/apib/fan.apib
|
121
|
+
- docs/apib/fan_mux.apib
|
122
|
+
- docs/apib/fan_muxes.apib
|
117
123
|
- docs/apib/node.apib
|
124
|
+
- docs/apib/power_supply.apib
|
125
|
+
- docs/apib/scalable_complex.apib
|
126
|
+
- docs/apib/squisher.rb
|
127
|
+
- docs/apib/switches.apib
|
118
128
|
- example/simple.rb
|
119
129
|
- lib/xclarity_client.rb
|
120
|
-
- lib/xclarity_client/
|
130
|
+
- lib/xclarity_client/cabinet.rb
|
131
|
+
- lib/xclarity_client/cabinet_management.rb
|
132
|
+
- lib/xclarity_client/canister.rb
|
133
|
+
- lib/xclarity_client/canister_management.rb
|
134
|
+
- lib/xclarity_client/chassi.rb
|
135
|
+
- lib/xclarity_client/chassi_management.rb
|
121
136
|
- lib/xclarity_client/client.rb
|
137
|
+
- lib/xclarity_client/cmm.rb
|
138
|
+
- lib/xclarity_client/cmm_management.rb
|
122
139
|
- lib/xclarity_client/configuration.rb
|
140
|
+
- lib/xclarity_client/fan.rb
|
141
|
+
- lib/xclarity_client/fan_management.rb
|
142
|
+
- lib/xclarity_client/fan_mux.rb
|
143
|
+
- lib/xclarity_client/fan_mux_management.rb
|
123
144
|
- lib/xclarity_client/node.rb
|
145
|
+
- lib/xclarity_client/node_management.rb
|
146
|
+
- lib/xclarity_client/power_supply.rb
|
147
|
+
- lib/xclarity_client/power_supply_management.rb
|
148
|
+
- lib/xclarity_client/scalable_complex.rb
|
149
|
+
- lib/xclarity_client/scalable_complex_management.rb
|
150
|
+
- lib/xclarity_client/switch.rb
|
151
|
+
- lib/xclarity_client/switch_management.rb
|
124
152
|
- lib/xclarity_client/version.rb
|
125
153
|
- lib/xclarity_client/virtual_appliance_management.rb
|
126
154
|
- lib/xclarity_client/xclarity_base.rb
|
155
|
+
- lib/xclarity_client/xclarity_resource.rb
|
127
156
|
- xclarity_client.gemspec
|
128
157
|
homepage: https://github.com/juliancheal/xclarity_client
|
129
158
|
licenses: []
|
@@ -147,6 +176,6 @@ rubyforge_project:
|
|
147
176
|
rubygems_version: 2.6.3
|
148
177
|
signing_key:
|
149
178
|
specification_version: 4
|
150
|
-
summary:
|
179
|
+
summary: Lenovo XClairty API Client
|
151
180
|
test_files: []
|
152
181
|
has_rdoc:
|