openvz 1.1

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.
@@ -0,0 +1,11 @@
1
+ #
2
+ # systemu can be used on any platform to return status, stdout, and stderr of
3
+ # any command. unlike other methods like open3/popen4 there is zero danger of
4
+ # full pipes or threading issues hanging your process or subprocess.
5
+ #
6
+ require 'systemu'
7
+
8
+ date = %q( ruby -e" t = Time.now; STDOUT.puts t; STDERR.puts t " )
9
+
10
+ status, stdout, stderr = systemu date
11
+ p [ status, stdout, stderr ]
@@ -0,0 +1,12 @@
1
+ #
2
+ # quite a few keys can be passed to the command to alter it's behaviour. if
3
+ # either stdout or stderr is supplied those objects should respond_to? '<<'
4
+ # and only status will be returned
5
+ #
6
+ require 'systemu'
7
+
8
+ date = %q( ruby -e" t = Time.now; STDOUT.puts t; STDERR.puts t " )
9
+
10
+ stdout, stderr = '', ''
11
+ status = systemu date, 'stdout' => stdout, 'stderr' => stderr
12
+ p [ status, stdout, stderr ]
@@ -0,0 +1,10 @@
1
+ #
2
+ # of course stdin can be supplied too. synonyms for 'stdin' include '0' and
3
+ # 0. the other stdio streams have similar shortcuts
4
+ #
5
+ require 'systemu'
6
+
7
+ cat = %q( ruby -e" ARGF.each{|line| puts line} " )
8
+
9
+ status = systemu cat, 0=>'the stdin for cat', 1=>stdout=''
10
+ puts stdout
@@ -0,0 +1,11 @@
1
+ #
2
+ # the cwd can be supplied
3
+ #
4
+ require 'systemu'
5
+ require 'tmpdir'
6
+
7
+ pwd = %q( ruby -e" STDERR.puts Dir.pwd " )
8
+
9
+ status = systemu pwd, 2=>(stderr=''), :cwd=>Dir.tmpdir
10
+ puts stderr
11
+
@@ -0,0 +1,9 @@
1
+ #
2
+ # any environment vars specified are merged into the child's environment
3
+ #
4
+ require 'systemu'
5
+
6
+ env = %q( ruby -r yaml -e" puts ENV[ 'answer' ] " )
7
+
8
+ status = systemu env, 1=>stdout='', 'env'=>{ 'answer' => 0b101010 }
9
+ puts stdout
@@ -0,0 +1,18 @@
1
+ #
2
+ # if a block is specified then it is passed the child pid and run in a
3
+ # background thread. note that this thread will __not__ be blocked during the
4
+ # execution of the command so it may do useful work such as killing the child
5
+ # if execution time passes a certain threshold
6
+ #
7
+ require 'systemu'
8
+
9
+ looper = %q( ruby -e" loop{ STDERR.puts Time.now.to_i; sleep 1 } " )
10
+
11
+ status, stdout, stderr =
12
+ systemu looper do |cid|
13
+ sleep 3
14
+ Process.kill 9, cid
15
+ end
16
+
17
+ p status
18
+ p stderr
data/openvz.gemspec ADDED
@@ -0,0 +1,48 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'openvz'
3
+ s.version = '1.1'
4
+ s.date = '2011-10-26'
5
+ s.authors = 'Stefan Schlesinger'
6
+ s.email = 'sts@ono.at'
7
+ s.homepage = 'http://github.com/sts/ruby-openvz'
8
+
9
+ s.summary = 'OpenVZ API'
10
+ s.description = 'OpenVZ is a container based virtualization for Linux. This API will
11
+ allow you to easily write tools to manipulate containers on a host.'
12
+
13
+ s.extra_rdoc_files = %w[COPYING]
14
+
15
+ # = MANIFEST =
16
+ s.files = %w[
17
+ openvz.gemspec
18
+ lib/openvz.rb
19
+ lib/openvz/vendor
20
+ lib/openvz/vendor/systemu
21
+ lib/openvz/vendor/systemu/README.tmpl
22
+ lib/openvz/vendor/systemu/gemspec.rb
23
+ lib/openvz/vendor/systemu/install.rb
24
+ lib/openvz/vendor/systemu/samples
25
+ lib/openvz/vendor/systemu/samples/e.rb
26
+ lib/openvz/vendor/systemu/samples/b.rb
27
+ lib/openvz/vendor/systemu/samples/d.rb
28
+ lib/openvz/vendor/systemu/samples/c.rb
29
+ lib/openvz/vendor/systemu/samples/a.rb
30
+ lib/openvz/vendor/systemu/samples/f.rb
31
+ lib/openvz/vendor/systemu/gen_readme.rb
32
+ lib/openvz/vendor/systemu/lib
33
+ lib/openvz/vendor/systemu/lib/systemu.rb
34
+ lib/openvz/vendor/systemu/a.rb
35
+ lib/openvz/vendor/systemu/README
36
+ lib/openvz/vendor/require_vendored.rb
37
+ lib/openvz/vendor/load_systemu.rb
38
+ lib/openvz/log.rb
39
+ lib/openvz/inventory.rb
40
+ lib/openvz/util.rb
41
+ lib/openvz/vendor.rb
42
+ lib/openvz/confighash.rb
43
+ lib/openvz/container.rb
44
+ lib/openvz/shell.rb
45
+ lib/openvz.rb
46
+ ]
47
+
48
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: openvz
3
+ version: !ruby/object:Gem::Version
4
+ hash: 13
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 1
9
+ version: "1.1"
10
+ platform: ruby
11
+ authors:
12
+ - Stefan Schlesinger
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-10-26 00:00:00 Z
18
+ dependencies: []
19
+
20
+ description: |-
21
+ OpenVZ is a container based virtualization for Linux. This API will
22
+ allow you to easily write tools to manipulate containers on a host.
23
+ email: sts@ono.at
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - COPYING
30
+ files:
31
+ - openvz.gemspec
32
+ - lib/openvz.rb
33
+ - lib/openvz/vendor/systemu/README.tmpl
34
+ - lib/openvz/vendor/systemu/gemspec.rb
35
+ - lib/openvz/vendor/systemu/install.rb
36
+ - lib/openvz/vendor/systemu/samples/e.rb
37
+ - lib/openvz/vendor/systemu/samples/b.rb
38
+ - lib/openvz/vendor/systemu/samples/d.rb
39
+ - lib/openvz/vendor/systemu/samples/c.rb
40
+ - lib/openvz/vendor/systemu/samples/a.rb
41
+ - lib/openvz/vendor/systemu/samples/f.rb
42
+ - lib/openvz/vendor/systemu/gen_readme.rb
43
+ - lib/openvz/vendor/systemu/lib/systemu.rb
44
+ - lib/openvz/vendor/systemu/a.rb
45
+ - lib/openvz/vendor/systemu/README
46
+ - lib/openvz/vendor/require_vendored.rb
47
+ - lib/openvz/vendor/load_systemu.rb
48
+ - lib/openvz/log.rb
49
+ - lib/openvz/inventory.rb
50
+ - lib/openvz/util.rb
51
+ - lib/openvz/vendor.rb
52
+ - lib/openvz/confighash.rb
53
+ - lib/openvz/container.rb
54
+ - lib/openvz/shell.rb
55
+ - COPYING
56
+ homepage: http://github.com/sts/ruby-openvz
57
+ licenses: []
58
+
59
+ post_install_message:
60
+ rdoc_options: []
61
+
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ hash: 3
79
+ segments:
80
+ - 0
81
+ version: "0"
82
+ requirements: []
83
+
84
+ rubyforge_project:
85
+ rubygems_version: 1.8.7
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: OpenVZ API
89
+ test_files: []
90
+