cobbler 2.0.0

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,119 @@
1
+ #! /usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../../spec_helper'
3
+
4
+ class TestConnection
5
+ include Cobbler::Common::Debug
6
+ include Cobbler::Connection::Handling
7
+ end
8
+
9
+ describe Cobbler::Connection::Handling do
10
+ [:hostname, :username, :password].each do |field|
11
+ it "should provide getters and setters for #{field}" do
12
+ TestConnection.should respond_to(field)
13
+ TestConnection.should respond_to("#{field}=".to_sym)
14
+ end
15
+ end
16
+
17
+ it "should provide a way to query the version of the cobbler server" do
18
+ TestConnection.should respond_to(:remote_version)
19
+ end
20
+
21
+ describe "querying remote version" do
22
+ before(:each) do
23
+ connection = Object.new
24
+ TestConnection.expects(:connect).returns(connection)
25
+ TestConnection.expects(:connection).returns(nil)
26
+ end
27
+
28
+ it "should return the version" do
29
+ TestConnection.expects(:make_call).with('version').returns("2.0")
30
+ TestConnection.remote_version.should == "2.0"
31
+ end
32
+ end
33
+
34
+ it "should provide a way to login to the cobbler server" do
35
+ TestConnection.should respond_to(:login)
36
+ end
37
+
38
+ describe "logging into cobbler server" do
39
+
40
+ it "should call the login server" do
41
+ TestConnection.username = 'foobar'
42
+ TestConnection.password = 'password'
43
+ TestConnection.expects(:make_call).with('login','foobar','password')
44
+ TestConnection.login
45
+ end
46
+
47
+ it "should not relogin if we are still logged in" do
48
+ TestConnection.username = 'foobar'
49
+ TestConnection.password = 'password'
50
+ TestConnection.expects(:make_call).with('login','foobar','password').returns("token")
51
+ TestConnection.login
52
+
53
+ TestConnection.username = 'foobar2'
54
+ TestConnection.password = 'password2'
55
+ TestConnection.expects(:make_call).with('login','foobar2','password2').never
56
+ TestConnection.login
57
+ end
58
+ end
59
+ it "should provide a way to connect to the cobbler server" do
60
+ TestConnection.should respond_to(:connect)
61
+ end
62
+
63
+ it "should connect to the cobbler server" do
64
+ TestConnection.hostname = 'localhost'
65
+ @connection = Object.new
66
+ XMLRPC::Client.expects(:new2).with('http://localhost/cobbler_api').returns(@connection)
67
+ TestConnection.send(:connect)
68
+ end
69
+
70
+ describe "making a call" do
71
+ it "should raise an exception if no connection have been established so far" do
72
+ TestConnection.expects(:connection).returns(nil)
73
+ lambda { TestConnection.make_call('foobar') }.should raise_error(Exception)
74
+ end
75
+
76
+ it "should pass all arguments to the connection and return the resul" do
77
+ connection = Object.new
78
+ connection.expects(:call).with('foo','bar').returns('juhu')
79
+ TestConnection.expects(:connection).twice.returns(connection)
80
+ TestConnection.make_call('foo','bar')
81
+ end
82
+ end
83
+
84
+ describe "handling transactions" do
85
+ it "should initialze and end a connection" do
86
+ TestConnection.expects(:begin_transaction)
87
+ TestConnection.expects(:end_transaction)
88
+ TestConnection.send(:in_transaction) do
89
+ #
90
+ end
91
+ end
92
+
93
+ it "should cleanup the connection" do
94
+ TestConnection.expects(:connect).returns('foobar')
95
+ TestConnection.in_transaction do
96
+ #
97
+ end
98
+ TestConnection.send(:connection).should be_nil
99
+ end
100
+
101
+ it "should login if you want a login and pass the token into the transaction and logout" do
102
+ connection = Object.new
103
+ TestConnection.expects(:login).returns('token')
104
+ TestConnection.expects(:logout)
105
+ TestConnection.expects(:connect).returns('foobar')
106
+ TestConnection.in_transaction(true) do |token|
107
+ token.should == 'token'
108
+ end
109
+ end
110
+
111
+ it "should ensure that the connection is cleaned up" do
112
+ TestConnection.expects(:connect).returns('foobar')
113
+ lambda { TestConnection.in_transaction do
114
+ raise "foobar"
115
+ end }.should raise_error(Exception)
116
+ TestConnection.send(:connection).should be_nil
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,27 @@
1
+ #! /usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../spec_helper'
3
+
4
+ describe Cobbler::System do
5
+
6
+ it "should define a method to store network interfaces" do
7
+ Cobbler::System.new.should respond_to(:store_interfaces)
8
+ end
9
+
10
+ describe "when saving" do
11
+ it "should store all interfaces" do
12
+ @test1 = Cobbler::System.new({'name' => 'foo'},false)
13
+ @test1.interfaces = { 'eth0' => { 'ipaddress' => '192.168.1.1' },
14
+ 'eth1' => { 'ipaddress' => '192.168.2.1' }
15
+ }
16
+ Cobbler::System.expects(:login).returns('muh')
17
+ Cobbler::System.expects(:logout)
18
+ Cobbler::System.expects(:find_one).with('foo').returns('entry')
19
+ Cobbler::System.expects(:connect).returns(Object.new)
20
+ Cobbler::System.expects(:make_call).with('get_system_handle','foo','muh').returns('id')
21
+ Cobbler::System.expects(:make_call).with('save_system','id','muh')
22
+ Cobbler::System.expects(:make_call).with('modify_system','id','modify_interface',{"ipaddress-eth0" => '192.168.1.1'},'muh')
23
+ Cobbler::System.expects(:make_call).with('modify_system','id','modify_interface',{"ipaddress-eth1" => '192.168.2.1'},'muh')
24
+ @test1.save
25
+ end
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,207 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cobbler
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15
5
+ prerelease:
6
+ segments:
7
+ - 2
8
+ - 0
9
+ - 0
10
+ version: 2.0.0
11
+ platform: ruby
12
+ authors:
13
+ - duritong
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-01-05 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ type: :runtime
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ version_requirements: *id001
33
+ name: active_support
34
+ prerelease: false
35
+ - !ruby/object:Gem::Dependency
36
+ type: :development
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ hash: 27
43
+ segments:
44
+ - 2
45
+ - 5
46
+ - 0
47
+ version: 2.5.0
48
+ version_requirements: *id002
49
+ name: rspec
50
+ prerelease: false
51
+ - !ruby/object:Gem::Dependency
52
+ type: :development
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ hash: 23
59
+ segments:
60
+ - 3
61
+ - 8
62
+ version: "3.8"
63
+ version_requirements: *id003
64
+ name: rdoc
65
+ prerelease: false
66
+ - !ruby/object:Gem::Dependency
67
+ type: :development
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ version_requirements: *id004
78
+ name: mocha
79
+ prerelease: false
80
+ - !ruby/object:Gem::Dependency
81
+ type: :development
82
+ requirement: &id005 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ hash: 23
88
+ segments:
89
+ - 1
90
+ - 0
91
+ - 0
92
+ version: 1.0.0
93
+ version_requirements: *id005
94
+ name: bundler
95
+ prerelease: false
96
+ - !ruby/object:Gem::Dependency
97
+ type: :development
98
+ requirement: &id006 !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ hash: 7
104
+ segments:
105
+ - 1
106
+ - 6
107
+ - 4
108
+ version: 1.6.4
109
+ version_requirements: *id006
110
+ name: jeweler
111
+ prerelease: false
112
+ - !ruby/object:Gem::Dependency
113
+ type: :development
114
+ requirement: &id007 !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ hash: 3
120
+ segments:
121
+ - 0
122
+ version: "0"
123
+ version_requirements: *id007
124
+ name: rcov
125
+ prerelease: false
126
+ description: " Provides Ruby bindings to interact with a Cobbler server.\n"
127
+ email: peter.meier@immerda.ch
128
+ executables: []
129
+
130
+ extensions: []
131
+
132
+ extra_rdoc_files:
133
+ - ChangeLog
134
+ - README.rdoc
135
+ - TODO
136
+ files:
137
+ - .document
138
+ - COPYING
139
+ - ChangeLog
140
+ - Gemfile
141
+ - Gemfile.lock
142
+ - NEWS
143
+ - README.rdoc
144
+ - Rakefile
145
+ - TODO
146
+ - config/cobbler.yml
147
+ - examples/example_distros.rb
148
+ - examples/example_version.rb
149
+ - examples/utils.rb
150
+ - lib/cobbler.rb
151
+ - lib/cobbler/base.rb
152
+ - lib/cobbler/common/debug.rb
153
+ - lib/cobbler/common/finders.rb
154
+ - lib/cobbler/common/lifecycle.rb
155
+ - lib/cobbler/connection/common.rb
156
+ - lib/cobbler/connection/handling.rb
157
+ - lib/cobbler/distro.rb
158
+ - lib/cobbler/image.rb
159
+ - lib/cobbler/profile.rb
160
+ - lib/cobbler/repo.rb
161
+ - lib/cobbler/system.rb
162
+ - rubygem-cobbler.spec
163
+ - spec/spec.opts
164
+ - spec/spec_helper.rb
165
+ - spec/unit/cobbler/base_spec.rb
166
+ - spec/unit/cobbler/common/debug_spec.rb
167
+ - spec/unit/cobbler/common/finders_spec.rb
168
+ - spec/unit/cobbler/common/lifecycle_spec.rb
169
+ - spec/unit/cobbler/connection/common_spec.rb
170
+ - spec/unit/cobbler/connection/handling_spec.rb
171
+ - spec/unit/cobbler/system_spec.rb
172
+ has_rdoc: true
173
+ homepage: http://github.com/duritong/ruby-cobbler/
174
+ licenses:
175
+ - GPLv2
176
+ post_install_message:
177
+ rdoc_options: []
178
+
179
+ require_paths:
180
+ - lib
181
+ required_ruby_version: !ruby/object:Gem::Requirement
182
+ none: false
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ hash: 3
187
+ segments:
188
+ - 0
189
+ version: "0"
190
+ required_rubygems_version: !ruby/object:Gem::Requirement
191
+ none: false
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ hash: 3
196
+ segments:
197
+ - 0
198
+ version: "0"
199
+ requirements: []
200
+
201
+ rubyforge_project:
202
+ rubygems_version: 1.6.2
203
+ signing_key:
204
+ specification_version: 3
205
+ summary: An interface for interacting with a Cobbler server.
206
+ test_files: []
207
+