xclarity_client 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +35 -62
- data/docs/apib/chassis.apib +4 -0
- data/docs/apib/storages.apib +48 -1
- data/lib/xclarity_client/endpoints/chassi.rb +7 -0
- data/lib/xclarity_client/endpoints/node.rb +8 -0
- data/lib/xclarity_client/endpoints/storage.rb +5 -4
- data/lib/xclarity_client/mixins/chassi_mixin.rb +20 -2
- data/lib/xclarity_client/mixins/node_mixin.rb +6 -6
- data/lib/xclarity_client/services/chassi_management.rb +4 -0
- data/lib/xclarity_client/services/mixins/power_action_sender_mixin.rb +60 -6
- data/lib/xclarity_client/services/node_management.rb +0 -8
- data/lib/xclarity_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46c74492a0ba842bb4252ace8c8a29eb6ff3eb0b
|
4
|
+
data.tar.gz: adaddc2302e33b60d7b4246fc0ffb19b2aeb1912
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db19eeba154a7afa8b8d33491ce33792fa461e54d2b714c40ded82e7e48eeef9d4e5c3ecbd8e918e427da6839c09abf40fae2e03fe842d7a0d6ba5fc1d88fbc4
|
7
|
+
data.tar.gz: 8475d380d21a2bfd08fb0f5c57cfb81d3248e096e7e72071c8da6d781b6502b3b8b39f5a03ae78e79f2c0fa167540a95ed82b9f5e49096d93820dd9a694a0db0
|
data/README.md
CHANGED
@@ -1,57 +1,11 @@
|
|
1
|
-
|
1
|
+
<p align="center"><a href="https://www3.lenovo.com/us/en/data-center/software/systems-management/xclarity/" target="_blank" rel="noopener noreferrer"><img width="200" src="https://www3.lenovo.com/medias/lenovo-systems-software-management-xclarity-intro.png?context=bWFzdGVyfHJvb3R8NjY0OXxpbWFnZS9wbmd8aDI2L2hlMS85NDQ4OTkwODAxOTUwLnBuZ3xjZTdiOWJhNDViMTVhMjJjNTFiMWRmNzlhMDFkYzRmN2NkNGJjMzk1NTUxN2ZhYjExYWU1MDJlYmUyNGJkYjIw" alt="Lenovo Xclarity Logo"></a></p>
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/xclarity_client`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
|
-
|
7
|
-
TODO: Delete this and the text above, and describe your gem
|
8
|
-
|
9
|
-
## Pre Configuration for Connection with LXCA
|
10
|
-
|
11
|
-
|
12
|
-
Get up and running mongo database
|
13
|
-
|
14
|
-
Execute rails console:
|
15
|
-
|
16
|
-
```ruby
|
17
|
-
$ bundle exec rails console
|
18
|
-
```
|
19
|
-
|
20
|
-
Add resources to your database:
|
21
|
-
|
22
|
-
Nodes:
|
23
|
-
|
24
|
-
```ruby
|
25
|
-
$ FactoryGirl.create(:node)
|
26
|
-
```
|
27
|
-
Switches:
|
28
|
-
|
29
|
-
```ruby
|
30
|
-
$ FactoryGirl.create(:switch)
|
31
|
-
```
|
32
|
-
Scalable Complexes:
|
33
|
-
|
34
|
-
```ruby
|
35
|
-
$ FactoryGirl.create(:scalable_complex)
|
36
|
-
```
|
37
|
-
|
38
|
-
Power Supplies:
|
39
|
-
|
40
|
-
```ruby
|
41
|
-
$ FactoryGirl.create(:power_supply)
|
42
|
-
```
|
3
|
+
xclarity_client
|
4
|
+
===
|
43
5
|
|
44
|
-
|
45
|
-
|
46
|
-
```ruby
|
47
|
-
$ FactoryGirl.create(:chassi)
|
48
|
-
```
|
49
|
-
|
50
|
-
Get up LXCA-Mock server:
|
6
|
+
[![Build Status](https://travis-ci.org/lenovo/xclarity_client.svg)](https://travis-ci.org/lenovo/xclarity_client)
|
51
7
|
|
52
|
-
|
53
|
-
$ bundle exec rails s
|
54
|
-
```
|
8
|
+
Ruby gem to interact with Lenovo XClarity.
|
55
9
|
|
56
10
|
## Installation
|
57
11
|
|
@@ -71,27 +25,46 @@ Or install it yourself as:
|
|
71
25
|
|
72
26
|
## Usage
|
73
27
|
|
74
|
-
To
|
28
|
+
To configure your appliance access:
|
75
29
|
|
76
30
|
```ruby
|
77
31
|
require 'xclarity_client'
|
78
32
|
|
79
33
|
conf = XClarityClient::Configuration.new(
|
80
|
-
:
|
81
|
-
:
|
82
|
-
:
|
83
|
-
:
|
34
|
+
:host => 'http://lxca_host.com'
|
35
|
+
:username => 'username',
|
36
|
+
:password => 'password',
|
37
|
+
:port => 'lxca_port',
|
38
|
+
:auth_type => 'auth_type', # ('token', 'basic_auth')
|
39
|
+
:verify_ssl => 'verify_ssl', # ('PEER', 'NONE')
|
40
|
+
:user_agent_label => 'user_agent' # Api gem client identification
|
84
41
|
)
|
85
42
|
|
86
|
-
|
43
|
+
client = XClarityClient::Client.new(conf)
|
44
|
+
```
|
87
45
|
|
88
|
-
|
46
|
+
To access the appliance data:
|
89
47
|
|
90
|
-
|
48
|
+
```ruby
|
49
|
+
client.discover_aicc # get AICC informations
|
50
|
+
|
51
|
+
client.discover_cabinet # get Cabinets from LXCA appliance
|
91
52
|
|
92
|
-
|
53
|
+
# get the cabinets with the specifieds UUIDs,
|
54
|
+
# and retrive just `storageList` and `height` attributes.
|
55
|
+
client.fetch_cabinet(
|
56
|
+
uuids = ['590b2546bbbc457f-bf801661018c408e', 'd27e57aa278c49a9b57e34a8e6c6e8ae'],
|
57
|
+
include_attributes = ['storageList', 'height']
|
58
|
+
)
|
59
|
+
|
60
|
+
# get the cabinets with the specifieds UUIDs,
|
61
|
+
# and retrive all attributes except `height`.
|
62
|
+
client.fetch_cabinet(
|
63
|
+
uuids = ['590b2546bbbc457f-bf801661018c408e', 'd27e57aa278c49a9b57e34a8e6c6e8ae'],
|
64
|
+
exclude_attributes = ['height']
|
65
|
+
)
|
93
66
|
```
|
94
|
-
|
67
|
+
> To see how to interact with other LXCA resources, please take a look at `lib/xclarity_client/mixins` folder.
|
95
68
|
|
96
69
|
## Development
|
97
70
|
|
@@ -101,4 +74,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
101
74
|
|
102
75
|
## Contributing
|
103
76
|
|
104
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
77
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/lenovo/xclarity_client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
data/docs/apib/chassis.apib
CHANGED
data/docs/apib/storages.apib
CHANGED
@@ -147,7 +147,54 @@ FORMAT: 1A
|
|
147
147
|
}
|
148
148
|
],
|
149
149
|
"drives":[
|
150
|
-
|
150
|
+
{
|
151
|
+
"model": "ST9300653SS",
|
152
|
+
"vendorName": "IBM-ESXS",
|
153
|
+
"status": "Up",
|
154
|
+
"location": "0.22",
|
155
|
+
"serialNumber": "6XN43QX50000B349D4LY",
|
156
|
+
"healthReason": "",
|
157
|
+
"health": "OK",
|
158
|
+
"type": "SAS",
|
159
|
+
"healthRecommendation": "",
|
160
|
+
"size": "300.0GB"
|
161
|
+
},
|
162
|
+
{
|
163
|
+
"model": "ST9300605SS",
|
164
|
+
"vendorName": "IBM-ESXS",
|
165
|
+
"status": "Up",
|
166
|
+
"location": "0.17",
|
167
|
+
"serialNumber": "6XP5L6ZE0000B344HRZG",
|
168
|
+
"healthReason": "",
|
169
|
+
"health": "OK",
|
170
|
+
"type": "SAS",
|
171
|
+
"healthRecommendation": "",
|
172
|
+
"size": "300.0GB"
|
173
|
+
},
|
174
|
+
{
|
175
|
+
"model": "ST9300653SS",
|
176
|
+
"vendorName": "IBM-ESXS",
|
177
|
+
"status": "Up",
|
178
|
+
"location": "0.23",
|
179
|
+
"serialNumber": "6XN43QR90000B350B5G2",
|
180
|
+
"healthReason": "A disk that was previously a member of a disk group has been detected.",
|
181
|
+
"health": "Degraded",
|
182
|
+
"type": "SAS",
|
183
|
+
"healthRecommendation": "- If the associated disk group is offline or quarantined, contact technical support. Otherwise, clear the disk metadata to reuse the disk.",
|
184
|
+
"size": "300.0GB"
|
185
|
+
},
|
186
|
+
{
|
187
|
+
"model": "ST9300605SS",
|
188
|
+
"vendorName": "IBM-ESXS",
|
189
|
+
"status": "Up",
|
190
|
+
"location": "0.16",
|
191
|
+
"serialNumber": "6XP5L7QP0000B344HS0E",
|
192
|
+
"healthReason": "",
|
193
|
+
"health": "OK",
|
194
|
+
"type": "SAS",
|
195
|
+
"healthRecommendation": "",
|
196
|
+
"size": "300.0GB"
|
197
|
+
}
|
151
198
|
],
|
152
199
|
"canisters":[
|
153
200
|
{
|
@@ -1,8 +1,15 @@
|
|
1
1
|
module XClarityClient
|
2
2
|
class Chassi < Endpoints::XclarityEndpoint
|
3
3
|
BASE_URI = '/chassis'.freeze
|
4
|
+
|
4
5
|
LIST_NAME = 'chassisList'.freeze
|
5
6
|
|
7
|
+
LED_STATES = %w(
|
8
|
+
Blinking
|
9
|
+
On
|
10
|
+
Off
|
11
|
+
).freeze
|
12
|
+
|
6
13
|
attr_accessor :accessState, :activationKeys, :activeAlerts, :backedBy,
|
7
14
|
:bladeSlots, :cmmDisplayName, :cmmHealthState, :cmms, :complex,
|
8
15
|
:contact, :dataHandle, :description, :displayName, :domainName,
|
@@ -1,7 +1,9 @@
|
|
1
1
|
module XClarityClient
|
2
2
|
class Node < Endpoints::XclarityEndpoint
|
3
3
|
BASE_URI = '/nodes'.freeze
|
4
|
+
|
4
5
|
LIST_NAME = 'nodeList'.freeze
|
6
|
+
|
5
7
|
POWER_ACTIONS = %i(
|
6
8
|
powerOn
|
7
9
|
powerOffSoftGraceful
|
@@ -11,6 +13,12 @@ module XClarityClient
|
|
11
13
|
bootToF1
|
12
14
|
).freeze
|
13
15
|
|
16
|
+
LED_STATES = %w(
|
17
|
+
Blinking
|
18
|
+
On
|
19
|
+
Off
|
20
|
+
).freeze
|
21
|
+
|
14
22
|
attr_accessor :accessState, :activationKeys, :addinCards, :addinCardSlots, :arch, :backedBy, :bladeState, :bladeState_health,
|
15
23
|
:bladeState_string, :bootMode, :bootOrder, :cmmDisplayName, :cmmHealthState, :complexID, :contact, :dataHandle,
|
16
24
|
:description, :displayName, :dnsHostnames, :domainName, :driveBays, :drives, :embeddedHypervisorPresence, :encapsulation,
|
@@ -10,9 +10,10 @@ module XClarityClient
|
|
10
10
|
LIST_NAME = 'storageList'.freeze
|
11
11
|
|
12
12
|
attr_accessor :uuid, :name, :type, :accessState, :cmmHealthState,
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
13
|
+
:enclosures, :overallHealthState, :driveBays,
|
14
|
+
:enclosureCount, :canisterSlots, :productName,
|
15
|
+
:machineType, :model, :serialNumber, :contact,
|
16
|
+
:description, :location, :room, :rack,
|
17
|
+
:lowestRackUnit, :mgmtProcIPaddress
|
17
18
|
end
|
18
19
|
end
|
@@ -4,17 +4,35 @@ module XClarityClient
|
|
4
4
|
#
|
5
5
|
module Mixins::ChassiMixin
|
6
6
|
def discover_chassis(opts = {})
|
7
|
-
|
7
|
+
chassi_management.fetch_all(opts)
|
8
8
|
end
|
9
9
|
|
10
10
|
def fetch_chassis(uuids = nil,
|
11
11
|
include_attributes = nil,
|
12
12
|
exclude_attributes = nil)
|
13
|
-
|
13
|
+
chassi_management.get_object(
|
14
14
|
uuids,
|
15
15
|
include_attributes,
|
16
16
|
exclude_attributes
|
17
17
|
)
|
18
18
|
end
|
19
|
+
|
20
|
+
def blink_loc_led_chassis(uuid = '', name = 'Location')
|
21
|
+
chassi_management.set_loc_led_state(uuid, 'Blinking', name)
|
22
|
+
end
|
23
|
+
|
24
|
+
def turn_on_loc_led_chassis(uuid = '', name = 'Location')
|
25
|
+
chassi_management.set_loc_led_state(uuid, 'On', name)
|
26
|
+
end
|
27
|
+
|
28
|
+
def turn_off_loc_led_chassis(uuid = '', name = 'Location')
|
29
|
+
chassi_management.set_loc_led_state(uuid, 'Off', name)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def chassi_management
|
35
|
+
ChassiManagement.new(@config)
|
36
|
+
end
|
19
37
|
end
|
20
38
|
end
|
@@ -17,16 +17,16 @@ module XClarityClient
|
|
17
17
|
)
|
18
18
|
end
|
19
19
|
|
20
|
-
def blink_loc_led(uuid = '')
|
21
|
-
node_management.set_loc_led_state(uuid, 'Blinking')
|
20
|
+
def blink_loc_led(uuid = '', name = 'Identify')
|
21
|
+
node_management.set_loc_led_state(uuid, 'Blinking', name)
|
22
22
|
end
|
23
23
|
|
24
|
-
def turn_on_loc_led(uuid = '')
|
25
|
-
node_management.set_loc_led_state(uuid, 'On')
|
24
|
+
def turn_on_loc_led(uuid = '', name = 'Identify')
|
25
|
+
node_management.set_loc_led_state(uuid, 'On', name)
|
26
26
|
end
|
27
27
|
|
28
|
-
def turn_off_loc_led(uuid = '')
|
29
|
-
node_management.set_loc_led_state(uuid, 'Off')
|
28
|
+
def turn_off_loc_led(uuid = '', name = 'Identify')
|
29
|
+
node_management.set_loc_led_state(uuid, 'Off', name)
|
30
30
|
end
|
31
31
|
|
32
32
|
def power_on_node(uuid = '')
|
@@ -4,6 +4,10 @@ module XClarityClient
|
|
4
4
|
# A Power Action Sender is capable to send power
|
5
5
|
# operation request for its managed endpoint.
|
6
6
|
#
|
7
|
+
# An XclarityEndpoint that supports power or LED operations
|
8
|
+
# must configure the supported operations through `POWER_ACTIONS` and
|
9
|
+
# `LED_STATES` constants.
|
10
|
+
#
|
7
11
|
module PowerActionSenderMixin
|
8
12
|
#
|
9
13
|
# Changes the power state for some resource.
|
@@ -15,21 +19,46 @@ module XClarityClient
|
|
15
19
|
# @return the LXCA response.
|
16
20
|
#
|
17
21
|
def set_power_state(uuid, state)
|
18
|
-
unless valid_arguments?(uuid, state)
|
22
|
+
unless valid_arguments?(uuid, state, managed_resource::POWER_ACTIONS)
|
19
23
|
error = 'Invalid target or power state requested'
|
20
24
|
source = "#{self.class.name} set_power_state"
|
21
25
|
$lxca_log.info(source, error)
|
22
26
|
raise ArgumentError, error
|
23
27
|
end
|
24
28
|
|
25
|
-
send_power_request(
|
29
|
+
send_power_request(
|
30
|
+
"#{managed_resource::BASE_URI}/#{uuid}", state
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# Changes the state of a LED of some resource.
|
36
|
+
#
|
37
|
+
# @param [String] uuid - resource identifier
|
38
|
+
# @param [String] state - the new LED state
|
39
|
+
# it must be listed on `managed_resource::LED_STATES`
|
40
|
+
# @param [String] name - name of the LED that must have it state changed
|
41
|
+
#
|
42
|
+
# @return the LXCA response
|
43
|
+
#
|
44
|
+
def set_loc_led_state(uuid, state, name = 'Identify')
|
45
|
+
unless valid_arguments?(uuid, state, managed_resource::LED_STATES)
|
46
|
+
error = 'Invalid target or power state requested'
|
47
|
+
source = "#{self.class.name} set_loc_led_state"
|
48
|
+
$lxca_log.info(source, error)
|
49
|
+
raise ArgumentError, error
|
50
|
+
end
|
51
|
+
|
52
|
+
send_led_state_request(
|
53
|
+
"#{managed_resource::BASE_URI}/#{uuid}", state, name
|
54
|
+
)
|
26
55
|
end
|
27
56
|
|
28
57
|
#
|
29
58
|
# Do a change power state request for an endpoint
|
30
59
|
#
|
31
|
-
# @param [String] uri
|
32
|
-
#
|
60
|
+
# @param [String] uri
|
61
|
+
# - the URI of the endpoint that must have its power state changed.
|
33
62
|
# @param [symbol] requested_state - the new power state.
|
34
63
|
#
|
35
64
|
# @return the LXCA response.
|
@@ -43,6 +72,31 @@ module XClarityClient
|
|
43
72
|
response
|
44
73
|
end
|
45
74
|
|
75
|
+
#
|
76
|
+
# Do a change LED state request for an endpoint
|
77
|
+
#
|
78
|
+
# @param [String] uri
|
79
|
+
# - The URI that must receive the request.
|
80
|
+
# @param [String] requested_state
|
81
|
+
# - The new LED state.
|
82
|
+
# @param [String] led_name
|
83
|
+
# - name of the LED that must have it state changed.
|
84
|
+
#
|
85
|
+
# @return the LXCA response.
|
86
|
+
#
|
87
|
+
def send_led_state_request(uri,
|
88
|
+
requested_state = nil,
|
89
|
+
led_name = 'Identify')
|
90
|
+
request = JSON.generate(
|
91
|
+
:leds => [{ :name => led_name, :state => requested_state }]
|
92
|
+
)
|
93
|
+
response = @connection.do_put(uri, request)
|
94
|
+
msg = "LED state request has been sent with request #{request}"
|
95
|
+
|
96
|
+
$lxca_log.info("#{self.class.name} send_led_state_request", msg)
|
97
|
+
response
|
98
|
+
end
|
99
|
+
|
46
100
|
private
|
47
101
|
|
48
102
|
#
|
@@ -50,9 +104,9 @@ module XClarityClient
|
|
50
104
|
# Verifies if the uuid is not blank
|
51
105
|
# Verifies if the endpoint supports the new state
|
52
106
|
#
|
53
|
-
def valid_arguments?(uuid,
|
107
|
+
def valid_arguments?(uuid, desired_state, allowed_states)
|
54
108
|
uuid ||= ''
|
55
|
-
!uuid.empty? &&
|
109
|
+
!uuid.empty? && allowed_states.include?(desired_state)
|
56
110
|
end
|
57
111
|
end
|
58
112
|
end
|
@@ -20,13 +20,5 @@ module XClarityClient
|
|
20
20
|
|
21
21
|
send_power_request(managed_resource::BASE_URI + '/' + uuid + '/bmc', requested_state)
|
22
22
|
end
|
23
|
-
|
24
|
-
def set_loc_led_state(uuid, state, name = 'Identify')
|
25
|
-
request = JSON.generate(leds: [{ name: name, state: state }])
|
26
|
-
|
27
|
-
$lxca_log.info "XclarityClient::ManagementMixin set_loc_led_state", "Loc led state action has been sent"
|
28
|
-
|
29
|
-
@connection.do_put("#{managed_resource::BASE_URI}/#{uuid}", request)
|
30
|
-
end
|
31
23
|
end
|
32
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xclarity_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manasa Rao
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-07-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|