classify_cluster 0.3.9 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,13 @@
1
1
  module ClassifyCluster
2
2
  class Base
3
3
  def self.default_config_file
4
- File.join('/etc', 'cluster.rb')
4
+ cluster_rb = File.join('/etc', 'cluster.rb')
5
+ cluster_yml = File.join('/etc', 'cluster.yml')
6
+ if !File.exists?(cluster_rb) && File.exists?(cluster_yml)
7
+ cluster_yml
8
+ else
9
+ cluster_rb
10
+ end
5
11
  end
6
12
  end
7
13
  end
@@ -1,10 +1,42 @@
1
+ require 'yaml'
1
2
  module ClassifyCluster
2
3
  module Configurator
3
4
  class Configuration
4
5
  attr_reader :clusters
5
6
  def initialize(config_path)
6
7
  @clusters = {}
7
- eval File.open(config_path).read
8
+ case File.extname(config_path)
9
+ when ".rb"
10
+ eval File.open(config_path).read
11
+ when ".yml"
12
+ config = YAML.load_file(config_path)
13
+ config.each_pair do |cluster_name, cluster_values|
14
+ cluster(cluster_name) do |cluster|
15
+ cluster_values['klasses'].each do |klass|
16
+ cluster.klass klass
17
+ end
18
+ cluster_values['variables'].each_pair do |variable_name, variable_value|
19
+ cluster.variable variable_name, variable_value
20
+ end
21
+ cluster_values['nodes'].each do |node_values|
22
+ cluster.node(node_values['hostname'], node_values['ip_address']) do |node|
23
+ node_values['roles'].each_pair do |role_name, role_values|
24
+ options={}
25
+ options['primary'] = true if role_values.delete('primary')
26
+ options['backup'] = true if role_values.delete('backup')
27
+ options['master'] = true if role_values.delete('master')
28
+ options['node'] = true if role_values.delete('node')
29
+ node.role(role_name, options) do |role|
30
+ role_values.each_pair do |role_value_name, role_value|
31
+ role.variable role_value_name, role_value
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
8
40
  end
9
41
 
10
42
  def cluster(cluster_name, &block)
@@ -1,3 +1,3 @@
1
1
  module ClassifyCluster
2
- VERSION = "0.3.9"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -47,7 +47,7 @@ module ClassifyCluster
47
47
  end
48
48
  private
49
49
  def self.output(string, options={})
50
- options.reverse_merge! :indent => 0
50
+ options = {:indent => 0}.merge(options)
51
51
  %Q%#{("\s" * 2) * options[:indent]}#{string}\n%
52
52
  end
53
53
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: classify_cluster
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 3
9
- - 9
10
- version: 0.3.9
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sean Cashin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-08 00:00:00 -08:00
18
+ date: 2011-03-15 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency