xclarity_client 0.6.3 → 0.6.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +5 -5
  2. data/docs/apib/discover_request.apib +3 -1
  3. data/docs/apib/event.apib +0 -1
  4. data/docs/apib/manage_request.apib +359 -0
  5. data/docs/apib/storages.apib +3 -3
  6. data/docs/apib/update_comp.apib +426 -0
  7. data/docs/apib/update_repo.apib +0 -57
  8. data/lib/xclarity_client.rb +0 -1
  9. data/lib/xclarity_client/client.rb +3 -0
  10. data/lib/xclarity_client/connection/connection.rb +73 -35
  11. data/lib/xclarity_client/endpoints/endpoints.rb +3 -0
  12. data/lib/xclarity_client/endpoints/manage_request.rb +11 -0
  13. data/lib/xclarity_client/endpoints/management_server.rb +5 -0
  14. data/lib/xclarity_client/endpoints/storage.rb +7 -6
  15. data/lib/xclarity_client/endpoints/update_comp.rb +18 -0
  16. data/lib/xclarity_client/mixins/job_mixin.rb +0 -4
  17. data/lib/xclarity_client/mixins/manage_request_mixin.rb +54 -0
  18. data/lib/xclarity_client/mixins/management_server_mixin.rb +40 -0
  19. data/lib/xclarity_client/mixins/mixins.rb +3 -0
  20. data/lib/xclarity_client/mixins/node_mixin.rb +42 -0
  21. data/lib/xclarity_client/mixins/update_comp_mixin.rb +37 -0
  22. data/lib/xclarity_client/mixins/update_repo_mixin.rb +107 -7
  23. data/lib/xclarity_client/services/job_management.rb +2 -4
  24. data/lib/xclarity_client/services/manage_request_management.rb +62 -0
  25. data/lib/xclarity_client/services/management_server_management.rb +86 -0
  26. data/lib/xclarity_client/services/node_management.rb +46 -0
  27. data/lib/xclarity_client/services/osimage_management.rb +3 -2
  28. data/lib/xclarity_client/services/remote_access_management.rb +6 -4
  29. data/lib/xclarity_client/services/services.rb +3 -0
  30. data/lib/xclarity_client/services/update_comp_management.rb +111 -0
  31. data/lib/xclarity_client/services/update_repo_management.rb +100 -47
  32. data/lib/xclarity_client/services/virtual_appliance_management.rb +13 -16
  33. data/lib/xclarity_client/services/xclarity_service.rb +2 -3
  34. data/lib/xclarity_client/version.rb +1 -1
  35. data/lib/xclarity_client/xclarity_credentials_validator.rb +8 -11
  36. data/xclarity_client.gemspec +2 -2
  37. metadata +26 -11
  38. data/lib/xclarity_client/xclarity_base.rb +0 -88
@@ -34,5 +34,8 @@ require 'xclarity_client/mixins/scalable_complex_mixin'
34
34
  require 'xclarity_client/mixins/storage_mixin'
35
35
  require 'xclarity_client/mixins/switch_mixin'
36
36
  require 'xclarity_client/mixins/unmanage_request_mixin'
37
+ require 'xclarity_client/mixins/manage_request_mixin'
37
38
  require 'xclarity_client/mixins/update_repo_mixin'
39
+ require 'xclarity_client/mixins/update_comp_mixin'
38
40
  require 'xclarity_client/mixins/user_mixin'
41
+ require 'xclarity_client/mixins/management_server_mixin'
@@ -57,8 +57,50 @@ module XClarityClient
57
57
  node_management.set_power_state(uuid, :bootToF1)
58
58
  end
59
59
 
60
+ def retrieve_mounted_media_details(uuid = '')
61
+ node_management.retrieve_mounted_media_details(uuid)
62
+ end
63
+
64
+ def enable_media_mount_support_thinkserver(uuid = '')
65
+ node_management.enable_media_mount_support(uuid)
66
+ end
67
+
68
+ def disable_media_mount_support_thinkserver(uuid = '')
69
+ node_management.disable_media_mount_support(uuid)
70
+ end
71
+
72
+ def remove_all_mounted_medias_thinksystem(uuid = '')
73
+ node_management.remove_all_mounted_medias(uuid)
74
+ end
75
+
76
+ def mount_media_thinkserver(uuid, opts)
77
+ validate_mount_media_params(opts, 'thinkserver')
78
+ node_management.mount_media(uuid, opts)
79
+ end
80
+
81
+ def mount_media_thinksystem(uuid, opts)
82
+ validate_mount_media_params(opts)
83
+ node_management.mount_media(uuid, opts)
84
+ end
85
+
86
+ def unmount_media_thinkserver(uuid, media_type = '')
87
+ node_management.unmount_media_thinkserver(uuid, media_type)
88
+ end
89
+
90
+ def unmount_media_thinksystem(uuid, media_uid = '')
91
+ node_management.unmount_media_thinksystem(uuid, media_uid)
92
+ end
93
+
60
94
  private
61
95
 
96
+ def validate_mount_media_params(opts, server_type = '')
97
+ msg = "parameter 'opts' should be of type hash"
98
+ raise(msg) unless opts.kind_of?(Hash)
99
+ err_msg = ':mediaType is mandatory field in input hash for thinkserver'
100
+ raise(err_msg) if server_type == 'thinkserver' &&
101
+ !opts.keys.include?(:mediaType)
102
+ end
103
+
62
104
  def node_management
63
105
  NodeManagement.new(@config)
64
106
  end
@@ -0,0 +1,37 @@
1
+ module XClarityClient
2
+ #
3
+ # Exposes UpdateCompManagement features
4
+ #
5
+ module Mixins::UpdateCompMixin
6
+ def discover_firmware_update_status
7
+ UpdateCompManagement.new(@config).fetch_all
8
+ end
9
+
10
+ def discover_updatable_device_comp
11
+ UpdateCompManagement.new(@config).updatable_device_comp
12
+ end
13
+
14
+ def apply_firmware_update(opts, activation_mode = nil,
15
+ force_update_mode = nil, onerror_mode = nil)
16
+ UpdateCompManagement.new(@config).apply_firmware_update(opts,
17
+ activation_mode,
18
+ force_update_mode,
19
+ onerror_mode)
20
+ end
21
+
22
+ def cancel_firmware_update(server = nil, switch = nil, storage = nil,
23
+ cmm = nil)
24
+ UpdateCompManagement.new(@config).cancel_firmware_update(server,
25
+ switch,
26
+ storage,
27
+ cmm)
28
+ end
29
+
30
+ def modify_power_state(server = nil, switch = nil, storage = nil, cmm = nil)
31
+ UpdateCompManagement.new(@config).modify_power_state(server,
32
+ switch,
33
+ storage,
34
+ cmm)
35
+ end
36
+ end
37
+ end
@@ -11,23 +11,123 @@ module XClarityClient
11
11
  UpdateRepoManagement.new(@config).read_update_repo
12
12
  end
13
13
 
14
- def refresh_update_repo(scope, mt, os)
15
- UpdateRepoManagement.new(@config).refresh_update_repo(scope, mt, os)
14
+ def refresh_update_repo_catalog(scope, machine_types)
15
+ mt = machine_types
16
+ msg = 'Parameter machine_types should be of type Array'
17
+ raise msg unless mt.kind_of?(Array)
18
+ UpdateRepoManagement.new(@config).refresh_update_repo_catalog(scope, mt)
16
19
  end
17
20
 
18
- def acquire_firmware_updates(scope, fixids, mt)
19
- UpdateRepoManagement.new(@config).acquire_firmware_updates(scope,
20
- fixids, mt)
21
+ def refresh_uxsp_update_repo_catalog(scope, machine_types)
22
+ mt = machine_types
23
+ msg = 'Parameter machine_types should be of type Array'
24
+ raise msg unless mt.kind_of?(Array)
25
+ UpdateRepoManagement.new(@config).refresh_uxsp_update_repo_catalog(scope,
26
+ mt)
21
27
  end
22
28
 
23
- def delete_firmware_updates(file_types, fixids)
29
+ def updates_info_by_machine_types(machine_types)
30
+ mt = machine_types
31
+ msg = 'Parameter machine_types should be of type Array'
32
+ raise msg unless mt.kind_of?(Array)
33
+ UpdateRepoManagement.new(@config).updates_info_by_machine_types(mt)
34
+ end
35
+
36
+ def uxsp_updates_info_by_machine_types(machine_types)
37
+ mt = machine_types
38
+ msg = 'Parameter machine_types should be of type Array'
39
+ raise msg unless mt.kind_of?(Array)
40
+ UpdateRepoManagement.new(@config).uxsp_updates_info_by_machine_types(mt)
41
+ end
42
+
43
+ def acquire_firmware_updates(machine_types, fixids)
44
+ mt = machine_types
45
+ msg = 'Parameter machine_types & fixids should be of type Array'
46
+ raise msg unless mt.kind_of?(Array) || fixids.kind_of?(Array)
47
+ UpdateRepoManagement.new(@config).acquire_firmware_updates(mt, fixids)
48
+ end
49
+
50
+ def delete_firmware_updates(file_types, fixids = [])
51
+ validate_inputs(file_types, fixids)
24
52
  UpdateRepoManagement.new(@config).delete_firmware_updates(file_types,
25
53
  fixids)
26
54
  end
27
55
 
28
- def export_firmware_updates(file_types, fixids)
56
+ def export_firmware_updates(file_types, fixids = [])
57
+ validate_inputs(file_types, fixids)
29
58
  UpdateRepoManagement.new(@config).export_firmware_updates(file_types,
30
59
  fixids)
31
60
  end
61
+
62
+ def download_exported_firmware_updates(file_name, dir_path_for_download)
63
+ dir = dir_path_for_download
64
+ validate_file_name_dir_path(file_name, dir)
65
+ UpdateRepoManagement.new(@config)
66
+ .download_exported_firmware_updates(file_name, dir)
67
+ end
68
+
69
+ def validate_import_updates(file_path)
70
+ validate_file_path(file_path)
71
+ UpdateRepoManagement.new(@config).validate_import_updates(file_path)
72
+ end
73
+
74
+ def import_firmware_updates(file_path)
75
+ validate_file_path(file_path)
76
+ UpdateRepoManagement.new(@config).import_firmware_updates(file_path)
77
+ end
78
+
79
+ def track_task_status(taskid, tasktype)
80
+ UpdateRepoManagement.new(@config).track_task_status(taskid, tasktype)
81
+ end
82
+
83
+ def supported_machine_types_detail
84
+ UpdateRepoManagement.new(@config).supported_machine_types_detail
85
+ end
86
+
87
+ def retrieve_compliance_policy_list
88
+ UpdateRepoManagement.new(@config).retrieve_compliance_policy_list
89
+ end
90
+
91
+ def export_compliance_policies(policy_names)
92
+ msg = 'Parameter policy_names should be of type Array'
93
+ raise msg unless policy_names.kind_of?(Array)
94
+ UpdateRepoManagement.new(@config).export_compliance_policies(policy_names)
95
+ end
96
+
97
+ def download_exported_compliance_policies(file_name, dir_path_for_download)
98
+ dir = dir_path_for_download
99
+ validate_file_name_dir_path(file_name, dir)
100
+ UpdateRepoManagement.new(@config)\
101
+ .download_exported_compliance_policies(file_name, dir)
102
+ end
103
+
104
+ def import_compliance_policies(file_path)
105
+ validate_file_path(file_path)
106
+ UpdateRepoManagement.new(@config).import_compliance_policies(file_path)
107
+ end
108
+
109
+ private
110
+
111
+ def validate_inputs(file_types, fixids)
112
+ msg = 'Invalid value for argument file_types. Allowed values are'\
113
+ + ' - all and payloads'
114
+ raise msg unless %w(payloads all).include?(file_types)
115
+ msg = 'Parameter fixids should be of type Array'
116
+ raise msg unless fixids.kind_of?(Array)
117
+ raise msg if file_types == 'payloads' && !fixids.any?
118
+ end
119
+
120
+ def validate_file_name_dir_path(file_name, dir_path_for_download)
121
+ msg = 'Parameter file_name and dir_path_for_download,'\
122
+ + 'should be of type String'
123
+ raise msg unless file_name.kind_of?(String)
124
+ dir = dir_path_for_download
125
+ msg = dir + ' directory doesnt exists'
126
+ raise msg unless File.directory?(dir)
127
+ end
128
+
129
+ def validate_file_path(file_path)
130
+ raise "file #{file_path} doesn't exists" unless File.file?(file_path)
131
+ end
32
132
  end
33
133
  end
@@ -6,13 +6,11 @@ module XClarityClient
6
6
 
7
7
  def cancel_job(uuid='')
8
8
  cancelReq = JSON.generate(cancelRequest: 'true')
9
- response = @connection.do_put(managed_resource::BASE_URI + '/' + uuid, cancelReq)
10
- response
9
+ @connection.do_put(managed_resource::BASE_URI + '/' + uuid, cancelReq)
11
10
  end
12
11
 
13
12
  def delete_job(uuid='')
14
- response = @connection.do_delete(managed_resource::BASE_URI + '/' + uuid)
15
- response
13
+ @connection.do_delete(managed_resource::BASE_URI + '/' + uuid)
16
14
  end
17
15
  end
18
16
  end
@@ -0,0 +1,62 @@
1
+ require 'json'
2
+
3
+ module XClarityClient
4
+ # manage request management class
5
+ class ManageRequestManagement < Services::XClarityService
6
+ manages_endpoint ManageRequest
7
+
8
+ def manage_discovered_devices(manage_request)
9
+ @connection.do_post(ManageRequest::BASE_URI,
10
+ JSON.generate([manage_request]))
11
+ end
12
+
13
+ def populate_manage_req_with_security_descriptor(manage_request, val)
14
+ security_descriptor = {}
15
+ val = val['securityDescriptor']
16
+ security_descriptor[:managedAuthEnabled] = val['managedAuthSupported']
17
+ security_descriptor[:managedAuthSupported] = val['managedAuthSupported']
18
+ res = security_descriptor[:managedAuthEnabled]
19
+ security_descriptor[:storedCredentials] = val['storedCredentials'] if res
20
+ manage_request[:securityDescriptor] = security_descriptor
21
+ end
22
+
23
+ def parse_manage_request(manage_request, val)
24
+ return false unless val.kind_of?(Array) && !val.empty?
25
+ manage_request[:managementPorts] = val[0]['managementPorts']
26
+ manage_request[:type] = val[0]['type']
27
+ manage_request[:uuid] = val[0]['uuid']
28
+ discovery_ip_addr = val[0]['ipAddresses'][0]
29
+ manage_request[:ipAddresses] = [discovery_ip_addr]
30
+ manage_request[:os] = val[0]['os'] if val[0]['type'] == 'Rackswitch'
31
+ populate_manage_req_with_security_descriptor(manage_request, val[0])
32
+ end
33
+
34
+ def populate_manage_request_with_discovery_res(discovery_result,
35
+ manage_request)
36
+ discovery_result.map do |req|
37
+ req.instance_variables.each do |attr|
38
+ val = req.instance_variable_get(attr)
39
+ parse_manage_request(manage_request, val)
40
+ end
41
+ end
42
+ end
43
+
44
+ def update_manage_request(manage_request, force, discovery_result)
45
+ populate_manage_request_with_discovery_res(discovery_result,
46
+ manage_request)
47
+ manage_request[:forceManage] = true if force.casecmp('true')
48
+ end
49
+
50
+ def fetch_manage_request(job_id)
51
+ response = @connection.do_get(ManageRequest::BASE_URI + '/jobs/' + job_id)
52
+ return [] unless response.success?
53
+ body = JSON.parse(response.body)
54
+ body = { ManageRequest::LIST_NAME => body } if body.kind_of?(Array)
55
+ mrql = ManageRequest::LIST_NAME
56
+ body = { ManageRequest::LIST_NAME => [body] } unless body.key?(mrql)
57
+ body[ManageRequest::LIST_NAME].map do |resource_params|
58
+ ManageRequest.new(resource_params)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,86 @@
1
+ require 'json'
2
+ require 'pathname'
3
+
4
+ module XClarityClient
5
+ # ManagementServerManagement class
6
+ class ManagementServerManagement < Services::XClarityService
7
+ manages_endpoint ManagementServer
8
+
9
+ private
10
+
11
+ def start_management_server_updates_import_job(file_type_dict, files, jobid)
12
+ url = "/files#{ManagementServer::BASE_URI}?action=import&jobid=#{jobid}"
13
+ index = 0
14
+ payload = {}
15
+ files.each do |file_name|
16
+ type = file_type_dict[File.extname(file_name)]
17
+ key = 'file_' + (index += 1).to_s
18
+ payload[key.to_sym] = Faraday::UploadIO.new(file_name, type)
19
+ end
20
+ @connection.do_post(url, payload, true)
21
+ end
22
+
23
+ def populate_payload_files(files, file_type_dict)
24
+ payload_files = []
25
+ index = 0
26
+ files.each do |file|
27
+ name = File.basename(file)
28
+ payload_file = { :index => index += 1, :name => name.strip,
29
+ :type => file_type_dict[File.extname(name)].strip,
30
+ :size => File.size?(file) }
31
+ payload_files.push(payload_file)
32
+ end
33
+ payload_files
34
+ end
35
+
36
+ public
37
+
38
+ def get_management_server_updates_info(key = nil)
39
+ base_url = ManagementServer::BASE_URI
40
+ url = key.nil? ? base_url : "#{base_url}?key=#{key}"
41
+ msg = "input key=#{key}"
42
+ $lxca_log.info(self.class.to_s + ' ' + __method__.to_s, msg)
43
+ @connection.do_get(url)
44
+ end
45
+
46
+ def download_management_server_updates(fixids)
47
+ url = "#{ManagementServer::BASE_URI}?action=acquire"
48
+ opts = { :fixids => fixids }
49
+ request_body = JSON.generate(opts)
50
+ @connection.do_post(url, request_body)
51
+ end
52
+
53
+ def import_management_server_updates(files)
54
+ url = "#{ManagementServer::BASE_URI}?action=import"
55
+ file_type_dict = { '.txt' => 'text/plain', '.xml' => 'text/xml',
56
+ '.chg' => 'application/octet-stream',
57
+ '.tgz' => 'application/x-compressed' }
58
+ payload_files = populate_payload_files(files, file_type_dict)
59
+ request_body = JSON.generate(:files => payload_files)
60
+ response = @connection.do_post(url, request_body)
61
+ jobid = JSON.parse(response.body)['jobid']
62
+ $lxca_log.info(self.class.to_s + ' ' + __method__.to_s, "jobid: #{jobid}")
63
+ start_management_server_updates_import_job(file_type_dict, files, jobid)
64
+ end
65
+
66
+ def apply_management_server_updates(fixids)
67
+ url = "#{ManagementServer::BASE_URI}?action=apply"
68
+ opts = { :fixids => fixids }
69
+ request_body = JSON.generate(opts)
70
+ @connection.do_put(url, request_body)
71
+ end
72
+
73
+ def delete_management_server_updates(fixids)
74
+ fixids = fixids.join(',')
75
+ url = "#{ManagementServer::BASE_URI}/#{fixids}"
76
+ @connection.do_delete(url)
77
+ end
78
+
79
+ def refresh_management_server_updates_catalog
80
+ url = "#{ManagementServer::BASE_URI}?action=refresh"
81
+ opts = { :mts => ['lxca'] }
82
+ request_body = JSON.generate(opts)
83
+ @connection.do_post(url, request_body)
84
+ end
85
+ end
86
+ end
@@ -20,5 +20,51 @@ module XClarityClient
20
20
 
21
21
  send_power_request(managed_resource::BASE_URI + '/' + uuid + '/bmc', requested_state)
22
22
  end
23
+
24
+ def retrieve_mounted_media_details(uuid)
25
+ uri = Node::BASE_URI + "/#{uuid}/" + 'mediaMount'
26
+ @connection.do_get(uri)
27
+ end
28
+
29
+ def enable_media_mount_support(uuid)
30
+ uri = Node::BASE_URI + "/#{uuid}/" + 'mediaMount'
31
+ req_body = JSON.generate(:action => 'enableMountMedia')
32
+ @connection.do_put(uri, req_body)
33
+ end
34
+
35
+ def disable_media_mount_support(uuid)
36
+ uri = Node::BASE_URI + "/#{uuid}/" + 'mediaMount'
37
+ req_body = JSON.generate(:action => 'disableMountMedia')
38
+ @connection.do_put(uri, req_body)
39
+ end
40
+
41
+ def remove_all_mounted_medias(uuid)
42
+ uri = Node::BASE_URI + "/#{uuid}/" + 'mediaMount'
43
+ req_body = JSON.generate(:action => 'reset')
44
+ @connection.do_put(uri, req_body)
45
+ end
46
+
47
+ def mount_media(uuid, opts)
48
+ uri = Node::BASE_URI + "/#{uuid}/" + 'mediaMount'
49
+ opts[:action] = 'mount'
50
+ req_body = JSON.generate(opts)
51
+ @connection.do_put(uri, req_body)
52
+ end
53
+
54
+ def unmount_media_thinkserver(uuid, media_type)
55
+ uri = Node::BASE_URI + "/#{uuid}/" + 'mediaMount'
56
+ opts = { :action => 'unmount',
57
+ :mediaType => media_type }
58
+ req_body = JSON.generate(opts)
59
+ @connection.do_put(uri, req_body)
60
+ end
61
+
62
+ def unmount_media_thinksystem(uuid, media_uid)
63
+ uri = Node::BASE_URI + "/#{uuid}/" + 'mediaMount'
64
+ opts = { :action => 'unmount',
65
+ :UID => media_uid }
66
+ req_body = JSON.generate(opts)
67
+ @connection.do_put(uri, req_body)
68
+ end
23
69
  end
24
70
  end