swarm_cluster_cli_ope 0.5.0.pre.4 → 0.5.0.pre.5
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/Gemfile.lock +1 -1
- data/lib/swarm_cluster_cli_ope/kubernetes/configuration.rb +17 -2
- data/lib/swarm_cluster_cli_ope/kubernetes/pod.rb +2 -1
- data/lib/swarm_cluster_cli_ope/kubernetes/sync_configs/rsync.rb +46 -38
- data/lib/swarm_cluster_cli_ope/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3ef506ff18497d7a1e4d7e8641d439f006d5a4efd6065436e4f9ab3ff9a251c
|
4
|
+
data.tar.gz: bbce35bf210097b7e2bb2d8a973ec345f2dd9cea786536947ddb88bd9baf0aef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa6b8661174a5b5c4961baf2c973c202b15b29ef25e5e796548c902339626d53aea85f6a70c83302127a4864ff868588d0c9b36431d9db71dd1c4626baa8482d
|
7
|
+
data.tar.gz: 6d81962999b8b01337c03c299db875264dde14bdf2b093448ed47e7f0f0dc51bc53fcdc70086975f0e66c6efee2ccfd5545a669e29d03a499fc1a88ab2ed9460
|
data/Gemfile.lock
CHANGED
@@ -2,14 +2,29 @@ module SwarmClusterCliOpe
|
|
2
2
|
module Kubernetes
|
3
3
|
class Configuration < BaseConfiguration
|
4
4
|
|
5
|
+
def shell
|
6
|
+
@_shell = Thor::Shell::Basic.new
|
7
|
+
end
|
8
|
+
|
9
|
+
delegate :yes?,to: :shell
|
5
10
|
|
6
11
|
##
|
7
12
|
# In kubernetes abbiamo il context, il context può essere ricevuto o dalla configurazione oppure dal current_context
|
8
13
|
# di kubelet
|
9
14
|
# @return [String]
|
10
15
|
def context
|
11
|
-
|
12
|
-
|
16
|
+
|
17
|
+
context = merged_configurations.dig(:connections_maps,:context) || nil
|
18
|
+
|
19
|
+
if context.nil?
|
20
|
+
cmd = ShellCommandExecution.new(['kubectl config current-context'])
|
21
|
+
context = cmd.execute.raw_result[:stdout]
|
22
|
+
unless yes? "Attenzione, non era presente il contesto nelle configurazioni, usiamo quello attualmente in uso: #{context}, proseguiamo lo stesso?[y,yes]"
|
23
|
+
exit
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
context
|
13
28
|
end
|
14
29
|
|
15
30
|
##
|
@@ -99,7 +99,8 @@ module SwarmClusterCliOpe
|
|
99
99
|
exit
|
100
100
|
else
|
101
101
|
if ris.single_obj[:items].empty?
|
102
|
-
|
102
|
+
puts "non abbiamo trovato il pod"
|
103
|
+
exit
|
103
104
|
else
|
104
105
|
self.new(ris.single_obj[:items].first, context: context)
|
105
106
|
end
|
@@ -60,49 +60,57 @@ module SwarmClusterCliOpe
|
|
60
60
|
puts "problema nella copia dei file di configurazione nel pod"
|
61
61
|
else
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
else
|
68
|
-
local_port = rand(30000..40000)
|
69
|
-
|
70
|
-
p = IO.popen(container.base_cmd("port-forward #{podname} #{local_port}:873").string_command)
|
71
|
-
pid = p.pid
|
72
|
-
say "PID in execuzione port forward:#{pid}"
|
73
|
-
|
74
|
-
sleep 1
|
75
|
-
|
76
|
-
# lanciamo il comando quindi per far rsync
|
77
|
-
rsync_command = [
|
78
|
-
"rsync -az --no-o --no-g",
|
79
|
-
"--delete",
|
80
|
-
"--password-file=#{ File.expand_path("../../rsync_cfgs/password", __FILE__)}"
|
81
|
-
]
|
82
|
-
|
83
|
-
if direction == :up
|
84
|
-
rsync_command << "#{local_folder}/."
|
85
|
-
rsync_command << "rsync://root@0.0.0.0:#{local_port}/archives#{remote_folder}"
|
63
|
+
begin
|
64
|
+
cmd = container.exec('bash -c "rsync --daemon --config=/tmp/rsyncd.conf --verbose --log-file=/tmp/rsync.log"')
|
65
|
+
if cmd.execute.failed?
|
66
|
+
say "Rsync non Inizializzato"
|
86
67
|
else
|
87
|
-
|
88
|
-
|
68
|
+
begin
|
69
|
+
local_port = rand(30000..40000)
|
70
|
+
|
71
|
+
p = IO.popen(container.base_cmd("port-forward #{podname} #{local_port}:873").string_command)
|
72
|
+
pid = p.pid
|
73
|
+
say "PID in execuzione port forward:#{pid}"
|
74
|
+
|
75
|
+
begin
|
76
|
+
|
77
|
+
sleep 1
|
78
|
+
|
79
|
+
# lanciamo il comando quindi per far rsync
|
80
|
+
rsync_command = [
|
81
|
+
"rsync -az --no-o --no-g",
|
82
|
+
"--delete",
|
83
|
+
"--password-file=#{ File.expand_path("../../rsync_cfgs/password", __FILE__)}"
|
84
|
+
]
|
85
|
+
|
86
|
+
if direction == :up
|
87
|
+
rsync_command << "#{local_folder}/."
|
88
|
+
rsync_command << "rsync://root@0.0.0.0:#{local_port}/archives#{remote_folder}"
|
89
|
+
else
|
90
|
+
rsync_command << "rsync://root@0.0.0.0:#{local_port}/archives#{remote_folder}/."
|
91
|
+
rsync_command << local_folder
|
92
|
+
end
|
93
|
+
say "Eseguo rsync #{rsync_command.join(" ")}"
|
94
|
+
|
95
|
+
cmd = ShellCommandExecution.new(rsync_command)
|
96
|
+
cmd.execute
|
97
|
+
|
98
|
+
ensure
|
99
|
+
sleep 1
|
100
|
+
say "Stoppo porta forwarded"
|
101
|
+
Process.kill("INT", pid)
|
102
|
+
end
|
103
|
+
ensure
|
104
|
+
say "Tolgo il servizio di rsyn"
|
105
|
+
cmd = container.exec('bash -c "killall rsync"')
|
106
|
+
cmd.execute
|
107
|
+
end
|
89
108
|
end
|
90
|
-
say "Eseguo rsync #{rsync_command.join(" ")}"
|
91
|
-
|
92
109
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
sleep 1
|
97
|
-
Process.kill("INT", pid)
|
98
|
-
|
99
|
-
|
100
|
-
say "Eseguo pulizia"
|
101
|
-
cmd = container.exec('bash -c "killall rsync"')
|
102
|
-
cmd.execute
|
110
|
+
ensure
|
111
|
+
say "Eseguo pulizia configurazioni caricate"
|
103
112
|
cmd = container.exec('bash -c "rm -fr /tmp/rsyncd*"')
|
104
113
|
cmd.execute
|
105
|
-
|
106
114
|
end
|
107
115
|
|
108
116
|
end
|