xclarity_client 0.4.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/docs/apib/chassis.apib +4 -4
- data/docs/apib/event.apib +3 -3
- data/docs/apib/scalable_complex.apib +6 -6
- data/example/simple.rb +1 -1
- data/lib/utils/logger.rb +33 -0
- data/lib/xclarity_client.rb +3 -0
- data/lib/xclarity_client/chassi.rb +14 -11
- data/lib/xclarity_client/cmm.rb +6 -4
- data/lib/xclarity_client/configuration.rb +16 -3
- data/lib/xclarity_client/discover.rb +34 -0
- data/lib/xclarity_client/event.rb +7 -6
- data/lib/xclarity_client/fan.rb +6 -6
- data/lib/xclarity_client/fan_mux.rb +3 -4
- data/lib/xclarity_client/node.rb +12 -12
- data/lib/xclarity_client/node_management.rb +4 -0
- data/lib/xclarity_client/power_supply.rb +4 -6
- data/lib/xclarity_client/scalable_complex.rb +2 -2
- data/lib/xclarity_client/switch.rb +7 -6
- data/lib/xclarity_client/version.rb +1 -1
- data/lib/xclarity_client/virtual_appliance_management.rb +5 -0
- data/lib/xclarity_client/xclarity_base.rb +30 -10
- data/lib/xclarity_client/xclarity_management_mixin.rb +12 -1
- data/xclarity_client.gemspec +5 -4
- metadata +24 -6
@@ -5,8 +5,8 @@ module XClarityClient
|
|
5
5
|
BASE_URI = '/scalableComplex'.freeze
|
6
6
|
LIST_NAME = 'complex'.freeze
|
7
7
|
|
8
|
-
attr_accessor :
|
9
|
-
|
8
|
+
attr_accessor :complexID, :location, :nodeCount, :orphanNodes,
|
9
|
+
:partition, :partitionCount, :uuid
|
10
10
|
|
11
11
|
|
12
12
|
def initialize(attributes)
|
@@ -5,12 +5,13 @@ module XClarityClient
|
|
5
5
|
BASE_URI = '/switches'.freeze
|
6
6
|
LIST_NAME = 'switchList'.freeze
|
7
7
|
|
8
|
-
attr_accessor :
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
attr_accessor :accessState, :attachedNodes, :backedBy, :cmmDisplayName, :cmmHealthState,
|
9
|
+
:dataHandle, :description, :dnsHostnames, :errorFields, :excludedHealthState,
|
10
|
+
:firmware, :FRU, :fruSerialNumber, :hostname, :ipInterfaces, :ipv4Addresses,
|
11
|
+
:ipv6Addresses, :leds, :macAddresses, :machineType, :manufacturer, :manufacturerId,
|
12
|
+
:model, :name, :overallHealthState, :parent, :partNumber, :posID, :powerAllocation,
|
13
|
+
:powerState, :productId, :productName, :protectedMode, :serialNumber, :slots,
|
14
|
+
:stackMode, :type, :uri, :userDescription, :uuid, :vpdID
|
14
15
|
|
15
16
|
def initialize(attributes)
|
16
17
|
build_resource(attributes)
|
@@ -23,6 +23,7 @@ module XClarityClient
|
|
23
23
|
|
24
24
|
def ip_enablement_state
|
25
25
|
uri = BASE_URI+NETWORK_URI+IPDISABLE_URI
|
26
|
+
$lxca_log.info "XclarityClient::VirtualApplianceManagement ip_enablement_state", "Action has been sent to #{uri}"
|
26
27
|
response = connection(uri)
|
27
28
|
response
|
28
29
|
end
|
@@ -33,6 +34,7 @@ module XClarityClient
|
|
33
34
|
|
34
35
|
def host_settings
|
35
36
|
uri = BASE_URI+NETWORK_URI+IPDISABLE_URI
|
37
|
+
$lxca_log.info "XclarityClient::VirtualApplianceManagement host_settings", "Action has been sent to #{uri}"
|
36
38
|
response = connection(uri)
|
37
39
|
response
|
38
40
|
end
|
@@ -43,6 +45,7 @@ module XClarityClient
|
|
43
45
|
|
44
46
|
def network_interface_settings(interface)
|
45
47
|
uri = BASE_URI+NETWORK_URI+INTERFACES_URI+"/#{interface}"
|
48
|
+
$lxca_log.info "XclarityClient::VirtualApplianceManagement network_interface_settings", "Action has been sent to #{uri}"
|
46
49
|
response = connection(uri)
|
47
50
|
response
|
48
51
|
end
|
@@ -53,6 +56,7 @@ module XClarityClient
|
|
53
56
|
|
54
57
|
def route_settings
|
55
58
|
uri = BASE_URI+NETWORK_URI+ROUTES_URI
|
59
|
+
$lxca_log.info "XclarityClient::VirtualApplianceManagement route_settings", "Action has been sent to #{uri}"
|
56
60
|
response = connection(uri)
|
57
61
|
response
|
58
62
|
end
|
@@ -63,6 +67,7 @@ module XClarityClient
|
|
63
67
|
|
64
68
|
def subscriptions
|
65
69
|
uri = BASE_URI+SUBSCRIPTIONS_URI
|
70
|
+
$lxca_log.info "XclarityClient::VirtualApplianceManagement subscriptions", "Action has been sent to #{uri}"
|
66
71
|
response = connection(uri)
|
67
72
|
response
|
68
73
|
end
|
@@ -1,22 +1,31 @@
|
|
1
1
|
require 'faraday'
|
2
2
|
require 'json'
|
3
3
|
require 'uri'
|
4
|
+
require 'uri/https'
|
4
5
|
|
5
6
|
module XClarityClient
|
6
7
|
class XClarityBase
|
7
8
|
|
8
9
|
token_auth = '/session'.freeze
|
9
|
-
|
10
10
|
attr_reader :conn
|
11
|
-
|
11
|
+
|
12
12
|
def initialize(conf, uri)
|
13
13
|
connection_builder(conf, uri)
|
14
14
|
end
|
15
15
|
|
16
16
|
def connection_builder(conf, uri)
|
17
|
-
|
17
|
+
$lxca_log.info "XClarityClient::XClarityBase connection_builder", "Building the url"
|
18
18
|
#Building configuration
|
19
|
-
|
19
|
+
hostname = URI.parse(conf.host)
|
20
|
+
url = URI::HTTPS.build({ :host => hostname.scheme ? hostname.host : hostname.path,
|
21
|
+
:port => conf.port.to_i,
|
22
|
+
:path => uri,
|
23
|
+
:query => hostname.query,
|
24
|
+
:fragment => hostname.fragment }).to_s
|
25
|
+
|
26
|
+
$lxca_log.info "XClarityClient::XClarityBase connection_builder", "Creating connection to #{url}"
|
27
|
+
|
28
|
+
@conn = Faraday.new(url: url) do |faraday|
|
20
29
|
faraday.request :url_encoded # form-encode POST params
|
21
30
|
faraday.response :logger # log requests to STDOUT -- This line, should be uncommented if you wanna inspect the URL Request
|
22
31
|
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
@@ -26,7 +35,7 @@ module XClarityClient
|
|
26
35
|
response = authentication(conf) unless conf.auth_type != 'token'
|
27
36
|
#TODO: What's to do with the response of authentication request?
|
28
37
|
@conn.basic_auth(conf.username, conf.password) if conf.auth_type == 'basic_auth'
|
29
|
-
|
38
|
+
$lxca_log.info "XClarityClient::XclarityBase connection_builder", "Connection created Successfuly"
|
30
39
|
@conn
|
31
40
|
end
|
32
41
|
|
@@ -34,14 +43,25 @@ module XClarityClient
|
|
34
43
|
|
35
44
|
def connection(uri = "", opts = {})
|
36
45
|
query = opts.size > 0 ? "?" + opts.map {|k, v| "#{k}=#{v}"}.join(",") : ""
|
37
|
-
|
46
|
+
begin
|
47
|
+
@conn.get(uri + query)
|
48
|
+
rescue Faraday::Error::ConnectionFailed => e
|
49
|
+
$lxca_log.error "XClarityClient::XclarityBase connection", "Error trying to send a GET to #{uri + query}"
|
50
|
+
Faraday::Response.new
|
51
|
+
end
|
38
52
|
end
|
39
53
|
|
40
54
|
def do_put (uri="", request = {})
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
55
|
+
begin
|
56
|
+
@conn.put do |req|
|
57
|
+
req.url uri
|
58
|
+
req.headers['Content-Type'] = 'application/json'
|
59
|
+
req.body = request
|
60
|
+
end
|
61
|
+
rescue Faraday::Error::ConnectionFailed => e
|
62
|
+
$lxca_log.error "XClarityClient::XclarityBase do_put", "Error trying to send a PUT to #{uri}"
|
63
|
+
$lxca_log.error "XClarityClient::XclarityBase do_put", "Request sent: #{request}"
|
64
|
+
Faraday::Response.new
|
45
65
|
end
|
46
66
|
end
|
47
67
|
|
@@ -1,8 +1,12 @@
|
|
1
1
|
module XClarityClient
|
2
2
|
module ManagementMixin
|
3
3
|
def get_all_resources (resource, opts = {})
|
4
|
+
$lxca_log.info "XclarityClient::ManagementMixin get_all_resources", "Sending request to #{resource} resource"
|
5
|
+
|
4
6
|
response = connection(resource::BASE_URI, opts)
|
5
7
|
|
8
|
+
$lxca_log.info "XclarityClient::ManagementMixin get_all_resources", "Response received from #{resource::BASE_URI}"
|
9
|
+
|
6
10
|
return [] unless response.success?
|
7
11
|
|
8
12
|
body = JSON.parse(response.body)
|
@@ -15,6 +19,8 @@ module XClarityClient
|
|
15
19
|
|
16
20
|
def get_object(uuids, includeAttributes, excludeAttributes, resource)
|
17
21
|
|
22
|
+
$lxca_log.info "XclarityClient::ManagementMixin get_object", "Sending request to #{resource} resource"
|
23
|
+
|
18
24
|
uuids.reject! { |uuid| UUID.validate(uuid).nil? } unless uuids.nil?
|
19
25
|
|
20
26
|
response = if not includeAttributes.nil?
|
@@ -39,6 +45,8 @@ module XClarityClient
|
|
39
45
|
|
40
46
|
def get_object_with_include_attributes(uuids, attributes, resource)
|
41
47
|
|
48
|
+
$lxca_log.info "XclarityClient::ManagementMixin get_object_with_include", "Sending request to #{resource} resource including the following attributes: #{attributes.join(",")}"
|
49
|
+
|
42
50
|
uuids.reject! { |uuid| UUID.validate(uuid).nil? } unless uuids.nil?
|
43
51
|
|
44
52
|
response = if not uuids.nil?
|
@@ -51,6 +59,8 @@ module XClarityClient
|
|
51
59
|
|
52
60
|
def get_object_with_exclude_attributes(uuids, attributes, resource)
|
53
61
|
|
62
|
+
$lxca_log.info "XclarityClient::ManagementMixin get_object_with_include", "Sending request to #{resource} resource excluding the following attributes: #{attributes.join(",")}"
|
63
|
+
|
54
64
|
uuids.reject! { |uuid| UUID.validate(uuid).nil? } unless uuids.nil?
|
55
65
|
|
56
66
|
response = if not uuids.nil?
|
@@ -78,7 +88,8 @@ module XClarityClient
|
|
78
88
|
else
|
79
89
|
filter += "?type=#{opts["type"]}"
|
80
90
|
end
|
81
|
-
|
91
|
+
$lxca_log.info "XclarityClient::ManagementMixin get_object_with_include", "Sending request to #{resource} resource using the following filter: #{filter}"
|
92
|
+
connection(resource::BASE_URI + filter)
|
82
93
|
end
|
83
94
|
|
84
95
|
return [] unless response.success?
|
data/xclarity_client.gemspec
CHANGED
@@ -6,11 +6,11 @@ require 'xclarity_client/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "xclarity_client"
|
8
8
|
spec.version = XClarityClient::VERSION
|
9
|
-
spec.authors = ["
|
10
|
-
spec.email = ["
|
9
|
+
spec.authors = ["Manasa Rao","Rodney H. Brown"]
|
10
|
+
spec.email = ["mrao@lenovo.com","rbrown4@lenovo.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{Lenovo
|
13
|
-
spec.homepage = "https://github.com/
|
12
|
+
spec.summary = %q{Lenovo XClarity API Client}
|
13
|
+
spec.homepage = "https://github.com/lenovo/xclarity_client"
|
14
14
|
|
15
15
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
16
|
spec.bindir = "exe"
|
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency "webmock", "~> 2.1.0"
|
25
25
|
spec.add_dependency "faraday", "~> 0.9.2"
|
26
26
|
spec.add_dependency "uuid", "~> 2.3.8"
|
27
|
+
spec.add_dependency "faker", "~> 1.8.3"
|
27
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xclarity_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Manasa Rao
|
8
|
+
- Rodney H. Brown
|
8
9
|
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date: 2017-
|
12
|
+
date: 2017-07-18 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
@@ -108,9 +109,24 @@ dependencies:
|
|
108
109
|
- - "~>"
|
109
110
|
- !ruby/object:Gem::Version
|
110
111
|
version: 2.3.8
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: faker
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 1.8.3
|
119
|
+
type: :runtime
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 1.8.3
|
111
126
|
description:
|
112
127
|
email:
|
113
|
-
-
|
128
|
+
- mrao@lenovo.com
|
129
|
+
- rbrown4@lenovo.com
|
114
130
|
executables: []
|
115
131
|
extensions: []
|
116
132
|
extra_rdoc_files: []
|
@@ -141,6 +157,7 @@ files:
|
|
141
157
|
- docs/apib/squisher.rb
|
142
158
|
- docs/apib/switches.apib
|
143
159
|
- example/simple.rb
|
160
|
+
- lib/utils/logger.rb
|
144
161
|
- lib/xclarity_client.rb
|
145
162
|
- lib/xclarity_client/cabinet.rb
|
146
163
|
- lib/xclarity_client/cabinet_management.rb
|
@@ -152,6 +169,7 @@ files:
|
|
152
169
|
- lib/xclarity_client/cmm.rb
|
153
170
|
- lib/xclarity_client/cmm_management.rb
|
154
171
|
- lib/xclarity_client/configuration.rb
|
172
|
+
- lib/xclarity_client/discover.rb
|
155
173
|
- lib/xclarity_client/event.rb
|
156
174
|
- lib/xclarity_client/event_management.rb
|
157
175
|
- lib/xclarity_client/fan.rb
|
@@ -172,7 +190,7 @@ files:
|
|
172
190
|
- lib/xclarity_client/xclarity_management_mixin.rb
|
173
191
|
- lib/xclarity_client/xclarity_resource.rb
|
174
192
|
- xclarity_client.gemspec
|
175
|
-
homepage: https://github.com/
|
193
|
+
homepage: https://github.com/lenovo/xclarity_client
|
176
194
|
licenses: []
|
177
195
|
metadata: {}
|
178
196
|
post_install_message:
|
@@ -194,5 +212,5 @@ rubyforge_project:
|
|
194
212
|
rubygems_version: 2.5.1
|
195
213
|
signing_key:
|
196
214
|
specification_version: 4
|
197
|
-
summary: Lenovo
|
215
|
+
summary: Lenovo XClarity API Client
|
198
216
|
test_files: []
|