broham 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -64,6 +64,13 @@ h4. Commandline Interface
64
64
  $ broham-unregister-all chad nfs_server
65
65
  Removing nfs_server from chad cluster
66
66
  {"timestamp":["20100405093238"],"fqdn":["nfs.infochimps.org"],"client_path":["/home"],"server_path":["/home"],"role":["nfs_server"],"private_ip":["10.123.156.231"],"default_ip":["10.123.156.231"],"public_ip":["104.136.251.50"]}
67
+
68
+ # Alternative interface:
69
+ broham-sup host # show host
70
+ broham-sup_yall hosts # show all hosts matching the given (start-of-string-anchored) regex
71
+ broham-yo host # register as given host
72
+ broham-diss host # unregister given host
73
+ broham-fuck_all_yall hosts_re # unregister all hosts matching the given (start-of-string-anchored) regex
67
74
  </code></pre>
68
75
 
69
76
  h4. IRB Usage
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.9
1
+ 0.0.10
data/bin/broham CHANGED
@@ -3,13 +3,132 @@ require 'rubygems'
3
3
  require 'broham'
4
4
  require 'broham/script'
5
5
 
6
- Broham.get_cluster_settings
7
- Broham.get_command_line_args :command, :role_name
8
- role_name = Settings[:role_name]
6
+ [
7
+ # ['sup', '', '(alias for hosts)'],
8
+ # ['yo', '', '(alias for register)'],
9
+ # ['diss', '', '(alias for unregister)'],
10
+ # ['fuck_all_yall', '', '(alias for unregister_like)'],
11
+ # ['word', '', '(alias for get)'],
12
+ #
13
+ ['hosts', 'role_pattern', 'Unregister all hosts prefixed by role_pattern'],
14
+ ['register', 'role [--extra_param=val...]', 'Registers this machine for the given role; stuff in any leftover params'],
15
+ ['unregister', 'role', 'Unregister that role'],
16
+ ['unregister_like', 'role_pattern', 'Unregister all hosts prefixed by role_pattern'],
17
+ ['get', 'role_pattern attr', 'show attr for all hosts prefixed by role_pattern']
18
+ ].each{|cmd| Configliere::COMMANDS << cmd }
9
19
 
20
+ class BrohamScript
21
+ attr_accessor :role_name, :attr
22
+ def command() Settings.command ; end
23
+ def role_name() Settings[:role_name] ; end
24
+ def attr() Settings[:attr] ; end
25
+
26
+ def hosts_cmd
27
+ BrohamScript.get_commandline_predicates :role_name
28
+ $stderr.puts %Q{Listing hosts like #{role_name}}
29
+ dump_table Broham.hosts_like(role_name)
30
+ end
31
+
32
+ def register_cmd
33
+ # Settings.define :set, :description => %Q{Any arg prefixed with "--set" will become an extra arg to register: 'broham-register foo --set-path=/path/to/foo' sets :path => '/path/to/foo' as an additional attribute}, :type => Hash
34
+ broham_args = Settings[:set]||{}
35
+ BrohamScript.get_commandline_predicates :role_name
36
+ $stderr.puts %Q{Registering #{role_name} -- #{broham_args}}
37
+ new_bro = Broham.register(role_name)
38
+ dump_table [new_bro]
39
+ end
40
+
41
+ def register_as_next_cmd
42
+ # Settings.define :set, :description => %Q{Any arg prefixed with "--set" will become an extra arg to register: 'broham-register foo --set-path=/path/to/foo' sets :path => '/path/to/foo' as an additional attribute}, :type => Hash
43
+ broham_args = Settings[:set]||{}
44
+ BrohamScript.get_commandline_predicates :role_name
45
+ $stderr.puts %Q{Registering #{role_name} -- #{broham_args}}
46
+ new_bro = Broham.register_as_next(role_name)
47
+ dump_table [new_bro]
48
+ end
49
+
50
+ def unregister_cmd
51
+ BrohamScript.get_commandline_predicates :role_name
52
+ $stderr.puts %Q{Unregistering #{role_name}}
53
+ dead_bro = Broham.unregister(role_name)
54
+ dump_table [dead_bro]
55
+ end
56
+
57
+ def unregister_like_cmd
58
+ BrohamScript.get_commandline_predicates :role_name
59
+ $stderr.puts %Q{Unregistering all hosts like #{role_name}}
60
+ dump_table Broham.unregister_like role_name
61
+ end
62
+
63
+ def get_cmd
64
+ BrohamScript.get_commandline_predicates :role_name, :attr
65
+ $stderr.puts %Q{Getting #{attr} for hosts like #{role_name}}
66
+ Broham.hosts_like(role_name).map do |bro|
67
+ $stdout.puts bro[attr]
68
+ end
69
+ end
70
+
71
+ def run
72
+ case Settings.command.to_s
73
+ when 'hosts', 'sup'
74
+ hosts_cmd
75
+ when 'register', 'yo'
76
+ register_cmd
77
+ when 'unregister', 'diss'
78
+ unregister_cmd
79
+ when 'unregister_like', 'fuck_all_yall'
80
+ unregister_like_cmd
81
+ when 'get', 'word'
82
+ get_cmd
83
+ when ''
84
+ Settings.die "Please use one of the commands listed above"
85
+ else
86
+ Settings.die "Don't know how to run command #{command}"
87
+ end
88
+ end
89
+
90
+ protected
91
+
92
+ # Dump a list of hashes as a formatted, equally-spaced table
93
+ def dump_table hosts_list
94
+ attr_lens = {}
95
+ # find all used fields, and their width
96
+ hosts_list.each do |host|
97
+ host.to_hash.each{|k,v| attr_lens[k] = [v.to_s.length, attr_lens[k].to_i].max }
98
+ end
99
+ # account for length of attr titles
100
+ attr_lens.each{|attr,len| attr_lens[attr] = [len, attr.length].max }
101
+ # take attrs in order, putting role first (and excluding id)
102
+ attrs = ['role', (attr_lens.keys - ['role', 'id']).sort].flatten
103
+ $stderr.puts attrs.map{|attr| "%-#{attr_lens[attr]}s"%attr}.join("\t")
104
+ hosts_list.each do |host|
105
+ $stdout.puts attrs.map{|attr| "%-#{attr_lens[attr]}s"%host[attr]}.join("\t")
106
+ end
107
+ end
108
+
109
+ # Loads defaults
110
+ def self.get_cluster_settings
111
+ Settings.read(ENV['HOME']+'/.poolparty/poolparty.yaml')
112
+ Settings.resolve!
113
+ Broham.establish_connection
114
+ end
115
+
116
+ # takes a list of attributes and pops each, in turn, from the commandline
117
+ # (the Settings.rest list)
118
+ def self.get_commandline_predicates *arg_names
119
+ arg_names.each do |arg_name|
120
+ Settings[arg_name] = Settings.rest.shift
121
+ end
122
+ check_args! *arg_names
123
+ end
124
+
125
+ #
126
+ def self.check_args! *arg_names
127
+ arg = arg_names.last
128
+ if Settings[arg].blank? then Settings.die "ERROR: Please supply #{arg_names.join(", ")} after the command." end
129
+ end
10
130
 
11
- case Settings[:command].to_s
12
- when 'public_ips' then puts Broham.hosts_like(role_name).map{|bro| bro[:public_ip]}.join("\n")
13
- else raise "Bad command #{Settings[:command]}"
14
131
  end
15
132
 
133
+ BrohamScript.get_cluster_settings
134
+ BrohamScript.new.run
@@ -3,11 +3,132 @@ require 'rubygems'
3
3
  require 'broham'
4
4
  require 'broham/script'
5
5
 
6
- Broham.get_cluster_settings
7
- Broham.get_command_line_args :role_name
8
- role_name = Settings[:role_name]
6
+ [
7
+ # ['sup', '', '(alias for hosts)'],
8
+ # ['yo', '', '(alias for register)'],
9
+ # ['diss', '', '(alias for unregister)'],
10
+ # ['fuck_all_yall', '', '(alias for unregister_like)'],
11
+ # ['word', '', '(alias for get)'],
12
+ #
13
+ ['hosts', 'role_pattern', 'Unregister all hosts prefixed by role_pattern'],
14
+ ['register', 'role [--extra_param=val...]', 'Registers this machine for the given role; stuff in any leftover params'],
15
+ ['unregister', 'role', 'Unregister that role'],
16
+ ['unregister_like', 'role_pattern', 'Unregister all hosts prefixed by role_pattern'],
17
+ ['get', 'role_pattern attr', 'show attr for all hosts prefixed by role_pattern']
18
+ ].each{|cmd| Configliere::COMMANDS << cmd }
9
19
 
10
- $stderr.puts %Q{Removing #{role_name}}
11
- resps = Broham.unregister role_name
12
- $stderr.puts resps.map{|resp| resp.to_pretty_json }
20
+ class BrohamScript
21
+ attr_accessor :role_name, :attr
22
+ def command() Settings.command ; end
23
+ def role_name() Settings[:role_name] ; end
24
+ def attr() Settings[:attr] ; end
13
25
 
26
+ def hosts_cmd
27
+ BrohamScript.get_commandline_predicates :role_name
28
+ $stderr.puts %Q{Listing hosts like #{role_name}}
29
+ dump_table Broham.hosts_like(role_name)
30
+ end
31
+
32
+ def register_cmd
33
+ # Settings.define :set, :description => %Q{Any arg prefixed with "--set" will become an extra arg to register: 'broham-register foo --set-path=/path/to/foo' sets :path => '/path/to/foo' as an additional attribute}, :type => Hash
34
+ broham_args = Settings[:set]||{}
35
+ BrohamScript.get_commandline_predicates :role_name
36
+ $stderr.puts %Q{Registering #{role_name} -- #{broham_args}}
37
+ new_bro = Broham.register(role_name)
38
+ dump_table [new_bro]
39
+ end
40
+
41
+ def register_as_next_cmd
42
+ # Settings.define :set, :description => %Q{Any arg prefixed with "--set" will become an extra arg to register: 'broham-register foo --set-path=/path/to/foo' sets :path => '/path/to/foo' as an additional attribute}, :type => Hash
43
+ broham_args = Settings[:set]||{}
44
+ BrohamScript.get_commandline_predicates :role_name
45
+ $stderr.puts %Q{Registering #{role_name} -- #{broham_args}}
46
+ new_bro = Broham.register_as_next(role_name)
47
+ dump_table [new_bro]
48
+ end
49
+
50
+ def unregister_cmd
51
+ BrohamScript.get_commandline_predicates :role_name
52
+ $stderr.puts %Q{Unregistering #{role_name}}
53
+ dead_bro = Broham.unregister(role_name)
54
+ dump_table [dead_bro]
55
+ end
56
+
57
+ def unregister_like_cmd
58
+ BrohamScript.get_commandline_predicates :role_name
59
+ $stderr.puts %Q{Unregistering all hosts like #{role_name}}
60
+ dump_table Broham.unregister_like role_name
61
+ end
62
+
63
+ def get_cmd
64
+ BrohamScript.get_commandline_predicates :role_name, :attr
65
+ $stderr.puts %Q{Getting #{attr} for hosts like #{role_name}}
66
+ Broham.hosts_like(role_name).map do |bro|
67
+ $stdout.puts bro[attr]
68
+ end
69
+ end
70
+
71
+ def run
72
+ case Settings.command.to_s
73
+ when 'hosts', 'sup'
74
+ hosts_cmd
75
+ when 'register', 'yo'
76
+ register_cmd
77
+ when 'unregister', 'diss'
78
+ unregister_cmd
79
+ when 'unregister_like', 'fuck_all_yall'
80
+ unregister_like_cmd
81
+ when 'get', 'word'
82
+ get_cmd
83
+ when ''
84
+ Settings.die "Please use one of the commands listed above"
85
+ else
86
+ Settings.die "Don't know how to run command #{command}"
87
+ end
88
+ end
89
+
90
+ protected
91
+
92
+ # Dump a list of hashes as a formatted, equally-spaced table
93
+ def dump_table hosts_list
94
+ attr_lens = {}
95
+ # find all used fields, and their width
96
+ hosts_list.each do |host|
97
+ host.to_hash.each{|k,v| attr_lens[k] = [v.to_s.length, attr_lens[k].to_i].max }
98
+ end
99
+ # account for length of attr titles
100
+ attr_lens.each{|attr,len| attr_lens[attr] = [len, attr.length].max }
101
+ # take attrs in order, putting role first (and excluding id)
102
+ attrs = ['role', (attr_lens.keys - ['role', 'id']).sort].flatten
103
+ $stderr.puts attrs.map{|attr| "%-#{attr_lens[attr]}s"%attr}.join("\t")
104
+ hosts_list.each do |host|
105
+ $stdout.puts attrs.map{|attr| "%-#{attr_lens[attr]}s"%host[attr]}.join("\t")
106
+ end
107
+ end
108
+
109
+ # Loads defaults
110
+ def self.get_cluster_settings
111
+ Settings.read(ENV['HOME']+'/.poolparty/poolparty.yaml')
112
+ Settings.resolve!
113
+ Broham.establish_connection
114
+ end
115
+
116
+ # takes a list of attributes and pops each, in turn, from the commandline
117
+ # (the Settings.rest list)
118
+ def self.get_commandline_predicates *arg_names
119
+ arg_names.each do |arg_name|
120
+ Settings[arg_name] = Settings.rest.shift
121
+ end
122
+ check_args! *arg_names
123
+ end
124
+
125
+ #
126
+ def self.check_args! *arg_names
127
+ arg = arg_names.last
128
+ if Settings[arg].blank? then Settings.die "ERROR: Please supply #{arg_names.join(", ")} after the command." end
129
+ end
130
+
131
+ end
132
+
133
+ BrohamScript.get_cluster_settings
134
+ BrohamScript.new.run
@@ -3,11 +3,132 @@ require 'rubygems'
3
3
  require 'broham'
4
4
  require 'broham/script'
5
5
 
6
- Broham.get_cluster_settings
7
- Broham.get_command_line_args :role_name
8
- role_name = Settings[:role_name]
6
+ [
7
+ # ['sup', '', '(alias for hosts)'],
8
+ # ['yo', '', '(alias for register)'],
9
+ # ['diss', '', '(alias for unregister)'],
10
+ # ['fuck_all_yall', '', '(alias for unregister_like)'],
11
+ # ['word', '', '(alias for get)'],
12
+ #
13
+ ['hosts', 'role_pattern', 'Unregister all hosts prefixed by role_pattern'],
14
+ ['register', 'role [--extra_param=val...]', 'Registers this machine for the given role; stuff in any leftover params'],
15
+ ['unregister', 'role', 'Unregister that role'],
16
+ ['unregister_like', 'role_pattern', 'Unregister all hosts prefixed by role_pattern'],
17
+ ['get', 'role_pattern attr', 'show attr for all hosts prefixed by role_pattern']
18
+ ].each{|cmd| Configliere::COMMANDS << cmd }
9
19
 
10
- $stderr.puts %Q{Removing all like #{role_name}}
11
- resps = Broham.unregister_like role_name
12
- $stderr.puts resps.map{|resp| resp.to_pretty_json }
20
+ class BrohamScript
21
+ attr_accessor :role_name, :attr
22
+ def command() Settings.command ; end
23
+ def role_name() Settings[:role_name] ; end
24
+ def attr() Settings[:attr] ; end
13
25
 
26
+ def hosts_cmd
27
+ BrohamScript.get_commandline_predicates :role_name
28
+ $stderr.puts %Q{Listing hosts like #{role_name}}
29
+ dump_table Broham.hosts_like(role_name)
30
+ end
31
+
32
+ def register_cmd
33
+ # Settings.define :set, :description => %Q{Any arg prefixed with "--set" will become an extra arg to register: 'broham-register foo --set-path=/path/to/foo' sets :path => '/path/to/foo' as an additional attribute}, :type => Hash
34
+ broham_args = Settings[:set]||{}
35
+ BrohamScript.get_commandline_predicates :role_name
36
+ $stderr.puts %Q{Registering #{role_name} -- #{broham_args}}
37
+ new_bro = Broham.register(role_name)
38
+ dump_table [new_bro]
39
+ end
40
+
41
+ def register_as_next_cmd
42
+ # Settings.define :set, :description => %Q{Any arg prefixed with "--set" will become an extra arg to register: 'broham-register foo --set-path=/path/to/foo' sets :path => '/path/to/foo' as an additional attribute}, :type => Hash
43
+ broham_args = Settings[:set]||{}
44
+ BrohamScript.get_commandline_predicates :role_name
45
+ $stderr.puts %Q{Registering #{role_name} -- #{broham_args}}
46
+ new_bro = Broham.register_as_next(role_name)
47
+ dump_table [new_bro]
48
+ end
49
+
50
+ def unregister_cmd
51
+ BrohamScript.get_commandline_predicates :role_name
52
+ $stderr.puts %Q{Unregistering #{role_name}}
53
+ dead_bro = Broham.unregister(role_name)
54
+ dump_table [dead_bro]
55
+ end
56
+
57
+ def unregister_like_cmd
58
+ BrohamScript.get_commandline_predicates :role_name
59
+ $stderr.puts %Q{Unregistering all hosts like #{role_name}}
60
+ dump_table Broham.unregister_like role_name
61
+ end
62
+
63
+ def get_cmd
64
+ BrohamScript.get_commandline_predicates :role_name, :attr
65
+ $stderr.puts %Q{Getting #{attr} for hosts like #{role_name}}
66
+ Broham.hosts_like(role_name).map do |bro|
67
+ $stdout.puts bro[attr]
68
+ end
69
+ end
70
+
71
+ def run
72
+ case Settings.command.to_s
73
+ when 'hosts', 'sup'
74
+ hosts_cmd
75
+ when 'register', 'yo'
76
+ register_cmd
77
+ when 'unregister', 'diss'
78
+ unregister_cmd
79
+ when 'unregister_like', 'fuck_all_yall'
80
+ unregister_like_cmd
81
+ when 'get', 'word'
82
+ get_cmd
83
+ when ''
84
+ Settings.die "Please use one of the commands listed above"
85
+ else
86
+ Settings.die "Don't know how to run command #{command}"
87
+ end
88
+ end
89
+
90
+ protected
91
+
92
+ # Dump a list of hashes as a formatted, equally-spaced table
93
+ def dump_table hosts_list
94
+ attr_lens = {}
95
+ # find all used fields, and their width
96
+ hosts_list.each do |host|
97
+ host.to_hash.each{|k,v| attr_lens[k] = [v.to_s.length, attr_lens[k].to_i].max }
98
+ end
99
+ # account for length of attr titles
100
+ attr_lens.each{|attr,len| attr_lens[attr] = [len, attr.length].max }
101
+ # take attrs in order, putting role first (and excluding id)
102
+ attrs = ['role', (attr_lens.keys - ['role', 'id']).sort].flatten
103
+ $stderr.puts attrs.map{|attr| "%-#{attr_lens[attr]}s"%attr}.join("\t")
104
+ hosts_list.each do |host|
105
+ $stdout.puts attrs.map{|attr| "%-#{attr_lens[attr]}s"%host[attr]}.join("\t")
106
+ end
107
+ end
108
+
109
+ # Loads defaults
110
+ def self.get_cluster_settings
111
+ Settings.read(ENV['HOME']+'/.poolparty/poolparty.yaml')
112
+ Settings.resolve!
113
+ Broham.establish_connection
114
+ end
115
+
116
+ # takes a list of attributes and pops each, in turn, from the commandline
117
+ # (the Settings.rest list)
118
+ def self.get_commandline_predicates *arg_names
119
+ arg_names.each do |arg_name|
120
+ Settings[arg_name] = Settings.rest.shift
121
+ end
122
+ check_args! *arg_names
123
+ end
124
+
125
+ #
126
+ def self.check_args! *arg_names
127
+ arg = arg_names.last
128
+ if Settings[arg].blank? then Settings.die "ERROR: Please supply #{arg_names.join(", ")} after the command." end
129
+ end
130
+
131
+ end
132
+
133
+ BrohamScript.get_cluster_settings
134
+ BrohamScript.new.run
@@ -0,0 +1,134 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'broham'
4
+ require 'broham/script'
5
+
6
+ [
7
+ # ['sup', '', '(alias for hosts)'],
8
+ # ['yo', '', '(alias for register)'],
9
+ # ['diss', '', '(alias for unregister)'],
10
+ # ['fuck_all_yall', '', '(alias for unregister_like)'],
11
+ # ['word', '', '(alias for get)'],
12
+ #
13
+ ['hosts', 'role_pattern', 'Unregister all hosts prefixed by role_pattern'],
14
+ ['register', 'role [--extra_param=val...]', 'Registers this machine for the given role; stuff in any leftover params'],
15
+ ['unregister', 'role', 'Unregister that role'],
16
+ ['unregister_like', 'role_pattern', 'Unregister all hosts prefixed by role_pattern'],
17
+ ['get', 'role_pattern attr', 'show attr for all hosts prefixed by role_pattern']
18
+ ].each{|cmd| Configliere::COMMANDS << cmd }
19
+
20
+ class BrohamScript
21
+ attr_accessor :role_name, :attr
22
+ def command() Settings.command ; end
23
+ def role_name() Settings[:role_name] ; end
24
+ def attr() Settings[:attr] ; end
25
+
26
+ def hosts_cmd
27
+ BrohamScript.get_commandline_predicates :role_name
28
+ $stderr.puts %Q{Listing hosts like #{role_name}}
29
+ dump_table Broham.hosts_like(role_name)
30
+ end
31
+
32
+ def register_cmd
33
+ # Settings.define :set, :description => %Q{Any arg prefixed with "--set" will become an extra arg to register: 'broham-register foo --set-path=/path/to/foo' sets :path => '/path/to/foo' as an additional attribute}, :type => Hash
34
+ broham_args = Settings[:set]||{}
35
+ BrohamScript.get_commandline_predicates :role_name
36
+ $stderr.puts %Q{Registering #{role_name} -- #{broham_args}}
37
+ new_bro = Broham.register(role_name)
38
+ dump_table [new_bro]
39
+ end
40
+
41
+ def register_as_next_cmd
42
+ # Settings.define :set, :description => %Q{Any arg prefixed with "--set" will become an extra arg to register: 'broham-register foo --set-path=/path/to/foo' sets :path => '/path/to/foo' as an additional attribute}, :type => Hash
43
+ broham_args = Settings[:set]||{}
44
+ BrohamScript.get_commandline_predicates :role_name
45
+ $stderr.puts %Q{Registering #{role_name} -- #{broham_args}}
46
+ new_bro = Broham.register_as_next(role_name)
47
+ dump_table [new_bro]
48
+ end
49
+
50
+ def unregister_cmd
51
+ BrohamScript.get_commandline_predicates :role_name
52
+ $stderr.puts %Q{Unregistering #{role_name}}
53
+ dead_bro = Broham.unregister(role_name)
54
+ dump_table [dead_bro]
55
+ end
56
+
57
+ def unregister_like_cmd
58
+ BrohamScript.get_commandline_predicates :role_name
59
+ $stderr.puts %Q{Unregistering all hosts like #{role_name}}
60
+ dump_table Broham.unregister_like role_name
61
+ end
62
+
63
+ def get_cmd
64
+ BrohamScript.get_commandline_predicates :role_name, :attr
65
+ $stderr.puts %Q{Getting #{attr} for hosts like #{role_name}}
66
+ Broham.hosts_like(role_name).map do |bro|
67
+ $stdout.puts bro[attr]
68
+ end
69
+ end
70
+
71
+ def run
72
+ case Settings.command.to_s
73
+ when 'hosts', 'sup'
74
+ hosts_cmd
75
+ when 'register', 'yo'
76
+ register_cmd
77
+ when 'unregister', 'diss'
78
+ unregister_cmd
79
+ when 'unregister_like', 'fuck_all_yall'
80
+ unregister_like_cmd
81
+ when 'get', 'word'
82
+ get_cmd
83
+ when ''
84
+ Settings.die "Please use one of the commands listed above"
85
+ else
86
+ Settings.die "Don't know how to run command #{command}"
87
+ end
88
+ end
89
+
90
+ protected
91
+
92
+ # Dump a list of hashes as a formatted, equally-spaced table
93
+ def dump_table hosts_list
94
+ attr_lens = {}
95
+ # find all used fields, and their width
96
+ hosts_list.each do |host|
97
+ host.to_hash.each{|k,v| attr_lens[k] = [v.to_s.length, attr_lens[k].to_i].max }
98
+ end
99
+ # account for length of attr titles
100
+ attr_lens.each{|attr,len| attr_lens[attr] = [len, attr.length].max }
101
+ # take attrs in order, putting role first (and excluding id)
102
+ attrs = ['role', (attr_lens.keys - ['role', 'id']).sort].flatten
103
+ $stderr.puts attrs.map{|attr| "%-#{attr_lens[attr]}s"%attr}.join("\t")
104
+ hosts_list.each do |host|
105
+ $stdout.puts attrs.map{|attr| "%-#{attr_lens[attr]}s"%host[attr]}.join("\t")
106
+ end
107
+ end
108
+
109
+ # Loads defaults
110
+ def self.get_cluster_settings
111
+ Settings.read(ENV['HOME']+'/.poolparty/poolparty.yaml')
112
+ Settings.resolve!
113
+ Broham.establish_connection
114
+ end
115
+
116
+ # takes a list of attributes and pops each, in turn, from the commandline
117
+ # (the Settings.rest list)
118
+ def self.get_commandline_predicates *arg_names
119
+ arg_names.each do |arg_name|
120
+ Settings[arg_name] = Settings.rest.shift
121
+ end
122
+ check_args! *arg_names
123
+ end
124
+
125
+ #
126
+ def self.check_args! *arg_names
127
+ arg = arg_names.last
128
+ if Settings[arg].blank? then Settings.die "ERROR: Please supply #{arg_names.join(", ")} after the command." end
129
+ end
130
+
131
+ end
132
+
133
+ BrohamScript.get_cluster_settings
134
+ BrohamScript.new.run