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.
- checksums.yaml +4 -4
- data/.codeclimate.yml +41 -0
- data/.rubocop_base.yml +211 -0
- data/.rubocop_cc.yml +2 -0
- data/.travis.yml +1 -1
- data/docs/apib/compliance_policies.apib +214 -0
- data/docs/apib/squisher.rb +21 -13
- data/docs/apib/storages.apib +481 -0
- data/docs/apib/switches.apib +4 -0
- data/lib/xclarity_client.rb +3 -4
- data/lib/xclarity_client/client.rb +37 -343
- data/lib/xclarity_client/connection/connection.rb +3 -3
- data/lib/xclarity_client/endpoints/compliance_policy.rb +19 -0
- data/lib/xclarity_client/endpoints/endpoints.rb +2 -0
- data/lib/xclarity_client/endpoints/node.rb +8 -0
- data/lib/xclarity_client/endpoints/storage.rb +18 -0
- data/lib/xclarity_client/endpoints/switch.rb +3 -0
- data/lib/xclarity_client/mixins/aicc_mixin.rb +10 -0
- data/lib/xclarity_client/mixins/cabinet_mixin.rb +20 -0
- data/lib/xclarity_client/mixins/canister_mixin.rb +20 -0
- data/lib/xclarity_client/mixins/chassi_mixin.rb +20 -0
- data/lib/xclarity_client/mixins/cmm_mixin.rb +20 -0
- data/lib/xclarity_client/mixins/compliance_policy_mixin.rb +38 -0
- data/lib/xclarity_client/mixins/config_pattern_mixin.rb +40 -0
- data/lib/xclarity_client/mixins/config_profile_mixin.rb +51 -0
- data/lib/xclarity_client/mixins/config_target_mixin.rb +16 -0
- data/lib/xclarity_client/mixins/discover_request_mixin.rb +18 -0
- data/lib/xclarity_client/mixins/discovery_mixin.rb +10 -0
- data/lib/xclarity_client/mixins/event_mixin.rb +14 -0
- data/lib/xclarity_client/mixins/fan_mixin.rb +20 -0
- data/lib/xclarity_client/mixins/fan_mux_mixin.rb +20 -0
- data/lib/xclarity_client/mixins/ffdc_mixin.rb +16 -0
- data/lib/xclarity_client/mixins/global_setting_mixin.rb +14 -0
- data/lib/xclarity_client/mixins/host_platform_mixin.rb +18 -0
- data/lib/xclarity_client/mixins/job_mixin.rb +32 -0
- data/lib/xclarity_client/mixins/mixins.rb +38 -0
- data/lib/xclarity_client/mixins/node_mixin.rb +66 -0
- data/lib/xclarity_client/mixins/os_image_mixin.rb +14 -0
- data/lib/xclarity_client/mixins/persisted_result_mixin.rb +10 -0
- data/lib/xclarity_client/mixins/power_supply_mixin.rb +20 -0
- data/lib/xclarity_client/mixins/remote_access_mixin.rb +10 -0
- data/lib/xclarity_client/mixins/remote_file_server_mixin.rb +28 -0
- data/lib/xclarity_client/mixins/scalable_complex_mixin.rb +20 -0
- data/lib/xclarity_client/mixins/storage_mixin.rb +20 -0
- data/lib/xclarity_client/mixins/switch_mixin.rb +30 -0
- data/lib/xclarity_client/mixins/unmanage_request_mixin.rb +18 -0
- data/lib/xclarity_client/mixins/update_repo_mixin.rb +10 -0
- data/lib/xclarity_client/mixins/user_mixin.rb +26 -0
- data/lib/xclarity_client/schemas.rb +184 -189
- data/lib/xclarity_client/services/aicc_management.rb +0 -4
- data/lib/xclarity_client/services/cabinet_management.rb +0 -4
- data/lib/xclarity_client/services/canister_management.rb +0 -4
- data/lib/xclarity_client/services/chassi_management.rb +0 -4
- data/lib/xclarity_client/services/cmm_management.rb +0 -4
- data/lib/xclarity_client/services/compliance_policy_management.rb +52 -0
- data/lib/xclarity_client/services/config_pattern_management.rb +0 -4
- data/lib/xclarity_client/services/config_profile_management.rb +0 -4
- data/lib/xclarity_client/services/config_target_management.rb +0 -4
- data/lib/xclarity_client/services/discover_request_management.rb +0 -4
- data/lib/xclarity_client/services/discovery_management.rb +0 -4
- data/lib/xclarity_client/services/event_management.rb +0 -4
- data/lib/xclarity_client/services/fan_management.rb +0 -4
- data/lib/xclarity_client/services/fan_mux_management.rb +0 -4
- data/lib/xclarity_client/services/ffdc_management.rb +0 -4
- data/lib/xclarity_client/services/job_management.rb +0 -9
- data/lib/xclarity_client/services/mixins/power_action_sender_mixin.rb +59 -0
- data/lib/xclarity_client/services/node_management.rb +3 -26
- data/lib/xclarity_client/services/osimage_management.rb +25 -27
- data/lib/xclarity_client/services/persisted_result_management.rb +0 -6
- data/lib/xclarity_client/services/power_supply_management.rb +0 -4
- data/lib/xclarity_client/services/scalable_complex_management.rb +0 -4
- data/lib/xclarity_client/services/services.rb +6 -4
- data/lib/xclarity_client/services/storage_management.rb +8 -0
- data/lib/xclarity_client/services/switch_management.rb +4 -4
- data/lib/xclarity_client/services/unmanage_request_management.rb +0 -4
- data/lib/xclarity_client/services/update_repo_management.rb +30 -9
- data/lib/xclarity_client/services/user_management.rb +0 -4
- data/lib/xclarity_client/services/xclarity_service.rb +6 -5
- data/lib/xclarity_client/version.rb +1 -1
- data/xclarity_client.gemspec +1 -1
- metadata +45 -5
- data/lib/xclarity_client/xclarity_power_management_mixin.rb +0 -36
@@ -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)
|
@@ -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)
|
@@ -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
|
-
|
9
|
-
|
10
|
-
def population(opts = {})
|
11
|
-
fetch_all(opts)
|
12
|
-
end
|
9
|
+
include Services::PowerActionSenderMixin
|
13
10
|
|
14
|
-
|
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(
|
18
|
-
|
19
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
@@ -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'
|