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
data/example/simple.rb CHANGED
@@ -1,15 +1,22 @@
1
1
  require 'xclarity_client'
2
2
 
3
3
  conf = XClarityClient::Configuration.new(
4
- :username => 'admin',
5
- :password => 'pass',
6
- :host => 'http://localhost:9292'
4
+ :username => '',
5
+ :password => '',
6
+ :host => '',
7
+ :auth_type => '',
8
+ :ssl_verify => ''
7
9
  )
8
10
 
9
- virtual_appliance = XClarityClient::VirtualApplianceManagement.new(conf)
11
+ # virtual_appliance = XClarityClient::VirtualApplianceManagement.new(conf)
10
12
 
11
13
  # puts virtual_appliance.configuration_settings
12
14
 
13
15
  client = XClarityClient::Client.new(conf)
14
16
 
15
- puts client.discover_nodes
17
+ puts "============= CABINETS ==============="
18
+ client.discover_cabinet.map do |cabinet|
19
+ cabinet.instance_variables.each do |att|
20
+ puts "#{att} - #{cabinet.instance_variable_get att}"
21
+ end
22
+ end
@@ -6,5 +6,25 @@ end
6
6
  require 'xclarity_client/configuration'
7
7
  require 'xclarity_client/client'
8
8
  require 'xclarity_client/xclarity_base'
9
+ require 'xclarity_client/xclarity_resource'
9
10
  require 'xclarity_client/virtual_appliance_management'
10
11
  require 'xclarity_client/node'
12
+ require 'xclarity_client/node_management'
13
+ require 'xclarity_client/chassi'
14
+ require 'xclarity_client/chassi_management'
15
+ require 'xclarity_client/scalable_complex'
16
+ require 'xclarity_client/scalable_complex_management'
17
+ require 'xclarity_client/power_supply'
18
+ require 'xclarity_client/power_supply_management'
19
+ require 'xclarity_client/switch'
20
+ require 'xclarity_client/switch_management'
21
+ require 'xclarity_client/fan_mux'
22
+ require 'xclarity_client/fan_mux_management'
23
+ require 'xclarity_client/fan'
24
+ require 'xclarity_client/fan_management'
25
+ require 'xclarity_client/cmm'
26
+ require 'xclarity_client/cmm_management'
27
+ require 'xclarity_client/canister'
28
+ require 'xclarity_client/canister_management'
29
+ require 'xclarity_client/cabinet'
30
+ require 'xclarity_client/cabinet_management'
@@ -0,0 +1,14 @@
1
+ module XClarityClient
2
+ class Cabinet
3
+ include XClarityClient::Resource
4
+
5
+ BASE_URI = '/cabinet'.freeze
6
+
7
+ attr_accessor :cabinetName, :chassisList, :complexList, :height, :location, :nodeList,
8
+ :placeholderList, :room, :storageList, :switchList, :UUID
9
+
10
+ def initialize(attributes)
11
+ build_resource(attributes)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,59 @@
1
+ require 'json'
2
+
3
+ module XClarityClient
4
+ class CabinetManagement < XClarityBase
5
+
6
+ BASE_URI = '/cabinet'.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 = {'cabinetList' => [body]} unless body.has_key? 'cabinetList'
17
+ body['cabinetList'].map do |cabinet|
18
+ Cabinet.new cabinet
19
+ end
20
+ end
21
+
22
+ def get_object_cabinet(uuids, includeAttributes, excludeAttributes)
23
+
24
+ response = if not includeAttributes.nil?
25
+ get_object_cabinet_include_attributes(uuids, includeAttributes)
26
+ elsif not excludeAttributes.nil?
27
+ get_object_cabinet_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 = {'cabinetList' => [body]} unless body.has_key? 'cabinetList'
36
+ body['cabinetList'].map do |cabinet|
37
+ Cabinet.new cabinet
38
+ end
39
+
40
+ end
41
+
42
+ def get_object_cabinet_exclude_attributes(uuids, attributes)
43
+
44
+ response = if not uuids.nil?
45
+ connection(BASE_URI + "/" + uuids.join(",") + "?excludeAttributes="+ attributes.join(","))
46
+ else
47
+ connection(BASE_URI + "?excludeAttributes=" + attributes.join(","))
48
+ end
49
+ end
50
+
51
+ def get_object_cabinet_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
@@ -0,0 +1,20 @@
1
+ module XClarityClient
2
+ class Canister
3
+ include XClarityClient::Resource
4
+
5
+ BASE_URI = '/canisters'.freeze
6
+
7
+ attr_accessor :cmmDisplayName, :backedBy, :contact, :dataHandle, :description,
8
+ :firmware, :FRU, :domainName, :driveBays, :drives, :errorFields, :ipInterfaces, :powerStatus,
9
+ :fruSerialNumber, :manufacturer, :manufacturerId, :processorSlots,
10
+ :processors, :name, :parent, :posID, :productId, :productName, :type,
11
+ :serviceHostName, :userDescription, :uri, :vnicMode, :uuid, :vpdID, :activationKeys, :bladeState, :cmmHealthState,
12
+ :hostname, :ipv4Addresses, :ipv4ServiceAddress,:ipv6Addresses, :ipv6ServiceAddress, :lanOverUsb, :leds, :location,
13
+ :macAddress, :machineType, :memoryModules, :memorySlots, :model, :partNumber, :posId,:serialNumber,:slots, :subType,
14
+ :subSlots
15
+
16
+ def initialize(attributes)
17
+ build_resource(attributes)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,60 @@
1
+ require 'json'
2
+
3
+ module XClarityClient
4
+ class CanisterManagement < XClarityBase
5
+
6
+ BASE_URI = '/canisters'.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 = {'canisterList' => [body]} unless body.has_key? 'canisterList'
17
+ body['canisterList'].map do |canister|
18
+ Canister.new canister
19
+ end
20
+ end
21
+
22
+ def get_object_canisters(uuids, includeAttributes, excludeAttributes)
23
+
24
+ response = if not includeAttributes.nil?
25
+ get_object_canisters_include_attributes(uuids, includeAttributes)
26
+ elsif not excludeAttributes.nil?
27
+ get_object_canisters_exclude_attributes(uuids, excludeAttributes)
28
+ elsif not uuids.nil?
29
+ connection(BASE_URI + "/" + uuids)
30
+ else
31
+ connection(BASE_URI)
32
+ end
33
+
34
+ body = JSON.parse(response.body)
35
+ body = {'canisterList' => [body]} unless body.has_key? 'canisterList'
36
+ body['canisterList'].map do |canister|
37
+ Canister.new canister
38
+ end
39
+
40
+ end
41
+
42
+ def get_object_canisters_exclude_attributes(uuids, attributes)
43
+
44
+ response = if not uuids.nil?
45
+ connection(BASE_URI + "/#{uuids}"+"?excludeAttributes=#{attributes.join(",")}")
46
+ else
47
+ connection(BASE_URI + "?excludeAttributes=" + attributes.join(","))
48
+ end
49
+
50
+ end
51
+
52
+ def get_object_canisters_include_attributes(uuids, attributes)
53
+ response = if not uuids.nil?
54
+ connection(BASE_URI + "/" + uuids + "?includeAttributes=" + attributes.join(","))
55
+ else
56
+ connection(BASE_URI + "?includeAttributes=" + attributes.join(","))
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,24 @@
1
+ module XClarityClient
2
+ class Chassi
3
+ include XClarityClient::Resource
4
+
5
+ BASE_URI = '/chassis'.freeze
6
+
7
+ attr_accessor :properties, :_id, :accessState, :activationKeys, :activeAlerts, :backedBy, :bladeSlots,
8
+ :cmmDisplayName, :cmmHealthState, :cmms, :cmmSlots, :complex, :contact, :dataHandle,
9
+ :description, :domainName, :encapsulation, :energyPolicies, :errorFields,
10
+ :excludedHealthState, :fanMuxes, :fanMuxSlots, :fans, :fanSlots, :height, :hostname,
11
+ :isConnectionTrusted, :ledCardSlots, :leds, :location, :machineType, :managerName,
12
+ :managerUuid, :manufacturer, :manufacturerId, :mgmtProcIPaddress, :model, :name,
13
+ :nist, :nodes, :partNumber, :passThroughModules, :posID, :powerAllocation,
14
+ :powerSupplySlots, :powerSupplies, :productId, :overallHealthState, :SecurityPolicy,
15
+ :serialNumber, :status, :switches, :switchSlots, :tlsVersion, :type, :userDescription,
16
+ :uri, :uuid, :vpdID, :mmSlots, :displayName, :productName, :parent, :fruNumber, :password, :recoveryPassword,
17
+ :username, :managementPorts, :ipAddresses
18
+
19
+ def initialize(attributes)
20
+ build_resource(attributes)
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,64 @@
1
+ require 'json'
2
+
3
+ module XClarityClient
4
+ class ChassiManagement < XClarityBase
5
+
6
+ BASE_URI = '/chassis'.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 = {'chassisList' => [body]} unless body.has_key? 'chassisList'
17
+ body['chassisList'].map do |chassi|
18
+ Chassi.new chassi
19
+ end
20
+ end
21
+
22
+ def discover_chassis
23
+ ChassiManagement.new(@connection).population
24
+ end
25
+
26
+ def get_object_chassis(uuids, includeAttributes, excludeAttributes)
27
+
28
+ if not includeAttributes.nil?
29
+ response = get_object_chassis_include_attributes(uuids, includeAttributes)
30
+ elsif not excludeAttributes.nil?
31
+ response = get_object_chassis_exclude_attributes(uuids, excludeAttributes)
32
+ elsif not uuids.nil?
33
+ response = connection(BASE_URI + "/" + uuids.join(","))
34
+ else
35
+ response = connection(BASE_URI)
36
+ end
37
+
38
+ body = JSON.parse(response.body) #rescue {}
39
+ body = {'chassisList' => [body]} unless body.has_key? 'chassisList'
40
+ body['chassisList'].map do |chassi|
41
+ Chassi.new chassi
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ def get_object_chassis_exclude_attributes(uuids, attributes)
48
+ if not uuids.nil?
49
+ response = connection(BASE_URI + "/#{uuids.join(",")}"+"?excludeAttributes=#{attributes.join(",")}")
50
+ else
51
+ response = connection(BASE_URI + "?excludeAttributes=" + attributes.join(","))
52
+ end
53
+ end
54
+
55
+ def get_object_chassis_include_attributes(uuids, attributes)
56
+ if not uuids.nil?
57
+ response = connection(BASE_URI + "/" + uuids.join(",") + "?includeAttributes=" + attributes.join(","))
58
+ else
59
+ response = connection(BASE_URI + "?includeAttributes=" + attributes.join(","))
60
+ end
61
+ end
62
+
63
+ end
64
+ end
@@ -6,8 +6,84 @@ module XClarityClient
6
6
  end
7
7
 
8
8
  def discover_nodes
9
- Node.new(@connection).populate
9
+ NodeManagement.new(@connection).population
10
10
  end
11
11
 
12
+ def discover_scalableComplexes
13
+ ScalableComplexManagement.new(@connection).population
14
+ end
15
+
16
+ def discover_cabinet
17
+ CabinetManagement.new(@connection).population
18
+ end
19
+
20
+ def fetch_cabinet(uuids = nil, includeAttributes = nil, excludeAttributes = nil)
21
+ CabinetManagement.new(@connection).get_object_cabinet(uuids, includeAttributes, excludeAttributes)
22
+ end
23
+
24
+ def discover_canisters
25
+ CanisterManagement.new(@connection).population
26
+ end
27
+
28
+ def fetch_canisters(uuids = nil, includeAttributes = nil, excludeAttributes = nil)
29
+ CanisterManagement.new(@connection).get_object_canisters(uuids, includeAttributes, excludeAttributes)
30
+ end
31
+
32
+ def discover_cmms
33
+ CmmManagement.new(@connection).population
34
+ end
35
+
36
+ def fetch_cmms(uuids = nil, includeAttributes = nil, excludeAttributes = nil)
37
+ CmmManagement.new(@connection).get_object_cmms(uuids, includeAttributes, excludeAttributes)
38
+ end
39
+
40
+ def fetch_fans(uuids = nil, includeAttributes = nil, excludeAttributes = nil)
41
+
42
+ FanManagement.new(@connection).get_object_fans(uuids, includeAttributes, excludeAttributes)
43
+ end
44
+
45
+ def discover_fans
46
+ FanManagement.new(@connection).population
47
+ end
48
+
49
+ def discover_switches
50
+ SwitchManagement.new(@connection).population
51
+ end
52
+
53
+ def discover_fan_muxes
54
+ FanMuxManagement.new(@connection).population
55
+ end
56
+
57
+ def fetch_fan_muxes(uuids = nil, includeAttributes = nil, excludeAttributes = nil)
58
+ FanMuxManagement.new(@connection).get_object_fan_muxes(uuids, includeAttributes, excludeAttributes)
59
+ end
60
+
61
+ def discover_chassis
62
+ ChassiManagement.new(@connection).population
63
+ end
64
+
65
+ def discover_power_supplies
66
+ PowerSupplyManagement.new(@connection).population
67
+ end
68
+
69
+ def fetch_nodes(uuids = nil, includeAttributes = nil, excludeAttributes = nil)
70
+ NodeManagement.new(@connection).get_object_nodes(uuids, includeAttributes, excludeAttributes)
71
+ end
72
+
73
+ def fetch_chassis(uuids = nil, includeAttributes = nil, excludeAttributes = nil)
74
+ ChassiManagement.new(@connection).get_object_chassis(uuids, includeAttributes, excludeAttributes)
75
+ end
76
+
77
+ def fetch_scalableComplexes(uuids = nil, includeAttributes = nil, excludeAttributes = nil)
78
+ ScalableComplexManagement.new(@connection).get_object_scalableComplexes(uuids, includeAttributes, excludeAttributes)
79
+ end
80
+
81
+ def fetch_switches(uuids = nil, includeAttributes = nil, excludeAttributes = nil)
82
+ SwitchManagement.new(@connection).get_object_switches(uuids, includeAttributes, excludeAttributes)
83
+ end
84
+
85
+ def fetch_power_supplies(uuids = nil, includeAttributes = nil, excludeAttributes = nil)
86
+ PowerSupplyManagement.new(@connection).get_object_power_supplies(uuids, includeAttributes, excludeAttributes)
87
+ end
12
88
  end
13
89
  end
@@ -0,0 +1,18 @@
1
+ require "pp"
2
+
3
+ module XClarityClient
4
+ class Cmm
5
+ include XClarityClient::Resource
6
+
7
+ BASE_URI = '/cmms'.freeze
8
+
9
+ attr_accessor :_id, :properties, :accessState, :backedBy, :cmmDisplayName, :cmmHealthState, :dataHandle, :dnsHostnames, :domainName, :errorFields,
10
+ :excludedHealthState, :firmware, :FRU, :fruSerialNumber, :hostConfig, :hostname, :ipInterfaces, :ipv4Addresses, :ipv6Addresses,
11
+ :macAddresses, :machineType, :mgmtProcIPaddress, :model, :name, :overallHealthState, :parent, :partNumber, :powerAllocation,
12
+ :productId, :role, :serialNumber, :slots, :type, :userDescription, :uri, :uuid,:description, :leds, :manufacturerId, :manufacturer
13
+
14
+ def initialize(attributes)
15
+ build_resource(attributes)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,61 @@
1
+ require 'json'
2
+
3
+ module XClarityClient
4
+ class CmmManagement < XClarityBase
5
+
6
+ BASE_URI = '/cmms'.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 = {'cmmList' => [body]} unless body.has_key? 'cmmList'
17
+ body['cmmList'].map do |cmm|
18
+ Cmm.new cmm
19
+ end
20
+ end
21
+
22
+ def get_object_cmms(uuids, includeAttributes, excludeAttributes)
23
+
24
+ if not includeAttributes.nil?
25
+ response = get_object_cmms_include_attributes(uuids, includeAttributes)
26
+ elsif not excludeAttributes.nil?
27
+ response = get_object_cmms_exclude_attributes(uuids, excludeAttributes)
28
+ elsif not uuids.nil?
29
+ response = connection(BASE_URI + "/" + uuids.join(","))
30
+ else
31
+ response = connection(BASE_URI)
32
+ end
33
+
34
+
35
+ body = JSON.parse(response.body) #rescue {}
36
+ body = {'cmmList' => [body]} unless body.has_key? 'cmmList'
37
+ body['cmmList'].map do |cmm|
38
+ Cmm.new cmm
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def get_object_cmms_exclude_attributes(uuids, attributes)
45
+ if not uuids.nil?
46
+ response = connection(BASE_URI + "/#{uuids.join(",")}"+"?excludeAttributes=#{attributes.join(",")}")
47
+ else
48
+ response = connection(BASE_URI + "?excludeAttributes=" + attributes.join(","))
49
+ end
50
+ end
51
+
52
+ def get_object_cmms_include_attributes(uuids, attributes)
53
+ if not uuids.nil?
54
+ response = connection(BASE_URI + "/" + uuids.join(",") + "?includeAttributes=" + attributes.join(","))
55
+ else
56
+ response = connection(BASE_URI + "?includeAttributes=" + attributes.join(","))
57
+ end
58
+ end
59
+
60
+ end
61
+ end