inventory-server 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 34cbc8d1572c70edb39377ffa1981fea38a03a21
4
- data.tar.gz: 423f3ca495ed66887c283618484ce7e1ad9baefa
3
+ metadata.gz: da0b3dd5098604defe01b1faec684df26ffb974a
4
+ data.tar.gz: 771e0c694a711e161a7c4fc6e9ada10d7ef019ce
5
5
  SHA512:
6
- metadata.gz: d73c6ac09d52200f1bd0b332a7e15fdfdd7e79947dec8d1fb3593781a01955834033f8ba03e1086a7a576281fc0eff309a710c6bbb15403c810e12c26f0001ae
7
- data.tar.gz: 458a1968d101447e15b1dab21d3ade878d720df78975025a60fde4ae268ce429cc1e6723ae10c98288a29930aadaba7cc738665aed62c6bc163832f5a1660083
6
+ metadata.gz: 9c52952f9d38a8d3dd8bb72120067094e737b7d21efa05e359314220b6b8b2cd4b627dbf79ae50aa13023c6d664e8946603d7285851c94e5d39b470f55e67a69
7
+ data.tar.gz: 7de13ce85a19acf1ac3743d86c605cb8277f139ef8160a643b99ec7254e4bbb0e3a148d39dca9087b9c86e35489e5b7a0597227959c197fd7773d9f0852d1feb
data/.travis.yml CHANGED
@@ -2,7 +2,6 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
- - 2.1.0
6
5
  - 2.2.0
7
6
  gemfile: Gemfile
8
7
  script: bundle exec rspec spec
data/README.md CHANGED
@@ -1,31 +1,107 @@
1
1
  # Inventory::Server [![Build Status](https://travis-ci.org/Filirom1/inventory.svg?branch=master)](https://travis-ci.org/Filirom1/inventory) [![Code Climate](https://codeclimate.com/github/Filirom1/inventory/badges/gpa.svg)](https://codeclimate.com/github/Filirom1/inventory) [![Test Coverage](https://codeclimate.com/github/Filirom1/inventory/badges/coverage.svg)](https://codeclimate.com/github/Filirom1/inventory)
2
2
 
3
- Inventory server store and index data sent from the agent
3
+ Inventory is an HTTP and SMTP Server that process and index facts produced by facter.
4
4
 
5
- ## Installation
5
+ ## Installation, the Docker way
6
6
 
7
- Install `postfix` with the following configuration
7
+ $ git clone https://github.com/Filirom1/inventory.git
8
+ $ cd inventory
9
+ $ fig up -d
8
10
 
9
- mydestination = $myhostname, localhost.$mydomain, localhost
10
- relay_domains = $mydestination
11
- relayhost = 127.0.0.1:2525
11
+ ## Installation, the hard way
12
12
 
13
- Install ElasticSearch
13
+ Install ElasticSearch, Kibana, ruby >=1.9 and bundler
14
14
 
15
- Install ruby and bundler
15
+ $ git clone https://github.com/Filirom1/inventory.git
16
+ $ cd inventory
17
+ $ bundle install
18
+ $ bundle exec rackup # to start the HTTP Server
19
+ $ bundle exec bin/inventory-smtpd # to start the SMTP Server
16
20
 
17
- Then
21
+ ## Usage
18
22
 
19
- bundle install
20
- bundle exec ruby smtp_server.rb
23
+ Send facts by HTTP:
21
24
 
25
+ ```
26
+ $ facter --json | curl -d @- localhost:9292/api/v1/facts/`hostname`
27
+ 2015-03-01 19:03:39 +0100 t-4864360 [dahu ] INFO | facts_parser.rb:20 | Facts parser
28
+ 2015-03-01 19:03:39 +0100 t-4864360 [dahu ] INFO | json_schema_valid...:14 | JSON Schema Validator
29
+ 2015-03-01 19:03:39 +0100 t-4864360 [dahu ] INFO | json_schema_valid...:24 | No JSON Schema found at /etc/inventory/json_schema/facts/1-0-0.json, skip validation
30
+ 2015-03-01 19:03:39 +0100 t-4864360 [dahu ] INFO | index.rb:23 | Index
31
+ 2015-03-01 19:03:39 +0100 t-4864360 [dahu ] INFO | index.rb:38 | {"_index":"inventory_facts","_type":"1-0-0","_id":"dahu","_version":2,"created":false}
32
+ 2015-03-01 19:03:39 +0100 t-4864360 [dahu ] INFO | http_server.rb:16 | 127.0.0.1 - - [01/Mar/2015 19:03:39] "POST /api/v1/facts/dahu HTTP/1.1" 200 36 0.0383
22
33
 
23
- ## Usage
34
+ 127.0.0.1 - - [01/Mar/2015 19:03:39] "POST /api/v1/facts/dahu HTTP/1.1" 200 36 0.0390
35
+ {"id":"dahu","ok":true,"status":200}
36
+ ```
37
+
38
+ Or send facts by Email:
39
+
40
+ ```
41
+ facter --json | mail -s `hostname` inventory@localdomain
42
+ 2015-03-01 19:43:35 +0100 t-70045727140840 [ ] INFO | email_parser.rb:9 | Email parser
43
+ 2015-03-01 19:43:35 +0100 t-70045727140840 [dahu ] INFO | facts_parser.rb:20 | Facts parser
44
+ 2015-03-01 19:43:35 +0100 t-70045727140840 [dahu ] INFO | json_schema_valid...:14 | JSON Schema Validator
45
+ 2015-03-01 19:43:35 +0100 t-70045727140840 [dahu ] INFO | json_schema_valid...:24 | No JSON Schema found at /etc/inventory/json_schema/facts/1-0-0.json, skip validation
46
+ 2015-03-01 19:43:35 +0100 t-70045727140840 [dahu ] INFO | index.rb:23 | Index
47
+ 2015-03-01 19:43:35 +0100 t-70045727140840 [dahu ] INFO | index.rb:38 | {"_index":"inventory_facts","_type":"1-0-0","_id":"dahu","_version":6,"created":false}
48
+ ```
49
+
50
+ ## Plugins
51
+
52
+ Inventory is built with plugins in mind. The default plugins could be found in the `plugins` dir. The default execution order is this one: `log_failures_on_disk`,`facts_parser`,`json_schema_validator`,`index`
53
+
54
+ To add/remove plugins or change the order, you have to change 2 configurations options (see configurations options below)
55
+
56
+ * `plugins_path`
57
+ * `plugins`
58
+
59
+ You could create your own plugin, copy the example `plugins/sample.rb` to start.
60
+
61
+ ### log_failures_on_disk
62
+
63
+ If an error is raised during the processing, the received facts will be stored in the file `failed_facts_dir`/$ID and the error message, stacktrace and context will be written to `failed_facts_dir`/$ID.log
64
+
65
+ ### facts_parser
66
+
67
+ Transform JSON, YAML, XML and XML with `__base64__` into a ruby hash
68
+
69
+ ### json_schema_validator
70
+
71
+ Check if the received facts are compliant with the JSON Schema in `json_schema_dir`/$TYPE/$VERSION.json
72
+
73
+ ### index
74
+
75
+ Index the received facts in ElasticSearch
76
+
77
+ ## Configuration
78
+
79
+ Configuration options could be set via environment variables. Each option should be prefixed with `INVENTORY_`. For exemple: `export INVENTORY_LOG_LEVEL=ERROR`
80
+
81
+ Configurations could also be defined in a YAML file: `/etc/inventory/inventory.yml`
82
+
83
+ The following options are configurable:
24
84
 
85
+ * `host` (default: '127.0.0.1'): SMTP host to bind on
86
+ * `smtp_port` (default: 2525): SMTP port
87
+ * `max_connections` (default: 4): SMTP maximum number of simultaneus allowed connexions
88
+ * `es_host` (default: 'http`//localhost`9200'): ElasticSearch URL
89
+ * `es_index_prefix` (default: 'inventory_'): ElasticSearch index prefix
90
+ * `failed_facts_dir` (default: '/var/log/inventory/failures'): Dir where failed facts will be written to
91
+ * `logger` (default: 'stdout'): stout/stderr or file for log destination
92
+ * `log_level` (default: 'INFO'): DEBUG/INFO/WARN/ERROR
93
+ * `debug` (default: false): Show more details, need log_level on DEBUG
94
+ * `type_key` (default: 'type'): Facts key that will be used as a type
95
+ * `type_default` (default: 'facts'): Default type if `type_key` not found in facts
96
+ * `version_key` (default: 'version'): Facts key that wll be used as a version
97
+ * `version_default` (default: '1-0-0'): Default version if not `version_key` found
98
+ * `json_schema_dir` (default: '/etc/inventory/json_schema'): directory containing JSON Schema
99
+ * `plugins_path` (default: ''): a directory containing middlewares.
100
+ * `plugins` (default: `log_failures_on_disk,facts_parser,json_schema_validator,index`): a comma separated list of plugins that will be executed in order.
25
101
 
26
102
  ## Contributing
27
103
 
28
- 1. Fork it ( https://github.com/[my-github-username]/inventory-server/fork )
104
+ 1. Fork it ( https://github.com/Filirom1/inventory-server/fork )
29
105
  2. Create your feature branch (`git checkout -b my-new-feature`)
30
106
  3. Commit your changes (`git commit -am 'Add some feature'`)
31
107
  4. Push to the branch (`git push origin my-new-feature`)
File without changes
@@ -0,0 +1,21 @@
1
+ ---
2
+ host: 127.0.0.1
3
+ smtp_port: 2525
4
+ max_connections: 4
5
+ debug: false
6
+ es_host: http://localhost:9200
7
+ es_index_prefix: inventory_
8
+ failed_facts_dir: /var/log/inventory/failures
9
+ logger: stdout
10
+ log_level: INFO
11
+ type_key: type
12
+ type_default: facts
13
+ version_key: version
14
+ version_default: 1-0-0
15
+ json_schema_dir: /etc/inventory/json_schema
16
+ plugins_path:
17
+ plugins:
18
+ - log_failures_on_disk
19
+ - facts_parser
20
+ - json_schema_validator
21
+ - index
data/fig.yml CHANGED
@@ -6,13 +6,5 @@ web:
6
6
  - "80:80"
7
7
  environment:
8
8
  INVENTORY_ES_HOST: http://elasticsearch:9200
9
- kibana:
10
- image: bobrik/kibana4:4.0.0-rc1
11
- ports:
12
- - 5601:5601
13
- links:
14
- - elasticsearch
15
- environment:
16
- KIBANA_ES_URL: http://elasticsearch:9200
17
9
  elasticsearch:
18
10
  image: elasticsearch:1.4.4
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["filirom1@gmail.com"]
11
11
  spec.summary = %q{Inventory server store and index data sent from the agent}
12
12
  spec.description = %q{Inventory server store and index data sent from the agent}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/Filirom1/inventory"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -24,22 +24,19 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency 'mail', '~> 2.6'
25
25
  spec.add_dependency 'filum', '~> 2.2'
26
26
  spec.add_dependency 'json', '~> 1.8'
27
- spec.add_dependency 'activesupport', '~> 4.2'
28
27
  spec.add_dependency 'libxml-to-hash', '~> 0.2'
29
28
  spec.add_dependency 'middleware', '~> 0.1'
30
- spec.add_dependency 'app_configuration', '~> 0.0'
31
29
  spec.add_dependency 'sinatra', '~> 1.4'
32
30
  spec.add_dependency 'ensure-encoding', '~> 0.1'
33
31
  spec.add_dependency 'json-schema', '~> 2.5'
34
32
  spec.add_dependency 'unicorn', '~> 4.8'
35
33
 
36
- spec.add_development_dependency "bundler", "~> 1.7"
34
+ spec.add_development_dependency "bundler"
37
35
  spec.add_development_dependency "rake", "~> 10.0"
38
36
  spec.add_development_dependency "rack-test", "~> 0.6"
39
37
  spec.add_development_dependency "codeclimate-test-reporter", "~> 0.4"
40
38
  spec.add_development_dependency "rspec", "~> 3.0"
41
39
  spec.add_development_dependency "rspec-mocks", "~> 3.2"
42
40
  spec.add_development_dependency "webmock", "~> 1.20"
43
- spec.add_development_dependency 'thin', '~> 1.6'
44
41
  spec.add_development_dependency 'parallel', '~> 1.4'
45
42
  end
@@ -1,4 +1,4 @@
1
- require 'app_configuration'
1
+ require 'yaml'
2
2
  require 'fileutils'
3
3
  require "inventory/server/logger"
4
4
 
@@ -6,73 +6,74 @@ module Inventory
6
6
  module Server
7
7
 
8
8
  module Config
9
- DEFAULTS = {
10
- :host => '127.0.0.1',
11
- :smtp_port => 2525,
12
- :max_connections => 4,
13
- :debug => false,
14
- :es_host => 'http://localhost:9200',
15
- :es_index_prefix => 'inventory_',
16
- :failed_facts_dir => '/var/log/inventory/failures',
17
- :logger => 'stdout',
18
- :log_level => 'INFO',
19
- :type_key => 'type',
20
- :type_default => 'facts',
21
- :version_key => 'version',
22
- :version_default => '1-0-0',
23
- :json_schema_dir => '/etc/inventory/json_schema',
24
- :plugins_path => '',
25
- :plugins => 'log_failures_on_disk,facts_parser,json_schema_validator,index',
26
- }
27
-
28
9
  def self.generate(cli_config)
10
+ mapping = {
11
+ 'stdout'=> $stdout,
12
+ 'stderr'=> $stderr,
13
+ 'INFO'=>Logger::INFO,
14
+ 'DEBUG'=>Logger::DEBUG,
15
+ 'WARN'=>Logger::WARN,
16
+ 'ERROR'=>Logger::ERROR,
17
+ 'FATAL'=>Logger::FATAL
18
+ }
29
19
 
30
- global = AppConfiguration.new('inventory.yml') do
31
- base_global_path '/etc'
32
- use_env_variables true
33
- prefix 'inventory' # ENV prefix: INVENTORY_XXXXX
34
- end
20
+ config = self.defaults.merge self.etc.merge self.env.merge cli_config
35
21
 
36
- config = {}
37
-
38
- DEFAULTS.each{|sym, default_value|
39
-
40
- val = cli_config[sym] || global[sym.to_s] || default_value
41
- result = val
42
-
43
- # cast config values (ENV values are strings only)
44
- if default_value.is_a? Integer
45
- result = val.to_i
46
- elsif !!default_value == default_value
47
- # Boolean
48
- if val == true || val =~ /^(true|t|yes|y|1)$/i
49
- result = true
50
- elsif val == false || val.blank? || val =~ /^(false|f|no|n|0)$/i
51
- result = false
52
- end
53
- # Logging
54
- elsif val == 'stdout'
55
- result = $stdout
56
- elsif val == 'stderr'
57
- result = $stderr
58
- # Logging Level
59
- elsif val == 'INFO'
60
- result = Logger::INFO
61
- elsif val == 'DEBUG'
62
- result = Logger::DEBUG
63
- elsif val == 'WARN'
64
- result = Logger::WARN
65
- elsif val == 'ERROR'
66
- result = Logger::ERROR
67
- elsif val == 'FATAL'
68
- result = Logger::FATAL
22
+ config.each{|sym, val|
23
+ next unless val
24
+ config[sym] = mapping[val] if mapping[val]
25
+
26
+ if val.is_a? String and [:plugins, :plugins_path].include? sym
27
+ config[sym] = val.split(',').collect(&:strip)
69
28
  end
70
- config[sym] = result
71
29
  }
72
30
 
73
31
  FileUtils.mkdir_p config[:failed_facts_dir]
74
32
 
75
- config
33
+ return config
34
+ end
35
+
36
+ private
37
+
38
+ def self.load_yaml(filepath)
39
+ begin
40
+ hash = YAML.load_file filepath
41
+ rescue
42
+ return {}
43
+ end
44
+ self.sym_keys! hash
45
+ hash
46
+ end
47
+
48
+ def self.defaults()
49
+ default_filename = File.join File.dirname(__FILE__), '..', '..', '..', 'config', 'inventory.yml'
50
+ self.load_yaml default_filename
51
+ end
52
+
53
+ def self.etc()
54
+ self.load_yaml "/etc/inventory/inventory.yml"
55
+ end
56
+
57
+ def self.sym_keys!(hash)
58
+ hash.keys.each do |key|
59
+ hash[(key.to_sym rescue key) || key] = hash.delete(key)
60
+ end
61
+ end
62
+
63
+ def self.env()
64
+ hash = {}
65
+ ENV.each {|key, value|
66
+ next unless key.start_with? 'INVENTORY_'
67
+ key = key.gsub 'INVENTORY_', ''
68
+ key = key.downcase
69
+ hash[key] = value
70
+ }
71
+
72
+ # This is an ugly trick to auto cast data types
73
+ hash = YAML.load hash.map{|k,v| "#{k}: #{v}"}.join("\n")
74
+
75
+ self.sym_keys! hash
76
+ hash
76
77
  end
77
78
  end
78
79
  end
@@ -7,11 +7,11 @@ module Inventory
7
7
  module Server
8
8
  class Loader
9
9
  def initialize(config)
10
- @plugins_path = [PLUGINS_DIR] + config[:plugins_path].split(',')
10
+ @plugins_path = [PLUGINS_DIR]
11
+ @plugins_path << config[:plugins_path] if config[:plugins_path]
11
12
  @plugins_path.each { |path|
12
13
  raise InventoryError.new "plugins_path #{path} not found" unless File.directory? path
13
14
  }
14
- @loaded = []
15
15
  end
16
16
 
17
17
  # search for plugins in the plugins_path and return a hash of plugin_filename:plugin_klass
@@ -32,17 +32,9 @@ module Inventory
32
32
  return plugin_klasses
33
33
  end
34
34
 
35
- # Load a ruby file if not already loaded
35
+ # Load a ruby file
36
36
  def load_file(file)
37
- return if @loaded.include? file
38
-
39
- begin
40
- @loaded << file
41
- kernel_load(file)
42
- rescue => e
43
- @loaded.delete(file)
44
- InventoryLogger.logger.error("Fail to load #{file}: #{e}")
45
- end
37
+ kernel_load(file)
46
38
  end
47
39
 
48
40
  # Usefull for tests
@@ -1,5 +1,5 @@
1
1
  module Inventory
2
2
  module Server
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -17,7 +17,7 @@ module Inventory
17
17
  InventoryLogger.logger.level = config[:log_level]
18
18
 
19
19
  # Dynamically load plugins from plugins_path
20
- plugin_names = config[:plugins].split(',')
20
+ plugin_names = config[:plugins]
21
21
  @middlewares = Middleware::Builder.new do
22
22
  plugins = Loader.new(config).load_plugins(*plugin_names)
23
23
  plugins.each {|klass|
@@ -27,6 +27,7 @@ module Inventory
27
27
 
28
28
  InventoryLogger.logger.info "Use JSON Schema #{json_schema_file}"
29
29
  JSON::Validator.validate!(json_schema_file, facts)
30
+ @app.call(env)
30
31
  end
31
32
  end
32
33
  end
data/plugins/sample.rb ADDED
@@ -0,0 +1,25 @@
1
+ require 'inventory/server/inventory_error'
2
+ require "inventory/server/logger"
3
+
4
+ module Inventory
5
+ module Server
6
+ class Sample
7
+ def initialize(app, config)
8
+ @app = app
9
+ @config = config
10
+ end
11
+
12
+ def call(env)
13
+ InventoryLogger.logger.info "Sample"
14
+
15
+ # Index it into elasticsearch
16
+ id = env[:id]
17
+ raise InventoryError.new 'id is missing' if id.nil? || id.empty?
18
+
19
+ # TODO
20
+
21
+ @app.call(env)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -12,53 +12,77 @@ RSpec.describe Inventory::Server::Config do
12
12
  end
13
13
  end
14
14
 
15
-
16
- context "with ENV configuration" do
17
- before do
18
- ENV['INVENTORY_HOST'] = "127.0.0.1"
19
- ENV['INVENTORY_SMTP_PORT'] = "2626"
20
- ENV['INVENTORY_DEBUG'] = "false"
21
- ENV['INVENTORY_LOGGER'] = "stdout"
22
- ENV['INVENTORY_LOG_LEVEL'] = "DEBUG"
23
- end
24
-
25
- after do
26
- ENV['INVENTORY_HOST'] = nil
27
- ENV['INVENTORY_SMTP_PORT'] = nil
28
- ENV['INVENTORY_DEBUG'] = nil
29
- ENV['INVENTORY_LOGGER'] = nil
30
- ENV['INVENTORY_LOG_LEVEL'] = nil
15
+ context "with etc configuration" do
16
+ before(:each) do
17
+ expect(Inventory::Server::Config).to receive(:etc).and_return({:smtp_port => 2424})
31
18
  end
32
19
 
33
- it "should use the ENV configuration" do
20
+ it "should use the etc configuration" do
34
21
  config = Inventory::Server::Config.generate({})
35
- expect(config[:host]).to eq '127.0.0.1'
22
+ expect(config[:smtp_port]).to eq 2424
36
23
  end
37
24
 
38
- it "should should cast integer" do
39
- config = Inventory::Server::Config.generate({})
40
- expect(config[:smtp_port]).to eq 2626
41
- end
25
+ context "with ENV configuration" do
26
+ before do
27
+ ENV['INVENTORY_HOST'] = "127.0.0.1"
28
+ ENV['INVENTORY_SMTP_PORT'] = "2626"
29
+ ENV['INVENTORY_DEBUG'] = "false"
30
+ ENV['INVENTORY_LOGGER'] = "stdout"
31
+ ENV['INVENTORY_LOG_LEVEL'] = "DEBUG"
32
+ ENV['INVENTORY_PLUGINS'] = "plugin1, plugin2"
33
+ ENV['INVENTORY_PLUGINS_PATH'] = "/path/to/plugin/dir1,/path/to/plugin/dir2"
34
+ end
42
35
 
43
- it "should should cast boolean" do
44
- config = Inventory::Server::Config.generate({})
45
- expect(config[:debug]).to eq false
46
- end
36
+ after do
37
+ ENV['INVENTORY_HOST'] = nil
38
+ ENV['INVENTORY_SMTP_PORT'] = nil
39
+ ENV['INVENTORY_DEBUG'] = nil
40
+ ENV['INVENTORY_LOGGER'] = nil
41
+ ENV['INVENTORY_LOG_LEVEL'] = nil
42
+ ENV['INVENTORY_PLUGINS'] = nil
43
+ ENV['INVENTORY_PLUGINS_PATH'] = nil
44
+ end
47
45
 
48
- it "should should cast stdout/stderr" do
49
- config = Inventory::Server::Config.generate({})
50
- expect(config[:logger]).to eq $stdout
51
- end
46
+ it "should use the ENV configuration" do
47
+ config = Inventory::Server::Config.generate({})
48
+ expect(config[:host]).to eq '127.0.0.1'
49
+ end
52
50
 
53
- it "should should cast DEBUG/INFO/WARN/ERROR/FATAL" do
54
- config = Inventory::Server::Config.generate({})
55
- expect(config[:log_level]).to eq Logger::DEBUG
56
- end
51
+ it "should should cast integer" do
52
+ config = Inventory::Server::Config.generate({})
53
+ expect(config[:smtp_port]).to eq 2626
54
+ end
55
+
56
+ it "should should cast boolean" do
57
+ config = Inventory::Server::Config.generate({})
58
+ expect(config[:debug]).to eq false
59
+ end
60
+
61
+ it "should should cast stdout/stderr" do
62
+ config = Inventory::Server::Config.generate({})
63
+ expect(config[:logger]).to eq $stdout
64
+ end
65
+
66
+ it "should should cast DEBUG/INFO/WARN/ERROR/FATAL" do
67
+ config = Inventory::Server::Config.generate({})
68
+ expect(config[:log_level]).to eq Logger::DEBUG
69
+ end
70
+
71
+ it "should should return an array for plugins" do
72
+ config = Inventory::Server::Config.generate({})
73
+ expect(config[:plugins]).to eq ['plugin1', 'plugin2']
74
+ end
75
+
76
+ it "should should return an array for plugins_path" do
77
+ config = Inventory::Server::Config.generate({})
78
+ expect(config[:plugins_path]).to eq ['/path/to/plugin/dir1', '/path/to/plugin/dir2']
79
+ end
57
80
 
58
- context "with CLI configuration" do
59
- it "should use the CLI configuration" do
60
- config = Inventory::Server::Config.generate({:smtp_port => 25})
61
- expect(config[:smtp_port]).to eq 25
81
+ context "with CLI configuration" do
82
+ it "should use the CLI configuration" do
83
+ config = Inventory::Server::Config.generate({:smtp_port => 25})
84
+ expect(config[:smtp_port]).to eq 25
85
+ end
62
86
  end
63
87
  end
64
88
  end
@@ -5,7 +5,7 @@ require 'webmock/rspec'
5
5
 
6
6
  noop = lambda {|env|}
7
7
 
8
- config = Inventory::Server::Config::DEFAULTS
8
+ config = Inventory::Server::Config::defaults
9
9
 
10
10
  RSpec.describe Inventory::Server::Index, '#call' do
11
11
  # needed for code climates to work after rspec
@@ -34,6 +34,18 @@ RSpec.describe Inventory::Server::Index, '#call' do
34
34
  end
35
35
  end
36
36
 
37
+ context "without an ElasticSearch Server" do
38
+ env = {:id => 'MY_UUID', :facts => { :key => 'value' } }
39
+
40
+ it "should throw an error" do
41
+ WebMock.allow_net_connect!
42
+
43
+ expect {
44
+ Inventory::Server::Index.new(noop, config).call(env)
45
+ }.to raise_error(Errno::ECONNREFUSED)
46
+ end
47
+ end
48
+
37
49
  context "with an ElasticSearch Server Crashed" do
38
50
  env = {:id => 'MY_UUID', :facts => { :key => 'value' } }
39
51
 
@@ -4,7 +4,7 @@ require 'rspec/mocks'
4
4
 
5
5
  noop = lambda {|env|}
6
6
 
7
- config = Inventory::Server::Config::DEFAULTS
7
+ config = Inventory::Server::Config::defaults
8
8
 
9
9
  RSpec.describe Inventory::Server::JsonSchemaValidator, '#call' do
10
10
 
@@ -3,7 +3,7 @@ require 'inventory/server/loader'
3
3
  RSpec.describe Inventory::Server::Loader do
4
4
 
5
5
  context "without plugin_path" do
6
- loader = Inventory::Server::Loader.new(Inventory::Server::Config::DEFAULTS)
6
+ loader = Inventory::Server::Loader.new(Inventory::Server::Config::defaults)
7
7
 
8
8
  it "should throw an error when loading non existing plugins" do
9
9
  expect {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inventory-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Filirom1
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-01 00:00:00.000000000 Z
11
+ date: 2015-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: midi-smtp-server
@@ -94,20 +94,6 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.8'
97
- - !ruby/object:Gem::Dependency
98
- name: activesupport
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '4.2'
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '4.2'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: libxml-to-hash
113
99
  requirement: !ruby/object:Gem::Requirement
@@ -136,20 +122,6 @@ dependencies:
136
122
  - - "~>"
137
123
  - !ruby/object:Gem::Version
138
124
  version: '0.1'
139
- - !ruby/object:Gem::Dependency
140
- name: app_configuration
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '0.0'
146
- type: :runtime
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '0.0'
153
125
  - !ruby/object:Gem::Dependency
154
126
  name: sinatra
155
127
  requirement: !ruby/object:Gem::Requirement
@@ -210,16 +182,16 @@ dependencies:
210
182
  name: bundler
211
183
  requirement: !ruby/object:Gem::Requirement
212
184
  requirements:
213
- - - "~>"
185
+ - - ">="
214
186
  - !ruby/object:Gem::Version
215
- version: '1.7'
187
+ version: '0'
216
188
  type: :development
217
189
  prerelease: false
218
190
  version_requirements: !ruby/object:Gem::Requirement
219
191
  requirements:
220
- - - "~>"
192
+ - - ">="
221
193
  - !ruby/object:Gem::Version
222
- version: '1.7'
194
+ version: '0'
223
195
  - !ruby/object:Gem::Dependency
224
196
  name: rake
225
197
  requirement: !ruby/object:Gem::Requirement
@@ -304,20 +276,6 @@ dependencies:
304
276
  - - "~>"
305
277
  - !ruby/object:Gem::Version
306
278
  version: '1.20'
307
- - !ruby/object:Gem::Dependency
308
- name: thin
309
- requirement: !ruby/object:Gem::Requirement
310
- requirements:
311
- - - "~>"
312
- - !ruby/object:Gem::Version
313
- version: '1.6'
314
- type: :development
315
- prerelease: false
316
- version_requirements: !ruby/object:Gem::Requirement
317
- requirements:
318
- - - "~>"
319
- - !ruby/object:Gem::Version
320
- version: '1.6'
321
279
  - !ruby/object:Gem::Dependency
322
280
  name: parallel
323
281
  requirement: !ruby/object:Gem::Requirement
@@ -336,7 +294,7 @@ description: Inventory server store and index data sent from the agent
336
294
  email:
337
295
  - filirom1@gmail.com
338
296
  executables:
339
- - inventory-server
297
+ - inventory-smtpd
340
298
  extensions: []
341
299
  extra_rdoc_files: []
342
300
  files:
@@ -350,9 +308,10 @@ files:
350
308
  - LICENSE.txt
351
309
  - README.md
352
310
  - Rakefile
353
- - bin/inventory-server
311
+ - bin/inventory-smtpd
354
312
  - circle.yml
355
313
  - config.ru
314
+ - config/inventory.yml
356
315
  - docker/passenger/passenger.conf
357
316
  - docker/passenger/run-httpd.sh
358
317
  - docker/unicorn/nginx.conf
@@ -375,6 +334,7 @@ files:
375
334
  - plugins/index.rb
376
335
  - plugins/json_schema_validator.rb
377
336
  - plugins/log_failures_on_disk.rb
337
+ - plugins/sample.rb
378
338
  - public/.gitignore
379
339
  - spec/integration/fixtures/facter.xml
380
340
  - spec/integration/http_spec.rb
@@ -392,7 +352,7 @@ files:
392
352
  - spec/unit/server_spec.rb
393
353
  - spec/unit/smtp_server_spec.rb
394
354
  - tmp/.gitignore
395
- homepage: ''
355
+ homepage: https://github.com/Filirom1/inventory
396
356
  licenses:
397
357
  - MIT
398
358
  metadata: {}