Module: ChefServerSlice
- Defined in:
- lib/chef-server-slice.rb
Overview
All Slice code is expected to be namespaced inside a module
Defined Under Namespace
Classes: Application, CookbookFiles, CookbookSegment, CookbookTemplates, Cookbooks, Exceptions, Main, Nodes, OpenidConsumer, OpenidRegister, OpenidServer, Roles, Search, SearchEntries, Status
Class Method Summary collapse
-
.activate ⇒ Object
Activation hook - runs after AfterAppLoads BootLoader.
-
.deactivate ⇒ Object
Deactivation hook - triggered by Merb::Slices.deactivate(Chefserver).
-
.init ⇒ Object
Initialization hook - runs before AfterAppLoads BootLoader.
-
.loaded ⇒ Object
Stub classes loaded hook - runs before LoadClasses BootLoader right after a slice’s classes have been loaded internally.
-
.setup_router(scope) ⇒ Object
Setup routes inside the host application.
Class Method Details
.activate ⇒ Object
Activation hook - runs after AfterAppLoads BootLoader
66 67 |
# File 'lib/chef-server-slice.rb', line 66 def self.activate end |
.deactivate ⇒ Object
Deactivation hook - triggered by Merb::Slices.deactivate(Chefserver)
70 71 |
# File 'lib/chef-server-slice.rb', line 70 def self.deactivate end |
.init ⇒ Object
Initialization hook - runs before AfterAppLoads BootLoader
62 63 |
# File 'lib/chef-server-slice.rb', line 62 def self.init end |
.loaded ⇒ Object
Stub classes loaded hook - runs before LoadClasses BootLoader right after a slice’s classes have been loaded internally.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/chef-server-slice.rb', line 35 def self.loaded Chef::Queue.connect # create the couch databases for openid association and nonce storage, if configured if Chef::Config[:openid_store_couchdb] || Chef::Config[:openid_cstore_couchdb] rest = Chef::REST.new(Chef::Config[:couchdb_url]) @database_list = rest.get_rest("_all_dbs") unless @database_list.detect { |db| db == 'associations' } response = rest.put_rest('associations', Hash.new) end unless @database_list.detect { |db| db == 'nonces' } response = rest.put_rest('nonces', Hash.new) end end # create the couch design docs for nodes and openid registrations Chef::Node.create_design_document Chef::Role.create_design_document Chef::OpenIDRegistration.create_design_document Chef::Log.logger = Merb.logger Chef::Log.info("Compiling routes... (totally normal to see 'Cannot find resource model')") Chef::Log.info("Loading roles") Chef::Role.sync_from_disk_to_couchdb end |
.setup_router(scope) ⇒ Object
prefix your named routes with :chefserverslice_ to avoid potential conflicts with global named routes.
Setup routes inside the host application
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/chef-server-slice.rb', line 82 def self.setup_router(scope) scope.resources :nodes scope.resources :roles scope.match("/status").to(:controller => "status", :action => "index").name(:status) scope.resources :searches, :path => "search", :controller => "search" scope.match("/search/:search_id/entries", :method => 'get').to(:controller => "search_entries", :action => "index") scope.match("/search/:search_id/entries", :method => 'post').to(:controller => "search_entries", :action => "create") scope.match("/search/:search_id/entries/:id", :method => 'get').to(:controller => "search_entries", :action => "show") scope.match("/search/:search_id/entries/:id", :method => 'put').to(:controller => "search_entries", :action => "create") scope.match("/search/:search_id/entries/:id", :method => 'post').to(:controller => "search_entries", :action => "update") scope.match("/search/:search_id/entries/:id", :method => 'delete').to(:controller => "search_entries", :action => "destroy") scope.match("/cookbooks/_attribute_files").to(:controller => "cookbooks", :action => "files", :type => :attributes) scope.match("/cookbooks/_recipe_files").to(:controller => "cookbooks", :action => "files", :type => :recipes) scope.match("/cookbooks/_definition_files").to(:controller => "cookbooks", :action => "files", :type => :definitions) scope.match("/cookbooks/_library_files").to(:controller => "cookbooks", :action => "files", :type => :libraries) scope.match("/cookbooks/_provider_files").to(:controller => "cookbooks", :action => "files", :type => :providers) scope.match("/cookbooks/_resource_files").to(:controller => "cookbooks", :action => "files", :type => :resources) scope.match("/cookbooks/:cookbook_id/templates", :cookbook_id => /[\w\.]+/).to(:controller => "cookbook_templates", :action => "index") scope.match("/cookbooks/:cookbook_id/libraries", :cookbook_id => /[\w\.]+/).to(:controller => "cookbook_segment", :action => "index", :type => :libraries) scope.match("/cookbooks/:cookbook_id/definitions", :cookbook_id => /[\w\.]+/).to(:controller => "cookbook_segment", :action => "index", :type => :definitions) scope.match("/cookbooks/:cookbook_id/providers", :cookbook_id => /[\w\.]+/).to(:controller => "cookbook_segment", :action => "index", :type => :providers) scope.match("/cookbooks/:cookbook_id/resources", :cookbook_id => /[\w\.]+/).to(:controller => "cookbook_segment", :action => "index", :type => :resources) scope.match("/cookbooks/:cookbook_id/recipes", :cookbook_id => /[\w\.]+/).to(:controller => "cookbook_segment", :action => "index", :type => :recipes) scope.match("/cookbooks/:cookbook_id/attributes", :cookbook_id => /[\w\.]+/).to(:controller => "cookbook_segment", :action => "index", :type => :attributes) scope.match("/cookbooks/:cookbook_id/files", :cookbook_id => /[\w\.]+/).to(:controller => "cookbook_files", :action => "index") scope.resources :cookbooks scope.resources :registrations, :controller => "openid_register" scope.resources :registrations, :controller => "openid_register", :member => { :validate => :post } scope.resources :registrations, :controller => "openid_register", :member => { :admin => :post } scope.match("/openid/server").to(:controller => "openid_server", :action => "index").name(:openid_server) scope.match("/openid/server/server/xrds"). to(:controller => "openid_server", :action => 'idp_xrds').name(:openid_server_xrds) scope.match("/openid/server/node/:id"). to(:controller => "openid_server", :action => 'node_page').name(:openid_node) scope.match('/openid/server/node/:id/xrds'). to(:controller => 'openid_server', :action => 'node_xrds').name(:openid_node_xrds) scope.match('/openid/server/decision').to(:controller => "openid_server", :action => "decision").name(:openid_server_decision) scope.match('/login').to(:controller=>'openid_consumer', :action=>'index').name(:openid_consumer) scope.match('/logout').to(:controller => 'openid_consumer', :action => 'logout').name(:openid_consumer_logout) scope.match('/openid/consumer').to(:controller => 'openid_consumer', :action => 'index').name(:openid_consumer) scope.match('/openid/consumer/start').to(:controller => 'openid_consumer', :action => 'start').name(:openid_consumer_start) scope.match('/openid/consumer/login').to(:controller => 'openid_consumer', :action => 'login').name(:openid_consumer_login) scope.match('/openid/consumer/complete').to(:controller => 'openid_consumer', :action => 'complete').name(:openid_consumer_complete) scope.match('/openid/consumer/logout').to(:controller => 'openid_consumer', :action => 'logout').name(:openid_consumer_logout) scope.match('/').to(:controller => 'nodes', :action =>'index').name(:top) # enable slice-level default routes by default # scope.default_routes end |