onering-client 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,8 @@ require 'rainbow'
6
6
  require 'pp'
7
7
 
8
8
  plugins = Onering::CLI.submodules.collect{|i| i.name.split('::').last.downcase }
9
+ exclude_plugins = %w{devices}
10
+
9
11
  global = Trollop::options do
10
12
  banner <<-EOS
11
13
  onering command line client utility - version #{Onering::Client::VERSION}
@@ -13,6 +15,9 @@ onering command line client utility - version #{Onering::Client::VERSION}
13
15
  Usage:
14
16
  onering [global] [plugin] [subcommand] [options]
15
17
 
18
+ Plugins (onering <plugin> --help for usage details):
19
+ #{(plugins - exclude_plugins).sort.join(', ')}
20
+
16
21
  where [global] options are:
17
22
  EOS
18
23
 
@@ -25,6 +30,7 @@ EOS
25
30
  opt :nosslverify, "Disable verification of the server SSL certificate", :type => :boolean
26
31
  opt :apikey, "The API token to use for authentication", :short => '-k', :type => :string
27
32
  opt :quiet, "Suppress standard output", :short => '-q'
33
+ opt :separator, "A string used to separate output values of delimited tabular data", :short => '-S', :default => "\t"
28
34
  opt :verbosity, "Set the log level (fatal, error, warn, info, debug)", :short => '-v', :type => :string, :default => 'warn'
29
35
 
30
36
  stop_on plugins
@@ -2,7 +2,7 @@ $: << File.expand_path(File.dirname(__FILE__))
2
2
 
3
3
  module Onering
4
4
  module Client
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.3"
6
6
 
7
7
  class Error < Exception; end
8
8
  class FatalError < Error; end
@@ -26,15 +26,20 @@ module Onering
26
26
 
27
27
  def self.output(data, format)
28
28
  return nil if @_args[:quiet]
29
+ return nil if data.nil?
29
30
 
30
31
  Onering::Logger.debug("Outputting data as #{format}:", "Onering::CLI")
31
32
 
32
33
  case format
33
- when 'text'
34
+ when 'text', 'txt'
34
35
  if data.is_a?(Hash)
35
36
  data.coalesce.each do |k,v|
36
37
  puts k.to_s+': '+v.to_s
37
38
  end
39
+
40
+ elsif data.is_a?(Array) and data.first.is_a?(Array)
41
+ puts data.collect{|i| i.map(&:to_s).join(@_args.get(:separator, "\t")) }.sort.join("\n")
42
+
38
43
  else
39
44
  [*data].each do |d|
40
45
  if d.is_a?(Hash)
@@ -48,7 +53,7 @@ module Onering
48
53
  end
49
54
 
50
55
  when 'json'
51
- puts MultiJson.dump(data)
56
+ puts MultiJson.dump(data, :pretty => true)
52
57
 
53
58
  when 'yaml'
54
59
  puts YAML.dump(data)
@@ -57,7 +62,7 @@ module Onering
57
62
  Onering::Logger.error("Unknown output format #{format.inspect}", "Onering::CLI")
58
63
  end
59
64
 
60
- nil
65
+ return nil
61
66
  end
62
67
  end
63
68
  end
@@ -0,0 +1,106 @@
1
+ module Onering
2
+ module CLI
3
+ module Assets
4
+ def self.configure(global={})
5
+ @api = Onering::CLI.connect(global).assets
6
+
7
+ @opts = ::Trollop::options do
8
+ banner <<-EOS
9
+ Search for, manipulate, and list values from one or more Onering assets.
10
+
11
+ Usage:
12
+ onering [global] assets [options] [subcommands]
13
+
14
+ Subcommands:
15
+ find <urlquery>
16
+ get <property> [property2 ..]
17
+ list <property> [property2 ..]
18
+ save
19
+ set <property> <value>
20
+ show <
21
+
22
+ Options:
23
+ EOS
24
+
25
+ opt :query, "The Onering urlquery to filter devices by", :short => '-f', :type => :string
26
+ opt :id, "The node ID of the device to operate on", :short => '-i', :type => :string
27
+
28
+ # subcommands
29
+ stop_on %w{show get set list find save}
30
+ end
31
+ end
32
+
33
+ def self.run(args)
34
+ sc = args.shift
35
+
36
+ case (sc.downcase.to_sym rescue nil)
37
+ # -----------------------------------------------------------------------------
38
+ when :show
39
+ return @api.assets.show(args[0])
40
+
41
+ # -----------------------------------------------------------------------------
42
+ when :get
43
+ Onering::Logger.fatal!("Expected 1 parameter, got #{args.length}", "Onering::CLI::Devices") unless args.length == 1
44
+
45
+ if @opts[:query_given]
46
+ # doing this until a bulk field query endpoint is built
47
+ return @api.list('id', {
48
+ :filter => @opts[:query]
49
+ }).collect{|i| @api.get_field(i, args[0])}
50
+
51
+ elsif @opts[:id_given]
52
+ return @api.get_field(@opts[:id], args[0])
53
+
54
+ end
55
+
56
+ # -----------------------------------------------------------------------------
57
+ when :set
58
+ Onering::Logger.fatal!("Expected 2 parameters, got #{args.length}", "Onering::CLI::Devices") unless args.length == 2
59
+
60
+ if @opts[:query]
61
+ # doing this until a bulk field set endpoint is built
62
+ return @api.list('id', {
63
+ :filter => @opts[:query]
64
+ }).collect{|i| @api.set_field(i, args[0])}
65
+
66
+ elsif @opts[:id]
67
+ return @api.set_field(@opts[:id], args[0], args[1])
68
+
69
+ end
70
+
71
+ # -----------------------------------------------------------------------------
72
+ when :list
73
+ Onering::Logger.fatal!("Expected 1 parameter, got #{args.length}", "Onering::CLI::Devices") unless args.length >= 1
74
+ return @api.list(args, {
75
+ :filter => @opts[:query]
76
+ }.compact)
77
+
78
+ # -----------------------------------------------------------------------------
79
+ when :find
80
+ Onering::Logger.fatal!("Expected 1 parameter, got #{args.length}", "Onering::CLI::Devices") unless args.length == 1
81
+ return @api.find(args[0])
82
+
83
+ # -----------------------------------------------------------------------------
84
+ when :save
85
+ rv = @api.save(args[0] || @opts[:id]) do
86
+ # read from pipe
87
+ if not STDIN.tty?
88
+ STDIN.read()
89
+
90
+ # read from specified file
91
+ elsif (File.readable?(args[1]) rescue false)
92
+ File.read(args[1])
93
+
94
+ else
95
+ Onering::Logger.fatal!("Cannot save data, no input data specified", "Onering::CLI::Devices")
96
+ end
97
+ end
98
+
99
+ rv.parsed_response
100
+ else
101
+ Onering::Logger.fatal!("Unknown subcommand #{sc.inspect}", "Onering::CLI::Devices")
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
@@ -2,10 +2,15 @@ module Onering
2
2
  module CLI
3
3
  module Devices
4
4
  def self.configure(global={})
5
- @api = Onering::CLI.connect(global).devices
5
+ @api = Onering::CLI.connect(global).assets
6
6
 
7
7
  @opts = ::Trollop::options do
8
8
  banner <<-EOS
9
+ [DEPRECATED in 0.1.3] Use the 'assets' plugin from now on.
10
+
11
+ Usage:
12
+ onering [global] report [options]
13
+
9
14
  Options:
10
15
  EOS
11
16
 
@@ -1,7 +1,10 @@
1
1
  module Onering
2
2
  module CLI
3
3
  module Report
4
+ DEFAULT_CACHE_MAXAGE=600
5
+
4
6
  def self.configure(global={})
7
+
5
8
  @api = (Onering::CLI.connect(global.merge({
6
9
  :autoconnect => false
7
10
  })) rescue nil)
@@ -20,17 +23,82 @@ EOS
20
23
  opt :save, "Save the report output to the configured Onering server"
21
24
  opt :timeout, "The maximum amount of time to wait for a report to be generated", :type => :integer, :default => 60
22
25
  opt :plugin_timeout, "The maximum amount of time to wait for a report plugin to return data", :type => :integer, :default => 10
26
+ opt :local, "Do not attempt to contact a remote server for retrieving values not found locally", :type => :boolean, :default => false
27
+ opt :cachefile, "Use the specified file as a local report cache", :type => :string, :short => '-F'
28
+ opt :nocache, "Do not attempt to use a cache file for report generation", :type => :boolean, :default => false
29
+ opt :maxage, "Maxmimum age (in seconds) of the cache before it is automatically regenerated", :type => :integer, :default => DEFAULT_CACHE_MAXAGE
30
+
31
+ stop_on %w{get save}
23
32
  end
24
33
 
25
34
  # initialize report generator with user options
26
35
  Onering::Reporter.setup({
27
36
  :id => @opts[:id],
28
37
  :timeout => @opts[:timeout],
29
- :plugin_timeout => @opts[:plugin_timeout]
38
+ :plugin_timeout => @opts[:plugin_timeout],
39
+ :nocache => @opts[:nocache],
40
+ :cachefile => @opts[:cachefile],
41
+ :maxage => @opts[:maxage]
30
42
  }.compact)
31
43
  end
32
44
 
33
45
  def self.run(args)
46
+ report = _report()
47
+
48
+ # pull overrides from CLI arguments
49
+ @opts[:fields].each do |field|
50
+ key, value = field.split('=', 2)
51
+ Onering::Logger.debug("Override value #{key} from command line argument", "Onering::CLI::Report")
52
+
53
+ value = nil if ['null', '', '-'].include?(value.to_s.strip.chomp)
54
+ report = report.set(key, value)
55
+ end
56
+
57
+ # save if specified
58
+ if @opts[:save] === true
59
+ _save(report)
60
+
61
+ else
62
+ sc = args.shift
63
+
64
+ case (sc.downcase.to_sym rescue nil)
65
+ # -----------------------------------------------------------------------------
66
+ when :save
67
+ _save(report)
68
+ return nil
69
+
70
+ when :get
71
+ Onering::Logger.fatal!("Expected at least 1 parameter, got #{args.length}", "Onering::CLI::Devices") unless args.length >= 1
72
+
73
+ rv = report.get("properties.#{args[0]}", report.get(args[0], args[1]))
74
+
75
+ # attempt to get the value remotely if not found locally
76
+ if rv.nil? and not @opts[:local]
77
+ hid = Onering::Util.fact(:hardwareid)
78
+
79
+ if not hid.nil?
80
+ Onering::Logger.debug("Getting remote value #{args[0]} for asset #{hid}")
81
+ @api.connect()
82
+ return @api.assets.get_field(hid, args[0], args[1])
83
+ end
84
+ end
85
+
86
+ return rv
87
+ end
88
+ end
89
+
90
+ return report
91
+ end
92
+
93
+ private
94
+ def self._save(report)
95
+ @api.connect()
96
+ @api.assets.save(report['id']) do
97
+ MultiJson.dump(report)
98
+ end
99
+ end
100
+
101
+ def self._report()
34
102
  begin
35
103
  Onering::Logger.debug("Gathering local data for report", "Onering::CLI::Report")
36
104
  report = Onering::Reporter.report().stringify_keys()
@@ -50,24 +118,6 @@ EOS
50
118
  end
51
119
  end
52
120
 
53
- # pull overrides from CLI arguments
54
- @opts[:fields].each do |field|
55
- key, value = field.split('=', 2)
56
- Onering::Logger.debug("Override value #{key} from command line argument", "Onering::CLI::Report")
57
-
58
- value = nil if ['null', '', '-'].include?(value.to_s.strip.chomp)
59
- report = report.set(key, value)
60
- end
61
-
62
-
63
- # save if specified
64
- if @opts[:save] === true
65
- @api.connect()
66
- @api.devices.save(report['id']) do
67
- MultiJson.dump(report)
68
- end
69
- end
70
-
71
121
  return report
72
122
  rescue Timeout::Error
73
123
  Onering::Logger.fatal!("Report took too long to generate, exiting...", "Onering::CLI::Report")
@@ -1,13 +1,15 @@
1
1
  module Onering
2
2
  class API
3
- class Devices < API
3
+ class Assets < API
4
4
  def show(id)
5
5
  get("/devices/#{id}").parsed_response
6
6
  end
7
7
 
8
- def get_field(id, field)
8
+ def get_field(id, field, fallback=nil)
9
9
  rv = get("/devices/#{id}/get/#{field}")
10
- rv.parsed_response rescue rv.response.body
10
+ rv = (rv.parsed_response rescue rv.response.body)
11
+ return fallback if rv.nil? or rv.strip.chomp.empty?
12
+ return rv
11
13
  end
12
14
 
13
15
  def set_field(id, field, value)
@@ -24,7 +26,7 @@ module Onering
24
26
  :q => make_filter(options[:filter])
25
27
  } if options[:filter]
26
28
 
27
- rv = get("/devices/list/#{field}", {
29
+ rv = get("/devices/list/#{[*field].join('/')}", {
28
30
  :query => qs
29
31
  }).parsed_response
30
32
 
@@ -23,6 +23,9 @@ module Onering
23
23
  '/etc/facter'
24
24
  ]
25
25
 
26
+ DEFAULT_CACHE_FILE='/var/tmp/.onering-report-cache.json'
27
+ DEFAULT_CACHE_MAXAGE=600
28
+
26
29
  class<<self
27
30
  include Onering::Util
28
31
 
@@ -143,29 +146,96 @@ module Onering
143
146
  @id = (@options[:id] || Onering::Util.fact('hardwareid', nil))
144
147
 
145
148
  if not @id.nil?
146
- Timeout.timeout((@options[:timeout] || 60).to_i) do
147
- hostname = (Facter.value('fqdn') rescue %x{hostname -f}.strip.chomp)
148
-
149
- @_report = {
150
- :id => @id,
151
- :name => hostname,
152
- :aliases => @options[:aliases],
153
- :tags => @options[:tags],
154
- :status => (@options[:status] || 'online'),
155
- :inventory => true,
156
- :properties => {}
157
- }
158
-
159
- # loads plugins and populates @_report
160
- load_plugins
161
-
162
- return @_report.stringify_keys()
149
+ if @options[:nocache]
150
+ return _generated_report()
151
+ else
152
+ rv = _cached_report()
153
+ return _generated_report() if rv.nil? or rv.empty?
154
+ return rv
163
155
  end
164
156
  else
165
157
  Onering::Logger.fatal!("Cannot generate report without a hardware ID", "Onering::Reporter")
166
158
  end
167
159
 
168
- {}
160
+ return {}
161
+ end
162
+
163
+
164
+ def _generated_report()
165
+ Timeout.timeout((@options[:timeout] || 60).to_i) do
166
+ hostname = (Facter.value('fqdn') rescue %x{hostname -f}.strip.chomp)
167
+
168
+ @_report = {
169
+ :id => @id,
170
+ :name => hostname,
171
+ :aliases => @options[:aliases],
172
+ :tags => @options[:tags],
173
+ :status => (@options[:status] || 'online'),
174
+ :inventory => true,
175
+ :properties => {}
176
+ }
177
+
178
+ # loads plugins and populates @_report
179
+ load_plugins
180
+
181
+ return @_report.stringify_keys()
182
+ end
183
+
184
+ return {}
185
+ end
186
+
187
+ def _cached_report()
188
+ cachefile = (@options[:cachefile] || DEFAULT_CACHE_FILE)
189
+
190
+ catch(:retry) do
191
+ if File.readable?(cachefile)
192
+ Onering::Logger.debug("Loading cache file at #{cachefile}", "Onering::Reporter")
193
+ cache = File.read(cachefile)
194
+ cache = (MultiJson.load(cache) rescue {})
195
+
196
+ if _cache_expired?(cache, @options[:maxage])
197
+ Onering::Logger.debug("Cache expired, regenerating...", "Onering::Reporter")
198
+ throw :retry if _update_cache_file(cachefile)
199
+ end
200
+
201
+ # remove cached_at key
202
+ Onering::Logger.debug("Using cached data (#{Time.now.to_i - Time.parse(cache.get('cached_at')).to_i} seconds old)", "Onering::Reporter")
203
+ cache.delete('cached_at')
204
+ return cache
205
+ else
206
+ Onering::Logger.debug("Report cache file could not be read at #{cachefile}", "Onering::Reporter")
207
+ throw :retry if _update_cache_file(cachefile)
208
+ end
209
+ end
210
+
211
+ return {}
212
+ end
213
+
214
+
215
+ def _update_cache_file(cachefile=DEFAULT_CACHE_FILE)
216
+ begin
217
+ File.open(cachefile, 'w+') do |file|
218
+ Onering::Logger.debug("Regenerating cache file at #{cachefile}", "Onering::Reporter")
219
+ report = _generated_report()
220
+ report['cached_at'] = Time.now.strftime('%Y-%m-%dT%H:%M:%S%z')
221
+ json = MultiJson.dump(report, :pretty => true)
222
+ file.puts(json)
223
+ end
224
+
225
+ return true
226
+ rescue Exception => e
227
+ Onering::Logger.warn("Error while writing cache file #{cachefile}: #{e.class.name} - #{e.message}", "Onering::Reporter")
228
+ return false
229
+ end
230
+ end
231
+
232
+
233
+ def _cache_expired?(cache, age=DEFAULT_CACHE_MAXAGE)
234
+ if cache.is_a?(Hash)
235
+ return (Time.parse(cache.get('cached_at')) < (Time.now - age) rescue true)
236
+ else
237
+ return true
238
+ end
169
239
  end
170
240
  end
171
241
  end
@@ -94,7 +94,16 @@ module Onering
94
94
  if name.downcase == 'all'
95
95
  return Facter.to_hash
96
96
  else
97
- fact = Facter.value(name)
97
+ case name.to_sym
98
+ when :hardwareid
99
+ if File.exists?('/etc/hardware.id')
100
+ fact = File.read('/etc/hardware.id').lines.first.strip.chomp
101
+ else
102
+ fact = Facter.value(name)
103
+ end
104
+ else
105
+ fact = Facter.value(name)
106
+ end
98
107
 
99
108
  # short circuit nil responses
100
109
  return default if fact.nil?
@@ -140,4 +149,10 @@ class Module
140
149
  def submodules
141
150
  constants.collect {|const_name| const_get(const_name)}.select {|const| const.class == Module}
142
151
  end
152
+ end
153
+
154
+ class NilClass
155
+ def <=>(*args)
156
+ return 1
157
+ end
143
158
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onering-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
5
4
  prerelease:
5
+ version: 0.1.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Gary Hetzel
@@ -12,104 +12,149 @@ cert_chain: []
12
12
  date: 2013-01-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: facter
16
- requirement: &11003660 !ruby/object:Gem::Requirement
15
+ type: :runtime
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ! '>='
19
+ - !ruby/object:Gem::Version
20
+ version: 1.7.2
17
21
  none: false
22
+ prerelease: false
23
+ name: facter
24
+ requirement: !ruby/object:Gem::Requirement
18
25
  requirements:
19
26
  - - ! '>='
20
27
  - !ruby/object:Gem::Version
21
28
  version: 1.7.2
29
+ none: false
30
+ - !ruby/object:Gem::Dependency
22
31
  type: :runtime
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - '='
35
+ - !ruby/object:Gem::Version
36
+ version: 1.0.0
37
+ none: false
23
38
  prerelease: false
24
- version_requirements: *11003660
25
- - !ruby/object:Gem::Dependency
26
39
  name: deep_merge
27
- requirement: &11019380 !ruby/object:Gem::Requirement
28
- none: false
40
+ requirement: !ruby/object:Gem::Requirement
29
41
  requirements:
30
- - - =
42
+ - - '='
31
43
  - !ruby/object:Gem::Version
32
44
  version: 1.0.0
45
+ none: false
46
+ - !ruby/object:Gem::Dependency
33
47
  type: :runtime
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '='
51
+ - !ruby/object:Gem::Version
52
+ version: 2.3.5
53
+ none: false
34
54
  prerelease: false
35
- version_requirements: *11019380
36
- - !ruby/object:Gem::Dependency
37
55
  name: addressable
38
- requirement: &11018780 !ruby/object:Gem::Requirement
39
- none: false
56
+ requirement: !ruby/object:Gem::Requirement
40
57
  requirements:
41
- - - =
58
+ - - '='
42
59
  - !ruby/object:Gem::Version
43
60
  version: 2.3.5
61
+ none: false
62
+ - !ruby/object:Gem::Dependency
44
63
  type: :runtime
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.11.0
69
+ none: false
45
70
  prerelease: false
46
- version_requirements: *11018780
47
- - !ruby/object:Gem::Dependency
48
71
  name: httparty
49
- requirement: &11018280 !ruby/object:Gem::Requirement
50
- none: false
72
+ requirement: !ruby/object:Gem::Requirement
51
73
  requirements:
52
- - - =
74
+ - - '='
53
75
  - !ruby/object:Gem::Version
54
76
  version: 0.11.0
77
+ none: false
78
+ - !ruby/object:Gem::Dependency
55
79
  type: :runtime
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: 0.0.35
85
+ none: false
56
86
  prerelease: false
57
- version_requirements: *11018280
58
- - !ruby/object:Gem::Dependency
59
87
  name: hashlib
60
- requirement: &11017620 !ruby/object:Gem::Requirement
61
- none: false
88
+ requirement: !ruby/object:Gem::Requirement
62
89
  requirements:
63
90
  - - ! '>='
64
91
  - !ruby/object:Gem::Version
65
92
  version: 0.0.35
93
+ none: false
94
+ - !ruby/object:Gem::Dependency
66
95
  type: :runtime
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - '='
99
+ - !ruby/object:Gem::Version
100
+ version: 1.7.9
101
+ none: false
67
102
  prerelease: false
68
- version_requirements: *11017620
69
- - !ruby/object:Gem::Dependency
70
103
  name: multi_json
71
- requirement: &11016940 !ruby/object:Gem::Requirement
72
- none: false
104
+ requirement: !ruby/object:Gem::Requirement
73
105
  requirements:
74
- - - =
106
+ - - '='
75
107
  - !ruby/object:Gem::Version
76
108
  version: 1.7.9
109
+ none: false
110
+ - !ruby/object:Gem::Dependency
77
111
  type: :runtime
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - <=
115
+ - !ruby/object:Gem::Version
116
+ version: 1.1.4
117
+ none: false
78
118
  prerelease: false
79
- version_requirements: *11016940
80
- - !ruby/object:Gem::Dependency
81
119
  name: rainbow
82
- requirement: &11016220 !ruby/object:Gem::Requirement
83
- none: false
120
+ requirement: !ruby/object:Gem::Requirement
84
121
  requirements:
85
122
  - - <=
86
123
  - !ruby/object:Gem::Version
87
124
  version: 1.1.4
125
+ none: false
126
+ - !ruby/object:Gem::Dependency
88
127
  type: :runtime
128
+ version_requirements: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - '='
131
+ - !ruby/object:Gem::Version
132
+ version: '2.0'
133
+ none: false
89
134
  prerelease: false
90
- version_requirements: *11016220
91
- - !ruby/object:Gem::Dependency
92
135
  name: trollop
93
- requirement: &11015380 !ruby/object:Gem::Requirement
94
- none: false
136
+ requirement: !ruby/object:Gem::Requirement
95
137
  requirements:
96
- - - =
138
+ - - '='
97
139
  - !ruby/object:Gem::Version
98
140
  version: '2.0'
141
+ none: false
142
+ - !ruby/object:Gem::Dependency
99
143
  type: :runtime
144
+ version_requirements: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - '='
147
+ - !ruby/object:Gem::Version
148
+ version: 1.1.2
149
+ none: false
100
150
  prerelease: false
101
- version_requirements: *11015380
102
- - !ruby/object:Gem::Dependency
103
151
  name: xml-simple
104
- requirement: &11013900 !ruby/object:Gem::Requirement
105
- none: false
152
+ requirement: !ruby/object:Gem::Requirement
106
153
  requirements:
107
- - - =
154
+ - - '='
108
155
  - !ruby/object:Gem::Version
109
156
  version: 1.1.2
110
- type: :runtime
111
- prerelease: false
112
- version_requirements: *11013900
157
+ none: false
113
158
  description: A Ruby wrapper for Onering
114
159
  email: ghetzel@outbrain.com
115
160
  executables:
@@ -125,14 +170,14 @@ files:
125
170
  - lib/onering/util.rb
126
171
  - lib/onering/plugins/authentication.rb
127
172
  - lib/onering/plugins/reporter.rb
128
- - lib/onering/plugins/devices.rb
129
173
  - lib/onering/plugins/config.rb
130
174
  - lib/onering/plugins/automation.rb
175
+ - lib/onering/plugins/assets.rb
131
176
  - lib/onering/cli/reporter.rb
132
177
  - lib/onering/cli/devices.rb
133
- - lib/onering/cli/config.rb
134
178
  - lib/onering/cli/automation.rb
135
179
  - lib/onering/cli/fact.rb
180
+ - lib/onering/cli/assets.rb
136
181
  - lib/onering/cli/call.rb
137
182
  - bin/onering
138
183
  homepage: https://github.com/outbrain/onering-ruby
@@ -142,20 +187,20 @@ rdoc_options: []
142
187
  require_paths:
143
188
  - lib
144
189
  required_ruby_version: !ruby/object:Gem::Requirement
145
- none: false
146
190
  requirements:
147
191
  - - ! '>='
148
192
  - !ruby/object:Gem::Version
149
193
  version: '0'
150
- required_rubygems_version: !ruby/object:Gem::Requirement
151
194
  none: false
195
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
196
  requirements:
153
197
  - - ! '>='
154
198
  - !ruby/object:Gem::Version
155
199
  version: '0'
200
+ none: false
156
201
  requirements: []
157
202
  rubyforge_project:
158
- rubygems_version: 1.8.11
203
+ rubygems_version: 1.8.28
159
204
  signing_key:
160
205
  specification_version: 3
161
206
  summary: Onering client API and utilities
@@ -1,55 +0,0 @@
1
- module Onering
2
- module CLI
3
- module Config
4
- def self.configure(global={})
5
- Onering::Reporter.setup()
6
- @api = Onering::CLI.connect(global)
7
-
8
- @opts = ::Trollop::options do
9
- banner <<-EOS
10
- Options:
11
- EOS
12
-
13
- opt :id, "The node ID of the device to operate on", :short => '-i', :type => :string, :default => Onering::Util.fact('hardwareid')
14
-
15
- # subcommands
16
- stop_on %w{get set test}
17
- end
18
- end
19
-
20
- def self.run(args)
21
- sc = args.shift
22
-
23
- case (sc.downcase.to_sym rescue nil)
24
- # -----------------------------------------------------------------------------
25
- when :get
26
- raise "Expected 1 parameter, got #{args.length}" unless args.length >= 1
27
-
28
- begin
29
- rv = @api.request(@opts[:method], "devices/#{@opts[:id]}/config/#{args[0].gsub('.','/')}")
30
- return (rv.parsed_response rescue rv.response.body)
31
- rescue Onering::API::Errors::NotFound
32
- if args[1].nil? and not STDIN.tty?
33
- args[1] = STDIN.read()
34
- end
35
-
36
- return (MultiJson.load(args[1]) rescue args[1])
37
- end
38
-
39
- # -----------------------------------------------------------------------------
40
- when :set
41
- raise "Expected 2 parameters, got #{args.length}" unless args.length == 2
42
-
43
- return @api.set_field(@opts[:id], "config.#{args[0]}", args[1])
44
-
45
- # -----------------------------------------------------------------------------
46
- when :test
47
- raise "Expected 1 parameter, got #{args.length}" unless args.length >= 1
48
-
49
- else
50
- raise "Unknown subcommand #{sc.inspect}"
51
- end
52
- end
53
- end
54
- end
55
- end