Class: XClarityClient::UpdateRepoManagement

Inherits:
Services::XClarityService show all
Defined in:
lib/xclarity_client/services/update_repo_management.rb

Instance Method Summary collapse

Methods inherited from Services::XClarityService

#get_headers_with_opts, #get_object, #get_object_with_id, #get_object_with_opts, #initialize

Methods included from Services::ResponseBuilderMixin

#build_response_with_resource_list

Methods included from Services::ListNameInterpreterMixin

#add_listname_on_body

Constructor Details

This class inherits a constructor from XClarityClient::Services::XClarityService

Instance Method Details

#acquire_firmware_updates(mt, fixids) ⇒ Object



86
87
88
89
90
# File 'lib/xclarity_client/services/update_repo_management.rb', line 86

def acquire_firmware_updates(mt, fixids)
  req_body = JSON.generate(:mt => mt, :fixids => fixids, :type => 'latest')
  @connection.do_put(UpdateRepo::BASE_URI\
           + '?action=acquire&with=payloads', req_body)
end

#delete_firmware_updates(file_types, fixids = []) ⇒ Object



92
93
94
95
96
97
# File 'lib/xclarity_client/services/update_repo_management.rb', line 92

def delete_firmware_updates(file_types, fixids = [])
  req_body = JSON.generate(:fixids => fixids)
  @connection.do_put(UpdateRepo::BASE_URI + '?action='\
                     + 'delete&filetypes=' + file_types.downcase,
                     req_body)
end

#download_exported_compliance_policies(fname, dir_path_for_download) ⇒ Object



135
136
137
138
139
# File 'lib/xclarity_client/services/update_repo_management.rb', line 135

def download_exported_compliance_policies(fname, dir_path_for_download)
  uri = '/compliancePolicies?exportDownload=' + fname
  file_path = File.join(dir_path_for_download, fname)
  @connection.do_get_file_download(uri, file_path)
end

#download_exported_firmware_updates(fname, dir_path_to_download) ⇒ Object



42
43
44
45
46
# File 'lib/xclarity_client/services/update_repo_management.rb', line 42

def download_exported_firmware_updates(fname, dir_path_to_download)
  uri = UpdateRepo::BASE_URI + '?action=export&exportRepoFilename=' + fname
  file_path = File.join(dir_path_to_download, fname)
  @connection.do_get_file_download(uri, file_path)
end

#export_compliance_policies(policy_names) ⇒ Object



129
130
131
132
133
# File 'lib/xclarity_client/services/update_repo_management.rb', line 129

def export_compliance_policies(policy_names)
  uri = '/compliancePolicies?action=export'
  req_body = JSON.generate(:export => policy_names)
  @connection.do_put(uri, req_body)
end

#export_firmware_updates(file_types, fixids = []) ⇒ Object



99
100
101
102
103
104
# File 'lib/xclarity_client/services/update_repo_management.rb', line 99

def export_firmware_updates(file_types, fixids = [])
  req_body = JSON.generate(:fixids => fixids)
  @connection.do_put(UpdateRepo::BASE_URI\
                     + '?action=export&filetypes='\
                     + file_types.downcase, req_body)
end

#fetch_all(opts = {}) ⇒ Object



5
6
7
8
# File 'lib/xclarity_client/services/update_repo_management.rb', line 5

def fetch_all(opts = {})
  validate_opts(opts)
  super(opts)
end

#import_compliance_policies(file_path) ⇒ Object



141
142
143
144
145
146
# File 'lib/xclarity_client/services/update_repo_management.rb', line 141

def import_compliance_policies(file_path)
  uri = '/files/compliancePolicies?action=import'
  type = 'application/x-zip-compressed'
  opts = { :upload_file => Faraday::UploadIO.new(file_path, type) }
  @connection.do_post(uri, opts, true)
end

#import_firmware_updates(file_path) ⇒ Object



117
118
119
120
121
122
# File 'lib/xclarity_client/services/update_repo_management.rb', line 117

def import_firmware_updates(file_path)
  uri = '/files/updateRepositories/firmware/import'
  type = 'application/x-zip-compressed'
  opts = { :upload_file => Faraday::UploadIO.new(file_path, type) }
  @connection.do_post(uri, opts, true)
end

#read_update_repoObject



48
49
50
# File 'lib/xclarity_client/services/update_repo_management.rb', line 48

def read_update_repo
  @connection.do_put(UpdateRepo::BASE_URI + '?action=read')
end

#refresh_update_repo_catalog(scope, mt, uxsp = false) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/xclarity_client/services/update_repo_management.rb', line 52

def refresh_update_repo_catalog(scope, mt, uxsp = false)
  unless %w(all latest).include?(scope)
    raise 'Invalid argument combination of action and scope. Action'\
           + ' refresh can have scope as either all or latest'
  end
  req_body = JSON.generate(:mt => mt, :os => '', :type => 'catalog')
  uri = UpdateRepo::BASE_URI
  uri += '/uxsps' if uxsp
  uri += '?action=refresh&with=' + scope
  @connection.do_put(uri, req_body)
end

#refresh_uxsp_update_repo_catalog(scope, mt) ⇒ Object



64
65
66
# File 'lib/xclarity_client/services/update_repo_management.rb', line 64

def refresh_uxsp_update_repo_catalog(scope, mt)
  refresh_update_repo_catalog(scope, mt, true)
end

#retrieve_compliance_policy_listObject



124
125
126
127
# File 'lib/xclarity_client/services/update_repo_management.rb', line 124

def retrieve_compliance_policy_list
  uri = '/compliancePolicies'
  @connection.do_get(uri)
end

#supported_machine_types_detailObject



82
83
84
# File 'lib/xclarity_client/services/update_repo_management.rb', line 82

def supported_machine_types_detail
  @connection.do_get(UpdateRepo::BASE_URI + '?key=supportedMts')
end

#track_task_status(taskid, tasktype) ⇒ Object



36
37
38
39
40
# File 'lib/xclarity_client/services/update_repo_management.rb', line 36

def track_task_status(taskid, tasktype)
  uri = UpdateRepo::BASE_URI + '/status' + '?tasktype=' + tasktype\
          + '&taskid=' + taskid.to_s
  @connection.do_get(uri)
end

#updates_info_by_machine_types(mt, uxsp = false) ⇒ Object



68
69
70
71
72
73
74
75
76
# File 'lib/xclarity_client/services/update_repo_management.rb', line 68

def updates_info_by_machine_types(mt, uxsp = false)
  mt = mt.join(',').to_str
  uri = UpdateRepo::BASE_URI
  uri += '/uxsps' if uxsp
  key = 'uxspsByMt' if uxsp
  key = 'updatesByMt' unless uxsp
  uri += '?key=' + key + '&with=all&payload&mt=' + mt
  @connection.do_get(uri)
end

#uxsp_updates_info_by_machine_types(mt) ⇒ Object



78
79
80
# File 'lib/xclarity_client/services/update_repo_management.rb', line 78

def uxsp_updates_info_by_machine_types(mt)
  updates_info_by_machine_types(mt, true)
end

#validate_import_updates(file_path) ⇒ Object



106
107
108
109
110
111
112
113
114
115
# File 'lib/xclarity_client/services/update_repo_management.rb', line 106

def validate_import_updates(file_path)
  type = 'application/x-zip-compressed'
  fname = File.basename(file_path)
  opts = { :index => 0, :name => fname,
           :type  => type,
           :size  => File.size?(file_path) }
  req_body = JSON.generate(opts)
  uri = '/files/updateRepositories/firmware/import/validate'
  @connection.do_post(uri, req_body)
end