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 CHANGED
@@ -1 +1 @@
1
- 0.3.4
1
+ 0.3.6
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gaptool-client"
8
- s.version = "0.3.4"
8
+ s.version = "0.3.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Bailey"]
@@ -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 instance
81
- @ssh = $api.ssh(role, environment, instance)
82
- else
81
+ if tmux?
83
82
  nodes = $api.getenvroles(role, environment)
84
- if first? || nodes.size == 1
85
- puts "No instnace specified, but only one instance in cluster or first forced"
86
- @ssh = $api.ssh(role, environment, nodes.first['instance'])
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
- puts "No instance specified, querying list."
89
- nodes.each_index do |i|
90
- puts "#{i}: #{nodes[i]['instance']}"
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
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: 3790817521907323443
242
+ hash: -1782639922451775426
243
243
  required_rubygems_version: !ruby/object:Gem::Requirement
244
244
  none: false
245
245
  requirements: