elecksee 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.md CHANGED
@@ -1,2 +1,5 @@
1
+ ## v0.1.2
2
+ * Update Chef::Log usage to only apply when Chef is loaded
3
+
1
4
  ## v0.1.0
2
5
  * Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- elecksee (1.0.0)
4
+ elecksee (1.0.1)
5
5
  mixlib-shellout
6
6
  net-ssh
7
7
 
@@ -122,7 +122,7 @@ class Lxc
122
122
  (retries.to_i + 1).times do
123
123
  ip = proc_detected_address || hw_detected_address || leased_address || lxc_stored_address
124
124
  return ip if ip && self.class.connection_alive?(ip)
125
- Chef::Log.warn "LXC IP discovery: Failed to detect live IP"
125
+ log.warn "LXC IP discovery: Failed to detect live IP"
126
126
  sleep(3) if retries > 0
127
127
  end
128
128
  raise "Failed to detect live IP address for container: #{name}" if raise_on_fail
@@ -137,7 +137,7 @@ class Lxc
137
137
  if(ip.to_s.empty?)
138
138
  nil
139
139
  else
140
- Chef::Log.info "LXC Discovery: Found container address via storage: #{ip}"
140
+ log.info "LXC Discovery: Found container address via storage: #{ip}"
141
141
  ip
142
142
  end
143
143
  end
@@ -157,7 +157,7 @@ class Lxc
157
157
  if(ip.to_s.empty?)
158
158
  nil
159
159
  else
160
- Chef::Log.info "LXC Discovery: Found container address via DHCP lease: #{ip}"
160
+ log.info "LXC Discovery: Found container address via DHCP lease: #{ip}"
161
161
  ip
162
162
  end
163
163
  end
@@ -175,7 +175,7 @@ class Lxc
175
175
  if(ip.to_s.empty?)
176
176
  nil
177
177
  else
178
- Chef::Log.info "LXC Discovery: Found container address via HW addr: #{ip}"
178
+ log.info "LXC Discovery: Found container address via HW addr: #{ip}"
179
179
  ip
180
180
  end
181
181
  end
@@ -291,7 +291,7 @@ class Lxc
291
291
  retries = args[:allow_failure_retry].to_i
292
292
  begin
293
293
  shlout = Mixlib::ShellOut.new(cmd,
294
- :logger => Chef::Log.logger,
294
+ :logger => defined?(Chef) ? Chef::Log.logger : log,
295
295
  :live_stream => STDOUT,
296
296
  :timeout => args[:timeout] || 1200,
297
297
  :environment => {'HOME' => detect_home}
@@ -300,8 +300,8 @@ class Lxc
300
300
  shlout.error!
301
301
  rescue Mixlib::ShellOut::ShellCommandFailed, CommandFailed, Mixlib::ShellOut::CommandTimeout
302
302
  if(retries > 0)
303
- Chef::Log.warn "LXC run command failed: #{cmd}"
304
- Chef::Log.warn "Retrying command. #{args[:allow_failure_retry].to_i - retries} of #{args[:allow_failure_retry].to_i} retries remain"
303
+ log.warn "LXC run command failed: #{cmd}"
304
+ log.warn "Retrying command. #{args[:allow_failure_retry].to_i - retries} of #{args[:allow_failure_retry].to_i} retries remain"
305
305
  sleep(0.3)
306
306
  retries -= 1
307
307
  retry
@@ -340,8 +340,8 @@ class Lxc
340
340
  )
341
341
  rescue => e
342
342
  if(retries.to_i > 0)
343
- Chef::Log.info "Encountered error running container command (#{cmd}): #{e}"
344
- Chef::Log.info "Retrying command..."
343
+ log.info "Encountered error running container command (#{cmd}): #{e}"
344
+ log.info "Retrying command..."
345
345
  retries = retries.to_i - 1
346
346
  sleep(1)
347
347
  retry
@@ -351,4 +351,16 @@ class Lxc
351
351
  end
352
352
  end
353
353
 
354
+ def log
355
+ if(defined?(Chef))
356
+ Chef::Log
357
+ else
358
+ unless(@logger)
359
+ require 'logger'
360
+ @logger = Logger.new('/dev/null')
361
+ end
362
+ @logger
363
+ end
364
+ end
365
+
354
366
  end
@@ -2,5 +2,5 @@ module Elecksee
2
2
  class Version < Gem::Version
3
3
  end
4
4
 
5
- VERSION = Version.new('1.0.0')
5
+ VERSION = Version.new('1.0.2')
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elecksee
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: