smart_proxy_salt 2.1.7 → 2.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a479ace7ffeb895281d60a176b7f47c5ed96975
4
- data.tar.gz: af15fc5c2a9072e3e7a70dc57b520895b2f94276
3
+ metadata.gz: 3617d7030f84c637b456820c2ed126a46a0891f8
4
+ data.tar.gz: e38b6cbe39839ac23e9b734fd1b72ee5baeb10fb
5
5
  SHA512:
6
- metadata.gz: 5c84eaea9f1a759457655941dd8a5c053543968bea016fe5e8301629d852c947a69ede9b8f331c6f4871c7fcc7484317d2efe5613323b3cbe0ba22c4351038b7
7
- data.tar.gz: 8a77baac462e5697879b14fbcec1a96d9b93a7cdca86f527aafb84edf47519bdf2b7b5c72a60322538d7b32c3e638e0af19d66b071885c491d3778c7ea98b113
6
+ metadata.gz: 5b4b844c9a4463aa77ca9769028fd5d32d9efa933c4ecc6cf90391ab437f78936a7882583f548bfa338c33dfd4731e27fba5f1d233e650521aaf3411888cf824
7
+ data.tar.gz: 657c0199e6aea9a2fefdcc4847f2a7107ba4dd1fbf28c2e7413a4119a09c79680e69a5ed569e13f2e854a07096ba82bc8e8e69752ea5e3b1b9fbf26f47f57c45
@@ -172,7 +172,7 @@ def enc(minion)
172
172
  http.cert = OpenSSL::X509::Certificate.new(File.read(SETTINGS[:ssl_cert]))
173
173
  http.key = OpenSSL::PKey::RSA.new(File.read(SETTINGS[:ssl_key]), nil)
174
174
  end
175
- elsif SETTINGS[:username] && SETTING[:password]
175
+ elsif SETTINGS[:username] && SETTINGS[:password]
176
176
  req.basic_auth(SETTINGS[:username], SETTINGS[:password])
177
177
  end
178
178
 
@@ -1,5 +1,5 @@
1
1
  module Proxy
2
2
  module Salt
3
- VERSION = '2.1.7'
3
+ VERSION = '2.1.8'
4
4
  end
5
5
  end
@@ -5,7 +5,6 @@ LAST_UPLOADED = '/etc/salt/last_uploaded'
5
5
  FOREMAN_CONFIG = '/etc/salt/foreman.yaml'
6
6
  LOCK_FILE = '/var/lock/salt-report-upload.lock'
7
7
 
8
- import urllib
9
8
  import httplib
10
9
  import ssl
11
10
  import json
@@ -27,7 +26,7 @@ def salt_config():
27
26
 
28
27
 
29
28
  def get_job(job_id):
30
- result = run('jobs.lookup_jid', argument=[job_id])
29
+ result = run('jobs.lookup_jid', [job_id])
31
30
 
32
31
  # If any minion's results are strings, they're exceptions
33
32
  # and should be wrapped in a list like other errors
@@ -64,31 +63,31 @@ def write_last_uploaded(last_uploaded):
64
63
  f.write(last_uploaded)
65
64
 
66
65
 
67
- def run(function, argument=[]):
66
+ def run(*args, **kwargs):
68
67
  __opts__ = salt.config.master_config(
69
68
  os.environ.get('SALT_MASTER_CONFIG', '/etc/salt/master'))
70
69
 
71
70
  runner = salt.runner.Runner(__opts__)
72
- stdout_bak = sys.stdout
73
71
  with open(os.devnull, 'wb') as f:
74
- sys.stdout = f
75
- ret = runner.cmd(function, argument)
76
- sys.stdout = stdout_bak
72
+ stdout_bak, sys.stdout = sys.stdout, f
73
+ try:
74
+ ret = runner.cmd(*args, **kwargs)
75
+ finally:
76
+ sys.stdout = stdout_bak
77
77
  return ret['data'] if 'data' in ret else ret
78
78
 
79
79
 
80
80
  def jobs_to_upload():
81
- jobs = run('jobs.list_jobs')
81
+ jobs = run('jobs.list_jobs', kwarg={
82
+ "search_function": "state.highstate",
83
+ })
82
84
  last_uploaded = read_last_uploaded()
83
85
 
84
- job_ids = [id for (id, value) in jobs.iteritems()
85
- if value['Function'] == 'state.highstate' and
86
- int(id) > last_uploaded]
86
+ job_ids = [jid for (jid, value) in jobs.iteritems()
87
+ if int(jid) > last_uploaded]
87
88
 
88
- jobs = dict([(job, get_job(job)) for job in job_ids])
89
- ids = sorted(jobs.keys())
90
-
91
- return (ids, jobs)
89
+ for job_id in sorted(job_ids):
90
+ yield job_id, get_job(job_id)
92
91
 
93
92
 
94
93
  def upload(jobs):
@@ -111,8 +110,7 @@ def upload(jobs):
111
110
  config[':password']))
112
111
  headers['Authorization'] = 'Basic {}'.format(token)
113
112
 
114
- for id in jobs[0]:
115
- job = jobs[1][id]
113
+ for job_id, job in jobs:
116
114
 
117
115
  if job['job']['result'] == {}:
118
116
  continue
@@ -122,8 +120,8 @@ def upload(jobs):
122
120
  response = connection.getresponse()
123
121
 
124
122
  if response.status == 200:
125
- write_last_uploaded(id)
126
- print "Success %s: %s" % (id, response.read())
123
+ write_last_uploaded(job_id)
124
+ print "Success %s: %s" % (job_id, response.read())
127
125
  else:
128
126
  print "Unable to upload job - aborting report upload"
129
127
  print response.read()
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_proxy_salt
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.7
4
+ version: 2.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Moll
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-10-07 00:00:00.000000000 Z
12
+ date: 2017-03-29 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: SaltStack Plug-In for Foreman's Smart Proxy
15
15
  email: foreman-dev@googlegroups.com
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  version: '0'
57
57
  requirements: []
58
58
  rubyforge_project:
59
- rubygems_version: 2.5.1
59
+ rubygems_version: 2.5.2
60
60
  signing_key:
61
61
  specification_version: 4
62
62
  summary: SaltStack Plug-In for Foreman's Smart Proxy