xclarity_client 0.1.0 → 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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/Gemfile +2 -0
  4. data/README.md +57 -4
  5. data/bin/mock_server.ru +1 -1
  6. data/docs/apib/cabinet.apib +63 -0
  7. data/docs/apib/canister.apib +69 -0
  8. data/docs/apib/chassis.apib +65 -1428
  9. data/docs/apib/cmm.apib +1102 -0
  10. data/docs/apib/fan.apib +383 -0
  11. data/docs/apib/fan_mux.apib +13 -0
  12. data/docs/apib/fan_muxes.apib +245 -0
  13. data/docs/apib/node.apib +8989 -869
  14. data/docs/apib/power_supply.apib +519 -0
  15. data/docs/apib/scalable_complex.apib +91 -0
  16. data/docs/apib/squisher.rb +26 -0
  17. data/docs/apib/switches.apib +1596 -0
  18. data/example/simple.rb +12 -5
  19. data/lib/xclarity_client.rb +20 -0
  20. data/lib/xclarity_client/cabinet.rb +14 -0
  21. data/lib/xclarity_client/cabinet_management.rb +59 -0
  22. data/lib/xclarity_client/canister.rb +20 -0
  23. data/lib/xclarity_client/canister_management.rb +60 -0
  24. data/lib/xclarity_client/chassi.rb +24 -0
  25. data/lib/xclarity_client/chassi_management.rb +64 -0
  26. data/lib/xclarity_client/client.rb +77 -1
  27. data/lib/xclarity_client/cmm.rb +18 -0
  28. data/lib/xclarity_client/cmm_management.rb +61 -0
  29. data/lib/xclarity_client/configuration.rb +13 -3
  30. data/lib/xclarity_client/fan.rb +20 -0
  31. data/lib/xclarity_client/fan_management.rb +83 -0
  32. data/lib/xclarity_client/fan_mux.rb +18 -0
  33. data/lib/xclarity_client/fan_mux_management.rb +82 -0
  34. data/lib/xclarity_client/node.rb +15 -94
  35. data/lib/xclarity_client/node_management.rb +62 -0
  36. data/lib/xclarity_client/power_supply.rb +18 -0
  37. data/lib/xclarity_client/power_supply_management.rb +89 -0
  38. data/lib/xclarity_client/scalable_complex.rb +16 -0
  39. data/lib/xclarity_client/scalable_complex_management.rb +83 -0
  40. data/lib/xclarity_client/switch.rb +19 -0
  41. data/lib/xclarity_client/switch_management.rb +59 -0
  42. data/lib/xclarity_client/version.rb +1 -1
  43. data/lib/xclarity_client/xclarity_base.rb +26 -1
  44. data/lib/xclarity_client/xclarity_resource.rb +20 -0
  45. data/xclarity_client.gemspec +1 -2
  46. metadata +34 -5
  47. data/lib/xclarity_client/chassis.rb +0 -7
@@ -1,14 +1,24 @@
1
+ require 'securerandom'
2
+
1
3
  module XClarityClient
2
4
  class Configuration
3
5
 
4
- attr_accessor :username, :password, :host
6
+ attr_accessor :username, :password, :host, :csrf_token, :auth_type, :generated_token, :verify_ssl
5
7
 
6
8
  def initialize(args)
9
+
7
10
  args.each { |key, value| send("#{key}=", value) }
8
11
 
9
- unless username && password && host
10
- raise ArgumentError, "username, password, and host must all be specified"
12
+ if [username, password, host, verify_ssl].any? { |item| item.nil? }
13
+ raise ArgumentError, "username, password, host, and verify_ssl must all be specified"
14
+ end
15
+
16
+
17
+ if not @auth_type.is_a?(String) or @auth_type == ''
18
+ @auth_type = 'basic_auth'
11
19
  end
20
+
21
+ @csrf_token ||= SecureRandom.base64(120) if @auth_type == 'token'
12
22
  end
13
23
  end
14
24
  end
@@ -0,0 +1,20 @@
1
+ module XClarityClient
2
+ class Fan
3
+ include XClarityClient::Resource
4
+
5
+ BASE_URI = '/fans'.freeze
6
+
7
+ attr_accessor :cmmDisplayName, :cmmHealthState, :dataHandle, :firmware, :FRU,
8
+ :fruSerialNumber, :hardwareRevision, :manufacturer, :manufacturerId,
9
+ :name, :parent, :partNumber, :posID, :powerState, :uri, :uuid, :vpdID, :description,
10
+ :errorFields,:leds,:machineType,:manufactureDate, :model, :powerAllocation,
11
+ :productId, :productName, :serialNumber, :slots, :type, :userDescription, :cmmHealthState
12
+
13
+
14
+
15
+ def initialize(attributes)
16
+ build_resource(attributes)
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,83 @@
1
+ require 'json'
2
+
3
+ module XClarityClient
4
+ class FanManagement < XClarityBase
5
+
6
+ BASE_URI = '/fans'.freeze
7
+
8
+ def initialize(conf)
9
+ super(conf, BASE_URI)
10
+ end
11
+
12
+ def population
13
+ response = connection(BASE_URI)
14
+
15
+
16
+ body = JSON.parse(response.body)
17
+ body = {'fanList' => [body]} unless body.has_key? 'fanList'
18
+ body['fanList'].map do |fan|
19
+ Fan.new fan
20
+ end
21
+ end
22
+
23
+ def get_object_fans(uuids, includeAttributes, excludeAttributes)
24
+
25
+ response = if not includeAttributes.nil?
26
+ get_object_fans_include_attributes(uuids, includeAttributes)
27
+ elsif not excludeAttributes.nil?
28
+ get_object_fans_exclude_attributes(uuids, excludeAttributes)
29
+ elsif not uuids.nil?
30
+ response = connection(BASE_URI + "/" + uuids)
31
+ body = JSON.parse(response.body)
32
+ body = {'fanList' => [body]} unless body.has_key? 'fanList'
33
+ body['fanList'].map do |fan|
34
+ Fan.new fan
35
+ end
36
+ else
37
+ response = connection(BASE_URI)
38
+ body = JSON.parse(response.body)
39
+ body = {'fanList' => [body]} unless body.has_key? 'fanList'
40
+ body['fanList'].map do |fan|
41
+ Fan.new fan
42
+ end
43
+ end
44
+ end
45
+
46
+ def get_object_fans_exclude_attributes(uuids, attributes)
47
+
48
+ response = if not uuids.nil?
49
+ response = connection(BASE_URI + "/" + uuids + "?excludeAttributes="+ attributes.join(","))
50
+ body = JSON.parse(response.body)
51
+ body = {'fanList' => [body]} unless body.has_key? 'fanList'
52
+ body['fanList'].map do |fan|
53
+ Fan.new fan
54
+ end
55
+ else
56
+ response = connection(BASE_URI + "?excludeAttributes=" + attributes.join(","))
57
+ body = JSON.parse(response.body)
58
+ body = {'fanList' => [body]} unless body.has_key? 'fanList'
59
+ body['fanList'].map do |fan|
60
+ Fan.new fan
61
+ end
62
+ end
63
+ end
64
+
65
+ def get_object_fans_include_attributes(uuids, attributes)
66
+ response = if not uuids.nil?
67
+ response = connection(BASE_URI + "/" + uuids + "?includeAttributes="+ attributes.join(","))
68
+ body = JSON.parse(response.body)
69
+ body = {'fanList' => [body]} unless body.has_key? 'fanList'
70
+ body['fanList'].map do |fan|
71
+ Fan.new fan
72
+ end
73
+ else
74
+ response = connection(BASE_URI + "?includeAttributes=" + attributes.join(","))
75
+ body = JSON.parse(response.body)
76
+ body = {'fanList' => [body]} unless body.has_key? 'fanList'
77
+ body['fanList'].map do |fan|
78
+ Fan.new fan
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,18 @@
1
+ module XClarityClient
2
+ class FanMux
3
+ include XClarityClient::Resource
4
+
5
+ BASE_URI = '/fan_muxes'.freeze
6
+
7
+ attr_accessor :cmmDisplayName, :cmmHealthState, :dataHandle, :description, :FRU,
8
+ :fruSerialNumber, :hardwareRevision, :leds, :machineType, :manufacturer, :manufactureDate,
9
+ :manufacturerId, :model, :name, :parent, :partNumber, :productId, :productName, :serialNumber,
10
+ :slots, :status, :type, :uri, :uuid
11
+
12
+
13
+ def initialize(attributes)
14
+ build_resource(attributes)
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,82 @@
1
+ require 'json'
2
+
3
+ module XClarityClient
4
+ class FanMuxManagement < XClarityBase
5
+
6
+ BASE_URI = '/fanMuxes'.freeze
7
+
8
+ def initialize(conf)
9
+ super(conf, BASE_URI)
10
+ end
11
+
12
+ def population
13
+ response = connection(BASE_URI)
14
+
15
+ body = JSON.parse(response.body)
16
+ body = {'fanMuxList' => [body]} unless body.has_key? 'fanMuxList'
17
+ body['fanMuxList'].map do |fan_mux|
18
+ FanMux.new fan_mux
19
+ end
20
+ end
21
+
22
+ def get_object_fan_muxes(uuids, includeAttributes, excludeAttributes)
23
+
24
+ response = if not includeAttributes.nil?
25
+ get_object_fan_muxes_include_attributes(uuids, includeAttributes)
26
+ elsif not excludeAttributes.nil?
27
+ get_object_fan_muxes_exclude_attributes(uuids, excludeAttributes)
28
+ elsif not uuids.nil?
29
+ response = connection(BASE_URI + "/" + uuids.join(","))
30
+ body = JSON.parse(response.body)
31
+ body = {'fanMuxList' => [body]} unless body.has_key? 'fanMuxList'
32
+ body['fanMuxList'].map do |fan_mux|
33
+ FanMux.new fan_mux
34
+ end
35
+ else
36
+ response = connection(BASE_URI)
37
+ body = JSON.parse(response.body)
38
+ body = {'fanMuxList' => [body]} unless body.has_key? 'fanMuxList'
39
+ body['fanMuxList'].map do |fan_mux|
40
+ FanMux.new fan_mux
41
+ end
42
+ end
43
+ end
44
+
45
+ def get_object_fan_muxes_exclude_attributes(uuids, attributes)
46
+
47
+ response = if not uuids.nil?
48
+ response = connection(BASE_URI + "/" + uuids.join(",") + "?excludeAttributes="+ attributes.join(","))
49
+ body = JSON.parse(response.body)
50
+ body = {'fanMuxList' => [body]} unless body.has_key? 'fanMuxList'
51
+ body['fanMuxList'].map do |fan_mux|
52
+ FanMux.new fan_mux
53
+ end
54
+ else
55
+ response = connection(BASE_URI + "?excludeAttributes=" + attributes.join(","))
56
+ body = JSON.parse(response.body)
57
+ body = {'fanMuxList' => [body]} unless body.has_key? 'fanMuxList'
58
+ body['fanMuxList'].map do |fan_mux|
59
+ FanMux.new fan_mux
60
+ end
61
+ end
62
+ end
63
+
64
+ def get_object_fan_muxes_include_attributes(uuids, attributes)
65
+ if not uuids.nil?
66
+ response = connection(BASE_URI + "/" + uuids.join(",") + "?includeAttributes="+ attributes.join(","))
67
+ body = JSON.parse(response.body)
68
+ body = {'fanMuxList' => [body]} unless body.has_key? 'fanMuxList'
69
+ body['fanMuxList'].map do |fan_mux|
70
+ FanMux.new fan_mux
71
+ end
72
+ else
73
+ response = connection(BASE_URI + "?includeAttributes=" + attributes.join(","))
74
+ body = JSON.parse(response.body)
75
+ body = {'fanMuxList' => [body]} unless body.has_key? 'fanMuxList'
76
+ body['fanMuxList'].map do |fan_mux|
77
+ FanMux.new fan_mux
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -1,103 +1,24 @@
1
- require 'json'
2
-
3
1
  module XClarityClient
4
- class Node < XClarityBase
2
+ class Node
3
+ include XClarityClient::Resource
5
4
 
6
5
  BASE_URI = '/nodes'.freeze
7
6
 
8
- # accessState
9
- # activationKeys
10
- # addinCardSlots
11
- # addinCards
12
- # arch
13
- # backedBy
14
- # bladeState
15
- # bootMode
16
- # bootOrder
17
- # cmmDisplayName
18
- # cmmHealthState
19
- # complexID
20
- # contact
21
- # dataHandle
22
- # description
23
- # dnsHostnames
24
- # domainName
25
- # driveBays
26
- # drives
27
- # embeddedHypervisorPresence
28
- # encapsulation
29
- # errorFields
30
- # excludedHealthState
31
- # expansionCardSlots
32
- # expansionCards
33
- # expansionProductType
34
- # expansionProducts
35
- # firmware
36
- # flashStorage
37
- # FRU
38
- # fruSerialNumber
39
- # hasOS
40
- # height
41
- # hostMacAddresses
42
- # hostname
43
- # ipInterfaces
44
- # ipv4Addresses
45
- # ipv6Addresses
46
- # isConnectionTrusted
47
- # isITME
48
- # isRemotePresenceEnabled
49
- # isScalable
50
- # lanOverUsb
51
- # leds
52
- # location
53
- # macAddress
54
- # machineType
55
- # manufacturer
56
- # manufacturerId
57
- # memoryModules
58
- # memorySlots
59
- # mgmtProcIPaddress
60
- # model
61
- # name
62
- # nist
63
- # onboardPciDevices
64
- # overallHealthState
65
- # partNumber
66
- # partitionID
67
- # pciCapabilities
68
- # pciDevices
69
- # ports
70
- # posID
71
- # powerAllocation
72
- # powerCappingPolicy
73
- # powerStatus
74
- # powerSupplies
75
- # processorSlots
76
- # processors
77
- # productId
78
- # productName
79
- # raidSettings
80
- # secureBootMode
81
- # serialNumber
82
- # slots
83
- # status
84
- # subSlots
85
- # subType
86
- # tlsVersion
87
- # type
88
- # uri
89
- # userDescription
90
- # uuid
91
- # vnicMode
92
- # vpdID
7
+ attr_accessor :properties,:_uuid, :accessState, :activationKeys, :uuid, :addinCardSlots, :addinCards, :vnicMode, :productName, :arch, :backedBy, :bladeState_health, :bootMode,
8
+ :bootOrder, :canisters, :canisterSlots, :cmmDisplayName, :cmmHealthState, :complexID, :dataHandle, :dnsHostnames, :domainName, :bladeState, :bladeState_string,
9
+ :driveBays, :embeddedHypervisorPresence, :errorFields, :excludedHealthState, :expansionCardSlots, :expansionCards, :lanOverUsbPortForwardingModes,
10
+ :expansionProductType, :expansionProducts, :expansionProductSlots, :firmware, :flashStorage, :fruSerialNumber, :hostMacAddresses, :hostname, :ipInterfaces,
11
+ :ipv4Addresses, :ipv6Addresses, :isConnectionTrusted, :isITME, :hasOS, :isRemotePresenceEnabled, :isScalable, :lanOverUsb,
12
+ :machineType, :manufacturer, :manufacturerId ,:memoryModules,:memorySlots, :mgmtProcIPaddress, :model, :nist, :onboardPciDevices,
13
+ :overallHealthState, :partitionEnabled, :powerStatus, :pciExpressCards, :pciExpressCardSlots, :physicalID, :ports, :posID, :powerAllocation, :powerCappingPolicy,
14
+ :powerSupplies, :primary, :processorSlots, :processors, :productId, :raidSettings, :secureBootMode, :serialNumber, :slots, :status, :subSlots,
15
+ :thinkServerFru, :tlsVersion, :type, :uri ,:userDescription ,:vpdID,:contact, :description, :driveBays, :drives,:encapsulation, :FRU,:height,:leds,:location,:logicalID,
16
+ :macAddress,:name,:parent,:parentComplexID, :parentPartitionUUID,:partNumber,:partitionEnabled,:partitionID,:pciCapabilities,:pciDevices,:subType, :fans, :fruNumber,
17
+ :password, :recoveryPassword, :username, :managementPorts, :displayName, :ipAddresses
93
18
 
94
- def initialize(conf)
95
- super(conf, BASE_URI)
96
- end
97
19
 
98
- def populate
99
- response = connection(BASE_URI)
100
- response.body
20
+ def initialize(attributes)
21
+ build_resource(attributes)
101
22
  end
102
23
 
103
24
  end
@@ -0,0 +1,62 @@
1
+ require 'json'
2
+ require 'uuid'
3
+
4
+ module XClarityClient
5
+ class NodeManagement < XClarityBase
6
+
7
+ BASE_URI = '/nodes'.freeze
8
+
9
+ def initialize(conf)
10
+ super(conf, BASE_URI)
11
+ end
12
+
13
+ def population
14
+ response = connection(BASE_URI)
15
+
16
+ body = JSON.parse(response.body)
17
+ body['nodeList'].map do |node|
18
+ Node.new node
19
+ end
20
+ end
21
+
22
+ def get_object_nodes(uuids, includeAttributes, excludeAttributes)
23
+
24
+ response = if not includeAttributes.nil?
25
+ get_object_nodes_include_attributes(uuids, includeAttributes)
26
+ elsif not excludeAttributes.nil?
27
+ get_object_nodes_exclude_attributes(uuids, excludeAttributes)
28
+ elsif not uuids.nil?
29
+ connection(BASE_URI + "/" + uuids.join(","))
30
+ else
31
+ connection(BASE_URI)
32
+ end
33
+
34
+ body = JSON.parse(response.body)
35
+ body = {'nodeList' => [body]} unless body.has_key? 'nodeList'
36
+ body['nodeList'].map do |node|
37
+ Node.new node
38
+ end
39
+
40
+ end
41
+
42
+ def get_object_nodes_exclude_attributes(uuids, attributes)
43
+ uuids.reject! { |uuid| UUID.validate(uuid).nil? } unless uuids.nil?
44
+
45
+ response = if not uuids.nil?
46
+ connection(BASE_URI + "/" + uuids.join(",") + "?excludeAttributes="+ attributes.join(","))
47
+ else
48
+ connection(BASE_URI + "?excludeAttributes=" + attributes.join(","))
49
+ end
50
+ end
51
+
52
+ def get_object_nodes_include_attributes(uuids, attributes)
53
+ uuids.reject! { |uuid| UUID.validate(uuid).nil? } unless uuids.nil?
54
+
55
+ response = if not uuids.nil?
56
+ connection(BASE_URI + "/" + uuids.join(",") + "?includeAttributes="+ attributes.join(","))
57
+ else
58
+ connection(BASE_URI + "?includeAttributes=" + attributes.join(","))
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,18 @@
1
+ module XClarityClient
2
+ class PowerSupply
3
+ include XClarityClient::Resource
4
+
5
+ BASE_URI = '/power_supplies'.freeze
6
+
7
+ attr_accessor :properties, :_id, :cmmDisplayName, :cmmHealthState, :dataHandle,
8
+ :description, :firmware, :FRU, :fruSerialNumber, :hardwareRevision, :inputVoltageMax,
9
+ :inputVoltageIsAC, :inputVoltageMin, :leds, :machineType, :manufacturer, :manufacturerId,
10
+ :manufactureDate, :model, :name, :parent, :powerAllocation, :partNumber, :posID,
11
+ :powerState, :productId, :productName, :serialNumber, :slots, :type, :uri,
12
+ :userDescription, :uuid, :vpdID, :description
13
+
14
+ def initialize(attributes)
15
+ build_resource(attributes)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,89 @@
1
+ require 'json'
2
+
3
+ module XClarityClient
4
+ class PowerSupplyManagement < XClarityBase
5
+ BASE_URI = '/powerSupplies'.freeze
6
+
7
+ def initialize(conf)
8
+ super(conf, BASE_URI)
9
+ end
10
+
11
+ def population
12
+ response = connection(BASE_URI)
13
+
14
+ body = JSON.parse(response.body)
15
+ body = {'powerSupplyList' => [body]} unless body.has_key? 'powerSupplyList'
16
+ body['powerSupplyList'].map do |power_supply|
17
+ PowerSupply.new power_supply
18
+ end
19
+ end
20
+
21
+ def get_object_power_supplies(uuids, includeAttributes, excludeAttributes)
22
+ uuids.reject! { |uuid| UUID.validate(uuid).nil? } unless uuids.nil?
23
+
24
+ response = nil
25
+ if not includeAttributes.nil?
26
+ response = get_object_power_supplies_include_attributes(uuids, includeAttributes)
27
+ elsif not excludeAttributes.nil?
28
+ response = get_object_power_supplies_exclude_attributes(uuids, excludeAttributes)
29
+ elsif not uuids.nil?
30
+ response = connection(BASE_URI + "/" + uuids.join(","))
31
+ body = JSON.parse(response.body)
32
+ body = {'powerSupplyList' => [body]} unless body.has_key? 'powerSupplyList'
33
+ body['powerSupplyList'].map do |power_supply|
34
+ PowerSupply.new power_supply
35
+ end
36
+ else
37
+ response = connection(BASE_URI)
38
+ body = JSON.parse(response.body)
39
+ body = {'powerSupplyList' => [body]} unless body.has_key? 'powerSupplyList'
40
+ body['powerSupplyList'].map do |power_supply|
41
+ PowerSupply.new power_supply
42
+ end
43
+ end
44
+ end
45
+
46
+ def get_object_power_supplies_exclude_attributes(uuids, attributes)
47
+ uuids.reject! { |uuid| UUID.validate(uuid).nil? } unless uuids.nil?
48
+
49
+ response = nil
50
+ if not uuids.nil?
51
+ response = connection(BASE_URI + "/" + uuids.join(",") + "?excludeAttributes="+ attributes.join(","))
52
+ body = JSON.parse(response.body)
53
+ body = {'powerSupplyList' => [body]} unless body.has_key? 'powerSupplyList'
54
+ body['powerSupplyList'].map do |power_supply|
55
+ PowerSupply.new power_supply
56
+ end
57
+ else
58
+ response = connection(BASE_URI + "?excludeAttributes=" + attributes.join(","))
59
+ body = JSON.parse(response.body)
60
+ body = {'powerSupplyList' => [body]} unless body.has_key? 'powerSupplyList'
61
+ body['powerSupplyList'].map do |power_supply|
62
+ PowerSupply.new power_supply
63
+ end
64
+ end
65
+ end
66
+
67
+ def get_object_power_supplies_include_attributes(uuids, attributes)
68
+ uuids.reject! { |uuid| UUID.validate(uuid).nil? } unless uuids.nil?
69
+
70
+ response = nil
71
+ if not uuids.nil?
72
+ response = connection(BASE_URI + "/" + uuids.join(",") + "?includeAttributes="+ attributes.join(","))
73
+ body = JSON.parse(response.body)
74
+ body = {'powerSupplyList' => [body]} unless body.has_key? 'powerSupplyList'
75
+ body['powerSupplyList'].map do |power_supply|
76
+ PowerSupply.new power_supply
77
+ end
78
+
79
+ else
80
+ response = connection(BASE_URI + "?includeAttributes=" + attributes.join(","))
81
+ body = JSON.parse(response.body)
82
+ body = {'powerSupplyList' => [body]} unless body.has_key? 'powerSupplyList'
83
+ body['powerSupplyList'].map do |power_supply|
84
+ PowerSupply.new power_supply
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end