Sha256: 1b8267d53a7d5d551b17279bc8d01ab2feafcb3054a0e46dcb10f64bf2a4baf2
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
require 'rest_client' module I2X class Client ## # => Load configuration properties from client/script code # def initialize config, log begin @config = config I2X::Config.token = config[:server][:api_key] I2X::Config.host = (config[:server][:host].end_with?('/') ? config[:server][:host] : config[:server][:host] << '/') I2X::Config.log = log I2X::Config.log.info(self.class.name) {'Configuration loaded successfully.'} rescue Exception => e I2X::Config.log.error(self.class.name) {"Failed to load configuration: #{e}"} end end ## # => Validate API key. # def validate begin I2X::Config.log.info(self.class.name) {'Launching validation.'} out = RestClient.post "#{I2X::Config.host}fluxcapacitor/validate_key.json", {:access_token => I2X::Config.access_token} response = {:status => 100, :response => out.to_str} rescue Exception => e I2X::Config.log.error(self.class.name) {"Failed validation: #{e}"} end response end ## # => Start processing agents from configuration properties. # def process I2X::Config.log.info(self.class.name) {'Starting agent processing.'} begin @config[:agents].each do |agent| a = I2X::Agent.new agent a.execute end rescue Exception => e I2X::Config.log.error(self.class.name) {"Failed agent processing: #{e}"} end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
i2x-0.0.7 | lib/i2x/client.rb |