foreman_patch 1.2.0.alpha1 → 1.2.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/app/services/foreman_patch/ticket/affected_items.rb +24 -3
- data/app/services/foreman_patch/ticket/api.rb +18 -14
- data/lib/foreman_patch/version.rb +1 -1
- data/public/assets/foreman_patch/cycle_plans-ff3d252119622a68828ff70f4a97328303963002237dbf850e92d6a706e93667.scss.gz +0 -0
- data/public/assets/foreman_patch/foreman_patch-be2e2ba89548f4a490612e8a6cd1cdebc0473be89f8023a3df7612f05a75d301.css.gz +0 -0
- data/public/assets/foreman_patch/foreman_patch.json +1 -1
- data/public/assets/foreman_patch/plan_edit_windows-9ba20f84f3ecf2c4eb903acd57d30ee3e16f023a79db30bc614aa22f26442ce3.js.gz +0 -0
- data/public/webpack/foreman_patch/vendor-4b77c91f1e9103179596.js.map +1 -1
- data/public/webpack/foreman_patch/vendor-4b77c91f1e9103179596.js.map.gz +0 -0
- metadata +7 -13
- data/public/assets/foreman_patch/cycle_plans-e5667e178ba389908f5c815b24ec0ea77c340849d56bc39c5ce72bb626bd446a.scss +0 -6
- data/public/assets/foreman_patch/cycle_plans-e5667e178ba389908f5c815b24ec0ea77c340849d56bc39c5ce72bb626bd446a.scss.gz +0 -0
- data/public/assets/foreman_patch/foreman_patch-ce5805a60c0d5f896f557ff5246e5a09172043004c850b39bea54e618df1c485.css +0 -1
- data/public/assets/foreman_patch/foreman_patch-ce5805a60c0d5f896f557ff5246e5a09172043004c850b39bea54e618df1c485.css.gz +0 -0
- data/public/assets/foreman_patch/plan_edit_windows-e656ba411642a7f983b51958ab30ac49c056322d19295a603cff4d5e6c71c8ed.js +0 -1
- data/public/assets/foreman_patch/plan_edit_windows-e656ba411642a7f983b51958ab30ac49c056322d19295a603cff4d5e6c71c8ed.js.gz +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61017bed1470ce847f846672dfeebd6a6067de86accd24b6eead1f91e4d9e40e
|
4
|
+
data.tar.gz: dd6090434ba0a7268ec4181c05329269aebd3c1e1cd688d52f5a0ec35ef04429
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ecbf824ada84059985681bdd48af13c6407ed64e3ff4adf828600b41a06758dc2dbf04c6bdc449af9261d8f1ce1ffebb9fd26e50cd2fd11c0f336a9de28d0a6
|
7
|
+
data.tar.gz: 7deff88e4728fcfac393bfa24aafa1756d463e4eca2707694aec5283e644066f7d4719f51894493b187a8aac52bbc71b7e0c744efc256735dee9798ea831c175
|
@@ -38,15 +38,36 @@ module ForemanPatch
|
|
38
38
|
private
|
39
39
|
|
40
40
|
def get_configuration_items(hosts)
|
41
|
+
###
|
42
|
+
# This needs to be batched as too many hostnames will excede most server url limits
|
43
|
+
###
|
41
44
|
params = {
|
42
|
-
sysparm_query: "host_nameIN#{hosts.map(&:name).join(',')}",
|
43
45
|
sysparm_exclude_reference_link: true,
|
44
46
|
sysparm_fields: 'sys_id,host_name',
|
45
47
|
}
|
46
48
|
|
47
|
-
|
49
|
+
uri = URI.join(Setting[:ticket_api_host], '/api/now/table/cmdb_ci_server')
|
48
50
|
|
49
|
-
|
51
|
+
hosts.each_with_object([]) do |host, batches|
|
52
|
+
batches.push([]) if batches.empty?
|
53
|
+
|
54
|
+
batch = batch.last.push(host)
|
55
|
+
|
56
|
+
uri.query = URI.encode_www_form(param.merge({
|
57
|
+
sysparm_query: "host_nameIN#{batch.join(',')}",
|
58
|
+
}))
|
59
|
+
|
60
|
+
if uri.to_s.length > (Setting[:ticket_api_max_url_length] || 8000)
|
61
|
+
batch.pop
|
62
|
+
batches.push([host])
|
63
|
+
end
|
64
|
+
end.each_with_object([]) do |batch, items|
|
65
|
+
get(uri.path, params.merge({
|
66
|
+
sysparm_query: "host_nameIN#{batch.join(',')}",
|
67
|
+
}))
|
68
|
+
|
69
|
+
items.concat(response['result']) unless response.nil?
|
70
|
+
end
|
50
71
|
end
|
51
72
|
|
52
73
|
def get_affected_items
|
@@ -1,16 +1,18 @@
|
|
1
1
|
module ForemanPatch
|
2
2
|
module Ticket
|
3
3
|
module API
|
4
|
-
attr_reader :
|
5
|
-
|
6
|
-
private
|
4
|
+
attr_reader :request
|
7
5
|
|
8
6
|
def host
|
9
7
|
Setting[:ticket_api_host]
|
10
8
|
end
|
11
9
|
|
12
|
-
def
|
13
|
-
|
10
|
+
def response
|
11
|
+
@response ||= send_request
|
12
|
+
end
|
13
|
+
|
14
|
+
def url
|
15
|
+
request.uri.to_s
|
14
16
|
end
|
15
17
|
|
16
18
|
def proxy
|
@@ -20,27 +22,27 @@ module ForemanPatch
|
|
20
22
|
end
|
21
23
|
|
22
24
|
def get(path, params = {})
|
23
|
-
|
25
|
+
create_request(:get, path, params)
|
24
26
|
end
|
25
27
|
|
26
28
|
def post(path, payload, params = {})
|
27
|
-
|
29
|
+
create_request(:post, path, params, payload)
|
28
30
|
end
|
29
31
|
|
30
32
|
def put(path, payload, params = {})
|
31
|
-
|
33
|
+
create_request(:put, path, params, payload)
|
32
34
|
end
|
33
35
|
|
34
36
|
def delete(path)
|
35
|
-
|
37
|
+
create_request(:delete, path)
|
36
38
|
end
|
37
39
|
|
38
|
-
def
|
40
|
+
def create_request(method, path, params = {}, payload = nil)
|
39
41
|
@response = nil
|
40
42
|
|
41
43
|
args = {
|
42
44
|
method: method,
|
43
|
-
url:
|
45
|
+
url: URI.join(Setting[:ticket_api_host], path).to_s,
|
44
46
|
headers: {
|
45
47
|
accept: :json,
|
46
48
|
content_type: :json,
|
@@ -53,15 +55,17 @@ module ForemanPatch
|
|
53
55
|
args[:payload] = payload.to_json unless payload.nil?
|
54
56
|
args[:proxy] = proxy
|
55
57
|
|
56
|
-
|
58
|
+
@request = RestClient::Request.new(args)
|
59
|
+
end
|
57
60
|
|
58
|
-
|
61
|
+
def send_request
|
62
|
+
@response = JSON.parse(@request.execute)
|
59
63
|
rescue RestClient::ExceptionWithResponse => error
|
60
64
|
Rails.logger.error(error.response)
|
61
65
|
rescue => error
|
62
66
|
Rails.logger.error(error)
|
63
67
|
end
|
64
|
-
|
68
|
+
|
65
69
|
end
|
66
70
|
end
|
67
71
|
end
|
Binary file
|
Binary file
|
@@ -1 +1 @@
|
|
1
|
-
{"files":{"foreman_patch/
|
1
|
+
{"files":{"foreman_patch/cycle_plans-ff3d252119622a68828ff70f4a97328303963002237dbf850e92d6a706e93667.scss":{"logical_path":"foreman_patch/cycle_plans.scss","mtime":"2024-12-04T21:07:08+00:00","size":106,"digest":"aa7bb2d36a98d83776b4dd9dd93431ba648b84a37478f93c445eb9bda0f84006","integrity":"sha256-qnuy02qY2Dd2tN2d2TQxumSLhKN0ePk8RF65vaD4QAY="},"foreman_patch/foreman_patch-be2e2ba89548f4a490612e8a6cd1cdebc0473be89f8023a3df7612f05a75d301.css":{"logical_path":"foreman_patch/foreman_patch.css","mtime":"2024-12-04T21:07:08+00:00","size":87,"digest":"d6fdcb3359ce0ca3edd9a493467bc366b5f2b52a0d3e2fd2b5d1dec121ef31ff","integrity":"sha256-1v3LM1nODKPt2aSTRnvDZrXytSoNPi/StdHewSHvMf8="},"foreman_patch/plan_edit_windows-9ba20f84f3ecf2c4eb903acd57d30ee3e16f023a79db30bc614aa22f26442ce3.js":{"logical_path":"foreman_patch/plan_edit_windows.js","mtime":"2024-12-04T21:07:08+00:00","size":144,"digest":"be5de0eef57205a38f90eda24c8f8aed707f5d30e8a5abbc3ce9f198ea55a620","integrity":"sha256-vl3g7vVyBaOPkO2iTI+K7XB/XTDopau8POnxmOpVpiA="}},"assets":{"foreman_patch/cycle_plans.scss":"foreman_patch/cycle_plans-ff3d252119622a68828ff70f4a97328303963002237dbf850e92d6a706e93667.scss","foreman_patch/foreman_patch.css":"foreman_patch/foreman_patch-be2e2ba89548f4a490612e8a6cd1cdebc0473be89f8023a3df7612f05a75d301.css","foreman_patch/plan_edit_windows.js":"foreman_patch/plan_edit_windows-9ba20f84f3ecf2c4eb903acd57d30ee3e16f023a79db30bc614aa22f26442ce3.js"}}
|