gaptool-client 0.3.4 → 0.3.6
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.
- data/VERSION +1 -1
- data/gaptool-client.gemspec +1 -1
- data/lib/gaptool-client.rb +32 -14
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.6
|
data/gaptool-client.gemspec
CHANGED
data/lib/gaptool-client.rb
CHANGED
@@ -75,27 +75,45 @@ module Gaptool
|
|
75
75
|
option ["-e", "--environment"], "ENVIRONMENT", "Which environment, e.g. production", :required => true
|
76
76
|
option ["-i", "--instance"], "INSTANCE", "Node instance, leave blank to query avilable nodes", :require => false
|
77
77
|
option ["-f", "--first"], :flag, "Just connect to first available instance"
|
78
|
+
option ["-t", "--tmux"], :flag, "Open cluster in windows in a tmux session"
|
78
79
|
|
79
80
|
def execute
|
80
|
-
if
|
81
|
-
@ssh = $api.ssh(role, environment, instance)
|
82
|
-
else
|
81
|
+
if tmux?
|
83
82
|
nodes = $api.getenvroles(role, environment)
|
84
|
-
|
85
|
-
|
86
|
-
@ssh = $api.ssh(role, environment, nodes
|
83
|
+
system "tmux start-server"
|
84
|
+
nodes.each_index do |i|
|
85
|
+
@ssh = $api.ssh(role, environment, nodes[i]['instance'])
|
86
|
+
if i == 0
|
87
|
+
system "tmux new-session -d -s #{role}-#{environment} -n #{nodes[i]['instance']}"
|
88
|
+
else
|
89
|
+
system "tmux new-window -t #{role}-#{environment}:#{i} -n #{nodes[i]['instance']}"
|
90
|
+
end
|
91
|
+
File.open("/tmp/gtkey-#{nodes[i]['instance']}", 'w') {|f| f.write(@ssh['key'])}
|
92
|
+
File.chmod(0600, "/tmp/gtkey-#{nodes[i]['instance']}")
|
93
|
+
system "tmux send-keys -t #{role}-#{environment}:#{i} 'SSH_AUTH_SOCK=\"\" ssh -i /tmp/gtkey-#{nodes[i]['instance']} admin@#{@ssh['hostname']}' C-m"
|
94
|
+
end
|
95
|
+
system "tmux attach -t #{role}-#{environment}"
|
96
|
+
else
|
97
|
+
if instance
|
98
|
+
@ssh = $api.ssh(role, environment, instance)
|
87
99
|
else
|
88
|
-
|
89
|
-
nodes.
|
90
|
-
puts "
|
100
|
+
nodes = $api.getenvroles(role, environment)
|
101
|
+
if first? || nodes.size == 1
|
102
|
+
puts "No instnace specified, but only one instance in cluster or first forced"
|
103
|
+
@ssh = $api.ssh(role, environment, nodes.first['instance'])
|
104
|
+
else
|
105
|
+
puts "No instance specified, querying list."
|
106
|
+
nodes.each_index do |i|
|
107
|
+
puts "#{i}: #{nodes[i]['instance']}"
|
108
|
+
end
|
109
|
+
print "Select a node: ".color(:cyan)
|
110
|
+
@ssh = $api.ssh(role, environment, nodes[$stdin.gets.chomp.to_i]['instance'])
|
91
111
|
end
|
92
|
-
print "Select a node: ".color(:cyan)
|
93
|
-
@ssh = $api.ssh(role, environment, nodes[$stdin.gets.chomp.to_i]['instance'])
|
94
112
|
end
|
113
|
+
File.open('/tmp/gtkey', 'w') {|f| f.write(@ssh['key'])}
|
114
|
+
File.chmod(0600, '/tmp/gtkey')
|
115
|
+
system "SSH_AUTH_SOCK='' ssh -i /tmp/gtkey admin@#{@ssh['hostname']}"
|
95
116
|
end
|
96
|
-
File.open('/tmp/gtkey', 'w') {|f| f.write(@ssh['key'])}
|
97
|
-
File.chmod(0600, '/tmp/gtkey')
|
98
|
-
system "SSH_AUTH_SOCK='' ssh -i /tmp/gtkey admin@#{@ssh['hostname']}"
|
99
117
|
end
|
100
118
|
|
101
119
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gaptool-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -239,7 +239,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
239
239
|
version: '0'
|
240
240
|
segments:
|
241
241
|
- 0
|
242
|
-
hash:
|
242
|
+
hash: -1782639922451775426
|
243
243
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
244
244
|
none: false
|
245
245
|
requirements:
|