xclarity_client 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +41 -0
  3. data/.rubocop_base.yml +211 -0
  4. data/.rubocop_cc.yml +2 -0
  5. data/.travis.yml +1 -1
  6. data/docs/apib/compliance_policies.apib +214 -0
  7. data/docs/apib/squisher.rb +21 -13
  8. data/docs/apib/storages.apib +481 -0
  9. data/docs/apib/switches.apib +4 -0
  10. data/lib/xclarity_client.rb +3 -4
  11. data/lib/xclarity_client/client.rb +37 -343
  12. data/lib/xclarity_client/connection/connection.rb +3 -3
  13. data/lib/xclarity_client/endpoints/compliance_policy.rb +19 -0
  14. data/lib/xclarity_client/endpoints/endpoints.rb +2 -0
  15. data/lib/xclarity_client/endpoints/node.rb +8 -0
  16. data/lib/xclarity_client/endpoints/storage.rb +18 -0
  17. data/lib/xclarity_client/endpoints/switch.rb +3 -0
  18. data/lib/xclarity_client/mixins/aicc_mixin.rb +10 -0
  19. data/lib/xclarity_client/mixins/cabinet_mixin.rb +20 -0
  20. data/lib/xclarity_client/mixins/canister_mixin.rb +20 -0
  21. data/lib/xclarity_client/mixins/chassi_mixin.rb +20 -0
  22. data/lib/xclarity_client/mixins/cmm_mixin.rb +20 -0
  23. data/lib/xclarity_client/mixins/compliance_policy_mixin.rb +38 -0
  24. data/lib/xclarity_client/mixins/config_pattern_mixin.rb +40 -0
  25. data/lib/xclarity_client/mixins/config_profile_mixin.rb +51 -0
  26. data/lib/xclarity_client/mixins/config_target_mixin.rb +16 -0
  27. data/lib/xclarity_client/mixins/discover_request_mixin.rb +18 -0
  28. data/lib/xclarity_client/mixins/discovery_mixin.rb +10 -0
  29. data/lib/xclarity_client/mixins/event_mixin.rb +14 -0
  30. data/lib/xclarity_client/mixins/fan_mixin.rb +20 -0
  31. data/lib/xclarity_client/mixins/fan_mux_mixin.rb +20 -0
  32. data/lib/xclarity_client/mixins/ffdc_mixin.rb +16 -0
  33. data/lib/xclarity_client/mixins/global_setting_mixin.rb +14 -0
  34. data/lib/xclarity_client/mixins/host_platform_mixin.rb +18 -0
  35. data/lib/xclarity_client/mixins/job_mixin.rb +32 -0
  36. data/lib/xclarity_client/mixins/mixins.rb +38 -0
  37. data/lib/xclarity_client/mixins/node_mixin.rb +66 -0
  38. data/lib/xclarity_client/mixins/os_image_mixin.rb +14 -0
  39. data/lib/xclarity_client/mixins/persisted_result_mixin.rb +10 -0
  40. data/lib/xclarity_client/mixins/power_supply_mixin.rb +20 -0
  41. data/lib/xclarity_client/mixins/remote_access_mixin.rb +10 -0
  42. data/lib/xclarity_client/mixins/remote_file_server_mixin.rb +28 -0
  43. data/lib/xclarity_client/mixins/scalable_complex_mixin.rb +20 -0
  44. data/lib/xclarity_client/mixins/storage_mixin.rb +20 -0
  45. data/lib/xclarity_client/mixins/switch_mixin.rb +30 -0
  46. data/lib/xclarity_client/mixins/unmanage_request_mixin.rb +18 -0
  47. data/lib/xclarity_client/mixins/update_repo_mixin.rb +10 -0
  48. data/lib/xclarity_client/mixins/user_mixin.rb +26 -0
  49. data/lib/xclarity_client/schemas.rb +184 -189
  50. data/lib/xclarity_client/services/aicc_management.rb +0 -4
  51. data/lib/xclarity_client/services/cabinet_management.rb +0 -4
  52. data/lib/xclarity_client/services/canister_management.rb +0 -4
  53. data/lib/xclarity_client/services/chassi_management.rb +0 -4
  54. data/lib/xclarity_client/services/cmm_management.rb +0 -4
  55. data/lib/xclarity_client/services/compliance_policy_management.rb +52 -0
  56. data/lib/xclarity_client/services/config_pattern_management.rb +0 -4
  57. data/lib/xclarity_client/services/config_profile_management.rb +0 -4
  58. data/lib/xclarity_client/services/config_target_management.rb +0 -4
  59. data/lib/xclarity_client/services/discover_request_management.rb +0 -4
  60. data/lib/xclarity_client/services/discovery_management.rb +0 -4
  61. data/lib/xclarity_client/services/event_management.rb +0 -4
  62. data/lib/xclarity_client/services/fan_management.rb +0 -4
  63. data/lib/xclarity_client/services/fan_mux_management.rb +0 -4
  64. data/lib/xclarity_client/services/ffdc_management.rb +0 -4
  65. data/lib/xclarity_client/services/job_management.rb +0 -9
  66. data/lib/xclarity_client/services/mixins/power_action_sender_mixin.rb +59 -0
  67. data/lib/xclarity_client/services/node_management.rb +3 -26
  68. data/lib/xclarity_client/services/osimage_management.rb +25 -27
  69. data/lib/xclarity_client/services/persisted_result_management.rb +0 -6
  70. data/lib/xclarity_client/services/power_supply_management.rb +0 -4
  71. data/lib/xclarity_client/services/scalable_complex_management.rb +0 -4
  72. data/lib/xclarity_client/services/services.rb +6 -4
  73. data/lib/xclarity_client/services/storage_management.rb +8 -0
  74. data/lib/xclarity_client/services/switch_management.rb +4 -4
  75. data/lib/xclarity_client/services/unmanage_request_management.rb +0 -4
  76. data/lib/xclarity_client/services/update_repo_management.rb +30 -9
  77. data/lib/xclarity_client/services/user_management.rb +0 -4
  78. data/lib/xclarity_client/services/xclarity_service.rb +6 -5
  79. data/lib/xclarity_client/version.rb +1 -1
  80. data/xclarity_client.gemspec +1 -1
  81. metadata +45 -5
  82. data/lib/xclarity_client/xclarity_power_management_mixin.rb +0 -36
@@ -1,9 +1,5 @@
1
1
  module XClarityClient
2
2
  class AiccManagement < Services::XClarityService
3
3
  manages_endpoint Aicc
4
-
5
- def population(opts = {})
6
- fetch_all(opts)
7
- end
8
4
  end
9
5
  end
@@ -1,9 +1,5 @@
1
1
  module XClarityClient
2
2
  class CabinetManagement < Services::XClarityService
3
3
  manages_endpoint Cabinet
4
-
5
- def population(opts = {})
6
- fetch_all(opts)
7
- end
8
4
  end
9
5
  end
@@ -1,9 +1,5 @@
1
1
  module XClarityClient
2
2
  class CanisterManagement < Services::XClarityService
3
3
  manages_endpoint Canister
4
-
5
- def population(opts = {})
6
- fetch_all(opts)
7
- end
8
4
  end
9
5
  end
@@ -1,9 +1,5 @@
1
1
  module XClarityClient
2
2
  class ChassiManagement < Services::XClarityService
3
3
  manages_endpoint Chassi
4
-
5
- def population(opts = {})
6
- fetch_all(opts)
7
- end
8
4
  end
9
5
  end
@@ -1,9 +1,5 @@
1
1
  module XClarityClient
2
2
  class CmmManagement < Services::XClarityService
3
3
  manages_endpoint Cmm
4
-
5
- def population(opts = {})
6
- fetch_all(opts)
7
- end
8
4
  end
9
5
  end
@@ -0,0 +1,52 @@
1
+ require 'json'
2
+
3
+ module XClarityClient
4
+ class CompliancePolicyManagement < Services::XClarityService
5
+ manages_endpoint CompliancePolicy
6
+
7
+ def get_applicable_firmware
8
+ get_update_policy(managed_resource::SUB_URIS[:applicableFirmware], {})
9
+ end
10
+
11
+ def get_persisted_compare_results(opts = {})
12
+ get_update_policy(managed_resource::SUB_URIS[:persistedResult], opts)
13
+ end
14
+
15
+ def get_compare_results(opts = {})
16
+ get_update_policy(managed_resource::SUB_URIS[:compareResult], opts)
17
+ end
18
+
19
+ def get_update_policy(uri, opts = {})
20
+ query = opts
21
+ response = @connection.do_get(uri, query)
22
+ build_response_with_resource_list(response, managed_resource)
23
+ end
24
+
25
+ def assign_compliance_policy(opts = {}, keep, auto_assign)
26
+ assign_hash = {:policyname => opts["policyname"], :type => opts["type"], :uuid => opts["uuid"]}
27
+
28
+ #Append keep only if value is false since default is true.
29
+ if keep.eql? "False" or keep.eql? "false"
30
+ assign_hash.merge!({:keep => false})
31
+ end
32
+
33
+ #Append auto_assign only is value is true since default is false
34
+ if auto_assign.eql? "True" or auto_assign.eql? "true"
35
+ assign_hash.merge!({:autoAssign => true})
36
+ end
37
+
38
+ assign_hash_str = assign_hash.to_json
39
+ response = @connection.do_post(managed_resource::SUB_URIS[:compareResult], "{\"compliance\": [#{assign_hash_str}]}")
40
+ puts response.body
41
+ end
42
+
43
+ def delete_compliance_policy(policy_name,removePackage)
44
+ query = policy_name.nil? ? "" : "?policyName=" + policy_name
45
+ query = removePackage.nil? ? query : query + "&removePackage=" + removePackage
46
+ response = @connection.do_delete(managed_resource::BASE_URI + query)
47
+ puts response.body
48
+ end
49
+
50
+ end
51
+ end
52
+
@@ -4,10 +4,6 @@ module XClarityClient
4
4
  class ConfigPatternManagement < Services::XClarityService
5
5
  manages_endpoint ConfigPattern
6
6
 
7
- def population(opts = {})
8
- fetch_all(opts)
9
- end
10
-
11
7
  def export(id)
12
8
  response = @connection.do_get(managed_resource::BASE_URI + "/" + id + "/includeSettings" )
13
9
  return [] unless response.success?
@@ -4,10 +4,6 @@ module XClarityClient
4
4
  class ConfigProfileManagement < Services::XClarityService
5
5
  manages_endpoint ConfigProfile
6
6
 
7
- def population(opts = {})
8
- fetch_all(opts)
9
- end
10
-
11
7
  def rename_config_profile(id='', name='')
12
8
  renameReq = JSON.generate(profileName: name)
13
9
  response = @connection.do_put(managed_resource::BASE_URI + '/' +id, renameReq)
@@ -1,9 +1,5 @@
1
1
  module XClarityClient
2
2
  class ConfigTargetManagement < Services::XClarityService
3
3
  manages_endpoint ConfigTarget
4
-
5
- def population(opts = {})
6
- fetch_all(opts)
7
- end
8
4
  end
9
5
  end
@@ -4,10 +4,6 @@ module XClarityClient
4
4
  class DiscoverRequestManagement < Services::XClarityService
5
5
  manages_endpoint DiscoverRequest
6
6
 
7
- def population(opts = {})
8
- fetch_all(opts)
9
- end
10
-
11
7
  def discover_manageable_devices(ip_addresses)
12
8
  post_req = JSON.generate([ipAddresses: ip_addresses])
13
9
  response = @connection.do_post(managed_resource::BASE_URI, post_req)
@@ -1,9 +1,5 @@
1
1
  module XClarityClient
2
2
  class DiscoveryManagement < Services::XClarityService
3
3
  manages_endpoint Discovery
4
-
5
- def population(opts = {})
6
- fetch_all(opts)
7
- end
8
4
  end
9
5
  end
@@ -1,9 +1,5 @@
1
1
  module XClarityClient
2
2
  class EventManagement < Services::XClarityService
3
3
  manages_endpoint Event
4
-
5
- def population(opts = {})
6
- fetch_all(opts)
7
- end
8
4
  end
9
5
  end
@@ -1,9 +1,5 @@
1
1
  module XClarityClient
2
2
  class FanManagement < Services::XClarityService
3
3
  manages_endpoint Fan
4
-
5
- def population(opts = {})
6
- fetch_all(opts)
7
- end
8
4
  end
9
5
  end
@@ -1,9 +1,5 @@
1
1
  module XClarityClient
2
2
  class FanMuxManagement < Services::XClarityService
3
3
  manages_endpoint FanMux
4
-
5
- def population(opts = {})
6
- fetch_all(opts)
7
- end
8
4
  end
9
5
  end
@@ -1,9 +1,5 @@
1
1
  module XClarityClient
2
2
  class FfdcManagement < Services::XClarityService
3
3
  manages_endpoint Ffdc
4
-
5
- def population(opts = {})
6
- fetch_all(opts)
7
- end
8
4
  end
9
5
  end
@@ -4,10 +4,6 @@ module XClarityClient
4
4
  class JobManagement < Services::XClarityService
5
5
  manages_endpoint Job
6
6
 
7
- def population(opts = {})
8
- fetch_all(opts)
9
- end
10
-
11
7
  def cancel_job(uuid='')
12
8
  cancelReq = JSON.generate(cancelRequest: 'true')
13
9
  response = @connection.do_put(managed_resource::BASE_URI + '/' + uuid, cancelReq)
@@ -18,10 +14,5 @@ module XClarityClient
18
14
  response = @connection.do_delete(managed_resource::BASE_URI + '/' + uuid)
19
15
  response
20
16
  end
21
-
22
- def get_job(job_id = "")
23
- response = connection(Job::BASE_URI + '/' + job_id)
24
- response = JSON.parse(response.body)
25
- end
26
17
  end
27
18
  end
@@ -0,0 +1,59 @@
1
+ module XClarityClient
2
+ module Services
3
+ #
4
+ # A Power Action Sender is capable to send power
5
+ # operation request for its managed endpoint.
6
+ #
7
+ module PowerActionSenderMixin
8
+ #
9
+ # Changes the power state for some resource.
10
+ #
11
+ # @param [String] uuid - resource identifier
12
+ # @param [symbol] state - the new power state
13
+ # it must be listed on `managed_resource::POWER_ACTIONS`
14
+ #
15
+ # @return the LXCA response.
16
+ #
17
+ def set_power_state(uuid, state)
18
+ unless valid_arguments?(uuid, state)
19
+ error = 'Invalid target or power state requested'
20
+ source = "#{self.class.name} set_power_state"
21
+ $lxca_log.info(source, error)
22
+ raise ArgumentError, error
23
+ end
24
+
25
+ send_power_request(managed_resource::BASE_URI + '/' + uuid, state)
26
+ end
27
+
28
+ #
29
+ # Do a change power state request for an endpoint
30
+ #
31
+ # @param [String] uri - the URI of the endpoint that must
32
+ # have its power state changed.
33
+ # @param [symbol] requested_state - the new power state.
34
+ #
35
+ # @return the LXCA response.
36
+ #
37
+ def send_power_request(uri, requested_state = nil)
38
+ power_request = JSON.generate(:powerState => requested_state)
39
+ response = @connection.do_put(uri, power_request)
40
+ msg = "Power state action has been sent with request #{power_request}"
41
+
42
+ $lxca_log.info("#{self.class.name} send_power_request", msg)
43
+ response
44
+ end
45
+
46
+ private
47
+
48
+ #
49
+ # Validates the power operations arguments.
50
+ # Verifies if the uuid is not blank
51
+ # Verifies if the endpoint supports the new state
52
+ #
53
+ def valid_arguments?(uuid, state)
54
+ uuid ||= ''
55
+ !uuid.empty? && managed_resource::POWER_ACTIONS.include?(state)
56
+ end
57
+ end
58
+ end
59
+ end
@@ -1,26 +1,14 @@
1
1
  require 'json'
2
2
  require 'uuid'
3
+ require 'xclarity_client/services/mixins/power_action_sender_mixin'
3
4
 
4
5
  # XClarityClient module/namespace
5
6
  module XClarityClient
6
7
  # Node Management class
7
8
  class NodeManagement < Services::XClarityService
8
- manages_endpoint Node
9
-
10
- def population(opts = {})
11
- fetch_all(opts)
12
- end
9
+ include Services::PowerActionSenderMixin
13
10
 
14
- def set_node_power_state(uuid, requested_state = nil)
15
- if [uuid, requested_state].any? { |item| item.nil? }
16
- error = 'Invalid target or power state requested'
17
- source = 'XClarity::NodeManagement set_node_power_state'
18
- $lxca_log.info source, error
19
- raise ArgumentError, error
20
- end
21
-
22
- send_power_request(managed_resource::BASE_URI + '/' + uuid, requested_state)
23
- end
11
+ manages_endpoint Node
24
12
 
25
13
  def set_bmc_power_state(uuid, requested_state = nil)
26
14
  if [uuid, requested_state].any? { |item| item.nil? }
@@ -40,16 +28,5 @@ module XClarityClient
40
28
 
41
29
  @connection.do_put("#{managed_resource::BASE_URI}/#{uuid}", request)
42
30
  end
43
-
44
- private
45
-
46
- def send_power_request(uri, requested_state = nil)
47
- power_request = JSON.generate(powerState: requested_state)
48
- response = @connection.do_put(uri, power_request)
49
- msg = "Power state action has been sent with request #{power_request}"
50
-
51
- $lxca_log.info 'XclarityClient::NodeManagement set_node_power_state', msg
52
- response
53
- end
54
31
  end
55
32
  end
@@ -14,34 +14,32 @@ module XClarityClient
14
14
  get_all_resources(OsImage)
15
15
  end
16
16
 
17
- def import_osimage(serverId, path)
18
- if not Schemas.validate_input_parameter("serverId", serverId, String)
19
- return
20
- end
17
+ def import_osimage(server_id, path)
18
+ return unless Schemas.validate_input_parameter("serverId", server_id, String) ||
19
+ Schemas.validate_input_parameter("path", path, String)
21
20
 
22
- if not Schemas.validate_input_parameter("path", path, String)
23
- return
24
- end
25
-
26
- msg="inputs serverId=#{serverId},path=#{path}"
27
- $lxca_log.info self.class.to_s+" "+__method__.to_s, msg
28
- opts = { "Action": "Init" }
29
- request_body = JSON.generate(opts)
30
- response = do_post("#{OsImage::BASE_URI}?imageType=OS", request_body)
31
- response = JSON.load(response.body).to_hash
32
- jobId = response["jobId"]
33
- puts jobId
34
- opts = { "serverId": serverId, "path": path }
35
- request_body = JSON.generate(opts)
36
- imageName = path.split(File::SEPARATOR).last
37
- begin
38
- response = do_post("#{OsImage::BASE_URI}/?jobId=#{jobId}"\
39
- "&imageType=OS&imageName=#{imageName}", request_body)
40
- response = JSON.parse(response.body)
41
- rescue Faraday::TimeoutError => e
42
- result = JSON.generate({"result": " Job for importing image is in progress with jobId #{jobId}"})
43
- response = JSON.parse(result)
44
- end
21
+ msg="inputs serverId=#{server_id},path=#{path}"
22
+ $lxca_log.info self.class.to_s+" "+__method__.to_s, msg
23
+ opts = { :Action => "Init" }
24
+ request_body = JSON.generate(opts)
25
+ response = do_post("#{OsImage::BASE_URI}?imageType=OS", request_body)
26
+ response = JSON.load(response.body).to_hash
27
+ job_id = response["jobId"]
28
+ opts = { :serverId => server_id, :path => path }
29
+ request_body = JSON.generate(opts)
30
+ image_name = path.split(File::SEPARATOR).last
31
+ begin
32
+ response = do_post(
33
+ "#{OsImage::BASE_URI}/?jobId=#{job_id}&imageType=OS&imageName=#{image_name}",
34
+ request_body
35
+ )
36
+ JSON.parse(response.body)
37
+ rescue Faraday::TimeoutError => e
38
+ result = JSON.generate(
39
+ :result => " Job for importing image is in progress with jobId #{job_id}"
40
+ )
41
+ JSON.parse(result)
42
+ end
45
43
  end
46
44
  end
47
45
  end
@@ -1,11 +1,5 @@
1
- require 'json'
2
-
3
1
  module XClarityClient
4
2
  class PersistedResultManagement < Services::XClarityService
5
3
  manages_endpoint PersistedResult
6
-
7
- def population(opts = {})
8
- fetch_all(opts)
9
- end
10
4
  end
11
5
  end
@@ -1,9 +1,5 @@
1
1
  module XClarityClient
2
2
  class PowerSupplyManagement< Services::XClarityService
3
3
  manages_endpoint PowerSupply
4
-
5
- def population(opts = {})
6
- fetch_all(opts)
7
- end
8
4
  end
9
5
  end
@@ -1,9 +1,5 @@
1
1
  module XClarityClient
2
2
  class ScalableComplexManagement< Services::XClarityService
3
3
  manages_endpoint ScalableComplex
4
-
5
- def population(opts = {})
6
- fetch_all(opts)
7
- end
8
4
  end
9
5
  end
@@ -11,6 +11,7 @@ require 'xclarity_client/services/cabinet_management'
11
11
  require 'xclarity_client/services/canister_management'
12
12
  require 'xclarity_client/services/chassi_management'
13
13
  require 'xclarity_client/services/cmm_management'
14
+ require 'xclarity_client/services/compliance_policy_management'
14
15
  require 'xclarity_client/services/config_pattern_management'
15
16
  require 'xclarity_client/services/config_profile_management'
16
17
  require 'xclarity_client/services/config_target_management'
@@ -20,18 +21,19 @@ require 'xclarity_client/services/event_management'
20
21
  require 'xclarity_client/services/fan_management'
21
22
  require 'xclarity_client/services/fan_mux_management'
22
23
  require 'xclarity_client/services/ffdc_management'
24
+ require 'xclarity_client/services/globalsettings_management'
25
+ require 'xclarity_client/services/hostplatform_management'
23
26
  require 'xclarity_client/services/job_management'
24
27
  require 'xclarity_client/services/node_management'
28
+ require 'xclarity_client/services/osimage_management'
25
29
  require 'xclarity_client/services/persisted_result_management'
26
30
  require 'xclarity_client/services/power_supply_management'
27
31
  require 'xclarity_client/services/remote_access_management'
32
+ require 'xclarity_client/services/remotefileserver_management'
28
33
  require 'xclarity_client/services/scalable_complex_management'
29
34
  require 'xclarity_client/services/switch_management'
35
+ require 'xclarity_client/services/storage_management'
30
36
  require 'xclarity_client/services/unmanage_request_management'
31
37
  require 'xclarity_client/services/update_repo_management'
32
38
  require 'xclarity_client/services/user_management'
33
39
  require 'xclarity_client/services/virtual_appliance_management'
34
- require 'xclarity_client/services/osimage_management'
35
- require 'xclarity_client/services/globalsettings_management'
36
- require 'xclarity_client/services/hostplatform_management'
37
- require 'xclarity_client/services/remotefileserver_management'