puppetdb_foreman 5.0.0 → 6.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -14
- data/Rakefile +9 -6
- data/app/controllers/api/v2/puppetdb_nodes_controller.rb +8 -6
- data/app/controllers/puppetdb_foreman/nodes_controller.rb +22 -8
- data/app/helpers/concerns/puppetdb_foreman/hosts_helper_extensions.rb +5 -3
- data/app/models/concerns/orchestration/puppetdb.rb +16 -8
- data/app/models/puppetdb_foreman/host_extensions.rb +5 -4
- data/app/services/puppetdb.rb +8 -12
- data/app/services/puppetdb_client/base.rb +8 -6
- data/app/services/puppetdb_client/v4.rb +48 -1
- data/app/services/puppetdb_host.rb +4 -2
- data/app/views/api/v2/puppetdb_nodes/import.json.rabl +2 -0
- data/app/views/api/v2/puppetdb_nodes/index.json.rabl +2 -0
- data/app/views/api/v2/puppetdb_nodes/unknown.json.rabl +2 -0
- data/config/routes.rb +11 -9
- data/db/migrate/20170717140010_migrate_puppetdb_api_version_setting.rb +4 -2
- data/db/migrate/20181001113836_remove_puppetdb_dashboard_address_setting.puppetdb_foreman.rb +3 -1
- data/db/migrate/20221026123754_fix_puppetdb_settings_category_to_dsl.rb +9 -0
- data/lib/puppetdb_foreman/engine.rb +55 -27
- data/lib/puppetdb_foreman/version.rb +3 -1
- data/lib/puppetdb_foreman.rb +2 -0
- data/lib/tasks/puppetdb_foreman_tasks.rake +4 -4
- data/test/controllers/api/v2/puppetdb_nodes_controller_test.rb +60 -55
- data/test/controllers/nodes_controller_test.rb +7 -6
- data/test/models/host_test.rb +6 -5
- data/test/test_plugin_helper.rb +2 -4
- data/test/unit/puppetdb_host_test.rb +5 -4
- data/test/unit/puppetdb_test.rb +18 -135
- metadata +21 -26
- data/app/models/setting/puppetdb.rb +0 -49
- data/app/services/puppetdb_client/v1.rb +0 -33
- data/app/services/puppetdb_client/v3.rb +0 -49
- data/test/static_fixtures/query_nodes.json +0 -61
@@ -1,33 +0,0 @@
|
|
1
|
-
module PuppetdbClient
|
2
|
-
class V1 < Base
|
3
|
-
# The payload is expected to be the certname of a node as a serialized JSON string.
|
4
|
-
def deactivate_node_payload(nodename)
|
5
|
-
payload = {
|
6
|
-
'command' => 'deactivate node',
|
7
|
-
'version' => 1,
|
8
|
-
'payload' => nodename.to_json
|
9
|
-
}.to_json
|
10
|
-
'payload=' + payload
|
11
|
-
end
|
12
|
-
|
13
|
-
def command_url
|
14
|
-
'/v3/commands'
|
15
|
-
end
|
16
|
-
|
17
|
-
def nodes_url
|
18
|
-
'/v3/nodes'
|
19
|
-
end
|
20
|
-
|
21
|
-
def facts_url
|
22
|
-
'/v3/facts'
|
23
|
-
end
|
24
|
-
|
25
|
-
def resources_url
|
26
|
-
'/v3/resources'
|
27
|
-
end
|
28
|
-
|
29
|
-
def query_nodes
|
30
|
-
super.map { |node| node['name'] }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module PuppetdbClient
|
2
|
-
class V3 < Base
|
3
|
-
# The payload is formatted as a JSON map.
|
4
|
-
# certname: The name of the node for which the catalog was compiled.
|
5
|
-
# producer_timestamp: The time of command submission.
|
6
|
-
def deactivate_node_payload(nodename)
|
7
|
-
{
|
8
|
-
'command' => 'deactivate node',
|
9
|
-
'version' => 3,
|
10
|
-
'payload' => {
|
11
|
-
'certname' => nodename,
|
12
|
-
'producer_timestamp' => producer_timestamp
|
13
|
-
}
|
14
|
-
}.to_json
|
15
|
-
end
|
16
|
-
|
17
|
-
def command_url
|
18
|
-
'/pdb/cmd/v1'
|
19
|
-
end
|
20
|
-
|
21
|
-
def nodes_url
|
22
|
-
'/pdb/query/v4/nodes'
|
23
|
-
end
|
24
|
-
|
25
|
-
def facts_url
|
26
|
-
'/pdb/query/v4/facts'
|
27
|
-
end
|
28
|
-
|
29
|
-
def resources_url
|
30
|
-
'/pdb/query/v4/resources'
|
31
|
-
end
|
32
|
-
|
33
|
-
def query_nodes
|
34
|
-
super.map { |node| node['certname'] }
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def post_options
|
40
|
-
{
|
41
|
-
content_type: :json
|
42
|
-
}
|
43
|
-
end
|
44
|
-
|
45
|
-
def producer_timestamp
|
46
|
-
Time.now.iso8601.to_s
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
[ {
|
2
|
-
"name" : "server1.example.com",
|
3
|
-
"deactivated" : null,
|
4
|
-
"catalog_timestamp" : "2017-04-20T15:07:27.114Z",
|
5
|
-
"facts_timestamp" : "2017-04-20T15:06:52.738Z",
|
6
|
-
"report_timestamp" : null
|
7
|
-
}, {
|
8
|
-
"name" : "server2.example.com",
|
9
|
-
"deactivated" : null,
|
10
|
-
"catalog_timestamp" : "2017-04-20T15:06:28.282Z",
|
11
|
-
"facts_timestamp" : "2017-04-20T15:06:12.253Z",
|
12
|
-
"report_timestamp" : null
|
13
|
-
}, {
|
14
|
-
"name" : "server3.example.com",
|
15
|
-
"deactivated" : null,
|
16
|
-
"catalog_timestamp" : "2017-04-20T15:12:56.090Z",
|
17
|
-
"facts_timestamp" : "2017-04-20T15:12:32.117Z",
|
18
|
-
"report_timestamp" : null
|
19
|
-
}, {
|
20
|
-
"name" : "server4.example.com",
|
21
|
-
"deactivated" : null,
|
22
|
-
"catalog_timestamp" : "2017-04-20T15:04:01.154Z",
|
23
|
-
"facts_timestamp" : "2017-04-20T15:03:38.150Z",
|
24
|
-
"report_timestamp" : null
|
25
|
-
}, {
|
26
|
-
"name" : "server5.example.com",
|
27
|
-
"deactivated" : null,
|
28
|
-
"catalog_timestamp" : "2017-04-20T15:20:06.853Z",
|
29
|
-
"facts_timestamp" : "2017-04-20T15:19:49.088Z",
|
30
|
-
"report_timestamp" : null
|
31
|
-
}, {
|
32
|
-
"name" : "server6.example.com",
|
33
|
-
"deactivated" : null,
|
34
|
-
"catalog_timestamp" : "2017-04-20T15:21:11.520Z",
|
35
|
-
"facts_timestamp" : "2017-04-20T15:20:57.685Z",
|
36
|
-
"report_timestamp" : null
|
37
|
-
}, {
|
38
|
-
"name" : "server7.example.com",
|
39
|
-
"deactivated" : null,
|
40
|
-
"catalog_timestamp" : "2017-04-20T15:15:37.033Z",
|
41
|
-
"facts_timestamp" : "2017-04-20T15:15:13.918Z",
|
42
|
-
"report_timestamp" : null
|
43
|
-
}, {
|
44
|
-
"name" : "server8.example.com",
|
45
|
-
"deactivated" : null,
|
46
|
-
"catalog_timestamp" : "2017-04-20T15:19:18.236Z",
|
47
|
-
"facts_timestamp" : "2017-04-20T15:19:02.659Z",
|
48
|
-
"report_timestamp" : null
|
49
|
-
}, {
|
50
|
-
"name" : "server9.example.com",
|
51
|
-
"deactivated" : null,
|
52
|
-
"catalog_timestamp" : "2017-04-20T14:39:35.070Z",
|
53
|
-
"facts_timestamp" : "2017-04-20T14:39:19.003Z",
|
54
|
-
"report_timestamp" : null
|
55
|
-
}, {
|
56
|
-
"name" : "server10.example.com",
|
57
|
-
"deactivated" : null,
|
58
|
-
"catalog_timestamp" : "2017-04-20T15:17:06.209Z",
|
59
|
-
"facts_timestamp" : "2017-04-20T15:16:50.007Z",
|
60
|
-
"report_timestamp" : null
|
61
|
-
} ]
|