oxford 0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ldap:
2
+ host: localhost
3
+ port: 3890
4
+ method: :plain
5
+ base: dc=test,dc=com
6
+ user: cn=admin,dc=test,dc=com
7
+ pass: test
@@ -0,0 +1,7 @@
1
+ ldap:
2
+ host: localhost
3
+ port: 6360
4
+ method: :ssl
5
+ base: dc=test,dc=com
6
+ user: cn=admin,dc=test,dc=com
7
+ pass: test
@@ -0,0 +1,95 @@
1
+ describe Oxford::Host do
2
+
3
+ before(:all) do
4
+ Oxford::LDAPAdapter.new
5
+ @g = Oxford::Host.find('galactica')
6
+ end
7
+
8
+ context "host" do
9
+ it 'should be able to tell me all known facts about a system' do
10
+ @g.factFqdn.should eql('galactica.test.com')
11
+ end
12
+
13
+ it 'should be able to write a fact' do
14
+ r = randomstring(10)
15
+ @g.factOperatingSystem = r
16
+ lambda { @g.save }.should_not raise_error
17
+ f = Oxford::Host.find('galactica')
18
+ f.factOperatingSystem.should eql(r)
19
+ end
20
+
21
+ it 'should gracefully handle an unknown fact' do
22
+ lambda { @g.factBlah = 'foo' }.should raise_error
23
+ end
24
+
25
+ it 'should be able to create a new host' do
26
+ r = randomstring(10)
27
+ a = Oxford::Host.new(r)
28
+ a.save
29
+ b = Oxford::Host.find(r)
30
+ b.should eql(a)
31
+ a.delete
32
+ end
33
+ end
34
+
35
+ context "networks" do
36
+ it 'should be able to retrieve a list of network devices on a host in ldap' do
37
+ @g.networks.should_not be_nil
38
+ @g.networks.should be_an(Array)
39
+ @g.networks.first.should be_an(Oxford::Network)
40
+ @g.networks.should have(2).items
41
+ end
42
+
43
+ it 'should be able to get information about an adapter from a host in ldap' do
44
+ n = @g.networks('NetworkLo0')
45
+ n.should have(1).item
46
+ n.first.should be_a(Oxford::Network)
47
+ end
48
+
49
+ it 'should be able to create a new network device' do
50
+ r = "test_interface"
51
+ v = { 'Interface' => 'eth1',
52
+ 'IpAddress' => '192.168.2.100',
53
+ 'MacAddress' => '22:22:22:22:22:22',
54
+ 'Network' => '255.255.255.0',
55
+ }
56
+ before = @g.networks
57
+ @g.add_network(r,v)
58
+ after = @g.networks
59
+ (after - before).should have(1).item
60
+ end
61
+
62
+ it 'should be able to delete a network device' do
63
+ before = @g.networks
64
+ @g.networks.each do |n|
65
+ n.delete if n.cn == 'test_interface'
66
+ end
67
+ after = @g.networks
68
+ (before - after).should have(1).item
69
+ end
70
+ end
71
+
72
+ context "processor" do
73
+ it 'should be able to list all processors on a host in ldap' do
74
+ @g.processors.should_not be_nil
75
+ @g.processors.should be_an(Array)
76
+ @g.processors.first.should be_an(Oxford::Processor)
77
+ end
78
+
79
+ it 'should be able to write a processor entry to a host in ldap' do
80
+ r = "processor" + (0...2).collect { rand(9) }.to_s
81
+ v = { "processorId" => "0", "processorInfo" => "some test stuff" }
82
+ before = @g.processors
83
+ @g.add_processor(r,v)
84
+ after = @g.processors
85
+ (after - before).should have(1).item
86
+ end
87
+
88
+ it 'should be able to delete a processor device' do
89
+ before = @g.processors
90
+ @g.processors.first.delete
91
+ after = @g.processors
92
+ (before - after).should have(1).item
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,19 @@
1
+ describe Oxford::LDAPAdapter do
2
+ it 'should connect to LDAP server from a config file' do
3
+ ldap = Oxford::LDAPAdapter.new
4
+ ldap.connected?.should == true
5
+ end
6
+
7
+ it 'should connect to LDAP over ssl' do
8
+ pending('need to fix the SSL certificate issue - pkild?')
9
+ # Oxford::Runner.config = File.join(File.dirname(__FILE__),'/fixtures/ssl.yaml')
10
+ # ldap = Oxford::LDAPAdapter.new
11
+ # ldap.connected?.should == true
12
+ end
13
+
14
+ it 'should connec to LDAP over plain' do
15
+ Oxford::Runner.config = File.join(File.dirname(__FILE__),'/fixtures/nossl.yaml')
16
+ ldap = Oxford::LDAPAdapter.new
17
+ ldap.connected?.should == true
18
+ end
19
+ end
@@ -0,0 +1,40 @@
1
+ describe Oxford::Runner do
2
+ before(:all) do
3
+ @f = Oxford::Facts.new
4
+ Oxford::LDAPAdapter.new
5
+ end
6
+
7
+ after(:all) do
8
+ g = Oxford::Host.find(@f.hostname)
9
+ g.networks.each { |n| n.delete }
10
+ g.processors.each { |p| p.delete }
11
+ g.delete
12
+ end
13
+
14
+ it 'should start with no hosts' do
15
+ g = Oxford::Host.find(@f.hostname)
16
+ g.count.should eql(0)
17
+ end
18
+
19
+ it 'should write the facts to the adapters' do
20
+ Oxford::Runner.run!
21
+ g = Oxford::Host.find(@f.hostname)
22
+ g.should be_an(Oxford::Host)
23
+ end
24
+
25
+ it 'should take a config file' do
26
+ Oxford::Runner.config = File.join(File.dirname(__FILE__),'/fixtures/nossl.yaml')
27
+ Oxford::Runner.config.should == File.join(File.dirname(__FILE__),'/fixtures/nossl.yaml')
28
+ end
29
+
30
+ it 'should update existing facts' do
31
+ g = Oxford::Host.find(@f.hostname)
32
+ g.__send__("facthardwaremodel=", "fakearch")
33
+ g.save!
34
+ g.facthardwaremodel.should eql("fakearch")
35
+ Oxford::Runner.run!
36
+ f = Oxford::Host.find(@f.hostname)
37
+ f.facthardwaremodel.should eql(@f.hardwaremodel)
38
+ end
39
+
40
+ end
@@ -0,0 +1,8 @@
1
+ require File.join(File.dirname(__FILE__),"../",'lib/oxford')
2
+
3
+ def randomstring(length)
4
+ o = [('a'..'z'), ('A'..'Z')].map{|i| i.to_a}.flatten
5
+ return (0..length).map { o[rand(o.length)] }.join
6
+ end
7
+
8
+
metadata ADDED
@@ -0,0 +1,179 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: oxford
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 9
9
+ version: "0.9"
10
+ platform: ruby
11
+ authors:
12
+ - James Fryman
13
+ - Aziz Shamim
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-11-03 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: facter
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 19
29
+ segments:
30
+ - 1
31
+ - 5
32
+ - 8
33
+ version: 1.5.8
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: activeldap
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 3
47
+ - 1
48
+ - 0
49
+ version: 3.1.0
50
+ type: :runtime
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: ruby-ldap
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 45
61
+ segments:
62
+ - 0
63
+ - 9
64
+ - 11
65
+ version: 0.9.11
66
+ type: :development
67
+ version_requirements: *id003
68
+ - !ruby/object:Gem::Dependency
69
+ name: rspec
70
+ prerelease: false
71
+ requirement: &id004 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ hash: 23
77
+ segments:
78
+ - 2
79
+ - 6
80
+ - 0
81
+ version: 2.6.0
82
+ type: :development
83
+ version_requirements: *id004
84
+ - !ruby/object:Gem::Dependency
85
+ name: rake
86
+ prerelease: false
87
+ requirement: &id005 !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 49
93
+ segments:
94
+ - 0
95
+ - 8
96
+ - 7
97
+ version: 0.8.7
98
+ type: :development
99
+ version_requirements: *id005
100
+ description: ""
101
+ email:
102
+ - james@frymanet.com
103
+ - azizshamim@gmail.com
104
+ executables:
105
+ - oxford
106
+ extensions: []
107
+
108
+ extra_rdoc_files: []
109
+
110
+ files:
111
+ - .autotest
112
+ - .gitignore
113
+ - .rspec
114
+ - Gemfile
115
+ - Gemfile.lock
116
+ - README.mkd
117
+ - Rakefile
118
+ - bin/oxford
119
+ - config/database.yaml
120
+ - inc/testing.ldif
121
+ - inc/websages.schema
122
+ - lib/oxford.rb
123
+ - lib/oxford/facts.rb
124
+ - lib/oxford/host.rb
125
+ - lib/oxford/ldap.rb
126
+ - lib/oxford/network.rb
127
+ - lib/oxford/processor.rb
128
+ - lib/oxford/runner.rb
129
+ - oxford.gemspec
130
+ - spec/facts_spec.rb
131
+ - spec/fixtures/ldap.yaml
132
+ - spec/fixtures/nossl.yaml
133
+ - spec/fixtures/ssl.yaml
134
+ - spec/host_spec.rb
135
+ - spec/ldap_spec.rb
136
+ - spec/runner_spec.rb
137
+ - spec/spec_helper.rb
138
+ homepage:
139
+ licenses: []
140
+
141
+ post_install_message:
142
+ rdoc_options: []
143
+
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ none: false
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ hash: 3
152
+ segments:
153
+ - 0
154
+ version: "0"
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ none: false
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ hash: 3
161
+ segments:
162
+ - 0
163
+ version: "0"
164
+ requirements: []
165
+
166
+ rubyforge_project:
167
+ rubygems_version: 1.8.10
168
+ signing_key:
169
+ specification_version: 3
170
+ summary: ""
171
+ test_files:
172
+ - spec/facts_spec.rb
173
+ - spec/fixtures/ldap.yaml
174
+ - spec/fixtures/nossl.yaml
175
+ - spec/fixtures/ssl.yaml
176
+ - spec/host_spec.rb
177
+ - spec/ldap_spec.rb
178
+ - spec/runner_spec.rb
179
+ - spec/spec_helper.rb