xclarity_client 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/docs/apib/event.apib +11 -0
  3. data/docs/apib/update_repo.apib +56 -0
  4. data/lib/xclarity_client/configuration.rb +43 -19
  5. data/lib/xclarity_client/connection/connection.rb +45 -37
  6. data/lib/xclarity_client/endpoints/buildable_resource_mixin.rb +6 -1
  7. data/lib/xclarity_client/endpoints/globalsettings.rb +0 -5
  8. data/lib/xclarity_client/endpoints/hostplatform.rb +0 -4
  9. data/lib/xclarity_client/endpoints/osimage.rb +0 -4
  10. data/lib/xclarity_client/endpoints/remotefileserver.rb +0 -4
  11. data/lib/xclarity_client/mixins/event_mixin.rb +6 -0
  12. data/lib/xclarity_client/mixins/global_setting_mixin.rb +1 -1
  13. data/lib/xclarity_client/mixins/host_platform_mixin.rb +1 -1
  14. data/lib/xclarity_client/mixins/os_image_mixin.rb +1 -1
  15. data/lib/xclarity_client/mixins/remote_file_server_mixin.rb +1 -1
  16. data/lib/xclarity_client/mixins/update_repo_mixin.rb +23 -0
  17. data/lib/xclarity_client/schemas.rb +183 -194
  18. data/lib/xclarity_client/services/compliance_policy_management.rb +4 -6
  19. data/lib/xclarity_client/services/globalsettings_management.rb +8 -15
  20. data/lib/xclarity_client/services/hostplatform_management.rb +9 -18
  21. data/lib/xclarity_client/services/osimage_management.rb +12 -24
  22. data/lib/xclarity_client/services/remotefileserver_management.rb +13 -25
  23. data/lib/xclarity_client/services/update_repo_management.rb +58 -0
  24. data/lib/xclarity_client/services/xclarity_service.rb +27 -32
  25. data/lib/xclarity_client/version.rb +1 -1
  26. data/xclarity_client.gemspec +1 -0
  27. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46c74492a0ba842bb4252ace8c8a29eb6ff3eb0b
4
- data.tar.gz: adaddc2302e33b60d7b4246fc0ffb19b2aeb1912
3
+ metadata.gz: 925a13b7e8f9b9f52254d8bc8e223f66575d906f
4
+ data.tar.gz: 49143f5132f618303c665035b8e07e1f48bd627a
5
5
  SHA512:
6
- metadata.gz: db19eeba154a7afa8b8d33491ce33792fa461e54d2b714c40ded82e7e48eeef9d4e5c3ecbd8e918e427da6839c09abf40fae2e03fe842d7a0d6ba5fc1d88fbc4
7
- data.tar.gz: 8475d380d21a2bfd08fb0f5c57cfb81d3248e096e7e72071c8da6d781b6502b3b8b39f5a03ae78e79f2c0fa167540a95ed82b9f5e49096d93820dd9a694a0db0
6
+ metadata.gz: ea345864b94e0a2abac7a61c9074c2fc8cfc7cad540b51bf711d3523813108232e7ca014c160c710067e9f8a2cd9f18f1c40b0fb06ae830b53c8b46a0ed3b454
7
+ data.tar.gz: ed2ac8bcef67945b1dcb403b8eeab2dc8712366768950c06449fe13acb5a71621ecfe26d02b7b9a402109e0e141b302fb8a55b2afed309af02a3ec49998fa0a8
data/docs/apib/event.apib CHANGED
@@ -4,8 +4,19 @@ FORMAT: 1A
4
4
 
5
5
  # GET /events
6
6
 
7
+ + Request (application/json)
8
+
9
+ + Response 200 (application/json)
10
+ [ { "eventDate": "2016-12-21T17:13:58Z", "systemTypeText": "Management", "chassisText": "Not Available", "timeStamp": "2016-12-21T17:13:58Z", "location": "", "args": [ "EAAC33576492E511B46A70E28412CA06" ], "originatorUUID": "", "systemName": "Management Server", "bayText": "Not Available", "mtm": "", "userid": "", "fruSerialNumberText": "Not Available", "eventSourceText": "Management", "senderUUID": "", "serialnum": "", "sourceLogID": "", "action": 100, "parameters": {}, "localLogSequence": "", "localLogID": "", "sourceID": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "systemTypeModelText": "Not Available", "commonEventID": "FQXHMTS0012X", "flags": "", "userIDIndex": 0, "failSNs": "", "severityText": "Warning", "severity": 300, "serviceabilityText": "User", "failFRUs": "", "msg": "Endpoint EAAC33576492E511B46A70E28412CA06 could not be accessed because credentials were refused.", "componentID": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "eventClass": 800, "eventID": "FQXHMTS0009G", "sourceLogSequence": 0, "systemSerialNumberText": "Not Available", "cn": "242679", "service": 300, "typeText": "System", "msgID": "", "systemFruNumberText": "Not Available", "systemText": "Management Server" }, { "eventDate": "2016-12-21T17:13:58Z", "systemTypeText": "Management", "chassisText": "Not Available", "timeStamp": "2016-12-21T17:13:58Z", "location": "", "args": [ "EAAC33576492E511B46A70E28412CA06", "03.76.208", "TB5TS381" ], "originatorUUID": "", "systemName": "Management Server", "bayText": "Not Available", "mtm": "", "userid": "", "fruSerialNumberText": "Not Available", "eventSourceText": "Management", "senderUUID": "", "serialnum": "", "sourceLogID": "", "action": 100, "parameters": {}, "localLogSequence": "", "localLogID": "", "sourceID": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "systemTypeModelText": "Not Available", "commonEventID": "FQXHMTS0012X", "flags": "", "userIDIndex": 0, "failSNs": "", "severityText": "Warning", "severity": 300, "serviceabilityText": "User", "failFRUs": "", "msg": "Inventory data could not be retrieved from the endpoint EAAC33576492E511B46A70E28412CA06. BIOS: 03.76.208, BMC: TB5TS381", "componentID": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "eventClass": 800, "eventID": "FQXHMTS0003G", "sourceLogSequence": 0, "systemSerialNumberText": "Not Available", "cn": "242678", "service": 300, "typeText": "System", "msgID": "", "systemFruNumberText": "Not Available", "systemText": "Management Server" }, { "eventDate": "2016-12-21T17:13:58Z", "systemTypeText": "Management", "chassisText": "Not Available", "timeStamp": "2016-12-21T17:13:58Z", "location": "", "args": [ "EAAC33576492E511B46A70E28412CA06" ], "originatorUUID": "", "systemName": "Management Server", "bayText": "Not Available", "mtm": "", "userid": "", "fruSerialNumberText": "Not Available", "eventSourceText": "Management", "senderUUID": "", "serialnum": "", "sourceLogID": "", "action": 100, "parameters": {}, "localLogSequence": "", "localLogID": "", "sourceID": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "systemTypeModelText": "Not Available", "commonEventID": "FQXHMTS0012X", "flags": "", "userIDIndex": 0, "failSNs": "", "severityText": "Warning", "severity": 300, "serviceabilityText": "User", "failFRUs": "", "msg": "Endpoint EAAC33576492E511B46A70E28412CA06 could not be accessed because credentials were refused.", "componentID": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "eventClass": 800, "eventID": "FQXHMTS0009G", "sourceLogSequence": 0, "systemSerialNumberText": "Not Available", "cn": "242677", "service": 300, "typeText": "System", "msgID": "", "systemFruNumberText": "Not Available", "systemText": "Management Server" } ]
11
+
12
+ + Request (application/json)
13
+ + Header
14
+ Range: "0-1"
15
+
7
16
  + Response 200 (application/json)
8
17
  [ { "eventDate": "2016-12-21T17:13:58Z", "systemTypeText": "Management", "chassisText": "Not Available", "timeStamp": "2016-12-21T17:13:58Z", "location": "", "args": [ "EAAC33576492E511B46A70E28412CA06" ], "originatorUUID": "", "systemName": "Management Server", "bayText": "Not Available", "mtm": "", "userid": "", "fruSerialNumberText": "Not Available", "eventSourceText": "Management", "senderUUID": "", "serialnum": "", "sourceLogID": "", "action": 100, "parameters": {}, "localLogSequence": "", "localLogID": "", "sourceID": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "systemTypeModelText": "Not Available", "commonEventID": "FQXHMTS0012X", "flags": "", "userIDIndex": 0, "failSNs": "", "severityText": "Warning", "severity": 300, "serviceabilityText": "User", "failFRUs": "", "msg": "Endpoint EAAC33576492E511B46A70E28412CA06 could not be accessed because credentials were refused.", "componentID": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "eventClass": 800, "eventID": "FQXHMTS0009G", "sourceLogSequence": 0, "systemSerialNumberText": "Not Available", "cn": "242679", "service": 300, "typeText": "System", "msgID": "", "systemFruNumberText": "Not Available", "systemText": "Management Server" }, { "eventDate": "2016-12-21T17:13:58Z", "systemTypeText": "Management", "chassisText": "Not Available", "timeStamp": "2016-12-21T17:13:58Z", "location": "", "args": [ "EAAC33576492E511B46A70E28412CA06", "03.76.208", "TB5TS381" ], "originatorUUID": "", "systemName": "Management Server", "bayText": "Not Available", "mtm": "", "userid": "", "fruSerialNumberText": "Not Available", "eventSourceText": "Management", "senderUUID": "", "serialnum": "", "sourceLogID": "", "action": 100, "parameters": {}, "localLogSequence": "", "localLogID": "", "sourceID": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "systemTypeModelText": "Not Available", "commonEventID": "FQXHMTS0012X", "flags": "", "userIDIndex": 0, "failSNs": "", "severityText": "Warning", "severity": 300, "serviceabilityText": "User", "failFRUs": "", "msg": "Inventory data could not be retrieved from the endpoint EAAC33576492E511B46A70E28412CA06. BIOS: 03.76.208, BMC: TB5TS381", "componentID": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "eventClass": 800, "eventID": "FQXHMTS0003G", "sourceLogSequence": 0, "systemSerialNumberText": "Not Available", "cn": "242678", "service": 300, "typeText": "System", "msgID": "", "systemFruNumberText": "Not Available", "systemText": "Management Server" }, { "eventDate": "2016-12-21T17:13:58Z", "systemTypeText": "Management", "chassisText": "Not Available", "timeStamp": "2016-12-21T17:13:58Z", "location": "", "args": [ "EAAC33576492E511B46A70E28412CA06" ], "originatorUUID": "", "systemName": "Management Server", "bayText": "Not Available", "mtm": "", "userid": "", "fruSerialNumberText": "Not Available", "eventSourceText": "Management", "senderUUID": "", "serialnum": "", "sourceLogID": "", "action": 100, "parameters": {}, "localLogSequence": "", "localLogID": "", "sourceID": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "systemTypeModelText": "Not Available", "commonEventID": "FQXHMTS0012X", "flags": "", "userIDIndex": 0, "failSNs": "", "severityText": "Warning", "severity": 300, "serviceabilityText": "User", "failFRUs": "", "msg": "Endpoint EAAC33576492E511B46A70E28412CA06 could not be accessed because credentials were refused.", "componentID": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "eventClass": 800, "eventID": "FQXHMTS0009G", "sourceLogSequence": 0, "systemSerialNumberText": "Not Available", "cn": "242677", "service": 300, "typeText": "System", "msgID": "", "systemFruNumberText": "Not Available", "systemText": "Management Server" } ]
18
+ + Header
19
+ Content-Range: "0-1/9999"
9
20
 
10
21
  + Response 400
11
22
  + Response 401
@@ -1548,3 +1548,59 @@ FORMAT: 1A
1548
1548
  + Response 409
1549
1549
  + Response 500
1550
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
@@ -1,43 +1,67 @@
1
1
  module XClarityClient
2
2
  class Configuration
3
3
 
4
- attr_accessor :username, :password, :host, :auth_type, :port, :verify_ssl, :user_agent_label
4
+ attr_accessor :username, :password, :host, :auth_type, :port, :verify_ssl,
5
+ :user_agent_label, :timeout
5
6
 
6
- def initialize(args)
7
+ HEADER_MESSAGE = 'XClarityClient::Configuration initialize'.freeze
7
8
 
9
+ def initialize(args)
8
10
  args.each { |key, value| send("#{key}=", value) }
11
+ validate_required_params
12
+ validate_auth_type
13
+ validate_port
14
+ validate_timeout
9
15
 
10
- if [username, password, host, port, verify_ssl].any? { |item| item.nil? }
11
- $lxca_log.error "XClarityClient::Configuration initialize","username, password, host, port and verify_ssl must all be specified"
12
- raise ArgumentError, "username, password, host, port and verify_ssl must all be specified"
13
- end
16
+ $lxca_log.info(HEADER_MESSAGE, 'Configuration built successfully')
17
+ end
14
18
 
15
- if ( not is_valid_port(port) ) or host == ""
16
- $lxca_log.error "XClarityClient::Configuration initialize","port number and host must be valid"
17
- raise ArgumentError, "port number and host must be valid"
18
- end
19
+ def validate_port
20
+ msg = 'The port number and host must be valid'
21
+ raise_exception(msg) unless valid_port?(port) || !host.empty?
22
+ end
19
23
 
20
- if not @auth_type.is_a?(String) or @auth_type == ''
21
- @auth_type = 'basic_auth'
22
- end
24
+ def validate_timeout
25
+ msg = 'the timeout must be in seconds and an Integer'
26
+ raise_exception(msg) unless timeout.kind_of?(Integer) || timeout.nil?
27
+ end
23
28
 
24
- $lxca_log.info "XClarityClient::Configuration initialize","Configuration built successfuly"
29
+ def validate_required_params
30
+ required_params = [username, password, host, port, verify_ssl]
31
+ msg = 'The follow params: username, password, host, port and ' \
32
+ 'verify_ssl must all be specified'
33
+ raise_exception(msg) if required_params.any?(&:nil?)
34
+ end
25
35
 
36
+ def validate_auth_type
37
+ msg = 'The auth_type must be a String'
38
+ raise_exception(msg) unless auth_type.kind_of?(String)
39
+ self.auth_type = 'basic_auth' if auth_type.strip.empty?
26
40
  end
27
41
 
28
42
  def self.default
29
- new({
43
+ data = {
30
44
  :username => ENV['LXCA_USERNAME'],
31
45
  :password => ENV['LXCA_PASSWORD'],
32
46
  :host => ENV['LXCA_HOST'],
33
47
  :port => ENV['LXCA_PORT'],
34
- :verify_ssl => ENV['LXCA_VERIFY_SSL'] != "NONE"
35
- })
48
+ :verify_ssl => ENV['LXCA_VERIFY_SSL'] != 'NONE'
49
+ }
50
+ new(data)
36
51
  end
37
52
 
38
- def is_valid_port(param)
53
+ private
54
+
55
+ def valid_port?(param)
39
56
  param = param.to_s
40
- /^([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$/.match(param) != nil
57
+ expression = '^([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}' \
58
+ '|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$'
59
+ !/#{expression}/.match(param).nil?
60
+ end
61
+
62
+ def raise_exception(message)
63
+ $lxca_log.error(HEADER_MESSAGE, message)
64
+ raise(ArgumentError, message)
41
65
  end
42
66
  end
43
67
  end
@@ -2,6 +2,7 @@ require 'faraday'
2
2
  require 'faraday-cookie_jar'
3
3
  require 'uri'
4
4
  require 'uri/https'
5
+ require 'timeout'
5
6
 
6
7
  module XClarityClient
7
8
  #
@@ -9,6 +10,7 @@ module XClarityClient
9
10
  # with the API.
10
11
  #
11
12
  class Connection
13
+ HEADER_MESSAGE = 'XClarityClient::Connection'.freeze
12
14
  #
13
15
  # @param [Hash] configuration - the data to create a connection with the LXCA
14
16
  # @option configuration [String] :host the LXCA host
@@ -18,9 +20,11 @@ module XClarityClient
18
20
  # @option configuration [String] :auth_type the type of the authentication ('token', 'basic_auth')
19
21
  # @option configuration [String] :verify_ssl ('PEER', 'NONE')
20
22
  # @option configuration [String] :user_agent_label Api gem client identification
23
+ # @option configuration [String] :timeout the limit time in seconds
21
24
  #
22
25
  def initialize(configuration)
23
26
  @connection = build(configuration)
27
+ @timeout = configuration.timeout
24
28
  end
25
29
 
26
30
  #
@@ -28,12 +32,20 @@ module XClarityClient
28
32
  #
29
33
  # @param [String] uri - endpoint to do the request
30
34
  # @param [Hash] query - params to query the endpoint resources
35
+ # @param [Hash] headers - add headers to the request
31
36
  #
32
- def do_get(uri = "", query = {})
37
+ def do_get(uri = "", query: {}, headers: {})
33
38
  url_query = query.size > 0 ? "?" + query.map {|k, v| "#{k}=#{v}"}.join("&") : ""
34
- @connection.get(uri + url_query)
35
- rescue Faraday::Error::ConnectionFailed => e
36
- $lxca_log.error "XClarityClient::XclarityBase connection", "Error trying to send a GET to #{uri + url_query}"
39
+ Timeout.timeout(@timeout) do
40
+ @connection.get do |req|
41
+ req.url(uri + url_query)
42
+ headers.map { |key, value| req.headers[key] = value }
43
+ end
44
+ end
45
+ rescue Faraday::Error::ConnectionFailed, Timeout::Error => e
46
+ msg = "Error trying to send a GET to #{uri + url_query} "\
47
+ "the reason: #{e.message}"
48
+ $lxca_log.error(HEADER_MESSAGE + ' do_get', msg)
37
49
  Faraday::Response.new
38
50
  end
39
51
 
@@ -43,16 +55,8 @@ module XClarityClient
43
55
  # @param [String] uri - endpoint to do the request
44
56
  # @param [JSON] body - json to be sent in request body
45
57
  #
46
- def do_post(uri = "", body = "")
47
- @connection.post do |req|
48
- req.url uri
49
- req.headers['Content-Type'] = 'application/json'
50
- req.body = body
51
- end
52
- rescue Faraday::Error::ConnectionFailed => e
53
- $lxca_log.error "XClarityClient::XclarityBase do_post", "Error trying to send a POST to #{uri}"
54
- $lxca_log.error "XClarityClient::XclarityBase do_post", "Request sent: #{body}"
55
- Faraday::Response.new
58
+ def do_post(uri = '', body = '')
59
+ build_request(:post, uri, body)
56
60
  end
57
61
 
58
62
  #
@@ -61,16 +65,8 @@ module XClarityClient
61
65
  # @param [String] uri - endpoint to do the request
62
66
  # @param [JSON] body - json to be sent in request body
63
67
  #
64
- def do_put(uri = "", body = "")
65
- @connection.put do |req|
66
- req.url uri
67
- req.headers['Content-Type'] = 'application/json'
68
- req.body = body
69
- end
70
- rescue Faraday::Error::ConnectionFailed => e
71
- $lxca_log.error "XClarityClient::XclarityBase do_put", "Error trying to send a PUT to #{uri}"
72
- $lxca_log.error "XClarityClient::XclarityBase do_put", "Request sent: #{body}"
73
- Faraday::Response.new
68
+ def do_put(uri = '', body = '')
69
+ build_request(:put, uri, body)
74
70
  end
75
71
 
76
72
  #
@@ -78,17 +74,30 @@ module XClarityClient
78
74
  #
79
75
  # @param [String] uri - endpoint to do the request
80
76
  #
81
- def do_delete(uri = "")
82
- @connection.delete do |req|
83
- req.url uri
84
- req.headers['Content-Type'] = 'application/json'
85
- end
77
+ def do_delete(uri = '')
78
+ build_request(:delete, uri)
86
79
  end
87
80
 
88
81
  private
89
82
 
83
+ def build_request(method, url, body = '')
84
+ @connection.send(method) do |request|
85
+ request.url(url)
86
+ request.headers['Content-Type'] = 'application/json'
87
+ request.body = body
88
+ end
89
+ rescue Faraday::Error::ConnectionFailed => e
90
+ header = HEADER_MESSAGE + " do_#{method}"
91
+ msg = "Error trying to send a #{method} to #{url} " \
92
+ "the reason: #{e.message}"
93
+ $lxca_log.error(header, msg)
94
+ $lxca_log.error(header, "Request sent: #{body}")
95
+ Faraday::Response.new
96
+ end
97
+
90
98
  def build(configuration)
91
- $lxca_log.info "XClarityClient::Connection build", "Building the connection"
99
+ header = HEADER_MESSAGE + ' build'
100
+ $lxca_log.info(header, 'Building the connection')
92
101
 
93
102
  hostname = URI.parse(configuration.host)
94
103
 
@@ -96,21 +105,20 @@ module XClarityClient
96
105
  :port => configuration.port.to_i,
97
106
  :query => hostname.query,
98
107
  :fragment => hostname.fragment }).to_s
99
-
100
- $lxca_log.info "XClarityClient::XClarityBase connection_builder", "Creating connection to #{url}"
108
+ $lxca_log.info(header, "Creating connection to #{url}")
101
109
 
102
110
  connection = Faraday.new(url: url) do |faraday|
103
- faraday.request :url_encoded # form-encode POST params
104
- faraday.response :logger, $lxca_log.log # log requests to STDOUT -- This line, should be uncommented if you wanna inspect the URL Request
105
- faraday.use :cookie_jar if configuration.auth_type == 'token'
106
- faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
111
+ faraday.request(:url_encoded) # form-encode POST params
112
+ faraday.response(:logger, $lxca_log.log) # log requests to log file
113
+ faraday.use(:cookie_jar) if configuration.auth_type == 'token'
114
+ faraday.adapter(:httpclient) # make requests with HTTPClient
107
115
  faraday.ssl[:verify] = configuration.verify_ssl == 'PEER'
108
116
  end
109
117
 
110
118
  connection.headers[:user_agent] = "LXCA via Ruby Client/#{XClarityClient::VERSION}" + (configuration.user_agent_label.nil? ? "" : " (#{configuration.user_agent_label})")
111
119
 
112
120
  connection.basic_auth(configuration.username, configuration.password) if configuration.auth_type == 'basic_auth'
113
- $lxca_log.info "XClarityClient::XclarityBase connection_builder", "Connection created Successfuly"
121
+ $lxca_log.info(header, 'Connection created Successfuly')
114
122
 
115
123
  connection
116
124
  end
@@ -40,7 +40,12 @@ module XClarityClient
40
40
  key = format_key(key)
41
41
  send("#{key}=", value)
42
42
  rescue
43
- $log.warn("UNEXISTING ATTRIBUTES FOR #{self.class}: #{key}") unless defined?(Rails).nil?
43
+ unless defined?(Rails).nil?
44
+ $lxca_log.info(
45
+ 'XClarityClient::Endpoints::BuildableResourceMixin',
46
+ "UNEXISTING ATTRIBUTES FOR #{self.class}: #{key}"
47
+ )
48
+ end
44
49
  end
45
50
 
46
51
  #
@@ -1,12 +1,7 @@
1
1
  module XClarityClient
2
2
  class GlobalSetting < Endpoints::XclarityEndpoint
3
3
  BASE_URI = '/osdeployment/globalSettings'.freeze
4
-
5
4
  attr_accessor :activeDirectory, :credentials, :ipAssignment,
6
5
  :isVLANMode, :licenseKeys
7
-
8
- def initialize(attributes)
9
- build_resource(attributes)
10
- end
11
6
  end
12
7
  end
@@ -9,9 +9,5 @@ module XClarityClient
9
9
  :name, :networkSettings, :nodeType, :primary, :rackID,
10
10
  :rackUnit, :readyCheck, :remoteControl, :storageSettings,
11
11
  :uuid
12
-
13
- def initialize(attributes)
14
- build_resource(attributes)
15
- end
16
12
  end
17
13
  end
@@ -6,9 +6,5 @@ module XClarityClient
6
6
  attr_accessor :description, :osrelease, :name, :profiles,
7
7
  :id, :type, :osBuildId, :deployStatus
8
8
 
9
- def initialize(attributes)
10
- build_resource(attributes)
11
- end
12
-
13
9
  end
14
10
  end
@@ -7,9 +7,5 @@ module XClarityClient
7
7
  :displayName, :serverId, :username,
8
8
  :keyType, :serverPublicKey
9
9
 
10
- def initialize(attributes)
11
- build_resource(attributes)
12
- end
13
-
14
10
  end
15
11
  end
@@ -10,5 +10,11 @@ module XClarityClient
10
10
  def fetch_events(opts = {})
11
11
  EventManagement.new(@config).get_object_with_opts(opts, Event)
12
12
  end
13
+
14
+ def get_last_cn(opts = {})
15
+ headers = EventManagement.new(@config).get_headers_with_opts(opts, Event)
16
+ range = headers['content-range']
17
+ range.slice(range.index('/') + 1, range.length).to_i
18
+ end
13
19
  end
14
20
  end
@@ -4,7 +4,7 @@ module XClarityClient
4
4
  #
5
5
  module Mixins::GlobalSettingMixin
6
6
  def get_globalsettings
7
- GlobalSettingManagement.new(@config).population
7
+ GlobalSettingManagement.new(@config).fetch_all
8
8
  end
9
9
 
10
10
  def set_globalsettings(opts = {})
@@ -4,7 +4,7 @@ module XClarityClient
4
4
  #
5
5
  module Mixins::HostPlatformMixin
6
6
  def get_hostplatforms
7
- HostPlatformManagement.new(@config).population
7
+ HostPlatformManagement.new(@config).fetch_all
8
8
  end
9
9
 
10
10
  def get_osimage_deployment_status(uuid = '')
@@ -8,7 +8,7 @@ module XClarityClient
8
8
  end
9
9
 
10
10
  def get_osimages
11
- OsImageManagement.new(@config).population
11
+ OsImageManagement.new(@config).fetch_all
12
12
  end
13
13
  end
14
14
  end
@@ -4,7 +4,7 @@ module XClarityClient
4
4
  #
5
5
  module Mixins::RemoteFileServerMixin
6
6
  def get_remotefileserver_profiles
7
- RemoteFileServerManagement.new(@config).population
7
+ RemoteFileServerManagement.new(@config).fetch_all
8
8
  end
9
9
 
10
10
  def create_remotefileserver_profile(opts = {})
@@ -6,5 +6,28 @@ module XClarityClient
6
6
  def discover_update_repo(opts = {})
7
7
  UpdateRepoManagement.new(@config).fetch_all(opts)
8
8
  end
9
+
10
+ def read_update_repo
11
+ UpdateRepoManagement.new(@config).read_update_repo
12
+ end
13
+
14
+ def refresh_update_repo(scope, mt, os)
15
+ UpdateRepoManagement.new(@config).refresh_update_repo(scope, mt, os)
16
+ end
17
+
18
+ def acquire_firmware_updates(scope, fixids, mt)
19
+ UpdateRepoManagement.new(@config).acquire_firmware_updates(scope,
20
+ fixids, mt)
21
+ end
22
+
23
+ def delete_firmware_updates(file_types, fixids)
24
+ UpdateRepoManagement.new(@config).delete_firmware_updates(file_types,
25
+ fixids)
26
+ end
27
+
28
+ def export_firmware_updates(file_types, fixids)
29
+ UpdateRepoManagement.new(@config).export_firmware_updates(file_types,
30
+ fixids)
31
+ end
9
32
  end
10
33
  end