chef-zero 4.2.3 → 4.3.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 +4 -4
- data/LICENSE +201 -201
- data/README.md +155 -150
- data/Rakefile +31 -31
- data/bin/chef-zero +100 -100
- data/lib/chef_zero.rb +10 -7
- data/lib/chef_zero/chef_data/acl_path.rb +139 -139
- data/lib/chef_zero/chef_data/cookbook_data.rb +240 -240
- data/lib/chef_zero/chef_data/data_normalizer.rb +207 -207
- data/lib/chef_zero/chef_data/default_creator.rb +446 -446
- data/lib/chef_zero/data_store/data_already_exists_error.rb +29 -29
- data/lib/chef_zero/data_store/data_error.rb +31 -31
- data/lib/chef_zero/data_store/data_not_found_error.rb +28 -28
- data/lib/chef_zero/data_store/default_facade.rb +149 -149
- data/lib/chef_zero/data_store/interface_v1.rb +67 -67
- data/lib/chef_zero/data_store/interface_v2.rb +18 -18
- data/lib/chef_zero/data_store/memory_store.rb +33 -33
- data/lib/chef_zero/data_store/memory_store_v2.rb +155 -155
- data/lib/chef_zero/data_store/raw_file_store.rb +147 -147
- data/lib/chef_zero/data_store/v1_to_v2_adapter.rb +142 -142
- data/lib/chef_zero/data_store/v2_to_v1_adapter.rb +107 -107
- data/lib/chef_zero/endpoints/acl_endpoint.rb +38 -38
- data/lib/chef_zero/endpoints/acls_endpoint.rb +29 -29
- data/lib/chef_zero/endpoints/actor_endpoint.rb +94 -88
- data/lib/chef_zero/endpoints/actors_endpoint.rb +64 -64
- data/lib/chef_zero/endpoints/authenticate_user_endpoint.rb +31 -31
- data/lib/chef_zero/endpoints/container_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/containers_endpoint.rb +13 -13
- data/lib/chef_zero/endpoints/cookbook_endpoint.rb +39 -39
- data/lib/chef_zero/endpoints/cookbook_version_endpoint.rb +119 -119
- data/lib/chef_zero/endpoints/cookbooks_base.rb +65 -65
- data/lib/chef_zero/endpoints/cookbooks_endpoint.rb +19 -19
- data/lib/chef_zero/endpoints/data_bag_endpoint.rb +45 -45
- data/lib/chef_zero/endpoints/data_bag_item_endpoint.rb +25 -25
- data/lib/chef_zero/endpoints/data_bags_endpoint.rb +23 -23
- data/lib/chef_zero/endpoints/environment_cookbook_endpoint.rb +24 -24
- data/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb +123 -123
- data/lib/chef_zero/endpoints/environment_cookbooks_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/environment_endpoint.rb +33 -33
- data/lib/chef_zero/endpoints/environment_nodes_endpoint.rb +23 -23
- data/lib/chef_zero/endpoints/environment_recipes_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/environment_role_endpoint.rb +36 -36
- data/lib/chef_zero/endpoints/file_store_file_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/group_endpoint.rb +20 -20
- data/lib/chef_zero/endpoints/groups_endpoint.rb +13 -13
- data/lib/chef_zero/endpoints/license_endpoint.rb +25 -25
- data/lib/chef_zero/endpoints/node_endpoint.rb +17 -17
- data/lib/chef_zero/endpoints/node_identifiers_endpoint.rb +22 -0
- data/lib/chef_zero/endpoints/not_found_endpoint.rb +11 -11
- data/lib/chef_zero/endpoints/organization_association_request_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/organization_association_requests_endpoint.rb +30 -29
- data/lib/chef_zero/endpoints/organization_authenticate_user_endpoint.rb +26 -26
- data/lib/chef_zero/endpoints/organization_endpoint.rb +46 -41
- data/lib/chef_zero/endpoints/organization_user_base.rb +15 -0
- data/lib/chef_zero/endpoints/organization_user_endpoint.rb +26 -48
- data/lib/chef_zero/endpoints/organization_users_endpoint.rb +43 -14
- data/lib/chef_zero/endpoints/organization_validator_key_endpoint.rb +20 -20
- data/lib/chef_zero/endpoints/organizations_endpoint.rb +62 -55
- data/lib/chef_zero/endpoints/policies_endpoint.rb +151 -154
- data/lib/chef_zero/endpoints/principal_endpoint.rb +42 -42
- data/lib/chef_zero/endpoints/rest_list_endpoint.rb +42 -42
- data/lib/chef_zero/endpoints/rest_object_endpoint.rb +63 -63
- data/lib/chef_zero/endpoints/role_endpoint.rb +16 -16
- data/lib/chef_zero/endpoints/role_environments_endpoint.rb +14 -14
- data/lib/chef_zero/endpoints/sandbox_endpoint.rb +27 -27
- data/lib/chef_zero/endpoints/sandboxes_endpoint.rb +50 -50
- data/lib/chef_zero/endpoints/search_endpoint.rb +194 -192
- data/lib/chef_zero/endpoints/searches_endpoint.rb +18 -18
- data/lib/chef_zero/endpoints/server_api_version_endpoint.rb +14 -0
- data/lib/chef_zero/endpoints/system_recovery_endpoint.rb +30 -30
- data/lib/chef_zero/endpoints/user_association_request_endpoint.rb +40 -40
- data/lib/chef_zero/endpoints/user_association_requests_count_endpoint.rb +19 -19
- data/lib/chef_zero/endpoints/user_association_requests_endpoint.rb +19 -19
- data/lib/chef_zero/endpoints/user_organizations_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/version_endpoint.rb +12 -12
- data/lib/chef_zero/log.rb +7 -7
- data/lib/chef_zero/rest_base.rb +242 -214
- data/lib/chef_zero/rest_error_response.rb +11 -11
- data/lib/chef_zero/rest_request.rb +69 -65
- data/lib/chef_zero/rest_router.rb +45 -45
- data/lib/chef_zero/rspec.rb +308 -308
- data/lib/chef_zero/server.rb +642 -637
- data/lib/chef_zero/socketless_server_map.rb +92 -92
- data/lib/chef_zero/solr/query/binary_operator.rb +52 -52
- data/lib/chef_zero/solr/query/phrase.rb +23 -23
- data/lib/chef_zero/solr/query/range_query.rb +46 -46
- data/lib/chef_zero/solr/query/regexpable_query.rb +29 -29
- data/lib/chef_zero/solr/query/subquery.rb +37 -37
- data/lib/chef_zero/solr/query/term.rb +45 -45
- data/lib/chef_zero/solr/query/unary_operator.rb +43 -43
- data/lib/chef_zero/solr/solr_doc.rb +53 -53
- data/lib/chef_zero/solr/solr_parser.rb +203 -203
- data/lib/chef_zero/version.rb +3 -3
- data/spec/run_oc_pedant.rb +63 -56
- data/spec/search_spec.rb +32 -32
- data/spec/server_spec.rb +92 -91
- data/spec/socketless_server_map_spec.rb +76 -76
- data/spec/support/oc_pedant.rb +132 -134
- data/spec/support/stickywicket.pem +27 -27
- metadata +10 -15
- data/spec/run_pedant.rb +0 -103
- data/spec/support/pedant.rb +0 -129
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
require 'ffi_yajl'
|
|
2
|
-
require 'chef_zero/endpoints/cookbooks_base'
|
|
3
|
-
|
|
4
|
-
module ChefZero
|
|
5
|
-
module Endpoints
|
|
6
|
-
# /environments/NAME/cookbooks
|
|
7
|
-
class EnvironmentCookbooksEndpoint < CookbooksBase
|
|
8
|
-
def get(request)
|
|
9
|
-
environment = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..3]), :create_additions => false)
|
|
10
|
-
constraints = environment['cookbook_versions'] || {}
|
|
11
|
-
if request.query_params['num_versions'] == 'all'
|
|
12
|
-
num_versions = nil
|
|
13
|
-
elsif request.query_params['num_versions']
|
|
14
|
-
num_versions = request.query_params['num_versions'].to_i
|
|
15
|
-
else
|
|
16
|
-
num_versions = 1
|
|
17
|
-
end
|
|
18
|
-
json_response(200, format_cookbooks_list(request, all_cookbooks_list(request), constraints, num_versions))
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
1
|
+
require 'ffi_yajl'
|
|
2
|
+
require 'chef_zero/endpoints/cookbooks_base'
|
|
3
|
+
|
|
4
|
+
module ChefZero
|
|
5
|
+
module Endpoints
|
|
6
|
+
# /environments/NAME/cookbooks
|
|
7
|
+
class EnvironmentCookbooksEndpoint < CookbooksBase
|
|
8
|
+
def get(request)
|
|
9
|
+
environment = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..3]), :create_additions => false)
|
|
10
|
+
constraints = environment['cookbook_versions'] || {}
|
|
11
|
+
if request.query_params['num_versions'] == 'all'
|
|
12
|
+
num_versions = nil
|
|
13
|
+
elsif request.query_params['num_versions']
|
|
14
|
+
num_versions = request.query_params['num_versions'].to_i
|
|
15
|
+
else
|
|
16
|
+
num_versions = 1
|
|
17
|
+
end
|
|
18
|
+
json_response(200, format_cookbooks_list(request, all_cookbooks_list(request), constraints, num_versions))
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
require 'ffi_yajl'
|
|
2
|
-
require 'chef_zero/endpoints/rest_object_endpoint'
|
|
3
|
-
require 'chef_zero/chef_data/data_normalizer'
|
|
4
|
-
|
|
5
|
-
module ChefZero
|
|
6
|
-
module Endpoints
|
|
7
|
-
# /environments/NAME
|
|
8
|
-
class EnvironmentEndpoint < RestObjectEndpoint
|
|
9
|
-
def delete(request)
|
|
10
|
-
if request.rest_path[3] == "_default"
|
|
11
|
-
# 405, really?
|
|
12
|
-
error(405, "The '_default' environment cannot be modified.")
|
|
13
|
-
else
|
|
14
|
-
super(request)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def put(request)
|
|
19
|
-
if request.rest_path[3] == "_default"
|
|
20
|
-
error(405, "The '_default' environment cannot be modified.")
|
|
21
|
-
else
|
|
22
|
-
super(request)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def populate_defaults(request, response_json)
|
|
27
|
-
response = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
|
|
28
|
-
response = ChefData::DataNormalizer.normalize_environment(response, request.rest_path[3])
|
|
29
|
-
FFI_Yajl::Encoder.encode(response, :pretty => true)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
1
|
+
require 'ffi_yajl'
|
|
2
|
+
require 'chef_zero/endpoints/rest_object_endpoint'
|
|
3
|
+
require 'chef_zero/chef_data/data_normalizer'
|
|
4
|
+
|
|
5
|
+
module ChefZero
|
|
6
|
+
module Endpoints
|
|
7
|
+
# /environments/NAME
|
|
8
|
+
class EnvironmentEndpoint < RestObjectEndpoint
|
|
9
|
+
def delete(request)
|
|
10
|
+
if request.rest_path[3] == "_default"
|
|
11
|
+
# 405, really?
|
|
12
|
+
error(405, "The '_default' environment cannot be modified.")
|
|
13
|
+
else
|
|
14
|
+
super(request)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def put(request)
|
|
19
|
+
if request.rest_path[3] == "_default"
|
|
20
|
+
error(405, "The '_default' environment cannot be modified.")
|
|
21
|
+
else
|
|
22
|
+
super(request)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def populate_defaults(request, response_json)
|
|
27
|
+
response = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
|
|
28
|
+
response = ChefData::DataNormalizer.normalize_environment(response, request.rest_path[3])
|
|
29
|
+
FFI_Yajl::Encoder.encode(response, :pretty => true)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
require 'ffi_yajl'
|
|
2
|
-
require 'chef_zero/rest_base'
|
|
3
|
-
|
|
4
|
-
module ChefZero
|
|
5
|
-
module Endpoints
|
|
6
|
-
# /environment/NAME/nodes
|
|
7
|
-
class EnvironmentNodesEndpoint < RestBase
|
|
8
|
-
def get(request)
|
|
9
|
-
# 404 if environment does not exist
|
|
10
|
-
get_data(request, request.rest_path[0..3])
|
|
11
|
-
|
|
12
|
-
result = {}
|
|
13
|
-
list_data(request, request.rest_path[0..1] + ['nodes']).each do |name|
|
|
14
|
-
node = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..1] + ['nodes', name]), :create_additions => false)
|
|
15
|
-
if node['chef_environment'] == request.rest_path[3]
|
|
16
|
-
result[name] = build_uri(request.base_uri, request.rest_path[0..1] + ['nodes', name])
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
json_response(200, result)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
1
|
+
require 'ffi_yajl'
|
|
2
|
+
require 'chef_zero/rest_base'
|
|
3
|
+
|
|
4
|
+
module ChefZero
|
|
5
|
+
module Endpoints
|
|
6
|
+
# /environment/NAME/nodes
|
|
7
|
+
class EnvironmentNodesEndpoint < RestBase
|
|
8
|
+
def get(request)
|
|
9
|
+
# 404 if environment does not exist
|
|
10
|
+
get_data(request, request.rest_path[0..3])
|
|
11
|
+
|
|
12
|
+
result = {}
|
|
13
|
+
list_data(request, request.rest_path[0..1] + ['nodes']).each do |name|
|
|
14
|
+
node = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..1] + ['nodes', name]), :create_additions => false)
|
|
15
|
+
if node['chef_environment'] == request.rest_path[3]
|
|
16
|
+
result[name] = build_uri(request.base_uri, request.rest_path[0..1] + ['nodes', name])
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
json_response(200, result)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
require 'ffi_yajl'
|
|
2
|
-
require 'chef_zero/endpoints/cookbooks_base'
|
|
3
|
-
|
|
4
|
-
module ChefZero
|
|
5
|
-
module Endpoints
|
|
6
|
-
# /environment/NAME/recipes
|
|
7
|
-
class EnvironmentRecipesEndpoint < CookbooksBase
|
|
8
|
-
def get(request)
|
|
9
|
-
environment = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..3]), :create_additions => false)
|
|
10
|
-
constraints = environment['cookbook_versions'] || {}
|
|
11
|
-
result = []
|
|
12
|
-
filter_cookbooks(all_cookbooks_list(request), constraints, 1) do |name, versions|
|
|
13
|
-
if versions.size > 0
|
|
14
|
-
cookbook = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..1] + ['cookbooks', name, versions[0]]), :create_additions => false)
|
|
15
|
-
result += recipe_names(name, cookbook)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
json_response(200, result.sort)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
1
|
+
require 'ffi_yajl'
|
|
2
|
+
require 'chef_zero/endpoints/cookbooks_base'
|
|
3
|
+
|
|
4
|
+
module ChefZero
|
|
5
|
+
module Endpoints
|
|
6
|
+
# /environment/NAME/recipes
|
|
7
|
+
class EnvironmentRecipesEndpoint < CookbooksBase
|
|
8
|
+
def get(request)
|
|
9
|
+
environment = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..3]), :create_additions => false)
|
|
10
|
+
constraints = environment['cookbook_versions'] || {}
|
|
11
|
+
result = []
|
|
12
|
+
filter_cookbooks(all_cookbooks_list(request), constraints, 1) do |name, versions|
|
|
13
|
+
if versions.size > 0
|
|
14
|
+
cookbook = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..1] + ['cookbooks', name, versions[0]]), :create_additions => false)
|
|
15
|
+
result += recipe_names(name, cookbook)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
json_response(200, result.sort)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
require 'ffi_yajl'
|
|
2
|
-
require 'chef_zero/endpoints/cookbooks_base'
|
|
3
|
-
|
|
4
|
-
module ChefZero
|
|
5
|
-
module Endpoints
|
|
6
|
-
# /environments/NAME/roles/NAME
|
|
7
|
-
# /roles/NAME/environments/NAME
|
|
8
|
-
class EnvironmentRoleEndpoint < CookbooksBase
|
|
9
|
-
def get(request)
|
|
10
|
-
# 404 if environment does not exist
|
|
11
|
-
if request.rest_path[2] == 'environments'
|
|
12
|
-
environment_path = request.rest_path[0..1] + request.rest_path[2..3]
|
|
13
|
-
role_path = request.rest_path[0..1] + request.rest_path[4..5]
|
|
14
|
-
else
|
|
15
|
-
environment_path = request.rest_path[0..1] + request.rest_path[4..5]
|
|
16
|
-
role_path = request.rest_path[0..1] + request.rest_path[2..3]
|
|
17
|
-
end
|
|
18
|
-
# Verify that the environment exists
|
|
19
|
-
get_data(request, environment_path)
|
|
20
|
-
|
|
21
|
-
role = FFI_Yajl::Parser.parse(get_data(request, role_path), :create_additions => false)
|
|
22
|
-
environment_name = environment_path[3]
|
|
23
|
-
if environment_name == '_default'
|
|
24
|
-
run_list = role['run_list']
|
|
25
|
-
else
|
|
26
|
-
if role['env_run_lists']
|
|
27
|
-
run_list = role['env_run_lists'][environment_name]
|
|
28
|
-
else
|
|
29
|
-
run_list = nil
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
json_response(200, { 'run_list' => run_list })
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
1
|
+
require 'ffi_yajl'
|
|
2
|
+
require 'chef_zero/endpoints/cookbooks_base'
|
|
3
|
+
|
|
4
|
+
module ChefZero
|
|
5
|
+
module Endpoints
|
|
6
|
+
# /environments/NAME/roles/NAME
|
|
7
|
+
# /roles/NAME/environments/NAME
|
|
8
|
+
class EnvironmentRoleEndpoint < CookbooksBase
|
|
9
|
+
def get(request)
|
|
10
|
+
# 404 if environment does not exist
|
|
11
|
+
if request.rest_path[2] == 'environments'
|
|
12
|
+
environment_path = request.rest_path[0..1] + request.rest_path[2..3]
|
|
13
|
+
role_path = request.rest_path[0..1] + request.rest_path[4..5]
|
|
14
|
+
else
|
|
15
|
+
environment_path = request.rest_path[0..1] + request.rest_path[4..5]
|
|
16
|
+
role_path = request.rest_path[0..1] + request.rest_path[2..3]
|
|
17
|
+
end
|
|
18
|
+
# Verify that the environment exists
|
|
19
|
+
get_data(request, environment_path)
|
|
20
|
+
|
|
21
|
+
role = FFI_Yajl::Parser.parse(get_data(request, role_path), :create_additions => false)
|
|
22
|
+
environment_name = environment_path[3]
|
|
23
|
+
if environment_name == '_default'
|
|
24
|
+
run_list = role['run_list']
|
|
25
|
+
else
|
|
26
|
+
if role['env_run_lists']
|
|
27
|
+
run_list = role['env_run_lists'][environment_name]
|
|
28
|
+
else
|
|
29
|
+
run_list = nil
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
json_response(200, { 'run_list' => run_list })
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
require 'chef_zero/rest_base'
|
|
2
|
-
|
|
3
|
-
module ChefZero
|
|
4
|
-
module Endpoints
|
|
5
|
-
# The minimum amount of S3 necessary to support cookbook upload/download
|
|
6
|
-
# /organizations/NAME/file_store/FILE
|
|
7
|
-
class FileStoreFileEndpoint < RestBase
|
|
8
|
-
def json_only
|
|
9
|
-
false
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def get(request)
|
|
13
|
-
[200, {"Content-Type" => 'application/x-binary'}, get_data(request) ]
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def put(request)
|
|
17
|
-
data_store.set(request.rest_path, request.body, :create, :create_dir, :requestor => request.requestor)
|
|
18
|
-
json_response(200, {})
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
1
|
+
require 'chef_zero/rest_base'
|
|
2
|
+
|
|
3
|
+
module ChefZero
|
|
4
|
+
module Endpoints
|
|
5
|
+
# The minimum amount of S3 necessary to support cookbook upload/download
|
|
6
|
+
# /organizations/NAME/file_store/FILE
|
|
7
|
+
class FileStoreFileEndpoint < RestBase
|
|
8
|
+
def json_only
|
|
9
|
+
false
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def get(request)
|
|
13
|
+
[200, {"Content-Type" => 'application/x-binary'}, get_data(request) ]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def put(request)
|
|
17
|
+
data_store.set(request.rest_path, request.body, :create, :create_dir, :requestor => request.requestor)
|
|
18
|
+
json_response(200, {})
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
require 'ffi_yajl'
|
|
2
|
-
require 'chef_zero/endpoints/rest_object_endpoint'
|
|
3
|
-
require 'chef_zero/chef_data/data_normalizer'
|
|
4
|
-
|
|
5
|
-
module ChefZero
|
|
6
|
-
module Endpoints
|
|
7
|
-
# /organizations/ORG/groups/NAME
|
|
8
|
-
class GroupEndpoint < RestObjectEndpoint
|
|
9
|
-
def initialize(server)
|
|
10
|
-
super(server, %w(id groupname))
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def populate_defaults(request, response_json)
|
|
14
|
-
group = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
|
|
15
|
-
group = ChefData::DataNormalizer.normalize_group(group, request.rest_path[3], request.rest_path[1])
|
|
16
|
-
FFI_Yajl::Encoder.encode(group, :pretty => true)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
1
|
+
require 'ffi_yajl'
|
|
2
|
+
require 'chef_zero/endpoints/rest_object_endpoint'
|
|
3
|
+
require 'chef_zero/chef_data/data_normalizer'
|
|
4
|
+
|
|
5
|
+
module ChefZero
|
|
6
|
+
module Endpoints
|
|
7
|
+
# /organizations/ORG/groups/NAME
|
|
8
|
+
class GroupEndpoint < RestObjectEndpoint
|
|
9
|
+
def initialize(server)
|
|
10
|
+
super(server, %w(id groupname))
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def populate_defaults(request, response_json)
|
|
14
|
+
group = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
|
|
15
|
+
group = ChefData::DataNormalizer.normalize_group(group, request.rest_path[3], request.rest_path[1])
|
|
16
|
+
FFI_Yajl::Encoder.encode(group, :pretty => true)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
require 'ffi_yajl'
|
|
2
|
-
require 'chef_zero/endpoints/rest_list_endpoint'
|
|
3
|
-
|
|
4
|
-
module ChefZero
|
|
5
|
-
module Endpoints
|
|
6
|
-
# /organizations/ORG/groups/NAME
|
|
7
|
-
class GroupsEndpoint < RestListEndpoint
|
|
8
|
-
def initialize(server)
|
|
9
|
-
super(server, %w(id groupname))
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
1
|
+
require 'ffi_yajl'
|
|
2
|
+
require 'chef_zero/endpoints/rest_list_endpoint'
|
|
3
|
+
|
|
4
|
+
module ChefZero
|
|
5
|
+
module Endpoints
|
|
6
|
+
# /organizations/ORG/groups/NAME
|
|
7
|
+
class GroupsEndpoint < RestListEndpoint
|
|
8
|
+
def initialize(server)
|
|
9
|
+
super(server, %w(id groupname))
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
require 'ffi_yajl'
|
|
2
|
-
require 'chef_zero/rest_base'
|
|
3
|
-
|
|
4
|
-
module ChefZero
|
|
5
|
-
module Endpoints
|
|
6
|
-
# /license
|
|
7
|
-
class LicenseEndpoint < RestBase
|
|
8
|
-
MAX_NODE_COUNT = 25
|
|
9
|
-
|
|
10
|
-
def get(request)
|
|
11
|
-
node_count = 0
|
|
12
|
-
list_data(request, [ 'organizations' ]).each do |orgname|
|
|
13
|
-
node_count += list_data(request, [ 'organizations', orgname, 'nodes' ]).size
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
json_response(200, {
|
|
17
|
-
"limit_exceeded" => (node_count > MAX_NODE_COUNT) ? true : false,
|
|
18
|
-
"node_license" => MAX_NODE_COUNT,
|
|
19
|
-
"node_count" => node_count,
|
|
20
|
-
"upgrade_url" => 'http://blah.com'
|
|
21
|
-
})
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
1
|
+
require 'ffi_yajl'
|
|
2
|
+
require 'chef_zero/rest_base'
|
|
3
|
+
|
|
4
|
+
module ChefZero
|
|
5
|
+
module Endpoints
|
|
6
|
+
# /license
|
|
7
|
+
class LicenseEndpoint < RestBase
|
|
8
|
+
MAX_NODE_COUNT = 25
|
|
9
|
+
|
|
10
|
+
def get(request)
|
|
11
|
+
node_count = 0
|
|
12
|
+
list_data(request, [ 'organizations' ]).each do |orgname|
|
|
13
|
+
node_count += list_data(request, [ 'organizations', orgname, 'nodes' ]).size
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
json_response(200, {
|
|
17
|
+
"limit_exceeded" => (node_count > MAX_NODE_COUNT) ? true : false,
|
|
18
|
+
"node_license" => MAX_NODE_COUNT,
|
|
19
|
+
"node_count" => node_count,
|
|
20
|
+
"upgrade_url" => 'http://blah.com'
|
|
21
|
+
})
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
require 'ffi_yajl'
|
|
2
|
-
require 'chef_zero/endpoints/rest_object_endpoint'
|
|
3
|
-
require 'chef_zero/chef_data/data_normalizer'
|
|
4
|
-
|
|
5
|
-
module ChefZero
|
|
6
|
-
module Endpoints
|
|
7
|
-
# /nodes/ID
|
|
8
|
-
class NodeEndpoint < RestObjectEndpoint
|
|
9
|
-
def populate_defaults(request, response_json)
|
|
10
|
-
node = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
|
|
11
|
-
node = ChefData::DataNormalizer.normalize_node(node, request.rest_path[3])
|
|
12
|
-
FFI_Yajl::Encoder.encode(node, :pretty => true)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
1
|
+
require 'ffi_yajl'
|
|
2
|
+
require 'chef_zero/endpoints/rest_object_endpoint'
|
|
3
|
+
require 'chef_zero/chef_data/data_normalizer'
|
|
4
|
+
|
|
5
|
+
module ChefZero
|
|
6
|
+
module Endpoints
|
|
7
|
+
# /nodes/ID
|
|
8
|
+
class NodeEndpoint < RestObjectEndpoint
|
|
9
|
+
def populate_defaults(request, response_json)
|
|
10
|
+
node = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
|
|
11
|
+
node = ChefData::DataNormalizer.normalize_node(node, request.rest_path[3])
|
|
12
|
+
FFI_Yajl::Encoder.encode(node, :pretty => true)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|