palo_alto 0.1.9 → 0.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/lib/palo_alto/version.rb +1 -1
- data/lib/palo_alto.rb +29 -16
- 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: 7442c2cf207b59a2ac451b8f2fe35e7333f5486b8fa8b124887df6dbec5f7501
|
4
|
+
data.tar.gz: b27f957f7e15285d6755d95136f3e8bacdb45ffa03bbcba9ee5274b5f9d651fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dafa319006719982ec6b910c0262c32f19e13019b7f90bb8ed93b3b2d0ece98ac5913b55d40357239860f800f6d3bc66961fdb85a14fd46d0fddadc3acdfd5b
|
7
|
+
data.tar.gz: 26418cfc13c83588cc1349060d55fb9adf716f2d18a1a6ef96b7466a12e00f0d1c21043fcc7de42964515a2d386d32ac3fb316cc171ff2f77a4202bd9c6eb010
|
data/lib/palo_alto/version.rb
CHANGED
data/lib/palo_alto.rb
CHANGED
@@ -99,7 +99,15 @@ module PaloAlto
|
|
99
99
|
|
100
100
|
thread[:http].start unless thread[:http].started?
|
101
101
|
|
102
|
-
|
102
|
+
payload = options[:payload]
|
103
|
+
response = if payload.values.any? { |value| [IO, StringIO].any? { |t| value.is_a?(t) } }
|
104
|
+
payload.values.select { |value| [IO, StringIO].any? { |t| value.is_a?(t) } }.each(&:rewind)
|
105
|
+
post_req = Net::HTTP::Post.new('/api/', options[:headers])
|
106
|
+
post_req.set_form payload.map { |k, v| [k.to_s, v] }, 'multipart/form-data'
|
107
|
+
thread[:http].request(post_req)
|
108
|
+
else
|
109
|
+
thread[:http].post('/api/', URI.encode_www_form(payload), options[:headers])
|
110
|
+
end
|
103
111
|
|
104
112
|
case response.code
|
105
113
|
when '200'
|
@@ -189,13 +197,14 @@ module PaloAlto
|
|
189
197
|
begin
|
190
198
|
Helpers::Rest.execute(payload, headers: { 'X-PAN-KEY': auth_key })
|
191
199
|
rescue TemporaryException => e
|
192
|
-
|
200
|
+
dont_retry_at = [
|
193
201
|
'Partial revert is not allowed. Full system commit must be completed.',
|
194
202
|
'Config for scope ',
|
195
203
|
'Config is not currently locked for scope ',
|
196
|
-
'Commit lock is not currently held by'
|
204
|
+
'Commit lock is not currently held by',
|
205
|
+
'You already own a config lock for scope '
|
197
206
|
]
|
198
|
-
if retried ||
|
207
|
+
if retried || dont_retry_at.any? { |x| e.message.start_with?(x) }
|
199
208
|
raise e
|
200
209
|
else
|
201
210
|
warn "Got error #{e.inspect}; retrying" if XML.debug.include?(:warnings)
|
@@ -266,14 +275,12 @@ module PaloAlto
|
|
266
275
|
# will execute block if given and unlock afterwards. returns false if lock could not be aquired
|
267
276
|
def lock(area:, comment: nil, type: nil, location: nil)
|
268
277
|
if block_given?
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
else
|
276
|
-
return false
|
278
|
+
return false unless lock(area: area, comment: comment, type: type, location: location)
|
279
|
+
|
280
|
+
begin
|
281
|
+
return yield
|
282
|
+
ensure
|
283
|
+
unlock(area: area, type: type, location: location)
|
277
284
|
end
|
278
285
|
end
|
279
286
|
|
@@ -309,8 +316,16 @@ module PaloAlto
|
|
309
316
|
end
|
310
317
|
|
311
318
|
def check_for_changes(usernames: [XML.username])
|
312
|
-
|
313
|
-
|
319
|
+
cmd = if usernames
|
320
|
+
{ show: { config: { list: { 'change-summary': { partial: { admin: usernames } } } } } }
|
321
|
+
else
|
322
|
+
{ show: { config: { list: 'change-summary' } } }
|
323
|
+
end
|
324
|
+
result = Op.new.execute(cmd)
|
325
|
+
{
|
326
|
+
device_groups: result.xpath('response/result/summary/device-group/member').map(&:inner_text),
|
327
|
+
templates: result.xpath('response/result/summary/template/member').map(&:inner_text)
|
328
|
+
}
|
314
329
|
end
|
315
330
|
|
316
331
|
def wait_for_job_completion(job_id, wait: 5, timeout: 300)
|
@@ -363,8 +378,6 @@ module PaloAlto
|
|
363
378
|
# attempt to obtain the auth_key
|
364
379
|
# raise 'Exception attempting to obtain the auth_key' if (self.class.auth_key = get_auth_key).nil?
|
365
380
|
self.class.get_auth_key
|
366
|
-
|
367
|
-
self
|
368
381
|
end
|
369
382
|
|
370
383
|
# Perform a query to the API endpoint for an auth_key based on the credentials provided
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: palo_alto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Roesner
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|