xclarity_client 0.6.6 → 0.6.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3de68cc1b07f9953dbefe5fda0b8b8e74df98f0a
4
- data.tar.gz: 39e2effba3ca1815ec833c2a63ea36a1e8e03a3d
3
+ metadata.gz: 35f2443209d986e5608952ffd73ff6136d41793c
4
+ data.tar.gz: 0c0d9593884792ad1e9be4b718c7d0951e86a99a
5
5
  SHA512:
6
- metadata.gz: fd9cdbe853931062976eb4ab76af736b258b5b2ce68900a131c1a93d95d1cc9c30bd8e4e333fbf6b2e0ff354ef45b01ca10b10334eb4e6dd537d45689c030195
7
- data.tar.gz: 930d73b66b1e7548274b83101bfe44611327948bae00df63f413bde98d3025f6da70da8132e4d07b63bb5175011e83d8c8b835d35340346650dea13b749d649f
6
+ metadata.gz: cc76fc06ce1c471841b8c5868419aa7ff418bda70557199fe4cf024f2212ebd18254baa40ac7f3e00fdfffa98550b050d631dd6767d153ed003ca3f250bc19d6
7
+ data.tar.gz: ba3dffa723f8eebbdcef91ed75000f8ed534929ff0c62ce16335bd40d3f0a954286156faa163e82328b66035e675a1838d6a1eb23b8ddaec25984128c7ebaa74
@@ -3,7 +3,7 @@ require 'faraday-cookie_jar'
3
3
  require 'uri'
4
4
  require 'uri/https'
5
5
  require 'timeout'
6
- require 'pp'
6
+ require 'net/http'
7
7
 
8
8
  module XClarityClient
9
9
  #
@@ -25,7 +25,9 @@ module XClarityClient
25
25
  def initialize(configuration)
26
26
  @connection = build(configuration)
27
27
  @connection_multipart = build(configuration, true)
28
+ @connection_net_http = build(configuration, false, true)
28
29
  @timeout = configuration.timeout
30
+ @configuration = configuration
29
31
  end
30
32
 
31
33
  # Does a GET request to an LXCA endpoint
@@ -34,10 +36,11 @@ module XClarityClient
34
36
  # @param [Hash] query - params to query the endpoint resources
35
37
  # @param [Hash] headers - add headers to the request
36
38
  #
37
- def do_get(uri = "", query: {}, headers: {})
39
+ def do_get(uri = "", query: {}, headers: {}, n_http: false)
38
40
  url_query = query.size > 0 ? "?" + query.map {|k, v| "#{k}=#{v}"}.join("&") : ""
39
41
  Timeout.timeout(@timeout) do
40
- @connection.get do |req|
42
+ con = n_http ? @connection_net_http : @connection
43
+ con.get do |req|
41
44
  req.url(uri + url_query)
42
45
  headers.map { |key, value| req.headers[key] = value }
43
46
  end
@@ -49,6 +52,32 @@ module XClarityClient
49
52
  Faraday::Response.new
50
53
  end
51
54
 
55
+ def do_get_file_download(url, file_path)
56
+ host = @configuration.host
57
+ username = @configuration.username
58
+ password = @configuration.password
59
+
60
+ uri = 'https://' + host + url unless host.include?('https')
61
+ uri = host + url if host.include?('https')
62
+
63
+ uri = URI(uri)
64
+ Net::HTTP.start(uri.host, uri.port,
65
+ :use_ssl => true,
66
+ :verify_mode => 0) do |http|
67
+
68
+ request = Net::HTTP::Get.new(uri.request_uri)
69
+ request.basic_auth(username, password)
70
+
71
+ http.request(request) do |response|
72
+ open file_path, 'wb' do |io|
73
+ response.read_body do |chunk|
74
+ io.write(chunk)
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+
52
81
  # Does a POST request to an LXCA endpoint
53
82
  #
54
83
  # @param [String] uri - endpoint to do the request
@@ -74,17 +103,11 @@ module XClarityClient
74
103
  private
75
104
 
76
105
  def build_request(method, url, body = '', multipart = false)
77
- if multipart == true
78
- @connection_multipart.send(method) do |request|
79
- request.url(url)
80
- request.body = body
81
- end
82
- else
83
- @connection.send(method) do |request|
84
- request.url(url)
85
- request.headers['Content-Type'] = 'application/json'
86
- request.body = body
87
- end
106
+ con = multipart ? @connection_multipart : @connection
107
+ con.send(method) do |request|
108
+ request.url(url)
109
+ request.headers['Content-Type'] = 'application/json' unless multipart
110
+ request.body = body
88
111
  end
89
112
  rescue Faraday::Error::ConnectionFailed => e
90
113
  header = HEADER_MESSAGE + " do_#{method}"
@@ -95,7 +118,7 @@ module XClarityClient
95
118
  Faraday::Response.new
96
119
  end
97
120
 
98
- def create_connection(connection, configuration)
121
+ def create_connection_obj(connection, configuration)
99
122
  user_agent_label = configuration.user_agent_label
100
123
  agent_label = user_agent_label.nil? ? "" : user_agent_label
101
124
  header = "LXCA via Ruby Client/#{XClarityClient::VERSION}"
@@ -108,34 +131,24 @@ module XClarityClient
108
131
  connection
109
132
  end
110
133
 
111
- def create_faraday_multipart_obj(url, configuration)
112
- Faraday.new(url: url) do |faraday|
113
- faraday.request(:multipart) # multipart form data
114
- faraday.request(:url_encoded) # form-encode POST params
115
- faraday.response(:logger, $lxca_log.log) # log requests to log file
116
- faraday.use(:cookie_jar) if configuration.auth_type == 'token'
117
- faraday.adapter(:net_http) # make requests with net_http
118
- faraday.ssl[:verify] = configuration.verify_ssl == 'PEER'
119
- end
120
- end
121
-
122
- def create_faraday_obj(url, configuration)
134
+ def create_faraday_obj(url, configuration, multipart, n_http)
123
135
  Faraday.new(url: url) do |faraday|
136
+ faraday.request(:multipart) if multipart # multipart form data
124
137
  faraday.request(:url_encoded) # form-encode POST params
125
138
  faraday.response(:logger, $lxca_log.log) # log requests to log file
126
139
  faraday.use(:cookie_jar) if configuration.auth_type == 'token'
127
- faraday.adapter(:httpclient) # make request with httpclient
140
+ faraday.adapter(:httpclient) unless n_http || multipart
141
+ faraday.adapter(:net_http) if n_http || multipart # with net_http
128
142
  faraday.ssl[:verify] = configuration.verify_ssl == 'PEER'
129
143
  end
130
144
  end
131
145
 
132
- def build_connection(url, configuration, multipart = false)
133
- con_obj = create_faraday_multipart_obj(url, configuration) if multipart
134
- con_obj = create_faraday_obj(url, configuration) unless multipart
135
- create_connection(con_obj, configuration)
146
+ def build_connection(url, configuration, multipart = false, n_http = false)
147
+ con_obj = create_faraday_obj(url, configuration, multipart, n_http)
148
+ create_connection_obj(con_obj, configuration)
136
149
  end
137
150
 
138
- def build(configuration, multipart = false)
151
+ def build(configuration, multipart = false, n_http = false)
139
152
  header = HEADER_MESSAGE + ' build'
140
153
  $lxca_log.info(header, 'Building the connection')
141
154
  hostname = URI.parse(configuration.host)
@@ -145,7 +158,7 @@ module XClarityClient
145
158
  :query => hostname.query,
146
159
  :fragment => hostname.fragment).to_s
147
160
  $lxca_log.info(header, "Creating connection to #{url}")
148
- build_connection(url, configuration, multipart)
161
+ build_connection(url, configuration, multipart, n_http)
149
162
  end
150
163
  end
151
164
  end
@@ -24,9 +24,5 @@ module XClarityClient
24
24
  def delete_job(id = '')
25
25
  JobManagement.new(@config).delete_job(id)
26
26
  end
27
-
28
- def get_job(job_id = '')
29
- JobManagement.new(@config).get_job(job_id)
30
- end
31
27
  end
32
28
  end
@@ -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
@@ -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
@@ -1,6 +1,5 @@
1
1
  require 'json'
2
2
  require 'pathname'
3
- require 'pp'
4
3
 
5
4
  module XClarityClient
6
5
  # ManagementServerManagement class
@@ -10,7 +9,7 @@ module XClarityClient
10
9
  private
11
10
 
12
11
  def start_management_server_updates_import_job(file_type_dict, files, jobid)
13
- url = "/files/#{ManagementServer::BASE_URI}?action=import&jobid=#{jobid}"
12
+ url = "/files#{ManagementServer::BASE_URI}?action=import&jobid=#{jobid}"
14
13
  index = 0
15
14
  payload = {}
16
15
  files.each do |file_name|
@@ -59,7 +58,7 @@ module XClarityClient
59
58
  payload_files = populate_payload_files(files, file_type_dict)
60
59
  request_body = JSON.generate(:files => payload_files)
61
60
  response = @connection.do_post(url, request_body)
62
- jobid = JSON.parse(response.body).to_hash['jobid']
61
+ jobid = JSON.parse(response.body)['jobid']
63
62
  $lxca_log.info(self.class.to_s + ' ' + __method__.to_s, "jobid: #{jobid}")
64
63
  start_management_server_updates_import_job(file_type_dict, files, jobid)
65
64
  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
@@ -18,8 +18,9 @@ module XClarityClient
18
18
  request_body = JSON.generate(opts)
19
19
  image_name = path.split(File::SEPARATOR).last
20
20
  begin
21
- response = @connection.do_post("#{OsImage::BASE_URI}?jobId=#{job_id}"\
22
- "&imageType=OS&imageName=#{image_name}",
21
+ response = @connection.do_post('/files'\
22
+ + '#{OsImage::BASE_URI}?jobId=#{job_id}'\
23
+ '&imageType=OS&imageName=' + image_name,
23
24
  request_body)
24
25
  response
25
26
  rescue Faraday::TimeoutError => e
@@ -13,11 +13,8 @@ module XClarityClient
13
13
  err_missing_key = 'Option key must be provided for update_repo resource'
14
14
  err_wrong_key = 'The value for option key should be one of these : '\
15
15
  "#{allowed_keys.join(', ')}"
16
-
17
16
  raise err_missing_key if opts.empty? || !(opts[:key] || opts['key'])
18
-
19
17
  repo_key = opts[:key] || opts['key']
20
-
21
18
  raise err_wrong_key unless allowed_keys.include?(repo_key)
22
19
  end
23
20
 
@@ -36,60 +33,116 @@ module XClarityClient
36
33
 
37
34
  public
38
35
 
39
- def check_file_types(file_types)
40
- x = 'Invalid value for argument file_types. Allowed values are'\
41
- + ' - all and payloads'
42
- raise x unless file_types.casecmp('payloads').zero? ||
43
- file_types.casecmp('all').zero?
36
+ def track_task_status(taskid, tasktype)
37
+ uri = UpdateRepo::BASE_URI + '/status' + '?tasktype=' + tasktype\
38
+ + '&taskid=' + taskid.to_s
39
+ @connection.do_get(uri)
40
+ end
41
+
42
+ def download_exported_firmware_updates(fname, dir_path_to_download)
43
+ uri = UpdateRepo::BASE_URI + '?action=export&exportRepoFilename=' + fname
44
+ file_path = File.join(dir_path_to_download, fname)
45
+ @connection.do_get_file_download(uri, file_path)
44
46
  end
45
47
 
46
48
  def read_update_repo
47
- response = @connection.do_put(UpdateRepo::BASE_URI + '?action=read')
48
- response.body
49
+ @connection.do_put(UpdateRepo::BASE_URI + '?action=read')
49
50
  end
50
51
 
51
- def refresh_update_repo(scope, mt, os)
52
- if scope.casecmp('all') != 0 && scope.casecmp('latest') != 0
52
+ def refresh_update_repo_catalog(scope, mt, uxsp = false)
53
+ unless %w(all latest).include?(scope)
53
54
  raise 'Invalid argument combination of action and scope. Action'\
54
55
  + ' refresh can have scope as either all or latest'
55
56
  end
56
- refresh_req = JSON.generate(:mt => mt, :os => os, :type => 'catalog')
57
- response = @connection.do_put(UpdateRepo::BASE_URI\
58
- + '?action=refresh&with='\
59
- + scope.downcase, refresh_req)
60
- response.body
57
+ req_body = JSON.generate(:mt => mt, :os => '', :type => 'catalog')
58
+ uri = UpdateRepo::BASE_URI
59
+ uri += '/uxsps' if uxsp
60
+ uri += '?action=refresh&with=' + scope
61
+ @connection.do_put(uri, req_body)
61
62
  end
62
63
 
63
- def acquire_firmware_updates(scope, fixids, mt)
64
- if scope.casecmp('payloads') != 0
65
- raise 'Invalid argument combination of action and scope. Action'\
66
- + ' acquire can have scope as payloads'
67
- end
68
- acquire_req = JSON.generate(:mt => mt, :fixids => fixids,
69
- :type => 'latest')
70
- response = @connection.do_put(UpdateRepo::BASE_URI\
71
- + '?action=acquire&with='\
72
- + scope.downcase, acquire_req)
73
- response.body
74
- end
75
-
76
- def delete_firmware_updates(file_types, fixids)
77
- check_file_types(file_types)
78
- delete_req = JSON.generate(:fixids => fixids)
79
- response = @connection.do_put(UpdateRepo::BASE_URI + '?action='\
80
- + 'delete&filetypes=' + file_types.downcase,
81
- delete_req)
82
- response.body
83
- end
84
-
85
- def export_firmware_updates(file_types, fixids)
86
- check_file_types(file_types)
87
-
88
- export_req = JSON.generate(:fixids => fixids)
89
- response = @connection.do_put(UpdateRepo::BASE_URI\
90
- + '?action=export&filetypes='\
91
- + file_types.downcase, export_req)
92
- response.body
64
+ def refresh_uxsp_update_repo_catalog(scope, mt)
65
+ refresh_update_repo_catalog(scope, mt, true)
66
+ end
67
+
68
+ def updates_info_by_machine_types(mt, uxsp = false)
69
+ mt = mt.join(',').to_str
70
+ uri = UpdateRepo::BASE_URI
71
+ uri += '/uxsps' if uxsp
72
+ key = 'uxspsByMt' if uxsp
73
+ key = 'updatesByMt' unless uxsp
74
+ uri += '?key=' + key + '&with=all&payload&mt=' + mt
75
+ @connection.do_get(uri)
76
+ end
77
+
78
+ def uxsp_updates_info_by_machine_types(mt)
79
+ updates_info_by_machine_types(mt, true)
80
+ end
81
+
82
+ def supported_machine_types_detail
83
+ @connection.do_get(UpdateRepo::BASE_URI + '?key=supportedMts')
84
+ end
85
+
86
+ def acquire_firmware_updates(mt, fixids)
87
+ req_body = JSON.generate(:mt => mt, :fixids => fixids, :type => 'latest')
88
+ @connection.do_put(UpdateRepo::BASE_URI\
89
+ + '?action=acquire&with=payloads', req_body)
90
+ end
91
+
92
+ def delete_firmware_updates(file_types, fixids = [])
93
+ req_body = JSON.generate(:fixids => fixids)
94
+ @connection.do_put(UpdateRepo::BASE_URI + '?action='\
95
+ + 'delete&filetypes=' + file_types.downcase,
96
+ req_body)
97
+ end
98
+
99
+ def export_firmware_updates(file_types, fixids = [])
100
+ req_body = JSON.generate(:fixids => fixids)
101
+ @connection.do_put(UpdateRepo::BASE_URI\
102
+ + '?action=export&filetypes='\
103
+ + file_types.downcase, req_body)
104
+ end
105
+
106
+ def validate_import_updates(file_path)
107
+ type = 'application/x-zip-compressed'
108
+ fname = File.basename(file_path)
109
+ opts = { :index => 0, :name => fname,
110
+ :type => type,
111
+ :size => File.size?(file_path) }
112
+ req_body = JSON.generate(opts)
113
+ uri = '/files/updateRepositories/firmware/import/validate'
114
+ @connection.do_post(uri, req_body)
115
+ end
116
+
117
+ def import_firmware_updates(file_path)
118
+ uri = '/files/updateRepositories/firmware/import'
119
+ type = 'application/x-zip-compressed'
120
+ opts = { :upload_file => Faraday::UploadIO.new(file_path, type) }
121
+ @connection.do_post(uri, opts, true)
122
+ end
123
+
124
+ def retrieve_compliance_policy_list
125
+ uri = '/compliancePolicies'
126
+ @connection.do_get(uri)
127
+ end
128
+
129
+ def export_compliance_policies(policy_names)
130
+ uri = '/compliancePolicies?action=export'
131
+ req_body = JSON.generate(:export => policy_names)
132
+ @connection.do_put(uri, req_body)
133
+ end
134
+
135
+ def download_exported_compliance_policies(fname, dir_path_for_download)
136
+ uri = '/compliancePolicies?exportDownload=' + fname
137
+ file_path = File.join(dir_path_for_download, fname)
138
+ @connection.do_get_file_download(uri, file_path)
139
+ end
140
+
141
+ def import_compliance_policies(file_path)
142
+ uri = '/files/compliancePolicies?action=import'
143
+ type = 'application/x-zip-compressed'
144
+ opts = { :upload_file => Faraday::UploadIO.new(file_path, type) }
145
+ @connection.do_post(uri, opts, true)
93
146
  end
94
147
  end
95
148
  end
@@ -1,3 +1,3 @@
1
1
  module XClarityClient
2
- VERSION = "0.6.6"
2
+ VERSION = '0.6.7'.freeze
3
3
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_development_dependency('bundler', '>= 1.12')
20
+ spec.add_development_dependency('bundler', '>= 1.11.2')
21
21
  spec.add_development_dependency "rake", "~> 10.0"
22
22
  spec.add_development_dependency "rspec", "~> 3.0"
23
23
  spec.add_development_dependency "apib-mock_server", "~> 1.0.3"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xclarity_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6
4
+ version: 0.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manasa Rao
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-01-07 00:00:00.000000000 Z
12
+ date: 2019-03-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '1.12'
20
+ version: 1.11.2
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '1.12'
27
+ version: 1.11.2
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement