topological_inventory-providers-common 2.1.5 → 3.0.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: 75348e5abd6addefc5c90886fe1b31fc8405239998e030f6f740ebd2b034d726
4
- data.tar.gz: 7b6c51b8299d5209587253954d41e8c7898c0f15fcab3fcdbcdfd631d8311aff
3
+ metadata.gz: 3292228e7688ff8aa1d33e40d3a50a6e30928cc4b8e950166e9d7d82df61ee53
4
+ data.tar.gz: a1f98d554c706ff3dc37ea9659ac88ddf9b7e7801958a68fbf6b1824e74f32d7
5
5
  SHA512:
6
- metadata.gz: d2e5ed6d7135c0ace48bcd109c8b757c8b3f93633053bb8878cbcdc69ea13d69b18461db763ca97ad140d729078d15c1b05b59462fdfcc28a9b487fac0a73d24
7
- data.tar.gz: 6967cf0f588c7fc477e308f1cc3d9ad9be1487cb8932506fb5cbd7604d372486a33eb3d503d77a21e7eb3a08e5a02dfeba056f1d04336b44b3037cd28a2f81d0
6
+ metadata.gz: d44938aa30f1002deb30d15f61f6c89d80da94f6387e3985468ca76ac219d64ad3b57a91d7638480c14d32a17610545dae82abe3044a1328b2ef10ea6f5c9773
7
+ data.tar.gz: fb858ce78c5a5123e78fb55cb69fe01d7d682baa4c83661ed7ab3e665da95cab283992356a89cd73da1e1cd6580e5b18c8b2e480c70b2a8c9b9cf604b06dbefb
data/CHANGELOG.md CHANGED
@@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+ ## [3.0.0] - 2021-03-08
7
+ Clowder migration #75
8
+
6
9
  ## [2.1.5] - 2021-01-07
7
10
  Include x-rh-id header in Kafka Availability-Status message #73
8
11
 
@@ -84,7 +87,9 @@ manageiq-loggers to >= 0.4.2 #20
84
87
  ## [1.0.0] - 2020-03-19
85
88
  ### Initial release to rubygems.org
86
89
 
87
- [Unreleased]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v2.1.5...HEAD
90
+ [Unreleased]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v3.0.0...HEAD
91
+ [3.0.0]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v2.1.5...v3.0.0
92
+ [2.1.5]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v2.1.4...v2.1.5
88
93
  [2.1.5]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v2.1.4...v2.1.5
89
94
  [2.1.4]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v2.1.3...v2.1.4
90
95
  [2.1.3]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v2.1.2...v2.1.3
@@ -0,0 +1,68 @@
1
+ require 'clowder-common-ruby'
2
+ require 'singleton'
3
+
4
+ module TopologicalInventory
5
+ module Providers
6
+ module Common
7
+ class ClowderConfig
8
+ include Singleton
9
+
10
+ def self.clowder_enabled?
11
+ ::ClowderCommonRuby::Config.clowder_enabled?
12
+ end
13
+
14
+ def self.instance
15
+ @instance ||= {}.tap do |options|
16
+ if clowder_enabled?
17
+ config = ::ClowderCommonRuby::Config.load
18
+ options["awsAccessKeyId"] = config.logging.cloudwatch.accessKeyId
19
+ options["awsRegion"] = config.logging.cloudwatch.region
20
+ options["awsSecretAccessKey"] = config.logging.cloudwatch.secretAccessKey
21
+ broker = config.kafka.brokers.first
22
+ options["kafkaHost"] = broker.hostname
23
+ options["kafkaPort"] = broker.port
24
+
25
+ options["kafkaTopics"] = {}.tap do |topics|
26
+ config.kafka.topics.each do |topic|
27
+ topics[topic.requestedName.to_s] = topic.name.to_s
28
+ end
29
+ end
30
+ options["logGroup"] = config.logging.cloudwatch.logGroup
31
+ options["metricsPort"] = config.metricsPort
32
+ options["metricsPath"] = config.metricsPath # not supported by PrometheusExporter
33
+ else
34
+ options["awsAccessKeyId"] = ENV['CW_AWS_ACCESS_KEY_ID']
35
+ options["awsRegion"] = 'us-east-1'
36
+ options["awsSecretAccessKey"] = ENV['CW_AWS_SECRET_ACCESS_KEY']
37
+ options["kafkaBrokers"] = ["#{ENV['QUEUE_HOST']}:#{ENV['QUEUE_PORT']}"]
38
+ options["kafkaHost"] = ENV['QUEUE_HOST'] || 'localhost'
39
+ options["kafkaPort"] = (ENV['QUEUE_PORT'] || '9092').to_i
40
+ options["kafkaTopics"] = {}
41
+ options["logGroup"] = 'platform-dev'
42
+ options["metricsPort"] = (ENV['METRICS_PORT'] || 9394).to_i
43
+ end
44
+ end
45
+ end
46
+
47
+ def self.fill_args_operations(args)
48
+ args[:metrics_port] = instance['metricsPort']
49
+ args[:queue_host] = instance['kafkaHost']
50
+ args[:queue_port] = instance['kafkaPort']
51
+ args
52
+ end
53
+
54
+ def self.kafka_topic(name)
55
+ instance["kafkaTopics"][name] || name
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+
62
+ # ManageIQ Message Client depends on these variables
63
+ ENV["QUEUE_HOST"] = TopologicalInventory::Providers::Common::ClowderConfig.instance["kafkaHost"]
64
+ ENV["QUEUE_PORT"] = TopologicalInventory::Providers::Common::ClowderConfig.instance["kafkaPort"].to_s
65
+
66
+ # ManageIQ Logger depends on these variables
67
+ ENV['CW_AWS_ACCESS_KEY_ID'] = TopologicalInventory::Providers::Common::ClowderConfig.instance["awsAccessKeyId"]
68
+ ENV['CW_AWS_SECRET_ACCESS_KEY'] = TopologicalInventory::Providers::Common::ClowderConfig.instance["awsSecretAccessKey"]
@@ -1,5 +1,6 @@
1
1
  require "more_core_extensions/core_ext/module/cache_with_timeout"
2
2
  require "manageiq-messaging"
3
+ require "topological_inventory/providers/common/clowder_config"
3
4
 
4
5
  module TopologicalInventory
5
6
  module Providers
@@ -11,8 +12,8 @@ module TopologicalInventory
11
12
  attr_accessor :queue_port
12
13
 
13
14
  def initialize
14
- self.queue_host = ENV['QUEUE_HOST'] || 'localhost'
15
- self.queue_port = (ENV['QUEUE_PORT'] || 9092).to_i
15
+ self.queue_host = TopologicalInventory::Providers::Common::ClowderConfig.instance["kafkaHost"]
16
+ self.queue_port = TopologicalInventory::Providers::Common::ClowderConfig.instance["kafkaPort"].to_i
16
17
  end
17
18
 
18
19
  def self.default
@@ -17,7 +17,7 @@ module TopologicalInventory
17
17
 
18
18
  STATUS_AVAILABLE, STATUS_UNAVAILABLE = %w[available unavailable].freeze
19
19
  EVENT_AVAILABILITY_STATUS = "availability_status".freeze
20
- SERVICE_NAME = "platform.sources.status".freeze
20
+ KAFKA_TOPIC_NAME = "platform.sources.status".freeze
21
21
 
22
22
  ERROR_MESSAGES = {
23
23
  :authentication_not_found => "Authentication not found in Sources API",
@@ -209,7 +209,7 @@ module TopologicalInventory
209
209
 
210
210
  def availability_status_message(payload)
211
211
  messaging_client.publish_topic(
212
- :service => SERVICE_NAME,
212
+ :service => TopologicalInventory::Providers::Common::ClowderConfig.kafka_topic(KAFKA_TOPIC_NAME),
213
213
  :event => EVENT_AVAILABILITY_STATUS,
214
214
  :payload => payload.to_json,
215
215
  :headers => identity
@@ -1,7 +1,7 @@
1
1
  module TopologicalInventory
2
2
  module Providers
3
3
  module Common
4
- VERSION = "2.1.5".freeze
4
+ VERSION = "3.0.0".freeze
5
5
  end
6
6
  end
7
7
  end
@@ -38,7 +38,7 @@ RSpec.shared_examples "availability_check" do
38
38
 
39
39
  def kafka_message(resource_type, resource_id, status, error_message = nil)
40
40
  res = {
41
- :service => described_class::SERVICE_NAME,
41
+ :service => described_class::KAFKA_TOPIC_NAME,
42
42
  :event => described_class::EVENT_AVAILABILITY_STATUS,
43
43
  :payload => {
44
44
  :resource_type => resource_type,
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ["lib"]
25
25
 
26
26
  spec.add_runtime_dependency 'activesupport', '~> 5.2.4.3'
27
+ spec.add_runtime_dependency 'clowder-common-ruby', '~> 0.2.1'
27
28
  spec.add_runtime_dependency 'config', '~> 1.7', '>= 1.7.2'
28
29
  spec.add_runtime_dependency 'json', '~> 2.3'
29
30
  spec.add_runtime_dependency 'manageiq-loggers', '>= 0.4.2'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: topological_inventory-providers-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.5
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Slemr
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-07 00:00:00.000000000 Z
11
+ date: 2021-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 5.2.4.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: clowder-common-ruby
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.2.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.2.1
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: config
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -304,6 +318,7 @@ files:
304
318
  - bin/console
305
319
  - bin/setup
306
320
  - lib/topological_inventory/providers/common.rb
321
+ - lib/topological_inventory/providers/common/clowder_config.rb
307
322
  - lib/topological_inventory/providers/common/collector.rb
308
323
  - lib/topological_inventory/providers/common/collector/inventory_collection_storage.rb
309
324
  - lib/topological_inventory/providers/common/collector/inventory_collection_wrapper.rb