Class: TopologicalInventory::Providers::Common::ClowderConfig

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/topological_inventory/providers/common/clowder_config.rb

Class Method Summary collapse

Class Method Details

.clowder_enabled?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/topological_inventory/providers/common/clowder_config.rb', line 10

def self.clowder_enabled?
  ::ClowderCommonRuby::Config.clowder_enabled?
end

.fill_args_operations(args) ⇒ Object



47
48
49
50
51
52
# File 'lib/topological_inventory/providers/common/clowder_config.rb', line 47

def self.fill_args_operations(args)
  args[:metrics_port] = instance['metricsPort']
  args[:queue_host]   = instance['kafkaHost']
  args[:queue_port]   = instance['kafkaPort']
  args
end

.instanceObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/topological_inventory/providers/common/clowder_config.rb', line 14

def self.instance
  @instance ||= {}.tap do |options|
    if clowder_enabled?
      config                        = ::ClowderCommonRuby::Config.load
      options["awsAccessKeyId"]     = config.logging.cloudwatch.accessKeyId
      options["awsRegion"]          = config.logging.cloudwatch.region
      options["awsSecretAccessKey"] = config.logging.cloudwatch.secretAccessKey
      broker                        = config.kafka.brokers.first
      options["kafkaHost"]          = broker.hostname
      options["kafkaPort"]          = broker.port

      options["kafkaTopics"] = {}.tap do |topics|
        config.kafka.topics.each do |topic|
          topics[topic.requestedName.to_s] = topic.name.to_s
        end
      end
      options["logGroup"]    = config.logging.cloudwatch.logGroup
      options["metricsPort"] = config.metricsPort
      options["metricsPath"] = config.metricsPath # not supported by PrometheusExporter
    else
      options["awsAccessKeyId"]     = ENV['CW_AWS_ACCESS_KEY_ID']
      options["awsRegion"]          = 'us-east-1'
      options["awsSecretAccessKey"] = ENV['CW_AWS_SECRET_ACCESS_KEY']
      options["kafkaBrokers"]       = ["#{ENV['QUEUE_HOST']}:#{ENV['QUEUE_PORT']}"]
      options["kafkaHost"]          = ENV['QUEUE_HOST'] || 'localhost'
      options["kafkaPort"]          = (ENV['QUEUE_PORT'] || '9092').to_i
      options["kafkaTopics"]        = {}
      options["logGroup"]           = 'platform-dev'
      options["metricsPort"]        = (ENV['METRICS_PORT'] || 9394).to_i
    end
  end
end

.kafka_topic(name) ⇒ Object



54
55
56
# File 'lib/topological_inventory/providers/common/clowder_config.rb', line 54

def self.kafka_topic(name)
  instance["kafkaTopics"][name] || name
end