swarm_cluster_cli_ope 0.5.0.pre.4 → 0.5.0.pre.5

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
  SHA256:
3
- metadata.gz: 38b75604119e4338ee0cc8552d15c82ab5f7bc7aa41f4cf45a4c5e3dd333fd36
4
- data.tar.gz: 7cc4fd8a3a39907dea28f413843e0d9d997fb7effd4dea3ba8081b8235ac1067
3
+ metadata.gz: b3ef506ff18497d7a1e4d7e8641d439f006d5a4efd6065436e4f9ab3ff9a251c
4
+ data.tar.gz: bbce35bf210097b7e2bb2d8a973ec345f2dd9cea786536947ddb88bd9baf0aef
5
5
  SHA512:
6
- metadata.gz: 10f7fc072a0eb4144ec717f8fe09b67d71831a88c3fd205639054e52c309ef8d43655ce4b1f997e9ce3ecb83587a30d01a75f02b555355414e47d87d793b8c6f
7
- data.tar.gz: 1546b4dfcf48483bfd0ff7502a2a2613d129acb59d21256aa2b94ecb8c3f1beeccc0313abfeb9e0f9da003efe5a187d4d69f356a8de2700c4d664ae5ed979887
6
+ metadata.gz: aa6b8661174a5b5c4961baf2c973c202b15b29ef25e5e796548c902339626d53aea85f6a70c83302127a4864ff868588d0c9b36431d9db71dd1c4626baa8482d
7
+ data.tar.gz: 6d81962999b8b01337c03c299db875264dde14bdf2b093448ed47e7f0f0dc51bc53fcdc70086975f0e66c6efee2ccfd5545a669e29d03a499fc1a88ab2ed9460
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- swarm_cluster_cli_ope (0.5.0.pre.4)
4
+ swarm_cluster_cli_ope (0.5.0.pre.5)
5
5
  activesupport
6
6
  open4
7
7
  thor (~> 1.0)
@@ -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
- cmd = ShellCommandExecution.new(['kubectl config current-context'])
12
- cmd.execute.raw_result[:stdout]
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
- logger.warn { "non abbiamo trovato il pod" }
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
- 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"
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
- rsync_command << "rsync://root@0.0.0.0:#{local_port}/archives#{remote_folder}/."
88
- rsync_command << local_folder
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
- cmd = ShellCommandExecution.new(rsync_command)
94
- cmd.execute
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
@@ -1,3 +1,3 @@
1
1
  module SwarmClusterCliOpe
2
- VERSION = "0.5.0.pre.4"
2
+ VERSION = "0.5.0.pre.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swarm_cluster_cli_ope
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0.pre.4
4
+ version: 0.5.0.pre.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marino Bonetti