xclarity_client 0.7.0 → 0.8.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf0c21b4fa01b0e4b17558a1427f7cba659a4db359c759ff1cb7a602a987293b
4
- data.tar.gz: 9fdf8103464d28c42d343488b013ce5a3294b1f758607b178031c4459c1151bb
3
+ metadata.gz: 5e827883dbabbf1114a1d83987846517654887296d94e0579206ba9da134d115
4
+ data.tar.gz: aeda36e0bd91c198b00c0c624c7412a023b8bc3588fa141762cf50ab1db0ebcd
5
5
  SHA512:
6
- metadata.gz: e608b1208b908366e1db064b8bf775edad14c7a0f1f39499c5a64c59fdbb6d87089fb024dfe0267351b0730f2e3b1b38b29d09d008cc153c5a3feb0234d4dcb3
7
- data.tar.gz: 46b3b54cce30d7c123eb905528f492a483f7e1f10a1be07b2e7160bf308c8f00557a79906f14c0c842b5b11ab578425b0c8fb61e85a838bc2649ff973fab59da
6
+ metadata.gz: 623be4a6ae9382ce763ea3e8defdbbe53e04ec1c6ec80750252a77f512b9b4a24b69c703237e23a747f4bbbb00dbb82438f6a871013cbb652233287023f28612
7
+ data.tar.gz: 7fc5643fd28d48178647c8605a3f9fd0cd3f043307445c8d55a044cd558e2bbf74d4e58e53e917ca4622407c1a5bb0a67fd63122b4467eec262cb366023b3ff5
data/.whitesource ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "settingsInheritedFrom": "ManageIQ/whitesource-config@master"
3
+ }
@@ -13,7 +13,7 @@ module XClarityClient
13
13
  validate_port
14
14
  validate_timeout
15
15
 
16
- $lxca_log.info(HEADER_MESSAGE, 'Configuration built successfully')
16
+ XClarityClient.logger.info("[#{HEADER_MESSAGE}] - Configuration built successfully")
17
17
  end
18
18
 
19
19
  def validate_port
@@ -60,7 +60,7 @@ module XClarityClient
60
60
  end
61
61
 
62
62
  def raise_exception(message)
63
- $lxca_log.error(HEADER_MESSAGE, message)
63
+ XClarityClient.logger.error("[#{HEADER_MESSAGE}] - #{message}")
64
64
  raise(ArgumentError, message)
65
65
  end
66
66
  end
@@ -47,10 +47,10 @@ module XClarityClient
47
47
  headers.map { |key, value| req.headers[key] = value }
48
48
  end
49
49
  end
50
- rescue Faraday::Error::ConnectionFailed, Timeout::Error => e
50
+ rescue Faraday::ConnectionFailed, Timeout::Error => e
51
51
  msg = "Error trying to send a GET to #{uri + url_query} "\
52
52
  "the reason: #{e.message}"
53
- $lxca_log.error(HEADER_MESSAGE + ' do_get', msg)
53
+ XClarityClient.logger.error("[#{HEADER_MESSAGE} do_get] - #{msg}")
54
54
  Faraday::Response.new
55
55
  end
56
56
 
@@ -111,12 +111,12 @@ module XClarityClient
111
111
  request.headers['Content-Type'] = 'application/json' unless multipart
112
112
  request.body = body
113
113
  end
114
- rescue Faraday::Error::ConnectionFailed => e
114
+ rescue Faraday::ConnectionFailed => e
115
115
  header = HEADER_MESSAGE + " do_#{method}"
116
116
  msg = "Error trying to send a #{method} to #{url} " \
117
117
  "the reason: #{e.message}"
118
- $lxca_log.error(header, msg)
119
- $lxca_log.error(header, "Request sent: #{body}")
118
+ XClarityClient.logger.error("[#{header}] - #{msg}")
119
+ XClarityClient.logger.error("[#{header}] - Request sent: #{body}")
120
120
  Faraday::Response.new
121
121
  end
122
122
 
@@ -129,7 +129,7 @@ module XClarityClient
129
129
  username = configuration.username
130
130
  password = configuration.password
131
131
  connection.request(:authorization, :basic, username, password) if basic_auth
132
- $lxca_log.info(header, 'Connection created Successfuly')
132
+ XClarityClient.logger.info("[#{header}] - Connection created Successfuly")
133
133
  connection
134
134
  end
135
135
 
@@ -137,7 +137,7 @@ module XClarityClient
137
137
  Faraday.new(url: url) do |faraday|
138
138
  faraday.request(:multipart) if multipart # multipart form data
139
139
  faraday.request(:url_encoded) # form-encode POST params
140
- faraday.response(:logger, $lxca_log.log) # log requests to log file
140
+ faraday.response(:logger, XClarityClient.logger) # log requests to log file
141
141
  faraday.use(:cookie_jar) if configuration.auth_type == 'token'
142
142
  faraday.adapter(:httpclient) unless n_http || multipart
143
143
  faraday.adapter(:net_http) if n_http || multipart # with net_http
@@ -152,14 +152,14 @@ module XClarityClient
152
152
 
153
153
  def build(configuration, multipart = false, n_http = false)
154
154
  header = HEADER_MESSAGE + ' build'
155
- $lxca_log.info(header, 'Building the connection')
155
+ XClarityClient.logger.info("[#{header}] - Building the connection")
156
156
  hostname = URI.parse(configuration.host)
157
157
  host = hostname.scheme ? hostname.host : hostname.path
158
158
  url = URI::HTTPS.build(:host => host,
159
159
  :port => configuration.port.to_i,
160
160
  :query => hostname.query,
161
161
  :fragment => hostname.fragment).to_s
162
- $lxca_log.info(header, "Creating connection to #{url}")
162
+ XClarityClient.logger.info("[#{header}] - Creating connection to #{url}")
163
163
  build_connection(url, configuration, multipart, n_http)
164
164
  end
165
165
  end
@@ -6,7 +6,7 @@ module XClarityClient
6
6
  def self.responds?(ipAddress, port)
7
7
  conf = Faraday.new(url: build_uri(ipAddress, port).to_s) do |faraday|
8
8
  faraday.request :url_encoded # form-encode POST params
9
- faraday.response :logger, $lxca_log.log # log requests to STDOUT -- This line, should be uncommented if you wanna inspect the URL Request
9
+ faraday.response :logger, XClarityClient.logger
10
10
  faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
11
11
  faraday.ssl[:verify] = false
12
12
  end
@@ -31,4 +31,4 @@ module XClarityClient
31
31
  URI("https://" + ipAddress+ ":" + port)
32
32
  end
33
33
  end
34
- end
34
+ end
@@ -41,9 +41,8 @@ module XClarityClient
41
41
  send("#{key}=", value)
42
42
  rescue
43
43
  unless defined?(Rails).nil?
44
- $lxca_log.info(
45
- 'XClarityClient::Endpoints::BuildableResourceMixin',
46
- "UNEXISTING ATTRIBUTES FOR #{self.class}: #{key}"
44
+ XClarityClient.logger.info(
45
+ "[XClarityClient::Endpoints::BuildableResourceMixin] - UNEXISTING ATTRIBUTES FOR #{self.class}: #{key}"
47
46
  )
48
47
  end
49
48
  end
@@ -0,0 +1,11 @@
1
+ require 'logger'
2
+
3
+ module XClarityClient
4
+ class << self
5
+ attr_writer :logger
6
+
7
+ def logger
8
+ @logger ||= ::Logger.new(IO::NULL)
9
+ end
10
+ end
11
+ end
@@ -171,10 +171,10 @@ module XClarityClient
171
171
  x = JSON::Validator.fully_validate(self::REQ_SCHEMA[schema_name], data)
172
172
  unless x.empty?
173
173
  errmsg = "input validation failed for data #{data}"
174
- $lxca_log.error('XClarityClient::Schemas validate_input', errmsg.to_s)
174
+ XClarityClient.logger.error("[XClarityClient::Schemas validate_input] - #{errmsg}")
175
175
  g = ''
176
176
  x.each do |k|
177
- $lxca_log.error('XClarityClient::Schemas validate_input', k)
177
+ XClarityClient.logger.error("[XClarityClient::Schemas validate_input] - #{k}")
178
178
  g << "#{k}, "
179
179
  end; return { :result => 'Input validation failed', :message => g }
180
180
  end; return { :result => 'success' }
@@ -39,7 +39,7 @@ module XClarityClient
39
39
  base_url = ManagementServer::BASE_URI
40
40
  url = key.nil? ? base_url : "#{base_url}?key=#{key}"
41
41
  msg = "input key=#{key}"
42
- $lxca_log.info(self.class.to_s + ' ' + __method__.to_s, msg)
42
+ XClarityClient.logger.info("[#{self.class} #{__method__}] - #{msg}")
43
43
  @connection.do_get(url)
44
44
  end
45
45
 
@@ -59,7 +59,7 @@ module XClarityClient
59
59
  request_body = JSON.generate(:files => payload_files)
60
60
  response = @connection.do_post(url, request_body)
61
61
  jobid = JSON.parse(response.body)['jobid']
62
- $lxca_log.info(self.class.to_s + ' ' + __method__.to_s, "jobid: #{jobid}")
62
+ XClarityClient.logger.info("[#{self.class} #{__method__}] - jobid: #{jobid}")
63
63
  start_management_server_updates_import_job(file_type_dict, files, jobid)
64
64
  end
65
65
 
@@ -22,7 +22,7 @@ module XClarityClient
22
22
  unless valid_arguments?(uuid, state, managed_resource::POWER_ACTIONS)
23
23
  error = 'Invalid target or power state requested'
24
24
  source = "#{self.class.name} set_power_state"
25
- $lxca_log.info(source, error)
25
+ XClarityClient.logger.info("[#{source}] - #{error}")
26
26
  raise ArgumentError, error
27
27
  end
28
28
 
@@ -45,7 +45,7 @@ module XClarityClient
45
45
  unless valid_arguments?(uuid, state, managed_resource::LED_STATES)
46
46
  error = 'Invalid target or power state requested'
47
47
  source = "#{self.class.name} set_loc_led_state"
48
- $lxca_log.info(source, error)
48
+ XClarityClient.logger.info("[#{source}] - #{error}")
49
49
  raise ArgumentError, error
50
50
  end
51
51
 
@@ -68,7 +68,7 @@ module XClarityClient
68
68
  response = @connection.do_put(uri, power_request)
69
69
  msg = "Power state action has been sent with request #{power_request}"
70
70
 
71
- $lxca_log.info("#{self.class.name} send_power_request", msg)
71
+ XClarityClient.logger.info("[#{self.class.name} send_power_request] - #{msg}")
72
72
  response
73
73
  end
74
74
 
@@ -93,7 +93,7 @@ module XClarityClient
93
93
  response = @connection.do_put(uri, request)
94
94
  msg = "LED state request has been sent with request #{request}"
95
95
 
96
- $lxca_log.info("#{self.class.name} send_led_state_request", msg)
96
+ XClarityClient.logger.info("[#{self.class.name} send_led_state_request] - #{msg}")
97
97
  response
98
98
  end
99
99
 
@@ -14,7 +14,7 @@ module XClarityClient
14
14
  if [uuid, requested_state].any? { |item| item.nil? }
15
15
  error = 'Invalid target or power state requested'
16
16
  source = 'XClarity::NodeManagement set_bmc_power_state'
17
- $lxca_log.info source, error
17
+ XClarityClient.logger.info("[#{source}] - #{error}")
18
18
  raise ArgumentError, error
19
19
  end
20
20
 
@@ -7,7 +7,7 @@ module XClarityClient
7
7
 
8
8
  def import_osimage(server_id, path)
9
9
  msg="inputs serverId=#{server_id},path=#{path}"
10
- $lxca_log.info self.class.to_s+" "+__method__.to_s, msg
10
+ XClarityClient.logger.info("[#{self.class} #{__method__}] - #{msg}")
11
11
  opts = { :Action => "Init" }
12
12
  request_body = JSON.generate(opts)
13
13
  response = @connection.do_post("#{OsImage::BASE_URI}?imageType=OS",
@@ -14,7 +14,7 @@ module XClarityClient
14
14
  )
15
15
 
16
16
  unless con.success?
17
- $lxca_log.error "XClarityClient::RemoteAccessManagement remote_control", "Request failed"
17
+ XClarityClient.logger.error("[XClarityClient::RemoteAccessManagement remote_control] - Request failed")
18
18
  raise 'Request failed'
19
19
  end
20
20
 
@@ -33,9 +33,8 @@ module XClarityClient
33
33
  when /application\/x-java-jnlp-file/
34
34
  build_jnlp_remote_access_object(connection.body)
35
35
  else
36
- $lxca_log.error(
37
- "XClarityClient::RemoteAccessManagement build_remote_access_object",
38
- "Unexpected server response. Expected Content-Type header to be one of these: #{SUPPORTED_MIME_TYPES}."
36
+ XClarityClient.logger.error(
37
+ "[XClarityClient::RemoteAccessManagement build_remote_access_object] - Unexpected server response. Expected Content-Type header to be one of these: #{SUPPORTED_MIME_TYPES}."
39
38
  )
40
39
  raise 'Unexpected Content-Type header'
41
40
  end
@@ -22,7 +22,7 @@ module XClarityClient
22
22
 
23
23
  def ip_enablement_state
24
24
  uri = BASE_URI+NETWORK_URI+IPDISABLE_URI
25
- $lxca_log.info "XclarityClient::VirtualApplianceManagement ip_enablement_state", "Action has been sent to #{uri}"
25
+ XClarityClient.logger.info("[XclarityClient::VirtualApplianceManagement ip_enablement_state] - Action has been sent to #{uri}")
26
26
 
27
27
  @connection.do_get(uri)
28
28
  end
@@ -33,7 +33,7 @@ module XClarityClient
33
33
 
34
34
  def host_settings
35
35
  uri = BASE_URI+NETWORK_URI+IPDISABLE_URI
36
- $lxca_log.info "XclarityClient::VirtualApplianceManagement host_settings", "Action has been sent to #{uri}"
36
+ XClarityClient.logger.info("[XclarityClient::VirtualApplianceManagement host_settings] - Action has been sent to #{uri}")
37
37
 
38
38
  @connection.do_get(uri)
39
39
  end
@@ -44,7 +44,7 @@ module XClarityClient
44
44
 
45
45
  def network_interface_settings(interface)
46
46
  uri = BASE_URI+NETWORK_URI+INTERFACES_URI+"/#{interface}"
47
- $lxca_log.info "XclarityClient::VirtualApplianceManagement network_interface_settings", "Action has been sent to #{uri}"
47
+ XClarityClient.logger.info("[XclarityClient::VirtualApplianceManagement network_interface_settings] - Action has been sent to #{uri}")
48
48
 
49
49
  @connection.do_get(uri)
50
50
  end
@@ -55,7 +55,7 @@ module XClarityClient
55
55
 
56
56
  def route_settings
57
57
  uri = BASE_URI+NETWORK_URI+ROUTES_URI
58
- $lxca_log.info "XclarityClient::VirtualApplianceManagement route_settings", "Action has been sent to #{uri}"
58
+ XClarityClient.logger.info("[XclarityClient::VirtualApplianceManagement route_settings] - Action has been sent to #{uri}")
59
59
 
60
60
  @connection.do_get(uri)
61
61
  end
@@ -66,7 +66,7 @@ module XClarityClient
66
66
 
67
67
  def subscriptions
68
68
  uri = BASE_URI+SUBSCRIPTIONS_URI
69
- $lxca_log.info "XclarityClient::VirtualApplianceManagement subscriptions", "Action has been sent to #{uri}"
69
+ XClarityClient.logger.info("[XclarityClient::VirtualApplianceManagement subscriptions] - Action has been sent to #{uri}")
70
70
 
71
71
  @connection.do_get(uri)
72
72
  end
@@ -1,11 +1,11 @@
1
1
  module XClarityClient
2
2
  module ManagementMixin
3
3
  def get_all_resources (resource, opts = {})
4
- $lxca_log.info "XclarityClient::ManagementMixin get_all_resources", "Sending request to #{resource} resource"
4
+ XClarityClient.logger.info("[XclarityClient::ManagementMixin get_all_resources] - Sending request to #{resource} resource")
5
5
 
6
6
  response = connection(resource::BASE_URI, opts)
7
7
 
8
- $lxca_log.info "XclarityClient::ManagementMixin get_all_resources", "Response received from #{resource::BASE_URI}"
8
+ XClarityClient.logger.info("[XclarityClient::ManagementMixin get_all_resources] - Response received from #{resource::BASE_URI}")
9
9
 
10
10
  return [] unless response.success?
11
11
 
@@ -23,7 +23,7 @@ module XClarityClient
23
23
 
24
24
  def get_object(uuids, includeAttributes, excludeAttributes, resource)
25
25
 
26
- $lxca_log.info "XclarityClient::ManagementMixin get_object", "Sending request to #{resource} resource"
26
+ XClarityClient.logger.info("[XclarityClient::ManagementMixin get_object] - Sending request to #{resource} resource")
27
27
 
28
28
  uuids.reject! { |uuid| UUID.validate(uuid).nil? } unless uuids.nil?
29
29
 
@@ -49,7 +49,7 @@ module XClarityClient
49
49
 
50
50
  def get_object_with_include_attributes(uuids, attributes, resource)
51
51
 
52
- $lxca_log.info "XclarityClient::ManagementMixin get_object_with_include", "Sending request to #{resource} resource including the following attributes: #{attributes.join(",")}"
52
+ XClarityClient.logger.info("[XclarityClient::ManagementMixin get_object_with_include] - Sending request to #{resource} resource including the following attributes: #{attributes.join(",")}")
53
53
 
54
54
  uuids.reject! { |uuid| UUID.validate(uuid).nil? } unless uuids.nil?
55
55
 
@@ -63,7 +63,7 @@ module XClarityClient
63
63
 
64
64
  def get_object_with_exclude_attributes(uuids, attributes, resource)
65
65
 
66
- $lxca_log.info "XclarityClient::ManagementMixin get_object_with_include", "Sending request to #{resource} resource excluding the following attributes: #{attributes.join(",")}"
66
+ XClarityClient.logger.info("[XclarityClient::ManagementMixin get_object_with_include] - Sending request to #{resource} resource excluding the following attributes: #{attributes.join(",")}")
67
67
 
68
68
  uuids.reject! { |uuid| UUID.validate(uuid).nil? } unless uuids.nil?
69
69
 
@@ -134,8 +134,8 @@ module XClarityClient
134
134
  else
135
135
  filter += "?type=#{opts["type"]}"
136
136
  end
137
- $lxca_log.info "XclarityClient::ManagementMixin get_object_with_include", "Sending request to #{resource} resource using the following filter: #{filter}"
138
- connection(resource::BASE_URI + filter)
137
+ XClarityClient.logger.info("[XclarityClient::ManagementMixin get_object_with_include] - Sending request to #{resource} resource using the following filter: #{filter}")
138
+ connection(resource::BASE_URI + filter)
139
139
  end
140
140
 
141
141
  return [] unless response.success?
@@ -21,20 +21,17 @@ module XClarityClient
21
21
  def fetch_all(opts = {}, uri = {})
22
22
  uri = managed_resource::BASE_URI if uri.empty? || uri.nil?
23
23
 
24
- $lxca_log.info "XclarityClient::Endpoints::XClarityService fetch_all",
25
- "Sending request to #{managed_resource} resource"
24
+ XClarityClient.logger.info("[XclarityClient::Endpoints::XClarityService fetch_all] - Sending request to #{managed_resource} resource")
26
25
 
27
26
  response = @connection.do_get(uri, :query => opts)
28
27
 
29
- $lxca_log.info("XclarityClient::Endpoints::XClarityService fetch_all",
30
- "Response received from #{uri}")
28
+ XClarityClient.logger.info("[XclarityClient::Endpoints::XClarityService fetch_all] - Response received from #{uri}")
31
29
 
32
30
  build_response_with_resource_list(response, managed_resource)
33
31
  end
34
32
 
35
33
  def get_object(uuids, includeAttributes, excludeAttributes)
36
- $lxca_log.info "XclarityClient::Endpoints::XClarityService get_object",
37
- "Sending request to #{managed_resource} resource"
34
+ XClarityClient.logger.info("[XclarityClient::Endpoints::XClarityService get_object] - Sending request to #{managed_resource} resource")
38
35
 
39
36
  uuid_array = uuids&.reject { |uuid| uuid.nil? || uuid.empty? }
40
37
 
@@ -92,8 +89,7 @@ module XClarityClient
92
89
  end
93
90
 
94
91
  def get_object_with_include_attributes(uuids, attributes)
95
- $lxca_log.info "XclarityClient::ManagementMixin get_object_with_include",
96
- "Sending request to #{managed_resource} resource including the following attributes: #{attributes.join(",")}"
92
+ XClarityClient.logger.info("[XclarityClient::ManagementMixin get_object_with_include] - Sending request to #{managed_resource} resource including the following attributes: #{attributes.join(",")}")
97
93
 
98
94
  response = if not uuids.nil?
99
95
  @connection.do_get(managed_resource::BASE_URI + "/" + uuids.join(",") + "?includeAttributes=" + attributes.join(","))
@@ -104,8 +100,7 @@ module XClarityClient
104
100
  end
105
101
 
106
102
  def get_object_with_exclude_attributes(uuids, attributes)
107
- $lxca_log.info "XclarityClient::ManagementMixin get_object_with_include",
108
- "Sending request to #{managed_resource} resource excluding the following attributes: #{attributes.join(",")}"
103
+ XClarityClient.logger.info("[XclarityClient::ManagementMixin get_object_with_include] - Sending request to #{managed_resource} resource excluding the following attributes: #{attributes.join(",")}")
109
104
 
110
105
  response = if not uuids.nil?
111
106
  @connection.do_get(managed_resource::BASE_URI + "/#{uuids.join(",")}"+"?excludeAttributes=#{attributes.join(",")}")
@@ -1,3 +1,3 @@
1
1
  module XClarityClient
2
- VERSION = '0.7.0'.freeze
2
+ VERSION = '0.8.0'.freeze
3
3
  end
@@ -10,11 +10,11 @@ module XClarityClient
10
10
  end
11
11
 
12
12
  def validate
13
- $lxca_log.info 'XClarityClient::XClarityValidate validate', 'Creating session ...'
13
+ XClarityClient.logger.info('[XClarityClient::XClarityValidate validate] - Creating session ...')
14
14
  build_session(@configuration)
15
15
 
16
16
  id_session = JSON.parse(@response.body)['messages'].first['id']
17
- $lxca_log.info 'XClarityClient::XClarityValidate validate', 'Session created ...'
17
+ XClarityClient.logger.info('[XClarityClient::XClarityValidate validate] - Session created ...')
18
18
 
19
19
  close_session(id_session)
20
20
  rescue => err
@@ -38,7 +38,7 @@ module XClarityClient
38
38
  :password => conf.password
39
39
  }.to_json)
40
40
 
41
- raise Faraday::Error::ConnectionFailed unless @response.success?
41
+ raise Faraday::ConnectionFailed unless @response.success?
42
42
  end
43
43
 
44
44
  def close_session(id_session)
@@ -1,12 +1,6 @@
1
1
  require 'xclarity_client/version'
2
- require 'utils/logger'
3
-
4
- module XClarityClient
5
- $lxca_log = XClarityClient::XClarityLogger.new
6
- end
7
-
2
+ require 'xclarity_client/logging'
8
3
  require 'xclarity_client/errors/errors'
9
-
10
4
  require 'xclarity_client/configuration'
11
5
  require 'xclarity_client/xclarity_credentials_validator'
12
6
  require 'xclarity_client/discover'
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.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manasa Rao
@@ -205,6 +205,7 @@ files:
205
205
  - ".rubocop_base.yml"
206
206
  - ".rubocop_cc.yml"
207
207
  - ".travis.yml"
208
+ - ".whitesource"
208
209
  - CODE_OF_CONDUCT.md
209
210
  - Gemfile
210
211
  - LICENSE
@@ -244,7 +245,6 @@ files:
244
245
  - docs/apib/update_repo.apib
245
246
  - docs/apib/users.apib
246
247
  - example/simple.rb
247
- - lib/utils/logger.rb
248
248
  - lib/xclarity_client.rb
249
249
  - lib/xclarity_client/client.rb
250
250
  - lib/xclarity_client/configuration.rb
@@ -292,6 +292,7 @@ files:
292
292
  - lib/xclarity_client/errors/connection_refused.rb
293
293
  - lib/xclarity_client/errors/errors.rb
294
294
  - lib/xclarity_client/errors/hostname_unknown.rb
295
+ - lib/xclarity_client/logging.rb
295
296
  - lib/xclarity_client/mixins/aicc_mixin.rb
296
297
  - lib/xclarity_client/mixins/cabinet_mixin.rb
297
298
  - lib/xclarity_client/mixins/canister_mixin.rb
data/lib/utils/logger.rb DELETED
@@ -1,34 +0,0 @@
1
- require 'logger'
2
- require 'fileutils'
3
- module XClarityClient
4
-
5
- class XClarityLogger
6
- attr_accessor :log
7
-
8
- def initialize(global_log=nil)
9
- # This block below looks for a log in the project which uses
10
- # this client or a defined log coming from initialize param.
11
- # If none of these logs exists, is created a log by default.
12
- @log = $lenovo_log ||= $log ||= global_log
13
-
14
- if not @log
15
- FileUtils::mkdir_p 'logs'
16
- file = File.open('logs/lxca_client.log', 'a+')
17
- file.sync = true
18
- @log = Logger.new file
19
- end
20
-
21
- end
22
-
23
- def info(header, msg)
24
- @log.level = Logger::DEBUG
25
- @log.info "[#{header}] - #{msg}"
26
- end
27
-
28
- def error(header, msg)
29
- @log.level = Logger::ERROR
30
- @log.error "[#{header}] - #{msg}"
31
- end
32
- end
33
-
34
- end