diplomat 2.2.2 → 2.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f59497c078200136ba585049f9182453f0c3ee359a4af6abaf1f99f3387c3a8
4
- data.tar.gz: 5b403009daf7a462efaf2056a4cc21b255d4baf832c784f9d3ea3eff86214946
3
+ metadata.gz: d677dfbfe3aef16d16366943f4b664181fbaef9c40cc00161e446bee7b4bf426
4
+ data.tar.gz: 835d978f094d95de09159ec6145f368fa40d8fa9e21ac23d43ce4c3378782663
5
5
  SHA512:
6
- metadata.gz: 3de2930fb3ca89ece1d973aeb584f904cb023ff4dfaa96804e461c6d7b24b14f43726adda01a92bbc6227d49d5871750b393b0c5ac6c47a94f334ff7ab6c72d6
7
- data.tar.gz: 6555bf2a8687443e7db4b2802b71b4c06fc72d33e936914961dbb0fd93ba0c6acfb35985d69d86fee2a628765f2678e603d1039d11e29d1d3113cd8f2ba7b094
6
+ metadata.gz: 375f689771a43ba6c363221a52db02c7ca0672797b924cc962c6d091d601b90fbb880c823ff8b123e15670ed9d5627dfc5a37093c62169ab22c2af023f266820
7
+ data.tar.gz: a9fc13759380a6f97730a1d7030c732a2f6e6f8b1cbdb8fb012be6c7156f94bd3b2e29342ac7926c4e4e268e6f113881fa9f26b09862d703e9ba92972710af01
@@ -1,3 +1,3 @@
1
1
  module Diplomat
2
- VERSION = '2.2.2'.freeze
2
+ VERSION = '2.2.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diplomat
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Hamelink
@@ -239,12 +239,6 @@ files:
239
239
  - lib/diplomat/session.rb
240
240
  - lib/diplomat/status.rb
241
241
  - lib/diplomat/version.rb
242
- - lib/diplomatic_bag.rb
243
- - lib/diplomatic_bag/datacenters.rb
244
- - lib/diplomatic_bag/info.rb
245
- - lib/diplomatic_bag/nodes.rb
246
- - lib/diplomatic_bag/service.rb
247
- - lib/diplomatic_bag/services.rb
248
242
  homepage: https://github.com/WeAreFarmGeek/diplomat
249
243
  licenses:
250
244
  - BSD-3-Clause
@@ -1,7 +0,0 @@
1
- require 'diplomat'
2
-
3
- # Usefull usage of Diplomat lib.
4
- module DiplomaticBag
5
- # Load all module files
6
- Dir[File.join(__dir__, 'diplomatic_bag', '*.rb')].each { |file| require file }
7
- end
@@ -1,11 +0,0 @@
1
- # Usefull usage of Diplomat lib: Datacenter functions
2
- module DiplomaticBag
3
- def self.get_datacenters_list(dc, options = {})
4
- dcs = []
5
- datacenters = Diplomat::Datacenter.get(nil, options)
6
- dc.each do |c|
7
- dcs.concat(datacenters.select { |d| d[/#{c}/] })
8
- end
9
- dcs.uniq
10
- end
11
- end
@@ -1,32 +0,0 @@
1
- # Usefull usage of Diplomat lib: Info functions
2
- module DiplomaticBag
3
- # rubocop:disable AbcSize
4
- def self.consul_info(options = {})
5
- consul_self = Diplomat::Agent.self(options)
6
- puts 'Server: ' + consul_self['Config']['NodeName']
7
- puts 'Datacenter: ' + consul_self['Config']['Datacenter']
8
- puts 'Consul Version: ' + consul_self['Config']['Version']
9
- if consul_self['Stats']['consul']['leader_addr']
10
- puts 'Leader Address: ' + consul_self['Stats']['consul']['leader_addr']
11
- puts 'applied_index: ' + consul_self['Stats']['raft']['applied_index']
12
- puts 'commit_index: ' + consul_self['Stats']['raft']['commit_index']
13
- end
14
- members = Diplomat::Members.get(options)
15
- servers = members.select { |member| member['Tags']['role'] == 'consul' }.sort_by { |n| n['Name'] }
16
- nodes = members.select { |member| member['Tags']['role'] == 'node' }
17
- leader = Diplomat::Status.leader(options).split(':')[0]
18
- puts 'Servers Count: ' + servers.count.to_s
19
- puts 'Nodes Count: ' + nodes.count.to_s
20
- puts 'Servers:'
21
- servers.map do |s|
22
- if s['Tags']['role'] == 'consul'
23
- if s['Addr'] == leader
24
- puts ' ' + s['Name'] + ' ' + s['Addr'] + ' *Leader*'
25
- else
26
- puts ' ' + s['Name'] + ' ' + s['Addr']
27
- end
28
- end
29
- end
30
- end
31
- # rubocop:enable AbcSize
32
- end
@@ -1,28 +0,0 @@
1
- # Usefull usage of Diplomat lib: Nodes functions
2
- module DiplomaticBag
3
- def self.get_duplicate_node_id(options = {})
4
- status = {
5
- 1 => 'Alive',
6
- 2 => '?',
7
- 3 => 'Left',
8
- 4 => 'Failed'
9
- }
10
- result = []
11
- members = Diplomat::Members.get(options)
12
- grouped = members.group_by do |row|
13
- [row['Tags']['id']]
14
- end
15
- filtered = grouped.values.select { |a| a.size > 1 }
16
- filtered.each do |dup|
17
- instance = {}
18
- instance[:node_id] = dup[0]['Tags']['id']
19
- nodes = []
20
- dup.each do |inst|
21
- nodes << { name: inst['Name'], status: status[inst['Status']] }
22
- end
23
- instance[:nodes] = nodes
24
- result << instance
25
- end
26
- result
27
- end
28
- end
@@ -1,20 +0,0 @@
1
- # Usefull usage of Diplomat lib: Service functions
2
- module DiplomaticBag
3
- def self.get_service_info(service, options = {})
4
- result = {}
5
- health = Diplomat::Health.service(service, options)
6
- result[service] = {}
7
- health.each do |h|
8
- result[service][h['Node']['Node']] = {
9
- 'Address': h['Node']['Address'],
10
- 'Port': h['Service']['Port']
11
- }
12
- checks = {}
13
- h['Checks'].each do |c|
14
- checks[c['Name']] = { 'status': c['Status'], 'output': c['Output'] }
15
- end
16
- result[service][h['Node']['Node']]['Checks'] = checks
17
- end
18
- result
19
- end
20
- end
@@ -1,38 +0,0 @@
1
- # Usefull usage of Diplomat lib: Services functions
2
- module DiplomaticBag
3
- def self.compute_service_name(s)
4
- return '/node::health/' if s.nil? || s == ''
5
-
6
- s
7
- end
8
-
9
- def self.get_all_services_status(options = {})
10
- result = {}
11
- services = Diplomat::Health.state('any', options)
12
- grouped_by_service = services.group_by { |h| compute_service_name(h['ServiceName']) }.values
13
- grouped_by_service.each do |s|
14
- grouped_by_status = s.group_by { |h| h['Status'] }.values
15
- status = {}
16
- grouped_by_status.each do |state|
17
- status[state[0]['Status']] = state.count
18
- end
19
- service_name = compute_service_name(s[0]['ServiceName'])
20
- result[service_name] = status
21
- end
22
- result
23
- end
24
-
25
- def self.get_services_list(service, options = {})
26
- services = Diplomat::Service.get_all(options)
27
- services.to_h.keys.grep(/#{service}/)
28
- end
29
-
30
- def self.get_services_info(service, options = {})
31
- result = []
32
- services = get_services_list(service, options)
33
- services.each do |s|
34
- result << get_service_info(s.to_s, options)
35
- end
36
- result
37
- end
38
- end