fauxhai 0.0.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,3 @@
1
+ {
2
+ "version": "10.04"
3
+ }
@@ -0,0 +1,237 @@
1
+ require 'chef'
2
+ require 'ohai'
3
+
4
+ module Fauxhai
5
+ class Runner
6
+ def initialize(args)
7
+ @system = Ohai::System.new
8
+ @system.all_plugins
9
+
10
+ result = @system.data.dup.delete_if{|k,v| !whitelist_attributes.include?(k)}.merge(
11
+ 'languages' => languages,
12
+ 'chef_packages' => chef_packages,
13
+ 'counters' => counters,
14
+ 'current_user' => current_user,
15
+ 'domain' => domain,
16
+ 'etc' => etc,
17
+ 'hostname' => hostname,
18
+ 'fqdn' => fqdn,
19
+ 'ipaddress' => ipaddress,
20
+ 'keys' => keys,
21
+ 'macaddress' => macaddress,
22
+ 'network' => network,
23
+ 'uptime' => uptime,
24
+ 'uptime_seconds' => uptime_seconds
25
+ )
26
+
27
+ puts JSON.pretty_generate(result)
28
+ end
29
+
30
+ private
31
+ def bin_dir
32
+ '/usr/local/bin'
33
+ end
34
+
35
+ def chef_packages
36
+ chef_version = @system.data['chef_packages']['chef']['version']
37
+ ohai_version = @system.data['chef_packages']['ohai']['version']
38
+
39
+ {
40
+ 'chef' => {
41
+ 'version' => chef_version,
42
+ 'chef_root' => [gems_dir, "chef-#{chef_version}", 'lib'].join('/')
43
+ },
44
+ 'ohai' => {
45
+ 'version' => ohai_version,
46
+ 'ohai_root' => [gems_dir, "ohai-#{ohai_version}", 'lib', 'ohai'].join('/')
47
+ }
48
+ }
49
+ end
50
+
51
+ def counters
52
+ {
53
+ 'network' => {
54
+ 'interfaces' => {
55
+ 'eth0' => {
56
+ 'rx' => {
57
+ 'bytes' => '0',
58
+ 'packets' => '0',
59
+ 'errors' => '0',
60
+ 'drop' => 0,
61
+ 'overrun' => 0,
62
+ 'frame' => 0,
63
+ 'compressed' => 0,
64
+ 'multicast' => 0
65
+ },
66
+ 'tx' => {
67
+ 'bytes' => '342',
68
+ 'packets' => '0',
69
+ 'errors' => '0',
70
+ 'drop' => 0,
71
+ 'overrun' => 0,
72
+ 'collisions' => '0',
73
+ 'carrier' => 0,
74
+ 'compressed' => 0
75
+ }
76
+ }
77
+ }
78
+ }
79
+ }
80
+ end
81
+
82
+ def current_user
83
+ 'fauxhai'
84
+ end
85
+
86
+ def default_gateway
87
+ '10.0.0.1'
88
+ end
89
+
90
+ def default_interface
91
+ 'eth0'
92
+ end
93
+
94
+ def domain
95
+ 'local'
96
+ end
97
+
98
+ def etc
99
+ {
100
+ 'passwd' => {
101
+ 'fauxhai' => {
102
+ 'dir' => '/home/fauxhai',
103
+ 'gid' => 0,
104
+ 'uid' => 0,
105
+ 'shell' => '/bin/bash',
106
+ 'gecos' => 'Fauxhai'
107
+ }
108
+ },
109
+ 'group' => {
110
+ 'fauxhai' => {
111
+ 'gid' => 0,
112
+ 'members' => [
113
+ 'fauxhai'
114
+ ]
115
+ }
116
+ }
117
+ }
118
+ end
119
+
120
+ def fqdn
121
+ 'fauxhai.local'
122
+ end
123
+
124
+ def gem_bin
125
+ '/usr/local/bin/gem'
126
+ end
127
+
128
+ def gems_dir
129
+ '/usr/local/gems'
130
+ end
131
+
132
+ def hostname
133
+ 'Fauxhai'
134
+ end
135
+
136
+ def ipaddress
137
+ '10.0.0.2'
138
+ end
139
+
140
+ def ip6address
141
+ 'fe80:0:0:0:0:0:a00:2'
142
+ end
143
+
144
+ def keys
145
+ {
146
+ 'ssh' => ssh
147
+ }
148
+ end
149
+
150
+ def languages
151
+ {
152
+ 'ruby' => @system.data['languages']['ruby'].merge({
153
+ 'bin_dir' => bin_dir,
154
+ 'gem_bin' => gem_bin,
155
+ 'gems_dir' => gems_dir,
156
+ 'ruby_bin' => ruby_bin,
157
+ })
158
+ }
159
+ end
160
+
161
+ def macaddress
162
+ '11:11:11:11:11:11'
163
+ end
164
+
165
+ def network
166
+ {
167
+ 'default_gateway' => default_gateway,
168
+ 'default_interface' => default_interface,
169
+ 'eth0' => {
170
+ 'addresses' => {
171
+ '10.0.0.2' => {
172
+ 'broadcast' => '10.0.0.255',
173
+ 'family' => 'inet',
174
+ 'netmask' => '255.255.255.0',
175
+ 'prefixlen' => '23',
176
+ 'scope' => 'Global'
177
+ }
178
+ },
179
+ 'arp' => {
180
+ '10.0.0.1' => 'fe:ff:ff:ff:ff:ff'
181
+ },
182
+ 'encapsulation' => 'Ethernet',
183
+ 'flags' => ['BROADCAST', 'MULTICAST', 'UP', 'LOWER_UP'],
184
+ 'mtu' => '1500',
185
+ 'number' => '0',
186
+ 'routes' => {
187
+ '10.0.0.0/255' => {
188
+ 'scope' => 'link',
189
+ 'src' => '10.0.0.2'
190
+ }
191
+ },
192
+ 'state' => 'up',
193
+ 'type' => 'eth'
194
+ }
195
+ }
196
+ end
197
+
198
+ def ruby_bin
199
+ '/usr/local/bin/ruby'
200
+ end
201
+
202
+ def ssh
203
+ {
204
+ 'host_dsa_public' => File.read( File.join(Fauxhai.root, 'lib', 'fauxhai', 'keys', 'id_dsa.pub') ).strip,
205
+ 'host_rsa_public' => File.read( File.join(Fauxhai.root, 'lib', 'fauxhai', 'keys', 'id_rsa.pub') ).strip
206
+ }
207
+ end
208
+
209
+ def uptime
210
+ '30 days 15 hours 07 minutes 30 seconds'
211
+ end
212
+
213
+ def uptime_seconds
214
+ 2646450
215
+ end
216
+
217
+ # Whitelist attributes are attributes that we *actually* want from the node. Other attributes are
218
+ # either ignored or overridden, but we ensure these are returned with the command.
219
+ #
220
+ # @return [Array] - the key of whitelisted attributes
221
+ def whitelist_attributes
222
+ [
223
+ 'command',
224
+ 'dmi',
225
+ 'filesystem',
226
+ 'kernel',
227
+ 'ohai_time',
228
+ 'os',
229
+ 'os_version',
230
+ 'platform',
231
+ 'platform_version',
232
+ 'platform_build',
233
+ 'platform_family'
234
+ ]
235
+ end
236
+ end
237
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fauxhai
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Seth Vargo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: chef
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: net-ssh
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
+ description: Easily mock out ohai data
47
+ email:
48
+ - svargo@customink.com
49
+ executables:
50
+ - fauxhai
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - .rvmrc
56
+ - Gemfile
57
+ - LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - bin/fauxhai
61
+ - examples/chefspec.md
62
+ - examples/rspec-chef.md
63
+ - fauxhai.gemspec
64
+ - lib/fauxhai.rb
65
+ - lib/fauxhai/exception.rb
66
+ - lib/fauxhai/fetcher.rb
67
+ - lib/fauxhai/keys/id_dsa
68
+ - lib/fauxhai/keys/id_dsa.pub
69
+ - lib/fauxhai/keys/id_rsa
70
+ - lib/fauxhai/keys/id_rsa.pub
71
+ - lib/fauxhai/mocker.rb
72
+ - lib/fauxhai/platforms/centos/6.0.json
73
+ - lib/fauxhai/platforms/centos/default.json
74
+ - lib/fauxhai/platforms/chefspec/0.6.1.json
75
+ - lib/fauxhai/platforms/chefspec/default.json
76
+ - lib/fauxhai/platforms/mac_os_x/10.7.4.json
77
+ - lib/fauxhai/platforms/mac_os_x/default.json
78
+ - lib/fauxhai/platforms/ubuntu/10.04.json
79
+ - lib/fauxhai/platforms/ubuntu/default.json
80
+ - lib/fauxhai/runner.rb
81
+ - tmp/.gitkeep
82
+ homepage: https://github.com/customink/fauxhai
83
+ licenses: []
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 1.8.24
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: Fauxhai provides an easy way to mock out your ohai data for testing with
106
+ chefspec!
107
+ test_files: []