topological_inventory-providers-common 0.1.0 → 1.0.3

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
  SHA256:
3
- metadata.gz: 0f2d31b001af718d1e0cb85a61754fcc3a7e74073718083aaf2706190906606e
4
- data.tar.gz: 28c1849fa09d45ec3f33600d43db393521dbd70c1c51775f5092cba1bceba91d
3
+ metadata.gz: dcac7f624e6e6d2ba88bed97e3d089cfd4258e38b968cbed141528888ede0ca0
4
+ data.tar.gz: 7fe176f46948a2359192f503091bce1fadfe3abbb089e4c8efc5606ea07e6ed0
5
5
  SHA512:
6
- metadata.gz: a0831719dc7226ba7aabb254b6d43fe154a779e69bac479c4d4fc6be3bf9c1990d86ffb9c4ee0a44fdd3695edd2ee83a522109bcf04cec2694c272ab5393999a
7
- data.tar.gz: fc9e8ccc5478379cde68f8b6fd6dcdd00db2d0193c692dbf1563b6d4e0d753b58eca9fe9eed30688f8bf0a6194b3369b44f4ecfce5fcd008df632f654b78d1b6
6
+ metadata.gz: 2609f90ca604593f8d1bed9c0567feae6151bb6a0805a6299a9077e8b812a58d49573e32eb1cc7a0ff9cf70369c8d7936f88887c4c0b6a7af7f9e50d1013275c
7
+ data.tar.gz: 36a45b32003a82705b03d15bc15fbdae18038fc04c2238db55b0077c50868b39ea199de86185a6b00c2d9afc6ce76d9308db8c0ef5ddbc844ef57340f71d6eb7
@@ -3,8 +3,8 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.4.5
7
- - 2.5.3
6
+ - 2.5.7
7
+ - 2.6.5
8
8
  before_install:
9
9
  - 'echo ''gem: --no-ri --no-rdoc --no-document'' > ~/.gemrc'
10
10
  - gem install bundler
@@ -0,0 +1,32 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [1.0.3] - 2020-06-?
8
+ ### Changed
9
+
10
+ Bump Sources API client to 3.0 #26
11
+
12
+ ## [1.0.2] - 2020-05-15
13
+ ### Changed
14
+
15
+ Extend logger with common logging phrases #22
16
+ Security update: JSON 2.3, ActiveSupport 5.2.4.3 #23
17
+
18
+ ## [1.0.1] - 2020-05-06
19
+ ### Changed
20
+
21
+ Add logging method to base collector #18
22
+ manageiq-loggers to 0.5.0 #19
23
+ manageiq-loggers to >= 0.4.2 #20
24
+
25
+ ## [1.0.0] - 2020-03-19
26
+ ### Initial release to rubygems.org
27
+
28
+ [Unreleased]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v1.0.3...HEAD
29
+ [1.0.3]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v1.0.2...v1.0.3
30
+ [1.0.2]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v1.0.1...v1.0.2
31
+ [1.0.1]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v1.0.0...v1.0.1
32
+ [1.0.0]: https://github.com/RedHatInsights/topological_inventory-providers-common/releases/v1.0.0
data/Gemfile CHANGED
@@ -6,10 +6,7 @@ require File.join(Bundler::Plugin.index.load_paths("bundler-inject")[0], "bundle
6
6
  # Specify your gem's dependencies in topological_inventory-providers-common.gemspec
7
7
  gemspec
8
8
 
9
- gem "sources-api-client", "~> 1.0"
10
- gem "topological_inventory-ingress_api-client", "~> 1.0"
11
-
12
9
  group :development, :test do
13
- gem 'rake', '~> 12.0.0'
10
+ gem 'rake', '>= 12.3.3'
14
11
  gem 'pry-byebug'
15
12
  end
data/README.md CHANGED
@@ -1,3 +1,8 @@
1
1
  # TopologicalInventory::Providers::Common
2
2
 
3
+ [![Build Status](https://travis-ci.org/RedHatInsights/topological_inventory-providers-common.svg?branch=master)](https://travis-ci.org/RedHatInsights/topological_inventory-providers-common)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/df747492b802bfea3c83/maintainability)](https://codeclimate.com/github/RedHatInsights/topological_inventory-providers-common/maintainability)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/df747492b802bfea3c83/test_coverage)](https://codeclimate.com/github/RedHatInsights/topological_inventory-providers-common/test_coverage)
6
+ [![security](https://hakiri.io/github/RedHatInsights/topological_inventory-providers-common/master.svg)](https://hakiri.io/github/RedHatInsights/topological_inventory-providers-common/master)
7
+
3
8
  Common code for topological-inventory collectors and Operation workers.
@@ -96,21 +96,27 @@ module TopologicalInventory
96
96
  def targeted_refresh(notices)
97
97
  end
98
98
 
99
+ # @param refresh_state_part_collected_at [Time] when this payload is collected (for [Core]:RefreshStatePart)
100
+ # @param refresh_state_part_sent_at [Time] when this payload is sent (for [Core]:RefreshStatePart)
99
101
  def save_inventory(collections,
100
102
  inventory_name,
101
103
  schema,
102
104
  refresh_state_uuid = nil,
103
- refresh_state_part_uuid = nil)
105
+ refresh_state_part_uuid = nil,
106
+ refresh_state_part_collected_at = nil,
107
+ refresh_state_part_sent_at = Time.now.utc)
104
108
  return 0 if collections.empty?
105
109
 
106
110
  SaveInventory::Saver.new(:client => ingress_api_client, :logger => logger).save(
107
111
  :inventory => TopologicalInventoryIngressApiClient::Inventory.new(
108
- :name => inventory_name,
109
- :schema => TopologicalInventoryIngressApiClient::Schema.new(:name => schema),
110
- :source => source,
111
- :collections => collections,
112
- :refresh_state_uuid => refresh_state_uuid,
113
- :refresh_state_part_uuid => refresh_state_part_uuid,
112
+ :name => inventory_name,
113
+ :schema => TopologicalInventoryIngressApiClient::Schema.new(:name => schema),
114
+ :source => source,
115
+ :collections => collections,
116
+ :refresh_state_uuid => refresh_state_uuid,
117
+ :refresh_state_part_uuid => refresh_state_part_uuid,
118
+ :refresh_state_part_collected_at => refresh_state_part_collected_at,
119
+ :refresh_state_part_sent_at => refresh_state_part_sent_at
114
120
  )
115
121
  )
116
122
  rescue => e
@@ -120,22 +126,28 @@ module TopologicalInventory
120
126
  raise e
121
127
  end
122
128
 
129
+ # @param refresh_state_started_at [Time] when collecting of this entity type is started (for [Core]:RefreshState)
130
+ # @param refresh_state_sent_at [Time] when this payload is sent (for [Core]:RefreshState)
123
131
  def sweep_inventory(inventory_name,
124
132
  schema,
125
133
  refresh_state_uuid,
126
134
  total_parts,
127
- sweep_scope)
135
+ sweep_scope,
136
+ refresh_state_started_at = nil,
137
+ refresh_state_sent_at = Time.now.utc)
128
138
  return if !total_parts || sweep_scope.empty?
129
139
 
130
140
  SaveInventory::Saver.new(:client => ingress_api_client, :logger => logger).save(
131
141
  :inventory => TopologicalInventoryIngressApiClient::Inventory.new(
132
- :name => inventory_name,
133
- :schema => TopologicalInventoryIngressApiClient::Schema.new(:name => schema),
134
- :source => source,
135
- :collections => [],
136
- :refresh_state_uuid => refresh_state_uuid,
137
- :total_parts => total_parts,
138
- :sweep_scope => sweep_scope,
142
+ :name => inventory_name,
143
+ :schema => TopologicalInventoryIngressApiClient::Schema.new(:name => schema),
144
+ :source => source,
145
+ :collections => [],
146
+ :refresh_state_uuid => refresh_state_uuid,
147
+ :total_parts => total_parts,
148
+ :sweep_scope => sweep_scope,
149
+ :refresh_state_started_at => refresh_state_started_at,
150
+ :refresh_state_sent_at => refresh_state_sent_at
139
151
  )
140
152
  )
141
153
  rescue => e
@@ -156,6 +168,10 @@ module TopologicalInventory
156
168
  def ingress_api_client
157
169
  TopologicalInventoryIngressApiClient::DefaultApi.new
158
170
  end
171
+
172
+ def log_external_url(url)
173
+ logger.info("[EXTERNAL URL] #{url}")
174
+ end
159
175
  end
160
176
  end
161
177
  end
@@ -3,13 +3,38 @@ require "manageiq/loggers"
3
3
  module TopologicalInventory
4
4
  module Providers
5
5
  module Common
6
+ module LoggingFunctions
7
+ def collecting(status, source, entity_type, refresh_state_uuid, total_parts = nil)
8
+ msg = "[#{status.to_s.upcase}] Collecting #{entity_type}"
9
+ msg += ", :total parts => #{total_parts}" if total_parts.present?
10
+ msg += ", :source_uid => #{source}, :refresh_state_uuid => #{refresh_state_uuid}"
11
+ info(msg)
12
+ end
13
+
14
+ def collecting_error(source, entity_type, refresh_state_uuid, exception)
15
+ msg = "[ERROR] Collecting #{entity_type}, :source_uid => #{source}, :refresh_state_uuid => #{refresh_state_uuid}"
16
+ msg += ":message => #{exception.message}\n#{exception.backtrace.join("\n")}"
17
+ error(msg)
18
+ end
19
+
20
+ def sweeping(status, source, sweep_scope, refresh_state_uuid)
21
+ msg = "[#{status.to_s.upcase}] Sweeping inactive records, :sweep_scope => #{sweep_scope}, :source_uid => #{source}, :refresh_state_uuid => #{refresh_state_uuid}"
22
+ info(msg)
23
+ end
24
+ end
25
+
26
+ class Logger < ManageIQ::Loggers::CloudWatch
27
+ def self.new(*args)
28
+ super.tap { |logger| logger.extend(TopologicalInventory::Providers::Common::LoggingFunctions) }
29
+ end
30
+ end
31
+
6
32
  class << self
7
33
  attr_writer :logger
8
34
  end
9
35
 
10
36
  def self.logger
11
- @logger ||= ManageIQ::Loggers::Container.new
12
- @logger
37
+ @logger ||= TopologicalInventory::Providers::Common::Logger.new
13
38
  end
14
39
 
15
40
  module Logging
@@ -1,7 +1,7 @@
1
1
  module TopologicalInventory
2
2
  module Providers
3
3
  module Common
4
- VERSION = "0.1.0"
4
+ VERSION = "1.0.3"
5
5
  end
6
6
  end
7
7
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.summary = %q{Common classes for topological-inventory collectors/operations}
13
13
  spec.description = %q{Common classes for topological-inventory collectors/operations}
14
- spec.homepage = "https://github.com/slemrmartin/topological_inventory-providers-common"
14
+ spec.homepage = "https://github.com/RedHatInsights/topological_inventory-providers-common"
15
15
  spec.license = "Apache-2.0"
16
16
 
17
17
  # Specify which files should be added to the gem when it is released.
@@ -23,13 +23,15 @@ Gem::Specification.new do |spec|
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ["lib"]
25
25
 
26
+ spec.add_runtime_dependency 'activesupport', '~> 5.2.4.3'
26
27
  spec.add_runtime_dependency 'config', '~> 1.7', '>= 1.7.2'
27
- spec.add_runtime_dependency "activesupport", "~> 5.2.2"
28
- spec.add_runtime_dependency "manageiq-loggers", "~> 0.4.0", ">= 0.4.2"
29
- spec.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0'
30
- spec.add_runtime_dependency "topological_inventory-api-client", "~> 2.0"
28
+ spec.add_runtime_dependency 'json', '~> 2.3'
29
+ spec.add_runtime_dependency "manageiq-loggers", ">= 0.4.2"
30
+ spec.add_runtime_dependency "sources-api-client", "~> 3.0"
31
+ spec.add_runtime_dependency "topological_inventory-api-client", "~> 3.0", ">= 3.0.1"
32
+ spec.add_runtime_dependency "topological_inventory-ingress_api-client", "~> 1.0"
31
33
 
32
34
  spec.add_development_dependency "bundler", "~> 2.0"
33
- spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rake", ">= 12.3.3"
34
36
  spec.add_development_dependency "rspec", "~> 3.0"
35
37
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: topological_inventory-providers-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Slemr
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-11 00:00:00.000000000 Z
11
+ date: 2020-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.2.4.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 5.2.4.3
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: config
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -31,26 +45,23 @@ dependencies:
31
45
  - !ruby/object:Gem::Version
32
46
  version: 1.7.2
33
47
  - !ruby/object:Gem::Dependency
34
- name: activesupport
48
+ name: json
35
49
  requirement: !ruby/object:Gem::Requirement
36
50
  requirements:
37
51
  - - "~>"
38
52
  - !ruby/object:Gem::Version
39
- version: 5.2.2
53
+ version: '2.3'
40
54
  type: :runtime
41
55
  prerelease: false
42
56
  version_requirements: !ruby/object:Gem::Requirement
43
57
  requirements:
44
58
  - - "~>"
45
59
  - !ruby/object:Gem::Version
46
- version: 5.2.2
60
+ version: '2.3'
47
61
  - !ruby/object:Gem::Dependency
48
62
  name: manageiq-loggers
49
63
  requirement: !ruby/object:Gem::Requirement
50
64
  requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: 0.4.0
54
65
  - - ">="
55
66
  - !ruby/object:Gem::Version
56
67
  version: 0.4.2
@@ -58,46 +69,57 @@ dependencies:
58
69
  prerelease: false
59
70
  version_requirements: !ruby/object:Gem::Requirement
60
71
  requirements:
61
- - - "~>"
62
- - !ruby/object:Gem::Version
63
- version: 0.4.0
64
72
  - - ">="
65
73
  - !ruby/object:Gem::Version
66
74
  version: 0.4.2
67
75
  - !ruby/object:Gem::Dependency
68
- name: json
76
+ name: sources-api-client
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.0'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: topological_inventory-api-client
69
91
  requirement: !ruby/object:Gem::Requirement
70
92
  requirements:
71
93
  - - "~>"
72
94
  - !ruby/object:Gem::Version
73
- version: '2.1'
95
+ version: '3.0'
74
96
  - - ">="
75
97
  - !ruby/object:Gem::Version
76
- version: 2.1.0
98
+ version: 3.0.1
77
99
  type: :runtime
78
100
  prerelease: false
79
101
  version_requirements: !ruby/object:Gem::Requirement
80
102
  requirements:
81
103
  - - "~>"
82
104
  - !ruby/object:Gem::Version
83
- version: '2.1'
105
+ version: '3.0'
84
106
  - - ">="
85
107
  - !ruby/object:Gem::Version
86
- version: 2.1.0
108
+ version: 3.0.1
87
109
  - !ruby/object:Gem::Dependency
88
- name: topological_inventory-api-client
110
+ name: topological_inventory-ingress_api-client
89
111
  requirement: !ruby/object:Gem::Requirement
90
112
  requirements:
91
113
  - - "~>"
92
114
  - !ruby/object:Gem::Version
93
- version: '2.0'
115
+ version: '1.0'
94
116
  type: :runtime
95
117
  prerelease: false
96
118
  version_requirements: !ruby/object:Gem::Requirement
97
119
  requirements:
98
120
  - - "~>"
99
121
  - !ruby/object:Gem::Version
100
- version: '2.0'
122
+ version: '1.0'
101
123
  - !ruby/object:Gem::Dependency
102
124
  name: bundler
103
125
  requirement: !ruby/object:Gem::Requirement
@@ -116,16 +138,16 @@ dependencies:
116
138
  name: rake
117
139
  requirement: !ruby/object:Gem::Requirement
118
140
  requirements:
119
- - - "~>"
141
+ - - ">="
120
142
  - !ruby/object:Gem::Version
121
- version: '10.0'
143
+ version: 12.3.3
122
144
  type: :development
123
145
  prerelease: false
124
146
  version_requirements: !ruby/object:Gem::Requirement
125
147
  requirements:
126
- - - "~>"
148
+ - - ">="
127
149
  - !ruby/object:Gem::Version
128
- version: '10.0'
150
+ version: 12.3.3
129
151
  - !ruby/object:Gem::Dependency
130
152
  name: rspec
131
153
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +172,7 @@ files:
150
172
  - ".gitignore"
151
173
  - ".rspec"
152
174
  - ".travis.yml"
175
+ - CHANGELOG.md
153
176
  - Gemfile
154
177
  - LICENSE.txt
155
178
  - README.md
@@ -171,7 +194,7 @@ files:
171
194
  - lib/topological_inventory/providers/common/save_inventory/saver.rb
172
195
  - lib/topological_inventory/providers/common/version.rb
173
196
  - topological_inventory-providers-common.gemspec
174
- homepage: https://github.com/slemrmartin/topological_inventory-providers-common
197
+ homepage: https://github.com/RedHatInsights/topological_inventory-providers-common
175
198
  licenses:
176
199
  - Apache-2.0
177
200
  metadata: {}
@@ -190,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
213
  - !ruby/object:Gem::Version
191
214
  version: '0'
192
215
  requirements: []
193
- rubygems_version: 3.1.2
216
+ rubygems_version: 3.0.8
194
217
  signing_key:
195
218
  specification_version: 4
196
219
  summary: Common classes for topological-inventory collectors/operations