xclarity_client 0.6.3 → 0.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/docs/apib/discover_request.apib +3 -1
- data/docs/apib/event.apib +0 -1
- data/docs/apib/manage_request.apib +359 -0
- data/docs/apib/storages.apib +3 -3
- data/docs/apib/update_comp.apib +426 -0
- data/docs/apib/update_repo.apib +0 -57
- data/lib/xclarity_client.rb +0 -1
- data/lib/xclarity_client/client.rb +3 -0
- data/lib/xclarity_client/connection/connection.rb +73 -35
- data/lib/xclarity_client/endpoints/endpoints.rb +3 -0
- data/lib/xclarity_client/endpoints/manage_request.rb +11 -0
- data/lib/xclarity_client/endpoints/management_server.rb +5 -0
- data/lib/xclarity_client/endpoints/storage.rb +7 -6
- data/lib/xclarity_client/endpoints/update_comp.rb +18 -0
- data/lib/xclarity_client/mixins/job_mixin.rb +0 -4
- data/lib/xclarity_client/mixins/manage_request_mixin.rb +54 -0
- data/lib/xclarity_client/mixins/management_server_mixin.rb +40 -0
- data/lib/xclarity_client/mixins/mixins.rb +3 -0
- data/lib/xclarity_client/mixins/node_mixin.rb +42 -0
- data/lib/xclarity_client/mixins/update_comp_mixin.rb +37 -0
- data/lib/xclarity_client/mixins/update_repo_mixin.rb +107 -7
- data/lib/xclarity_client/services/job_management.rb +2 -4
- data/lib/xclarity_client/services/manage_request_management.rb +62 -0
- data/lib/xclarity_client/services/management_server_management.rb +86 -0
- data/lib/xclarity_client/services/node_management.rb +46 -0
- data/lib/xclarity_client/services/osimage_management.rb +3 -2
- data/lib/xclarity_client/services/remote_access_management.rb +6 -4
- data/lib/xclarity_client/services/services.rb +3 -0
- data/lib/xclarity_client/services/update_comp_management.rb +111 -0
- data/lib/xclarity_client/services/update_repo_management.rb +100 -47
- data/lib/xclarity_client/services/virtual_appliance_management.rb +13 -16
- data/lib/xclarity_client/services/xclarity_service.rb +2 -3
- data/lib/xclarity_client/version.rb +1 -1
- data/lib/xclarity_client/xclarity_credentials_validator.rb +8 -11
- data/xclarity_client.gemspec +2 -2
- metadata +26 -11
- data/lib/xclarity_client/xclarity_base.rb +0 -88
data/docs/apib/update_repo.apib
CHANGED
@@ -1547,60 +1547,3 @@ FORMAT: 1A
|
|
1547
1547
|
+ Response 404
|
1548
1548
|
+ Response 409
|
1549
1549
|
+ Response 500
|
1550
|
-
|
1551
|
-
# XClarity Update Repositories [/updatableComponents{?action,with,filetypes}]
|
1552
|
-
|
1553
|
-
+ Parameters
|
1554
|
-
+ action - The action to take. This can be one of the following values - read, refresh, acquire, delete, export
|
1555
|
-
+ with - The scope of the action. This can be one of the following values - all, latest, payloads
|
1556
|
-
+ filetypes - When action=delete or action=export is specified, this parameter is used. Value can be set to payloads
|
1557
|
-
|
1558
|
-
## Update Repo [PUT]
|
1559
|
-
+ Request (application/json)
|
1560
|
-
{
|
1561
|
-
"mt": [
|
1562
|
-
"7167"
|
1563
|
-
],
|
1564
|
-
"os": "",
|
1565
|
-
"type": "catalog"
|
1566
|
-
}
|
1567
|
-
+ Response 200
|
1568
|
-
|
1569
|
-
+ Response 400
|
1570
|
-
+ Response 401
|
1571
|
-
+ Response 404
|
1572
|
-
+ Response 409
|
1573
|
-
+ Response 500
|
1574
|
-
|
1575
|
-
+ Request (application/json)
|
1576
|
-
{
|
1577
|
-
"fixids": [
|
1578
|
-
"brcd_fw_bcsw_nos5.0.1_anyos_noarch",
|
1579
|
-
"brcd_fw_cna_3.2.4.0_linux_32-64",
|
1580
|
-
"brcd_fw_cna_3.2.3.0_linux_32-64",
|
1581
|
-
"lenovo_fw_dsa_dsyte2f-9.61_anyos_32-64"
|
1582
|
-
],
|
1583
|
-
"mt": "0000",
|
1584
|
-
"type": "latest"
|
1585
|
-
}
|
1586
|
-
+ Response 200
|
1587
|
-
|
1588
|
-
+ Response 400
|
1589
|
-
+ Response 401
|
1590
|
-
+ Response 404
|
1591
|
-
+ Response 409
|
1592
|
-
+ Response 500
|
1593
|
-
|
1594
|
-
+ Request (application/json)
|
1595
|
-
{
|
1596
|
-
"fixids": [
|
1597
|
-
"lnvgy_fw_cmm_1aon01k-1.0.0k_anyos_noarch"
|
1598
|
-
]
|
1599
|
-
}
|
1600
|
-
+ Response 200
|
1601
|
-
|
1602
|
-
+ Response 400
|
1603
|
-
+ Response 401
|
1604
|
-
+ Response 404
|
1605
|
-
+ Response 409
|
1606
|
-
+ Response 500
|
data/lib/xclarity_client.rb
CHANGED
@@ -8,7 +8,6 @@ end
|
|
8
8
|
require 'xclarity_client/errors/errors'
|
9
9
|
|
10
10
|
require 'xclarity_client/configuration'
|
11
|
-
require 'xclarity_client/xclarity_base'
|
12
11
|
require 'xclarity_client/xclarity_credentials_validator'
|
13
12
|
require 'xclarity_client/discover'
|
14
13
|
require 'xclarity_client/endpoints/endpoints'
|
@@ -31,8 +31,11 @@ module XClarityClient
|
|
31
31
|
include XClarityClient::Mixins::StorageMixin
|
32
32
|
include XClarityClient::Mixins::SwitchMixin
|
33
33
|
include XClarityClient::Mixins::UnmanageRequestMixin
|
34
|
+
include XClarityClient::Mixins::ManageRequestMixin
|
34
35
|
include XClarityClient::Mixins::UpdateRepoMixin
|
36
|
+
include XClarityClient::Mixins::UpdateCompMixin
|
35
37
|
include XClarityClient::Mixins::UserMixin
|
38
|
+
include XClarityClient::Mixins::ManagementServerMixin
|
36
39
|
|
37
40
|
def initialize(config)
|
38
41
|
@config = config
|
@@ -3,6 +3,7 @@ require 'faraday-cookie_jar'
|
|
3
3
|
require 'uri'
|
4
4
|
require 'uri/https'
|
5
5
|
require 'timeout'
|
6
|
+
require 'net/http'
|
6
7
|
|
7
8
|
module XClarityClient
|
8
9
|
#
|
@@ -11,7 +12,6 @@ module XClarityClient
|
|
11
12
|
#
|
12
13
|
class Connection
|
13
14
|
HEADER_MESSAGE = 'XClarityClient::Connection'.freeze
|
14
|
-
#
|
15
15
|
# @param [Hash] configuration - the data to create a connection with the LXCA
|
16
16
|
# @option configuration [String] :host the LXCA host
|
17
17
|
# @option configuration [String] :username the LXCA username
|
@@ -24,20 +24,23 @@ module XClarityClient
|
|
24
24
|
#
|
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)
|
29
|
+
@timeout = configuration.timeout
|
30
|
+
@configuration = configuration
|
28
31
|
end
|
29
32
|
|
30
|
-
#
|
31
33
|
# Does a GET request to an LXCA endpoint
|
32
34
|
#
|
33
35
|
# @param [String] uri - endpoint to do the request
|
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
|
-
@
|
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,41 +52,61 @@ module XClarityClient
|
|
49
52
|
Faraday::Response.new
|
50
53
|
end
|
51
54
|
|
52
|
-
|
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
|
+
|
53
81
|
# Does a POST request to an LXCA endpoint
|
54
82
|
#
|
55
83
|
# @param [String] uri - endpoint to do the request
|
56
84
|
# @param [JSON] body - json to be sent in request body
|
57
85
|
#
|
58
|
-
def do_post(uri = '', body = '')
|
59
|
-
build_request(:post, uri, body)
|
86
|
+
def do_post(uri = '', body = '', multipart = false)
|
87
|
+
build_request(:post, uri, body, multipart)
|
60
88
|
end
|
61
89
|
|
62
|
-
#
|
63
90
|
# Does a PUT request to an LXCA endpoint
|
64
|
-
#
|
65
91
|
# @param [String] uri - endpoint to do the request
|
66
92
|
# @param [JSON] body - json to be sent in request body
|
67
|
-
#
|
68
93
|
def do_put(uri = '', body = '')
|
69
94
|
build_request(:put, uri, body)
|
70
95
|
end
|
71
96
|
|
72
|
-
#
|
73
97
|
# Does a DELETE request to an LXCA endpoint
|
74
|
-
#
|
75
98
|
# @param [String] uri - endpoint to do the request
|
76
|
-
#
|
77
99
|
def do_delete(uri = '')
|
78
100
|
build_request(:delete, uri)
|
79
101
|
end
|
80
102
|
|
81
103
|
private
|
82
104
|
|
83
|
-
def build_request(method, url, body = '')
|
84
|
-
@
|
105
|
+
def build_request(method, url, body = '', multipart = false)
|
106
|
+
con = multipart ? @connection_multipart : @connection
|
107
|
+
con.send(method) do |request|
|
85
108
|
request.url(url)
|
86
|
-
request.headers['Content-Type'] = 'application/json'
|
109
|
+
request.headers['Content-Type'] = 'application/json' unless multipart
|
87
110
|
request.body = body
|
88
111
|
end
|
89
112
|
rescue Faraday::Error::ConnectionFailed => e
|
@@ -95,32 +118,47 @@ module XClarityClient
|
|
95
118
|
Faraday::Response.new
|
96
119
|
end
|
97
120
|
|
98
|
-
def
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
121
|
+
def create_connection_obj(connection, configuration)
|
122
|
+
user_agent_label = configuration.user_agent_label
|
123
|
+
agent_label = user_agent_label.nil? ? "" : user_agent_label
|
124
|
+
header = "LXCA via Ruby Client/#{XClarityClient::VERSION}"
|
125
|
+
connection.headers[:user_agent] = header + agent_label
|
126
|
+
basic_auth = configuration.auth_type == 'basic_auth'
|
127
|
+
username = configuration.username
|
128
|
+
password = configuration.password
|
129
|
+
connection.basic_auth(username, password) if basic_auth
|
130
|
+
$lxca_log.info(header, 'Connection created Successfuly')
|
131
|
+
connection
|
132
|
+
end
|
109
133
|
|
110
|
-
|
134
|
+
def create_faraday_obj(url, configuration, multipart, n_http)
|
135
|
+
Faraday.new(url: url) do |faraday|
|
136
|
+
faraday.request(:multipart) if multipart # multipart form data
|
111
137
|
faraday.request(:url_encoded) # form-encode POST params
|
112
138
|
faraday.response(:logger, $lxca_log.log) # log requests to log file
|
113
139
|
faraday.use(:cookie_jar) if configuration.auth_type == 'token'
|
114
|
-
faraday.adapter(:httpclient)
|
140
|
+
faraday.adapter(:httpclient) unless n_http || multipart
|
141
|
+
faraday.adapter(:net_http) if n_http || multipart # with net_http
|
115
142
|
faraday.ssl[:verify] = configuration.verify_ssl == 'PEER'
|
116
143
|
end
|
144
|
+
end
|
117
145
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
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)
|
149
|
+
end
|
122
150
|
|
123
|
-
|
151
|
+
def build(configuration, multipart = false, n_http = false)
|
152
|
+
header = HEADER_MESSAGE + ' build'
|
153
|
+
$lxca_log.info(header, 'Building the connection')
|
154
|
+
hostname = URI.parse(configuration.host)
|
155
|
+
host = hostname.scheme ? hostname.host : hostname.path
|
156
|
+
url = URI::HTTPS.build(:host => host,
|
157
|
+
:port => configuration.port.to_i,
|
158
|
+
:query => hostname.query,
|
159
|
+
:fragment => hostname.fragment).to_s
|
160
|
+
$lxca_log.info(header, "Creating connection to #{url}")
|
161
|
+
build_connection(url, configuration, multipart, n_http)
|
124
162
|
end
|
125
163
|
end
|
126
164
|
end
|
@@ -26,7 +26,9 @@ require 'xclarity_client/endpoints/scalable_complex'
|
|
26
26
|
require 'xclarity_client/endpoints/switch'
|
27
27
|
require 'xclarity_client/endpoints/storage'
|
28
28
|
require 'xclarity_client/endpoints/unmanage_request'
|
29
|
+
require 'xclarity_client/endpoints/manage_request'
|
29
30
|
require 'xclarity_client/endpoints/update_repo'
|
31
|
+
require 'xclarity_client/endpoints/update_comp'
|
30
32
|
require 'xclarity_client/endpoints/user'
|
31
33
|
require 'xclarity_client/endpoints/remote_access'
|
32
34
|
require 'xclarity_client/endpoints/globalsettings'
|
@@ -34,3 +36,4 @@ require 'xclarity_client/endpoints/hostplatform'
|
|
34
36
|
require 'xclarity_client/endpoints/osimage'
|
35
37
|
require 'xclarity_client/endpoints/remotefileserver'
|
36
38
|
require 'xclarity_client/endpoints/compliance_policy'
|
39
|
+
require 'xclarity_client/endpoints/management_server'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module XClarityClient
|
2
|
+
# ManageRequest class
|
3
|
+
class ManageRequest < Endpoints::XclarityEndpoint
|
4
|
+
BASE_URI = '/manageRequest'.freeze
|
5
|
+
LIST_NAME = 'manageRequestList'.freeze
|
6
|
+
|
7
|
+
attr_accessor :progress, :results, :messageBundle, :messageID,
|
8
|
+
:messageParameters, :result, :resultLongDescription,
|
9
|
+
:resultShortDescription, :status, :taskid, :time_spent, :uuid
|
10
|
+
end
|
11
|
+
end
|
@@ -6,14 +6,15 @@ module XClarityClient
|
|
6
6
|
# speed, security and high availability
|
7
7
|
#
|
8
8
|
class Storage < Endpoints::XclarityEndpoint
|
9
|
-
BASE_URI = '/
|
9
|
+
BASE_URI = '/storage'.freeze
|
10
10
|
LIST_NAME = 'storageList'.freeze
|
11
11
|
|
12
12
|
attr_accessor :uuid, :name, :type, :accessState, :cmmHealthState,
|
13
|
-
:enclosures, :overallHealthState, :driveBays,
|
14
|
-
:enclosureCount, :canisterSlots, :
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
13
|
+
:enclosures, :canisters, :overallHealthState, :driveBays,
|
14
|
+
:enclosureCount, :canisterSlots, :parent,
|
15
|
+
:productName, :machineType, :model,
|
16
|
+
:serialNumber, :contact, :description,
|
17
|
+
:location, :room, :rack, :lowestRackUnit,
|
18
|
+
:mgmtProcIPaddress
|
18
19
|
end
|
19
20
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module XClarityClient
|
2
|
+
# update component class
|
3
|
+
class UpdateComp < Endpoints::XclarityEndpoint
|
4
|
+
BASE_URI = '/updatableComponents'.freeze
|
5
|
+
LIST_NAME = 'updateCompList'.freeze
|
6
|
+
|
7
|
+
attr_accessor :DeviceList, :CMMList, :ServerList, :StorageList, :SwitchList,
|
8
|
+
:UpdateStatusMetrics, :TotaldeviceUpdates,
|
9
|
+
:TotaldeviceUpdatesActive, :TotaldeviceUpdatesComplete,
|
10
|
+
:TotaldeviceUpdatesInProgress, :TotalJobs, :TotalJobsComplete,
|
11
|
+
:TotalJobsInProgress, :TotalJobsPercentComplete,
|
12
|
+
:TotalSupportTasks, :TotalSupportTasksActive, :TotalTasks,
|
13
|
+
:TotalTasksBlocked, :TotalTasksCanceled, :TotalTasksComplete,
|
14
|
+
:TotalTasksFailed, :TotalTasksInProgress, :TotalTasksSuccess,
|
15
|
+
:TotalUpdateTasksActive, :TotalUpdateTasks, :result,
|
16
|
+
:messages, :id, :text
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module XClarityClient
|
2
|
+
#
|
3
|
+
# Exposes ManageRequestManagement features
|
4
|
+
#
|
5
|
+
module Mixins::ManageRequestMixin
|
6
|
+
def fetch_manage_request(job_id)
|
7
|
+
ManageRequestManagement.new(@config).fetch_manage_request(job_id)
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_job_progress(dji, discovery_job_progress)
|
11
|
+
discovery_result = DiscoverRequestManagement.new(@config)\
|
12
|
+
.monitor_discover_request(dji)
|
13
|
+
discovery_result.map do |req|
|
14
|
+
req.instance_variables.each do |attr|
|
15
|
+
value = req.instance_variable_get(attr)
|
16
|
+
discovery_job_progress = value if attr.id2name.eql?('@progress')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
{ :discovery_job_progress => discovery_job_progress,
|
20
|
+
:discovery_result => discovery_result }
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_discovery_result(discovery_job_id)
|
24
|
+
discovery_job_id = discovery_job_id[:location].split('/')[3]
|
25
|
+
discovery_job_progress = 0
|
26
|
+
return false if discovery_job_id.nil?
|
27
|
+
while discovery_job_progress < 100
|
28
|
+
sleep 30
|
29
|
+
opts = get_job_progress(discovery_job_id, discovery_job_progress)
|
30
|
+
discovery_job_progress = opts[:discovery_job_progress]
|
31
|
+
end
|
32
|
+
opts[:discovery_result]
|
33
|
+
end
|
34
|
+
|
35
|
+
def update_manage_request(manage_request, force, discovery_result)
|
36
|
+
ManageRequestManagement.new(@config)\
|
37
|
+
.update_manage_request(manage_request,
|
38
|
+
force,
|
39
|
+
discovery_result)
|
40
|
+
end
|
41
|
+
|
42
|
+
def manage_discovered_devices(manage_request, force)
|
43
|
+
discovery_job_id = DiscoverRequestManagement.new(@config)\
|
44
|
+
.discover_manageable_devices(
|
45
|
+
manage_request[:ip_address]
|
46
|
+
)
|
47
|
+
d_res = get_discovery_result(discovery_job_id)
|
48
|
+
raise 'manageable device Discovery failed' unless d_res
|
49
|
+
update_manage_request(manage_request, force, d_res)
|
50
|
+
ManageRequestManagement.new(@config)\
|
51
|
+
.manage_discovered_devices(manage_request)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module XClarityClient
|
2
|
+
#
|
3
|
+
# Exposes ManagementServerManagement features
|
4
|
+
#
|
5
|
+
module Mixins::ManagementServerMixin
|
6
|
+
def get_management_server_updates_info(key = nil)
|
7
|
+
obj = ManagementServerManagement.new(@config)
|
8
|
+
obj.get_management_server_updates_info(key)
|
9
|
+
end
|
10
|
+
|
11
|
+
def delete_management_server_updates(fixids)
|
12
|
+
return "parameter 'fixids' should be array" unless fixids.kind_of?(Array)
|
13
|
+
obj = ManagementServerManagement.new(@config)
|
14
|
+
obj.delete_management_server_updates(fixids)
|
15
|
+
end
|
16
|
+
|
17
|
+
def download_management_server_updates(fixids)
|
18
|
+
return "parameter 'fixids' should be array" unless fixids.kind_of?(Array)
|
19
|
+
obj = ManagementServerManagement.new(@config)
|
20
|
+
obj.download_management_server_updates(fixids)
|
21
|
+
end
|
22
|
+
|
23
|
+
def apply_management_server_updates(fixids)
|
24
|
+
return "parameter 'fixids' should be array" unless fixids.kind_of?(Array)
|
25
|
+
obj = ManagementServerManagement.new(@config)
|
26
|
+
obj.apply_management_server_updates(fixids)
|
27
|
+
end
|
28
|
+
|
29
|
+
def refresh_management_server_updates_catalog
|
30
|
+
obj = ManagementServerManagement.new(@config)
|
31
|
+
obj.refresh_management_server_updates_catalog
|
32
|
+
end
|
33
|
+
|
34
|
+
def import_management_server_updates(files)
|
35
|
+
return "parameter 'files' should be array" unless files.kind_of?(Array)
|
36
|
+
obj = ManagementServerManagement.new(@config)
|
37
|
+
obj.import_management_server_updates(files)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|