xclarity_client 0.5.2 → 0.5.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c225f7e8fa4892e4d6df4a2d52b28baeee25bdfa
4
- data.tar.gz: 45626fcb6f69044de36d88d0eb77e6aa1d965ae6
3
+ metadata.gz: 66b57c7b42803f37cb0a30b52a4e98224beeb4e4
4
+ data.tar.gz: 68bccb6791d594e9215cd1f415520e009aba56f0
5
5
  SHA512:
6
- metadata.gz: f4e5f46a91ff93ceb5993e2ce7a62898906fe442d124c42f31c43e837eb93ceb30bade4c9af9dc930f63e2813e58e2a8208d8491218597a65f953f6cd6097ed2
7
- data.tar.gz: 3d13dc05ecaeaab18e3e688e93c28c5b2e03ad884c78c5d488b098b13675426a8af2aad7c1e3cb6e4d9b2a55937a52853ee91b6a57346b63ce7bfd48b6e143ab
6
+ metadata.gz: 6e9b91e844ad444cad459fdef944c327d9925016b2928c1e53a1f436a4d355161b2aad9cf2f95aa887cd83702775e8944700ab8b90545416c2fb7fa138c6c520
7
+ data.tar.gz: 830f1079550d10f203feba46d65db5bd54c497e5a0a77b80265a1d784c5eb7aaad1e87ebfd9ada21fa3b7a58d61794779d1a53126c82b97ce8b01deea44f4682
@@ -0,0 +1,15 @@
1
+ FORMAT: 1A
2
+
3
+ # XClarity Nodes
4
+
5
+ # PUT /nodes/6B538D351B8211E193F65CF3FC6E4030/bmc
6
+
7
+ + Response 200
8
+ {
9
+ }
10
+ + Response 400
11
+ + Response 401
12
+ + Response 404
13
+ + Response 409
14
+ + Response 500
15
+
@@ -1,5 +1,7 @@
1
1
  module XClarityClient
2
2
  class Client
3
+ include XClarityClient::PowerManagementMixin
4
+
3
5
  def initialize(connection)
4
6
  @connection = connection
5
7
  end
@@ -142,20 +144,6 @@ module XClarityClient
142
144
  EventManagement.new(@connection).get_object_with_opts(opts, Event)
143
145
  end
144
146
 
145
- def power_on_node(uuid = '')
146
- NodeManagement.new(@connection).set_node_power_state(uuid, 'powerOn')
147
- end
148
-
149
- def power_off_node(uuid = '')
150
- NodeManagement.new(@connection).set_node_power_state(uuid, 'powerOff')
151
- end
152
-
153
- def power_restart_node(uuid = '')
154
- NodeManagement.new(@connection).set_node_power_state(uuid,
155
- 'powerCycleSoftGrace'
156
- )
157
- end
158
-
159
147
  def blink_loc_led(uuid = '')
160
148
  NodeManagement.new(@connection).set_loc_led_state(uuid, 'Blinking')
161
149
  end
@@ -1,9 +1,10 @@
1
1
  require 'json'
2
2
  require 'uuid'
3
3
 
4
+ # XClarityClient module/namespace
4
5
  module XClarityClient
6
+ # Node Management class
5
7
  class NodeManagement < XClarityBase
6
- OFF = 1
7
8
  include XClarityClient::ManagementMixin
8
9
 
9
10
  def initialize(conf)
@@ -14,17 +15,26 @@ module XClarityClient
14
15
  get_all_resources(Node, opts)
15
16
  end
16
17
 
17
- def set_node_power_state(uuid, powerState = OFF)
18
- puts 'UUID to shutdown ' + uuid
19
- power_request = case powerState
20
- when OFF
21
- JSON.generate(powerState: 'powerOff')
22
- else
23
- JSON.generate(powerState: 'powerOn')
24
- end
25
- $lxca_log.info "XclarityClient::ManagementMixin set_node_power_state", "Power state action has been sent"
26
-
27
- do_put(Node::BASE_URI + '/' + uuid, power_request)
18
+ def set_node_power_state(uuid, requested_state = nil)
19
+ if [uuid, requested_state].any? { |item| item.nil? }
20
+ error = 'Invalid target or power state requested'
21
+ source = 'XClarity::NodeManagement set_node_power_state'
22
+ $lxca_log.info source, error
23
+ raise ArgumentError, error
24
+ end
25
+
26
+ send_power_request(Node::BASE_URI + '/' + uuid, requested_state)
27
+ end
28
+
29
+ def set_bmc_power_state(uuid, requested_state = nil)
30
+ if [uuid, requested_state].any? { |item| item.nil? }
31
+ error = 'Invalid target or power state requested'
32
+ source = 'XClarity::NodeManagement set_bmc_power_state'
33
+ $lxca_log.info source, error
34
+ raise ArgumentError, error
35
+ end
36
+
37
+ send_power_request(Node::BASE_URI + '/' + uuid + '/bmc', requested_state)
28
38
  end
29
39
 
30
40
  def set_loc_led_state(uuid, state, name = 'Identify')
@@ -34,5 +44,16 @@ module XClarityClient
34
44
 
35
45
  do_put("#{Node::BASE_URI}/#{uuid}", request)
36
46
  end
47
+
48
+ private
49
+
50
+ def send_power_request(uri, requested_state = nil)
51
+ power_request = JSON.generate(powerState: requested_state)
52
+ response = do_put(uri, power_request)
53
+ msg = "Power state action has been sent with request #{power_request}"
54
+
55
+ $lxca_log.info 'XclarityClient::NodeManagement set_node_power_state', msg
56
+ response
57
+ end
37
58
  end
38
59
  end
@@ -1,3 +1,3 @@
1
1
  module XClarityClient
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
@@ -0,0 +1,36 @@
1
+ # Top Level Xclarity module
2
+ module XClarityClient
3
+ # Power management mixin
4
+ module PowerManagementMixin
5
+ def power_on_node(uuid = '')
6
+ NodeManagement.new(@connection).set_node_power_state(uuid, :powerOn)
7
+ end
8
+
9
+ def power_off_node(uuid = '')
10
+ NodeManagement.new(@connection).set_node_power_state(uuid, :powerOff)
11
+ end
12
+
13
+ def power_off_node_now(uuid = '')
14
+ NodeManagement.new(@connection).set_node_power_state(uuid, :powerNMI)
15
+ end
16
+
17
+ def power_restart_node(uuid = '')
18
+ client = NodeManagement.new(@connection)
19
+ client.set_node_power_state(uuid, :powerCycleSoftGrace)
20
+ end
21
+
22
+ def power_restart_node_now(uuid = '')
23
+ client = NodeManagement.new(@connection)
24
+ client.set_node_power_state(uuid, :powerCycleSoft)
25
+ end
26
+
27
+ def power_restart_node_controller(uuid = '')
28
+ client = NodeManagement.new(@connection)
29
+ client.set_bmc_power_state(uuid, :restart)
30
+ end
31
+
32
+ def power_restart_node_to_setup(uuid = '')
33
+ NodeManagement.new(@connection).set_node_power_state(uuid, :bootToF1)
34
+ end
35
+ end
36
+ end
@@ -4,6 +4,7 @@ module XClarityClient
4
4
  attributes.each do |key, value|
5
5
  begin
6
6
  value = value.gsub("\u0000", '') if value.is_a?(String)
7
+ key = key.to_s.gsub("-","_")
7
8
  send("#{key}=", value)
8
9
  rescue
9
10
  $log.warn("UNEXISTING ATTRIBUTES FOR #{self.class}: #{key}") unless defined?(Rails).nil?
@@ -6,10 +6,10 @@ module XClarityClient
6
6
  end
7
7
 
8
8
  require 'xclarity_client/configuration'
9
- require 'xclarity_client/client'
10
9
  require 'xclarity_client/xclarity_base'
11
10
  require 'xclarity_client/xclarity_resource'
12
11
  require 'xclarity_client/xclarity_management_mixin'
12
+ require 'xclarity_client/xclarity_power_management_mixin'
13
13
  require 'xclarity_client/virtual_appliance_management'
14
14
  require 'xclarity_client/node'
15
15
  require 'xclarity_client/node_management'
@@ -34,3 +34,4 @@ require 'xclarity_client/cabinet_management'
34
34
  require 'xclarity_client/event'
35
35
  require 'xclarity_client/event_management'
36
36
  require 'xclarity_client/discover'
37
+ require 'xclarity_client/client'
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.5.2
4
+ version: 0.5.3
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: 2017-07-18 00:00:00.000000000 Z
12
+ date: 2017-07-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -152,6 +152,7 @@ files:
152
152
  - docs/apib/fan_mux.apib
153
153
  - docs/apib/fan_muxes.apib
154
154
  - docs/apib/node.apib
155
+ - docs/apib/node_bmc.apib
155
156
  - docs/apib/power_supply.apib
156
157
  - docs/apib/scalable_complex.apib
157
158
  - docs/apib/squisher.rb
@@ -188,6 +189,7 @@ files:
188
189
  - lib/xclarity_client/virtual_appliance_management.rb
189
190
  - lib/xclarity_client/xclarity_base.rb
190
191
  - lib/xclarity_client/xclarity_management_mixin.rb
192
+ - lib/xclarity_client/xclarity_power_management_mixin.rb
191
193
  - lib/xclarity_client/xclarity_resource.rb
192
194
  - xclarity_client.gemspec
193
195
  homepage: https://github.com/lenovo/xclarity_client