chef_fixie 0.1.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.
- checksums.yaml +7 -0
- data/LICENSE +201 -0
- data/README.md +69 -0
- data/bin/bundler +16 -0
- data/bin/chef-apply +16 -0
- data/bin/chef-client +16 -0
- data/bin/chef-shell +16 -0
- data/bin/chef-solo +16 -0
- data/bin/chef-zero +16 -0
- data/bin/chef_fixie +5 -0
- data/bin/coderay +16 -0
- data/bin/edit_json.rb +16 -0
- data/bin/erubis +16 -0
- data/bin/ffi-yajl-bench +16 -0
- data/bin/fixie~ +231 -0
- data/bin/htmldiff +16 -0
- data/bin/knife +16 -0
- data/bin/ldiff +16 -0
- data/bin/net-dhcp +16 -0
- data/bin/ohai +16 -0
- data/bin/prettify_json.rb +16 -0
- data/bin/pry +16 -0
- data/bin/rackup +16 -0
- data/bin/rake +16 -0
- data/bin/rdoc +16 -0
- data/bin/restclient +16 -0
- data/bin/ri +16 -0
- data/bin/rspec +16 -0
- data/bin/s3sh +16 -0
- data/bin/sequel +16 -0
- data/bin/serverspec-init +16 -0
- data/doc/AccessingSQL.md +36 -0
- data/doc/AccessingSQL.md~ +32 -0
- data/doc/BulkFixup.md~ +28 -0
- data/doc/CommonTasks.md +20 -0
- data/doc/CommonTasks.md~ +0 -0
- data/doc/GETTING_STARTED.md +228 -0
- data/doc/GETTING_STARTED.md~ +6 -0
- data/fixie.conf.example +8 -0
- data/lib/chef_fixie.rb +27 -0
- data/lib/chef_fixie/authz_mapper.rb +143 -0
- data/lib/chef_fixie/authz_objects.rb +285 -0
- data/lib/chef_fixie/check_org_associations.rb +242 -0
- data/lib/chef_fixie/config.rb +139 -0
- data/lib/chef_fixie/console.rb +91 -0
- data/lib/chef_fixie/context.rb +72 -0
- data/lib/chef_fixie/sql.rb +74 -0
- data/lib/chef_fixie/sql_objects.rb +497 -0
- data/lib/chef_fixie/utility_helpers.rb +59 -0
- data/lib/chef_fixie/version.rb +3 -0
- data/spec/chef_fixie/acl_spec.rb +83 -0
- data/spec/chef_fixie/assoc_invite_spec.rb +47 -0
- data/spec/chef_fixie/assoc_invite_spec.rb~ +26 -0
- data/spec/chef_fixie/check_org_associations_spec.rb +140 -0
- data/spec/chef_fixie/check_org_associations_spec.rb~ +34 -0
- data/spec/chef_fixie/groups_spec.rb +34 -0
- data/spec/chef_fixie/org_spec.rb +26 -0
- data/spec/chef_fixie/org_spec.rb~ +53 -0
- data/spec/chef_fixie/orgs_spec.rb +53 -0
- data/spec/spec_helper.rb +41 -0
- metadata +252 -0
data/bin/ffi-yajl-bench
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'ffi-yajl-bench' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('ffi-yajl', 'ffi-yajl-bench')
|
data/bin/fixie~
ADDED
@@ -0,0 +1,231 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "bundler/setup"
|
5
|
+
|
6
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib/')
|
7
|
+
|
8
|
+
require 'optparse'
|
9
|
+
require 'irb'
|
10
|
+
require 'irb/init'
|
11
|
+
require 'irb/completion'
|
12
|
+
require 'irb/ext/history'
|
13
|
+
require 'pp'
|
14
|
+
require 'pry'
|
15
|
+
|
16
|
+
require 'fixie/config'
|
17
|
+
|
18
|
+
require 'fixie'
|
19
|
+
|
20
|
+
# IRB tries to overwrite our custom settings when it loads, so we have to hax0r
|
21
|
+
# it to work.
|
22
|
+
module IRB
|
23
|
+
class << self
|
24
|
+
alias :run_original_config :run_config
|
25
|
+
|
26
|
+
def run_config
|
27
|
+
run_original_config
|
28
|
+
::Fixie::Console.configure_irb
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
module Fixie
|
35
|
+
|
36
|
+
module Context
|
37
|
+
|
38
|
+
def describe_orgs
|
39
|
+
OrgMetrics.org_stats(orgs)
|
40
|
+
end
|
41
|
+
|
42
|
+
def orgs
|
43
|
+
Fixie::Organizations.new
|
44
|
+
end
|
45
|
+
|
46
|
+
def jobs
|
47
|
+
Fixie::Jobs.new
|
48
|
+
end
|
49
|
+
|
50
|
+
def users
|
51
|
+
Fixie::Users.new
|
52
|
+
end
|
53
|
+
|
54
|
+
def global_groups
|
55
|
+
Fixie::GlobalGroups.new
|
56
|
+
end
|
57
|
+
|
58
|
+
def help
|
59
|
+
puts(<<-HALP)
|
60
|
+
** ORGS **
|
61
|
+
* access with ORGS or ORGS
|
62
|
+
* access a specific org: ORGS['orgname']
|
63
|
+
|
64
|
+
** USERS **
|
65
|
+
* users.find('clownco-org-admin')
|
66
|
+
* users.grep :clownco
|
67
|
+
* users.usernames
|
68
|
+
|
69
|
+
** RAW SQL ACCESS**
|
70
|
+
* sql[:users].select(:column, :column).where(:column => "condition").all
|
71
|
+
|
72
|
+
** irb Help **
|
73
|
+
irb_help
|
74
|
+
|
75
|
+
HALP
|
76
|
+
:COOL_STORY_BRO
|
77
|
+
end
|
78
|
+
|
79
|
+
def sql
|
80
|
+
Opscode::Mappers.default_connection
|
81
|
+
end
|
82
|
+
|
83
|
+
def associate_user(username, orgname)
|
84
|
+
unless user = users.find(username)
|
85
|
+
raise ArgumentError, "No users matched '#{username}'"
|
86
|
+
end
|
87
|
+
unless org = ORGS[orgname]
|
88
|
+
raise ArgumentError, "No orgs matched '#{orgname}'"
|
89
|
+
end
|
90
|
+
|
91
|
+
Fixie::Associator.associate_user(org, user)
|
92
|
+
end
|
93
|
+
|
94
|
+
def dissociate_user(username, orgname)
|
95
|
+
unless user = users.find(username)
|
96
|
+
raise ArgumentError, "No users matched '#{username}'"
|
97
|
+
end
|
98
|
+
unless org = ORGS[orgname]
|
99
|
+
raise ArgumentError, "No orgs matched '#{orgname}'"
|
100
|
+
end
|
101
|
+
|
102
|
+
Fixie::Dissociator.dissociate_user(org, user)
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
module Console
|
108
|
+
extend self
|
109
|
+
|
110
|
+
def irb_conf
|
111
|
+
IRB.conf
|
112
|
+
end
|
113
|
+
|
114
|
+
def start
|
115
|
+
# FUGLY HACK: irb gives us no other choice.
|
116
|
+
irb_help = [:help, :irb_help, IRB::ExtendCommandBundle::NO_OVERRIDE]
|
117
|
+
IRB::ExtendCommandBundle.instance_variable_get(:@ALIASES).delete(irb_help)
|
118
|
+
|
119
|
+
# This has to come before IRB.setup b/c IRB.setup eats ARGV.
|
120
|
+
configure
|
121
|
+
|
122
|
+
# HACK: this duplicates the functions of IRB.start, but we have to do it
|
123
|
+
# to get access to the main object before irb starts.
|
124
|
+
::IRB.setup(nil)
|
125
|
+
|
126
|
+
irb = IRB::Irb.new
|
127
|
+
|
128
|
+
setup(irb.context.main)
|
129
|
+
|
130
|
+
|
131
|
+
irb_conf[:IRB_RC].call(irb.context) if irb_conf[:IRB_RC]
|
132
|
+
irb_conf[:MAIN_CONTEXT] = irb.context
|
133
|
+
|
134
|
+
trap("SIGINT") do
|
135
|
+
irb.signal_handle
|
136
|
+
end
|
137
|
+
|
138
|
+
catch(:IRB_EXIT) do
|
139
|
+
irb.eval_input
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def configure
|
144
|
+
|
145
|
+
if ARGV.first && ARGV[0].chars.first != "-" && config_file = ARGV.shift
|
146
|
+
config_file = File.expand_path(config_file)
|
147
|
+
|
148
|
+
load_config_file = true
|
149
|
+
end
|
150
|
+
|
151
|
+
options = {}
|
152
|
+
OptionParser.new do |opt|
|
153
|
+
opt.banner = "Usage: orgmapper [config] [options]"
|
154
|
+
opt.on('--couchdb-uri COUCH_URI', 'The URI of the couchdb server to connect to') { |v| options[:couchdb_uri] = v }
|
155
|
+
opt.on("--database ACCOUNT_DATABASE", 'The name of the opscode account database') { |v| options[:database] = v }
|
156
|
+
opt.on('--auth-uri AUTH_URI', "The URI of the opscode authz service") { |v| options[:auth_uri] =v }
|
157
|
+
opt.on_tail('-h', '--help', 'Show this message') do
|
158
|
+
puts opt
|
159
|
+
puts "\nExample configuration file:\n\n"
|
160
|
+
puts Fixie::Config.instance.example_config
|
161
|
+
puts "\n"
|
162
|
+
exit(1)
|
163
|
+
end
|
164
|
+
opt.parse!(ARGV)
|
165
|
+
end
|
166
|
+
pp :cli_opts => options if ENV["DEBUG"]
|
167
|
+
|
168
|
+
if load_config_file
|
169
|
+
puts "loading config: #{config_file}..."
|
170
|
+
Kernel.load(config_file)
|
171
|
+
end
|
172
|
+
|
173
|
+
Fixie::Config.instance.merge_opts(options)
|
174
|
+
puts Fixie::Config.instance.to_text
|
175
|
+
end
|
176
|
+
|
177
|
+
def setup(context)
|
178
|
+
Object.send(:include, Mixlib::Authorization::AuthHelper)
|
179
|
+
Object.const_set(:PLATFORM_BACKEND, Fixie::Backend.new(*Config.instance.to_ary))
|
180
|
+
Object.const_set(:ORGS, Fixie::Organizations.new)
|
181
|
+
Object.const_set(:JOBS, Fixie::Jobs.new)
|
182
|
+
Object.const_set(:USERS, Fixie::Users.new)
|
183
|
+
Object.const_set(:GLOBAL_GROUPS, Fixie::GlobalGroups.new)
|
184
|
+
|
185
|
+
context.extend(Context)
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
# Configure IRB how we like it. This needs to be hooked into IRB.run_config
|
190
|
+
Object.send(:include, Mixlib::Authorization::AuthHelper)
|
191
|
+
Object.const_set(:PLATFORM_BACKEND, Fixie::Backend.new(*Config.instance.to_ary))
|
192
|
+
Object.const_set(:ORGS, Fixie::Organizations.new)
|
193
|
+
Object.const_set(:JOBS, Fixie::Jobs.new)
|
194
|
+
Object.const_set(:USERS, Fixie::Users.new)
|
195
|
+
Object.const_set(:GLOBAL_GROUPS, Fixie::GlobalGroups.new)
|
196
|
+
|
197
|
+
context.extend(Context)
|
198
|
+
|
199
|
+
end
|
200
|
+
|
201
|
+
# Configure IRB how we like it. This needs to be hooked into IRB.run_config
|
202
|
+
# because much of IRB's code is anachronistic
|
203
|
+
def configure_irb
|
204
|
+
IRB.init_config(__FILE__)
|
205
|
+
|
206
|
+
IRB.conf[:HISTORY_FILE] = "~/.orgmapper_history"
|
207
|
+
IRB.conf[:SAVE_HISTORY]=1000
|
208
|
+
IRB.conf[:USE_READLINE]=true
|
209
|
+
IRB.conf[:PROMPT][:ORGMAPPER] = { # name of prompt mode
|
210
|
+
:PROMPT_I => "orgmapper:%i > ", # normal prompt
|
211
|
+
:PROMPT_S => "..%l ", # prompt for continuing strings
|
212
|
+
:PROMPT_C => "... ", # prompt for continuing statement
|
213
|
+
:RETURN => "%s\n" # format to return value
|
214
|
+
}
|
215
|
+
|
216
|
+
IRB.conf[:PROMPT_MODE] = :ORGMAPPER
|
217
|
+
|
218
|
+
begin
|
219
|
+
require 'wirble'
|
220
|
+
Wirble.init
|
221
|
+
Wirble.colorize
|
222
|
+
rescue LoadError
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|
226
|
+
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
Fixie::Console.start
|
231
|
+
|
data/bin/htmldiff
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'htmldiff' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('diff-lcs', 'htmldiff')
|
data/bin/knife
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'knife' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('chef', 'knife')
|
data/bin/ldiff
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'ldiff' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('diff-lcs', 'ldiff')
|
data/bin/net-dhcp
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'net-dhcp' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('net-dhcp', 'net-dhcp')
|
data/bin/ohai
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'ohai' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('ohai', 'ohai')
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'prettify_json.rb' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('json', 'prettify_json.rb')
|
data/bin/pry
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'pry' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('pry', 'pry')
|
data/bin/rackup
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rackup' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rack', 'rackup')
|
data/bin/rake
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rake' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rake', 'rake')
|
data/bin/rdoc
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rdoc' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rdoc', 'rdoc')
|
data/bin/restclient
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'restclient' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rest-client', 'restclient')
|