foreman_patch 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/lib/actions/foreman_patch/window/publish.rb +1 -1
- data/app/services/foreman_patch/ticket/affected_items.rb +4 -4
- data/app/services/foreman_patch/ticket/api.rb +8 -21
- data/app/services/foreman_patch/ticket/change_request.rb +24 -25
- 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 +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e085e0af8a761e81fc5c3cddd51588babe0e0e6397d2f2448cbb7c346ef8b42
|
4
|
+
data.tar.gz: 752762b8b5a4f034e348500315e5a962ffd9e87b3875cc3943e4fbbeaad79a60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 054e1ea317df4617f8c6748239c80401c45c3c61efb8f666e6495e7f502346bf612d55c9dca07f70ff5d3fafde7ec357e441dabe7721f67a566de965e28b33b3
|
7
|
+
data.tar.gz: 3c07b4f6f0d4b0fb154819a3f1f0c7e931bbe59beacfe4bdca42de9b3ca53b45a6864c5c855b011dc0d4947144e8ca58dbca4100c9a1db9b822010bca0a3d56e
|
@@ -51,9 +51,9 @@ module ForemanPatch
|
|
51
51
|
hosts.each_with_object([]) do |host, batches|
|
52
52
|
batches.push([]) if batches.empty?
|
53
53
|
|
54
|
-
batch =
|
54
|
+
batch = batches.last.push(host)
|
55
55
|
|
56
|
-
uri.query = URI.encode_www_form(
|
56
|
+
uri.query = URI.encode_www_form(params.merge({
|
57
57
|
sysparm_query: "host_nameIN#{batch.join(',')}",
|
58
58
|
}))
|
59
59
|
|
@@ -62,7 +62,7 @@ module ForemanPatch
|
|
62
62
|
batches.push([host])
|
63
63
|
end
|
64
64
|
end.each_with_object([]) do |batch, items|
|
65
|
-
get(uri.path, params.merge({
|
65
|
+
response = get(uri.path, params.merge({
|
66
66
|
sysparm_query: "host_nameIN#{batch.join(',')}",
|
67
67
|
}))
|
68
68
|
|
@@ -77,7 +77,7 @@ module ForemanPatch
|
|
77
77
|
sysparm_fields: 'sys_id,task,ci_item',
|
78
78
|
}
|
79
79
|
|
80
|
-
get('/api/now/table/task_ci', params)
|
80
|
+
response = get('/api/now/table/task_ci', params)
|
81
81
|
|
82
82
|
response.nil? ? [] : response['result']
|
83
83
|
end
|
@@ -7,14 +7,6 @@ module ForemanPatch
|
|
7
7
|
Setting[:ticket_api_host]
|
8
8
|
end
|
9
9
|
|
10
|
-
def response
|
11
|
-
@response ||= send_request
|
12
|
-
end
|
13
|
-
|
14
|
-
def url
|
15
|
-
request.uri.to_s
|
16
|
-
end
|
17
|
-
|
18
10
|
def proxy
|
19
11
|
return nil if Setting[:ticket_api_proxy].blank?
|
20
12
|
|
@@ -22,24 +14,24 @@ module ForemanPatch
|
|
22
14
|
end
|
23
15
|
|
24
16
|
def get(path, params = {})
|
25
|
-
|
17
|
+
send_request(:get, path, params)
|
26
18
|
end
|
27
19
|
|
28
20
|
def post(path, payload, params = {})
|
29
|
-
|
21
|
+
send_request(:post, path, params, payload)
|
30
22
|
end
|
31
23
|
|
32
24
|
def put(path, payload, params = {})
|
33
|
-
|
25
|
+
send_request(:put, path, params, payload)
|
34
26
|
end
|
35
27
|
|
36
28
|
def delete(path)
|
37
|
-
|
29
|
+
send_request(:delete, path)
|
38
30
|
end
|
39
31
|
|
40
|
-
|
41
|
-
|
42
|
-
|
32
|
+
private
|
33
|
+
|
34
|
+
def send_request(method, path, params = {}, payload = nil)
|
43
35
|
args = {
|
44
36
|
method: method,
|
45
37
|
url: URI.join(Setting[:ticket_api_host], path).to_s,
|
@@ -55,17 +47,12 @@ module ForemanPatch
|
|
55
47
|
args[:payload] = payload.to_json unless payload.nil?
|
56
48
|
args[:proxy] = proxy
|
57
49
|
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
def send_request
|
62
|
-
@response = JSON.parse(@request.execute)
|
50
|
+
JSON.parse(RestClient::Request.execute(args))
|
63
51
|
rescue RestClient::ExceptionWithResponse => error
|
64
52
|
Rails.logger.error(error.response)
|
65
53
|
rescue => error
|
66
54
|
Rails.logger.error(error)
|
67
55
|
end
|
68
|
-
|
69
56
|
end
|
70
57
|
end
|
71
58
|
end
|
@@ -5,42 +5,43 @@ module ForemanPatch
|
|
5
5
|
|
6
6
|
attr_reader :window, :response, :affected_items
|
7
7
|
|
8
|
-
def self.publish(window)
|
9
|
-
ticket = Ticket.new(window)
|
10
|
-
ticket.save
|
11
|
-
end
|
12
|
-
|
13
8
|
def initialize(window)
|
14
9
|
@window = window
|
15
|
-
@
|
10
|
+
@ticket = {}
|
16
11
|
reload
|
17
12
|
end
|
18
13
|
|
19
14
|
def reload
|
20
15
|
return if window.ticket_id.blank?
|
21
16
|
|
22
|
-
get(path)
|
23
|
-
|
24
|
-
|
17
|
+
response = get(path)
|
18
|
+
unless response.empty?
|
19
|
+
@ticket = response['result']
|
20
|
+
|
21
|
+
@affected_items = AffectedItems.new(self)
|
22
|
+
end
|
25
23
|
|
26
|
-
ticket
|
24
|
+
@ticket
|
27
25
|
end
|
28
26
|
|
29
27
|
def save
|
28
|
+
response = {}
|
30
29
|
if window.ticket_id.blank?
|
31
|
-
post(path, payload)
|
30
|
+
response = post(path, payload)
|
32
31
|
else
|
33
|
-
put(path, payload)
|
32
|
+
response = put(path, payload)
|
34
33
|
end
|
35
34
|
|
36
35
|
unless response.empty?
|
36
|
+
@ticket = response['result']
|
37
|
+
|
38
|
+
window.update(ticket_id: id) if id != window.ticket_id
|
39
|
+
|
37
40
|
@affected_items = AffectedItems.new(self)
|
38
41
|
@affected_items.set(window.hosts)
|
39
42
|
end
|
40
43
|
|
41
|
-
|
42
|
-
|
43
|
-
ticket
|
44
|
+
@ticket
|
44
45
|
end
|
45
46
|
|
46
47
|
def payload
|
@@ -48,11 +49,11 @@ module ForemanPatch
|
|
48
49
|
end
|
49
50
|
|
50
51
|
def id
|
51
|
-
ticket.fetch(Setting[:ticket_id_field], window.ticket_id)
|
52
|
+
@ticket.fetch(Setting[:ticket_id_field], window.ticket_id)
|
52
53
|
end
|
53
54
|
|
54
55
|
def label
|
55
|
-
ticket.fetch(Setting[:ticket_label_field], window.name)
|
56
|
+
@ticket.fetch(Setting[:ticket_label_field], window.name)
|
56
57
|
end
|
57
58
|
|
58
59
|
def link
|
@@ -62,11 +63,15 @@ module ForemanPatch
|
|
62
63
|
end
|
63
64
|
|
64
65
|
def keys
|
65
|
-
ticket.keys
|
66
|
+
@ticket.keys
|
66
67
|
end
|
67
68
|
|
68
69
|
def [](key)
|
69
|
-
ticket[key]
|
70
|
+
@ticket[key]
|
71
|
+
end
|
72
|
+
|
73
|
+
def to_h
|
74
|
+
@ticket
|
70
75
|
end
|
71
76
|
|
72
77
|
class Jail < Safemode::Jail
|
@@ -75,12 +80,6 @@ module ForemanPatch
|
|
75
80
|
|
76
81
|
private
|
77
82
|
|
78
|
-
def ticket
|
79
|
-
return {} if response.empty?
|
80
|
-
|
81
|
-
response['result']
|
82
|
-
end
|
83
|
-
|
84
83
|
def path
|
85
84
|
path = Setting[:ticket_api_path]
|
86
85
|
path += "/#{window.ticket_id}" unless id.blank?
|
Binary file
|
Binary file
|
@@ -1 +1 @@
|
|
1
|
-
{"files":{"foreman_patch/cycle_plans-ff3d252119622a68828ff70f4a97328303963002237dbf850e92d6a706e93667.scss":{"logical_path":"foreman_patch/cycle_plans.scss","mtime":"
|
1
|
+
{"files":{"foreman_patch/cycle_plans-ff3d252119622a68828ff70f4a97328303963002237dbf850e92d6a706e93667.scss":{"logical_path":"foreman_patch/cycle_plans.scss","mtime":"2025-01-06T17:18:57+00:00","size":106,"digest":"aa7bb2d36a98d83776b4dd9dd93431ba648b84a37478f93c445eb9bda0f84006","integrity":"sha256-qnuy02qY2Dd2tN2d2TQxumSLhKN0ePk8RF65vaD4QAY="},"foreman_patch/foreman_patch-be2e2ba89548f4a490612e8a6cd1cdebc0473be89f8023a3df7612f05a75d301.css":{"logical_path":"foreman_patch/foreman_patch.css","mtime":"2025-01-06T17:18:57+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":"2025-01-06T17:18:57+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"}}
|