foreman_patch 1.2.0.alpha1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (17) hide show
  1. checksums.yaml +4 -4
  2. data/app/services/foreman_patch/ticket/affected_items.rb +24 -3
  3. data/app/services/foreman_patch/ticket/api.rb +18 -14
  4. data/lib/foreman_patch/version.rb +1 -1
  5. data/public/assets/foreman_patch/cycle_plans-ff3d252119622a68828ff70f4a97328303963002237dbf850e92d6a706e93667.scss.gz +0 -0
  6. data/public/assets/foreman_patch/foreman_patch-be2e2ba89548f4a490612e8a6cd1cdebc0473be89f8023a3df7612f05a75d301.css.gz +0 -0
  7. data/public/assets/foreman_patch/foreman_patch.json +1 -1
  8. data/public/assets/foreman_patch/plan_edit_windows-9ba20f84f3ecf2c4eb903acd57d30ee3e16f023a79db30bc614aa22f26442ce3.js.gz +0 -0
  9. data/public/webpack/foreman_patch/vendor-4b77c91f1e9103179596.js.map +1 -1
  10. data/public/webpack/foreman_patch/vendor-4b77c91f1e9103179596.js.map.gz +0 -0
  11. metadata +7 -13
  12. data/public/assets/foreman_patch/cycle_plans-e5667e178ba389908f5c815b24ec0ea77c340849d56bc39c5ce72bb626bd446a.scss +0 -6
  13. data/public/assets/foreman_patch/cycle_plans-e5667e178ba389908f5c815b24ec0ea77c340849d56bc39c5ce72bb626bd446a.scss.gz +0 -0
  14. data/public/assets/foreman_patch/foreman_patch-ce5805a60c0d5f896f557ff5246e5a09172043004c850b39bea54e618df1c485.css +0 -1
  15. data/public/assets/foreman_patch/foreman_patch-ce5805a60c0d5f896f557ff5246e5a09172043004c850b39bea54e618df1c485.css.gz +0 -0
  16. data/public/assets/foreman_patch/plan_edit_windows-e656ba411642a7f983b51958ab30ac49c056322d19295a603cff4d5e6c71c8ed.js +0 -1
  17. 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: 900b05514ac7bb3e7cec9d95b0ad2b982feea0081dd73be23ab17041cb44c95d
4
- data.tar.gz: ebdd75375aaf6acebd342f0f00e7be6658ec5399c9172f84b50263fe2b22573a
3
+ metadata.gz: 61017bed1470ce847f846672dfeebd6a6067de86accd24b6eead1f91e4d9e40e
4
+ data.tar.gz: dd6090434ba0a7268ec4181c05329269aebd3c1e1cd688d52f5a0ec35ef04429
5
5
  SHA512:
6
- metadata.gz: d01c259cd2d57f7e4febcac38b3d9161c5ae3bd9fa84df2ef3f8cb9443a79350b7f6cc007c47aab787478f5516a70661fdae4777e13e95f8e4f25b459da0b449
7
- data.tar.gz: 78a7fd36dd08a76f613bbf839ebbff94d5e7e7d31766276ff3f1a4b42f4a2555a316cbf377a8ec6e63610914f51f37447f5b7446b987c29efb310a7fffc5dd7a
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
- get('/api/now/table/cmdb_ci_server', params)
49
+ uri = URI.join(Setting[:ticket_api_host], '/api/now/table/cmdb_ci_server')
48
50
 
49
- response.nil? ? [] : response['result']
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 :response, :errors
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 url(path)
13
- host + path
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
- request(:get, path, params)
25
+ create_request(:get, path, params)
24
26
  end
25
27
 
26
28
  def post(path, payload, params = {})
27
- request(:post, path, params, payload)
29
+ create_request(:post, path, params, payload)
28
30
  end
29
31
 
30
32
  def put(path, payload, params = {})
31
- request(:put, path, params, payload)
33
+ create_request(:put, path, params, payload)
32
34
  end
33
35
 
34
36
  def delete(path)
35
- request(:delete, path)
37
+ create_request(:delete, path)
36
38
  end
37
39
 
38
- def request(method, path, params = {}, payload = nil)
40
+ def create_request(method, path, params = {}, payload = nil)
39
41
  @response = nil
40
42
 
41
43
  args = {
42
44
  method: method,
43
- url: url(path),
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
- raw = RestClient::Request.execute(args)
58
+ @request = RestClient::Request.new(args)
59
+ end
57
60
 
58
- @response = JSON.parse(raw)
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
@@ -1,3 +1,3 @@
1
1
  module ForemanPatch
2
- VERSION = '1.2.0.alpha1'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
@@ -1 +1 @@
1
- {"files":{"foreman_patch/foreman_patch-ce5805a60c0d5f896f557ff5246e5a09172043004c850b39bea54e618df1c485.css":{"logical_path":"foreman_patch/foreman_patch.css","mtime":"2024-11-21T20:30:22+00:00","size":87,"digest":"d6fdcb3359ce0ca3edd9a493467bc366b5f2b52a0d3e2fd2b5d1dec121ef31ff","integrity":"sha256-1v3LM1nODKPt2aSTRnvDZrXytSoNPi/StdHewSHvMf8="},"foreman_patch/cycle_plans-e5667e178ba389908f5c815b24ec0ea77c340849d56bc39c5ce72bb626bd446a.scss":{"logical_path":"foreman_patch/cycle_plans.scss","mtime":"2024-11-21T20:30:22+00:00","size":106,"digest":"aa7bb2d36a98d83776b4dd9dd93431ba648b84a37478f93c445eb9bda0f84006","integrity":"sha256-qnuy02qY2Dd2tN2d2TQxumSLhKN0ePk8RF65vaD4QAY="},"foreman_patch/plan_edit_windows-e656ba411642a7f983b51958ab30ac49c056322d19295a603cff4d5e6c71c8ed.js":{"logical_path":"foreman_patch/plan_edit_windows.js","mtime":"2024-11-21T20:30:22+00:00","size":144,"digest":"be5de0eef57205a38f90eda24c8f8aed707f5d30e8a5abbc3ce9f198ea55a620","integrity":"sha256-vl3g7vVyBaOPkO2iTI+K7XB/XTDopau8POnxmOpVpiA="},"foreman_patch/foreman_patch-be2e2ba89548f4a490612e8a6cd1cdebc0473be89f8023a3df7612f05a75d301.css":{"logical_path":"foreman_patch/foreman_patch.css","mtime":"2024-11-21T20:42:30+00:00","size":87,"digest":"d6fdcb3359ce0ca3edd9a493467bc366b5f2b52a0d3e2fd2b5d1dec121ef31ff","integrity":"sha256-1v3LM1nODKPt2aSTRnvDZrXytSoNPi/StdHewSHvMf8="},"foreman_patch/cycle_plans-ff3d252119622a68828ff70f4a97328303963002237dbf850e92d6a706e93667.scss":{"logical_path":"foreman_patch/cycle_plans.scss","mtime":"2024-11-21T20:42:30+00:00","size":106,"digest":"aa7bb2d36a98d83776b4dd9dd93431ba648b84a37478f93c445eb9bda0f84006","integrity":"sha256-qnuy02qY2Dd2tN2d2TQxumSLhKN0ePk8RF65vaD4QAY="},"foreman_patch/plan_edit_windows-9ba20f84f3ecf2c4eb903acd57d30ee3e16f023a79db30bc614aa22f26442ce3.js":{"logical_path":"foreman_patch/plan_edit_windows.js","mtime":"2024-11-21T20:42:30+00:00","size":144,"digest":"be5de0eef57205a38f90eda24c8f8aed707f5d30e8a5abbc3ce9f198ea55a620","integrity":"sha256-vl3g7vVyBaOPkO2iTI+K7XB/XTDopau8POnxmOpVpiA="}},"assets":{"foreman_patch/foreman_patch.css":"foreman_patch/foreman_patch-be2e2ba89548f4a490612e8a6cd1cdebc0473be89f8023a3df7612f05a75d301.css","foreman_patch/cycle_plans.scss":"foreman_patch/cycle_plans-ff3d252119622a68828ff70f4a97328303963002237dbf850e92d6a706e93667.scss","foreman_patch/plan_edit_windows.js":"foreman_patch/plan_edit_windows-9ba20f84f3ecf2c4eb903acd57d30ee3e16f023a79db30bc614aa22f26442ce3.js"}}
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"}}