pps_commons 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pps_commons.rb +10 -9
- data/lib/pps_commons/chef_comms.rb +21 -7
- data/lib/pps_commons/delegation_agent.rb +1 -7
- data/lib/pps_commons/thycotic_comms.rb +12 -4
- data/lib/pps_commons/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 077733f6f45fe8fc48e1d23a95c0ebc33084bd64
|
4
|
+
data.tar.gz: 2d30fbe452ba517f4325938771bd5ac22956f41d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37f56ac8aa318d4fcc2c333108c489da8c2939ddba89ea64e1df8a054e8c06834737f05062ef0de0aef57055724181a69fa3f5866e188ad55333bf624649dd00
|
7
|
+
data.tar.gz: 866b6f852eababaee476435be68765897357e5d4018695562868e81494a9688a17e6c105857a4fe225d47ee5e52a390b3a1e96a45aa98db92e2eb30fa93cad08
|
data/lib/pps_commons.rb
CHANGED
@@ -1,18 +1,13 @@
|
|
1
1
|
require 'rest-client'
|
2
2
|
require 'json'
|
3
|
+
require 'logger'
|
3
4
|
|
4
5
|
module WGU
|
5
6
|
module PPSCommons
|
6
7
|
def self.included(base)
|
7
8
|
base.send :include, InstanceMethods
|
8
9
|
end
|
9
|
-
|
10
|
-
# in this project so it helps to run a higher number.
|
11
|
-
# EM defaults to '20', PPS defaults to '40'
|
12
|
-
def PPSCommons.unleash_the_fury_level
|
13
|
-
found = ENV['PPS_THREAD_COUNT'].to_i
|
14
|
-
found.eql?(0) ? 40 : found.to_i
|
15
|
-
end
|
10
|
+
|
16
11
|
# search through a hash's nested keys for crap
|
17
12
|
def PPSCommons.deep_find(key, object=self, found=nil)
|
18
13
|
if object.respond_to?(:key?) && object.key?(key)
|
@@ -23,12 +18,18 @@ module WGU
|
|
23
18
|
end
|
24
19
|
end
|
25
20
|
|
21
|
+
# this tells EventMachine how many threads it can use. There is a lot of Deferrals
|
22
|
+
# in this project so it helps to run a higher number.
|
23
|
+
# EM defaults to '20', PPS defaults to '40'
|
24
|
+
def PPSCommons.unleash_the_fury_level
|
25
|
+
found = ENV['PPS_THREAD_COUNT'].to_i
|
26
|
+
found.eql?(0) ? 40 : found.to_i
|
27
|
+
end
|
28
|
+
|
26
29
|
# Common instance methods
|
27
30
|
module InstanceMethods
|
28
31
|
def logger(file = ENV['PPS_COMMONS_DEFAULT_LOG_LOCATION'])
|
29
32
|
if @logger.nil?
|
30
|
-
file ||= File.join('logs', 'log.log')
|
31
|
-
puts "PPSCommons created a log file at #{file}"
|
32
33
|
log = ::File.expand_path(file)
|
33
34
|
unless ::File.exist?(log)
|
34
35
|
log_dir = File.dirname(log)
|
@@ -25,14 +25,21 @@ module WGU
|
|
25
25
|
end
|
26
26
|
|
27
27
|
private
|
28
|
+
def self.cache_client
|
29
|
+
@cache_client ||= Aws::S3::Client.new(
|
30
|
+
access_key_id: ENV['ACCESS_KEY_ID'],
|
31
|
+
secret_access_key: ENV['SECRET_ACCESS_KEY']
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
28
35
|
def self.client(config)
|
29
36
|
client = ChefAPI::Connection.new(
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
37
|
+
client: ENV['CM_CHEF_API_CLIENT'],
|
38
|
+
endpoint: config[:endpoint],
|
39
|
+
key: config[:key]
|
40
|
+
)
|
34
41
|
|
35
|
-
|
42
|
+
block_given? ? yield(client) : client
|
36
43
|
end
|
37
44
|
|
38
45
|
def self.clients
|
@@ -46,8 +53,15 @@ module WGU
|
|
46
53
|
|
47
54
|
endpoints.map do |endpoint|
|
48
55
|
chef_env = endpoint.gsub(/CM_CHEF_API_ENDPOINT_(\w+)$/, '\1')
|
49
|
-
|
50
|
-
|
56
|
+
key = self.cache_client.get_object(
|
57
|
+
bucket: ENV['PPS_PASS_CACHE'],
|
58
|
+
key: ENV["CM_CHEF_API_KEY_#{chef_env}"]
|
59
|
+
)
|
60
|
+
|
61
|
+
{
|
62
|
+
endpoint: ENV[endpoint],
|
63
|
+
key: key
|
64
|
+
}
|
51
65
|
end
|
52
66
|
end
|
53
67
|
end
|
@@ -82,17 +82,11 @@ module WGU
|
|
82
82
|
# Send a message to the appropriate receiver.
|
83
83
|
def send_response_to(recipient, results = @results)
|
84
84
|
msg = results.kind_of?(WGU::Sentence) ? results.log_entry : "#{results.to_s.strip}\n"
|
85
|
-
msg
|
86
85
|
logger.info(
|
87
86
|
"#{requester.agent_name.capitalize} sending message: \"#{msg}\" to -> #{recipient}"
|
88
87
|
)
|
89
88
|
|
90
|
-
|
91
|
-
@connections[recipient].receive_data(msg)
|
92
|
-
else
|
93
|
-
requester.send_data(msg)
|
94
|
-
end
|
95
|
-
|
89
|
+
@connections[recipient].receive_data(msg)
|
96
90
|
self
|
97
91
|
end
|
98
92
|
|
@@ -39,7 +39,7 @@ module WGU
|
|
39
39
|
|
40
40
|
# find a good way to remove this hardcoding of 545 parent folder id
|
41
41
|
def self.folder_lookup(*args)
|
42
|
-
base_folder_id =
|
42
|
+
base_folder_id = ENV['SECRET_STORE_BASE_FOLDER']
|
43
43
|
return base_folder_id if args.empty?
|
44
44
|
query = args[0] || base_folder_id
|
45
45
|
parent_folder_query = args[1]
|
@@ -126,7 +126,7 @@ module WGU
|
|
126
126
|
begin
|
127
127
|
bucket.versioning.suspend
|
128
128
|
rescue Exception => e
|
129
|
-
retry_count_for_suspend +=1
|
129
|
+
retry_count_for_suspend += 1
|
130
130
|
sleep 3
|
131
131
|
retry unless retry_count_for_suspend > 3
|
132
132
|
raise e
|
@@ -171,11 +171,19 @@ module WGU
|
|
171
171
|
end
|
172
172
|
|
173
173
|
def self.get_new_key
|
174
|
+
user = self.cache_client.get_object(
|
175
|
+
bucket: ENV['PPS_PASS_CACHE'],
|
176
|
+
key: ENV['SECRET_STORE_USERNAME']
|
177
|
+
)
|
178
|
+
pass = self.cache_client.get_object(
|
179
|
+
bucket: ENV['PPS_PASS_CACHE'],
|
180
|
+
key: ENV['SECRET_STORE_PASSWORD']
|
181
|
+
)
|
174
182
|
res = RestClient.post(
|
175
183
|
self.ss_url(URI(ENV['SECRET_STORE_TOKEN'])),
|
176
184
|
{
|
177
|
-
'username' =>
|
178
|
-
'password' =>
|
185
|
+
'username' => user,
|
186
|
+
'password' => pass,
|
179
187
|
'grant_type' => 'password'
|
180
188
|
},
|
181
189
|
{
|
data/lib/pps_commons/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pps_commons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Phillipps
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|