vmit 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,50 @@
1
+ #
2
+ # Copyright (C) 2013 Duncan Mac-Vicar P. <dmacvicar@suse.de>
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ # this software and associated documentation files (the "Software"), to deal in
6
+ # the Software without restriction, including without limitation the rights to
7
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8
+ # the Software, and to permit persons to whom the Software is furnished to do so,
9
+ # subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in all
12
+ # copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ #
21
+ require File.join(File.dirname(__FILE__), "helper")
22
+ require 'test/unit'
23
+ require 'vmit/bootstrap'
24
+ require 'tempfile'
25
+
26
+ class Bootstrap_test < Test::Unit::TestCase
27
+
28
+ def test_accept_locations
29
+ assert Vmit::Bootstrap::FromMedia.accept?('http://www.foof.com/repo')
30
+ assert Vmit::Bootstrap::FromMedia.accept?(URI.parse('http://www.foof.com/repo'))
31
+ assert Vmit::Bootstrap::FromMedia.accept?('http://www.foof.com/repo/')
32
+ assert Vmit::Bootstrap::FromMedia.accept?(URI.parse('http://www.foof.com/repo/'))
33
+
34
+ iso_path = File.expand_path('data/test_vfs.iso', File.dirname(__FILE__))
35
+ tmp_raw = Tempfile.new(['vmit-test-', '.raw'])
36
+ raw_path = tmp_raw.path
37
+
38
+ assert Vmit::Bootstrap::FromMedia.accept?(iso_path)
39
+ assert !Vmit::Bootstrap::FromMedia.accept?('/non/existing/file.iso')
40
+ assert !Vmit::Bootstrap::FromMedia.accept?('/non/existing/file.raw')
41
+
42
+ assert !Vmit::Bootstrap::FromImage.accept?(iso_path)
43
+ assert !Vmit::Bootstrap::FromImage.accept?('/non/existing/file.iso')
44
+ assert !Vmit::Bootstrap::FromImage.accept?('/non/existing/file.raw')
45
+
46
+ assert !Vmit::Bootstrap::FromMedia.accept?(raw_path)
47
+ assert Vmit::Bootstrap::FromImage.accept?(raw_path)
48
+ end
49
+
50
+ end
@@ -0,0 +1,2 @@
1
+ This is the content
2
+
Binary file
data/test/helper.rb ADDED
@@ -0,0 +1,28 @@
1
+ #
2
+ # Copyright (C) 2013 Duncan Mac-Vicar P. <dmacvicar@suse.de>
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ # this software and associated documentation files (the "Software"), to deal in
6
+ # the Software without restriction, including without limitation the rights to
7
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8
+ # the Software, and to permit persons to whom the Software is furnished to do so,
9
+ # subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in all
12
+ # copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ #
21
+ $: << File.join(File.dirname(__FILE__), "..", "lib")
22
+ require 'test/unit'
23
+ require 'vmit'
24
+
25
+ if ENV["DEBUG"]
26
+ Vmitlogger = Logger.new(STDERR)
27
+ Vmit.logger.level = Logger::DEBUG
28
+ end
@@ -0,0 +1,35 @@
1
+ #
2
+ # Copyright (C) 2013 Duncan Mac-Vicar P. <dmacvicar@suse.de>
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ # this software and associated documentation files (the "Software"), to deal in
6
+ # the Software without restriction, including without limitation the rights to
7
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8
+ # the Software, and to permit persons to whom the Software is furnished to do so,
9
+ # subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in all
12
+ # copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ #
21
+ require File.join(File.dirname(__FILE__), "helper")
22
+ require 'test/unit'
23
+ require 'vmit/refcounted_resource'
24
+
25
+ class RefcountedResource_test < Test::Unit::TestCase
26
+
27
+ def test_creation
28
+
29
+ r1 = Vmit::RefcountedResource.new('test1')
30
+
31
+ r1 = Vmit::RefcountedResource.new('test1')
32
+
33
+ end
34
+
35
+ end
data/test/vfs_test.rb ADDED
@@ -0,0 +1,85 @@
1
+ #
2
+ # Copyright (C) 2013 Duncan Mac-Vicar P. <dmacvicar@suse.de>
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ # this software and associated documentation files (the "Software"), to deal in
6
+ # the Software without restriction, including without limitation the rights to
7
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8
+ # the Software, and to permit persons to whom the Software is furnished to do so,
9
+ # subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in all
12
+ # copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ #
21
+ require File.join(File.dirname(__FILE__), "helper")
22
+ require 'test/unit'
23
+ require 'webmock/test_unit'
24
+ require 'vmit/vfs'
25
+
26
+ class VFS_test < Test::Unit::TestCase
27
+
28
+ def test_http_media
29
+ stub_request(:get, 'www.server.com/foo/file').to_return(:body => 'Test response', :status => 200)
30
+
31
+ http = Vmit::VFS::URI.from('http://www.server.com')
32
+ http.open('/foo/file') do |f|
33
+ assert_equal 'Test response', f .read
34
+ end
35
+ end
36
+
37
+ def test_http_media_404
38
+ stub_request(:get, 'www.server.com/lala.php').to_return(:status => [400, 'Not Found'])
39
+
40
+ http = Vmit::VFS::URI.from('http://www.server.com')
41
+ assert_raise OpenURI::HTTPError do
42
+ http.open('/lala.php')
43
+ end
44
+ end
45
+
46
+ def test_http_invalid_host
47
+ stub_request(:get, 'www.unknown.com').to_raise(SocketError)
48
+ http = Vmit::VFS::URI.from('http://www.unknown.com')
49
+ assert_raise SocketError do
50
+ http.open('/')
51
+ end
52
+ end
53
+
54
+ def test_http_without_base_uri
55
+ stub_request(:get, 'www.server.com/foo/file').to_return(:body => 'Test response', :status => 200)
56
+
57
+ Vmit::VFS::URI.open('http://www.server.com/foo/file') do |f|
58
+ assert_equal 'Test response', f .read
59
+ end
60
+
61
+ assert_raise ArgumentError do
62
+ Vmit::VFS::URI.open('/foo/file')
63
+ end
64
+ end
65
+
66
+ def test_media_iso
67
+ iso_path = File.expand_path('data/test_vfs.iso', File.dirname(__FILE__))
68
+ iso = Vmit::VFS::ISO.from("iso://#{iso_path}")
69
+
70
+ iso.open('/dir1/file.txt') do |f|
71
+ assert_equal "This is the content\n\n", f.read
72
+ end
73
+ assert_raise Errno::ENOENT do
74
+ iso.open('/dir2/lala.txt')
75
+ end
76
+ end
77
+
78
+ def test_iso_uri
79
+ iso_path = File.expand_path('data/test_vfs.iso', File.dirname(__FILE__))
80
+ path = '/dir1/file.txt'
81
+ Vmit::VFS::ISO.open("iso://#{iso_path}?path=#{path}") do |f|
82
+ assert_equal "This is the content\n\n", f.read
83
+ end
84
+ end
85
+ end
data/vmit.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "vmit/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "vmit"
7
+ s.version = Vmit::VERSION
8
+ s.authors = ["Duncan Mac-Vicar P."]
9
+ s.email = ["dmacvicar@suse.de"]
10
+ s.homepage = ""
11
+ s.summary = %q{Virtual machine (kvm) command line tool}
12
+ s.description = %q{vmit makes easy to maintain and run virtual machines.}
13
+
14
+ s.rubyforge_project = "vmit"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+ s.add_dependency('clamp')
21
+ s.add_dependency('open4')
22
+ s.add_dependency('pidfile')
23
+ s.add_dependency('cheetah')
24
+ s.add_dependency('ipaddress')
25
+ s.add_dependency('abstract_method')
26
+ s.add_dependency('progressbar')
27
+ s.add_dependency('activesupport')
28
+ s.add_dependency('nokogiri')
29
+
30
+ s.add_development_dependency('webmock')
31
+ end
metadata ADDED
@@ -0,0 +1,244 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vmit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Duncan Mac-Vicar P.
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: clamp
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: open4
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: pidfile
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: cheetah
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: ipaddress
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: abstract_method
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: progressbar
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: activesupport
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :runtime
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: nokogiri
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :runtime
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: webmock
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ description: vmit makes easy to maintain and run virtual machines.
175
+ email:
176
+ - dmacvicar@suse.de
177
+ executables:
178
+ - vmit
179
+ - vmit-ifdown
180
+ - vmit-ifup
181
+ extensions: []
182
+ extra_rdoc_files: []
183
+ files:
184
+ - .gitignore
185
+ - Gemfile
186
+ - MIT-LICENSE
187
+ - README.rdoc
188
+ - Rakefile
189
+ - bin/vmit
190
+ - bin/vmit-ifdown
191
+ - bin/vmit-ifup
192
+ - lib/vmit.rb
193
+ - lib/vmit/autoyast.rb
194
+ - lib/vmit/bootstrap.rb
195
+ - lib/vmit/debian_preseed.rb
196
+ - lib/vmit/ext.rb
197
+ - lib/vmit/kickstart.rb
198
+ - lib/vmit/logger.rb
199
+ - lib/vmit/network.rb
200
+ - lib/vmit/plugins/bootstrap.rb
201
+ - lib/vmit/plugins/hello.rb
202
+ - lib/vmit/refcounted_resource.rb
203
+ - lib/vmit/utils.rb
204
+ - lib/vmit/version.rb
205
+ - lib/vmit/vfs.rb
206
+ - lib/vmit/virtual_machine.rb
207
+ - test/bootstrap_test.rb
208
+ - test/data/dir1/file.txt
209
+ - test/data/test_vfs.iso
210
+ - test/helper.rb
211
+ - test/refcounted_resource_test.rb
212
+ - test/vfs_test.rb
213
+ - vmit.gemspec
214
+ homepage: ''
215
+ licenses: []
216
+ post_install_message:
217
+ rdoc_options: []
218
+ require_paths:
219
+ - lib
220
+ required_ruby_version: !ruby/object:Gem::Requirement
221
+ none: false
222
+ requirements:
223
+ - - ! '>='
224
+ - !ruby/object:Gem::Version
225
+ version: '0'
226
+ required_rubygems_version: !ruby/object:Gem::Requirement
227
+ none: false
228
+ requirements:
229
+ - - ! '>='
230
+ - !ruby/object:Gem::Version
231
+ version: '0'
232
+ requirements: []
233
+ rubyforge_project: vmit
234
+ rubygems_version: 1.8.23
235
+ signing_key:
236
+ specification_version: 3
237
+ summary: Virtual machine (kvm) command line tool
238
+ test_files:
239
+ - test/bootstrap_test.rb
240
+ - test/data/dir1/file.txt
241
+ - test/data/test_vfs.iso
242
+ - test/helper.rb
243
+ - test/refcounted_resource_test.rb
244
+ - test/vfs_test.rb