port-authority 0.5.0 → 0.5.1
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9ae0f6c484615e82c028a5eda9b6b5d3c9fb59c
|
4
|
+
data.tar.gz: 02534027bd8e7f01bb56f7a110ae90124bc0e45c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 951bcbc83d7b399e5ae00730f9f6bdf0845cf4340605d9b2300b6f03323ba8de9f2e4cfdb4cf275d72fe405cb72a08a9a786a25940b55259ec58a2f58cfebe0c
|
7
|
+
data.tar.gz: 53cb57289059b35c82ca6a57ac51375f1813011c2168203f376d8a09ce8687ff68abbf41c1efde9c20bd26535416eb5cf0389263ca1606b19fadbc853e781ce4
|
data/lib/port-authority/agent.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'timeout'
|
2
|
-
require 'digest/sha2'
|
3
2
|
require 'json'
|
4
3
|
require 'yaml'
|
5
4
|
require 'port-authority'
|
@@ -146,15 +145,6 @@ module PortAuthority
|
|
146
145
|
@@_threads.each_value(&:join)
|
147
146
|
end
|
148
147
|
|
149
|
-
# Run command in Bash.
|
150
|
-
def shellcmd(*args)
|
151
|
-
cmd = args.join(' ').to_s
|
152
|
-
cksum = Digest::SHA256.hexdigest(args.join.to_s)[0..15]
|
153
|
-
Logger.debug "Executing shellcommand #{cksum} - #{cmd}"
|
154
|
-
ret = system cmd
|
155
|
-
Logger.debug "Shellcommand #{cksum} returned #{ret.to_s}"
|
156
|
-
end
|
157
|
-
|
158
148
|
# Return hostname.
|
159
149
|
def hostname
|
160
150
|
@hostname ||= Socket.gethostname
|
@@ -36,7 +36,6 @@ module PortAuthority
|
|
36
36
|
|
37
37
|
FloatingIP.init!
|
38
38
|
LoadBalancer.init!
|
39
|
-
LoadBalancer.container || ( LoadBalancer.pull! && LoadBalancer.create! )
|
40
39
|
|
41
40
|
Logger.debug 'Waiting for threads to gather something...'
|
42
41
|
sleep Config.lbaas[:interval]
|
@@ -73,7 +72,7 @@ module PortAuthority
|
|
73
72
|
Logger.notice 'FloatingIP is free :) assigning'
|
74
73
|
FloatingIP.handle! status_swarm
|
75
74
|
Logger.notice 'Notifying the network about change'
|
76
|
-
FloatingIP.
|
75
|
+
FloatingIP.arp_update!
|
77
76
|
end
|
78
77
|
end
|
79
78
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# rubocop:disable Metrics/LineLength, Metrics/AbcSize
|
2
2
|
require 'net/ping'
|
3
|
+
require 'digest/sha2'
|
3
4
|
|
4
5
|
module PortAuthority
|
5
6
|
module Mechanism
|
@@ -11,17 +12,20 @@ module PortAuthority
|
|
11
12
|
|
12
13
|
def init!
|
13
14
|
@_icmp = Net::Ping::ICMP.new(Config.lbaas[:floating_ip])
|
15
|
+
Logger.debug(Config.lbaas.to_yaml)
|
14
16
|
end
|
15
17
|
|
16
18
|
# add or remove VIP on interface
|
17
19
|
def handle!(leader)
|
18
|
-
return true if shellcmd Config.commands[:iproute], 'address', leader ? 'add' : 'delete', "#{Config.lbaas[:floating_ip]}/32", 'dev', Config.lbaas[:
|
20
|
+
return true if shellcmd Config.commands[:iproute], 'address', leader ? 'add' : 'delete', "#{Config.lbaas[:floating_ip]}/32", 'dev', Config.lbaas[:floating_iface], '>/dev/null 2>&1'
|
19
21
|
false
|
20
22
|
end
|
21
23
|
|
22
24
|
# send gratuitous ARP to the network
|
23
25
|
def arp_update!
|
24
|
-
return true if shellcmd Config.commands[:arping], '-U', '-q', '-c', Config.lbaas[:arping_count], '-I', Config.lbaas[:
|
26
|
+
# return true if shellcmd Config.commands[:arping], '-U', '-q', '-c', Config.lbaas[:arping_count], '-I', Config.lbaas[:floating_iface], Config.lbaas[:floating_ip]
|
27
|
+
return true if shellcmd Config.commands[:arping], '-U', '-q', '-c', Config.lbaas[:arping_count], '-I', Config.lbaas[:floating_iface], Config.lbaas[:floating_ip]
|
28
|
+
|
25
29
|
false
|
26
30
|
end
|
27
31
|
|
@@ -43,9 +47,19 @@ module PortAuthority
|
|
43
47
|
|
44
48
|
# check whether the IP is registered anywhere
|
45
49
|
def duplicate?
|
46
|
-
return
|
47
|
-
|
50
|
+
return false if shellcmd Config.commands[:arping], '-D', '-q', '-c', Config.lbaas[:arping_count], '-w', Config.lbaas[:arping_wait], '-I', Config.lbaas[:floating_iface], Config.lbaas[:floating_ip]
|
51
|
+
true
|
48
52
|
end
|
53
|
+
|
54
|
+
private
|
55
|
+
def shellcmd(*args)
|
56
|
+
cmd = args.join(' ').to_s
|
57
|
+
cksum = Digest::SHA256.hexdigest(args.join.to_s)[0..15]
|
58
|
+
Logger.debug "Executing shellcommand #{cksum} - #{cmd}"
|
59
|
+
ret = system cmd
|
60
|
+
Logger.debug "Shellcommand #{cksum} returned #{ret.to_s}"
|
61
|
+
end
|
62
|
+
|
49
63
|
end
|
50
64
|
end
|
51
65
|
end
|
@@ -11,6 +11,7 @@ module PortAuthority
|
|
11
11
|
def init!
|
12
12
|
Docker.url = Config.lbaas[:docker_endpoint]
|
13
13
|
Docker.options = { connect_timeout: Config.lbaas[:docker_timeout] || 10 }
|
14
|
+
self.container || ( self.pull! && self.create! )
|
14
15
|
end
|
15
16
|
|
16
17
|
def container
|
@@ -56,7 +57,7 @@ module PortAuthority
|
|
56
57
|
|
57
58
|
def update!
|
58
59
|
begin
|
59
|
-
self.stop! && start = true if self.up?
|
60
|
+
( self.stop! && start = true ) if self.up?
|
60
61
|
self.remove!
|
61
62
|
self.pull!
|
62
63
|
self.create!
|
@@ -69,19 +70,19 @@ module PortAuthority
|
|
69
70
|
end
|
70
71
|
|
71
72
|
def remove!
|
72
|
-
|
73
|
+
@_container.delete
|
73
74
|
end
|
74
75
|
|
75
76
|
def up?
|
76
|
-
|
77
|
+
@_container.json['State']['Running']
|
77
78
|
end
|
78
79
|
|
79
80
|
def start!
|
80
|
-
|
81
|
+
@_container.start
|
81
82
|
end
|
82
83
|
|
83
84
|
def stop!
|
84
|
-
|
85
|
+
@_container.stop
|
85
86
|
end
|
86
87
|
|
87
88
|
end
|
metadata
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: port-authority
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Radek 'blufor' Slavicinsky
|
8
|
+
- Tomas 'arteal' Hejatko
|
9
|
+
- Jan 'liquid' Kaufman
|
8
10
|
autorequire:
|
9
11
|
bindir: bin
|
10
12
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
13
|
+
date: 2016-05-11 00:00:00.000000000 Z
|
12
14
|
dependencies:
|
13
15
|
- !ruby/object:Gem::Dependency
|
14
16
|
name: etcd
|
@@ -90,8 +92,8 @@ dependencies:
|
|
90
92
|
- - ">="
|
91
93
|
- !ruby/object:Gem::Version
|
92
94
|
version: 1.25.0
|
93
|
-
description:
|
94
|
-
email:
|
95
|
+
description: Highly opinionated PaaS based on Docker Swarm and ETCD
|
96
|
+
email: cloud@prozeta.eu
|
95
97
|
executables:
|
96
98
|
- pa-lbaas-agent
|
97
99
|
- pa-service-list
|
@@ -130,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
132
|
version: '0'
|
131
133
|
requirements: []
|
132
134
|
rubyforge_project:
|
133
|
-
rubygems_version: 2.4.
|
135
|
+
rubygems_version: 2.4.6
|
134
136
|
signing_key:
|
135
137
|
specification_version: 4
|
136
138
|
summary: Port Authority
|