openvz 1.2 → 1.4

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/lib/openvz.rb CHANGED
@@ -11,7 +11,7 @@ module OpenVZ
11
11
  autoload :Util, "openvz/util"
12
12
  autoload :ConfigHash, "openvz/confighash"
13
13
 
14
- VERSION = "1.2"
14
+ VERSION = "1.4"
15
15
 
16
16
  def self.version
17
17
  VERSION
@@ -28,6 +28,7 @@ module OpenVZ
28
28
  class Container
29
29
 
30
30
  attr_accessor :config
31
+ attr_reader :ctid
31
32
 
32
33
  class StatemachineError < StandardError;end
33
34
  class Config < ::OpenVZ::ConfigHash ; end
@@ -222,6 +223,19 @@ module OpenVZ
222
223
  end
223
224
 
224
225
 
226
+ # Return the current uptime in seconds.
227
+ # Return zero if the container is not running.
228
+ #
229
+ # @example
230
+ # puts container.uptime()
231
+ # 1188829
232
+ def uptime
233
+ return 0 unless status.include? "running"
234
+ raw = command "cat /proc/uptime"
235
+ Log.debug("Container (#{@ctid}) uptime requested: #{raw}")
236
+ raw.split(/\W/).first.to_i
237
+ end
238
+
225
239
 
226
240
  ####
227
241
  #### Helper methods
@@ -16,5 +16,9 @@ module OpenVZ
16
16
  end
17
17
  }
18
18
  end
19
+
20
+ def to_hash
21
+ @data
22
+ end
19
23
  end
20
24
  end
data/lib/openvz/log.rb CHANGED
@@ -35,7 +35,6 @@ module OpenVZ
35
35
 
36
36
  # logs message at level
37
37
  def log(level, msg)
38
- puts "#{@known_levels.index(level)} <= #{@known_levels.index(@active_level)}"
39
38
  if @known_levels.index(level) <= @known_levels.index(@active_level)
40
39
  t = Time.new.strftime("%H:%M:%S")
41
40
  STDERR.puts "#{t}: #{level}: #{from}: #{msg}"
data/openvz.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'openvz'
3
- s.version = '1.2'
3
+ s.version = '1.4'
4
4
  s.date = '2011-10-26'
5
5
  s.authors = 'Stefan Schlesinger'
6
6
  s.email = 'sts@ono.at'
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openvz
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 2
9
- version: "1.2"
8
+ - 4
9
+ version: "1.4"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Stefan Schlesinger