gaptool-client 0.2.2 → 0.3.0

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.2.2
1
+ 0.3.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gaptool-client"
8
- s.version = "0.2.2"
8
+ s.version = "0.3.0"
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"]
12
- s.date = "2013-01-16"
12
+ s.date = "2013-01-17"
13
13
  s.description = "client for gaptool-server"
14
14
  s.email = "m@mdb.io"
15
15
  s.executables = ["gt"]
@@ -31,29 +31,46 @@ class SshCommand < Clamp::Command
31
31
  option ["-e", "--environment"], "ENVIRONMENT", "Which environment, e.g. production", :required => true
32
32
  option ["-i", "--instance"], "INSTANCE", "Node instance, leave blank to query avilable nodes", :require => false
33
33
  option ["-f", "--first"], :flag, "Just connect to first available instance"
34
+ option ["-t", "--tmux"], :flag, "Open cluster in windows in a tmux session"
34
35
 
35
36
  def execute
36
- if instance
37
- @ssh = $api.ssh(role, environment, instance)
38
- else
37
+ if tmux?
39
38
  nodes = $api.getenvroles(role, environment)
40
- if first? || nodes.size == 1
41
- puts "No instnace specified, but only one instance in cluster or first forced"
42
- @ssh = $api.ssh(role, environment, nodes.first['instance'])
39
+ system "tmux start-server"
40
+ nodes.each_index do |i|
41
+ @ssh = $api.ssh(role, environment, nodes[i]['instance'])
42
+ if i == 0
43
+ system "tmux new-session -d -s #{role}-#{environment} -n #{nodes[i]['instance']}"
44
+ else
45
+ system "tmux new-window -t #{role}-#{environment}:#{i} -n #{nodes[i]['instance']}"
46
+ end
47
+ File.open("/tmp/gtkey-#{nodes[i]['instance']}", 'w') {|f| f.write(@ssh['key'])}
48
+ File.chmod(0600, "/tmp/gtkey-#{nodes[i]['instance']}")
49
+ system "tmux send-keys -t #{role}-#{environment}:#{i} 'SSH_AUTH_SOCK=\"\" ssh -i /tmp/gtkey-#{nodes[i]['instance']} admin@#{@ssh['hostname']}' C-m"
50
+ end
51
+ system "tmux attach -t #{role}-#{environment}"
52
+ else
53
+ if instance
54
+ @ssh = $api.ssh(role, environment, instance)
43
55
  else
44
- puts "No instance specified, querying list."
45
- nodes.each_index do |i|
46
- puts "#{i}: #{nodes[i]['instance']}"
56
+ nodes = $api.getenvroles(role, environment)
57
+ if first? || nodes.size == 1
58
+ puts "No instnace specified, but only one instance in cluster or first forced"
59
+ @ssh = $api.ssh(role, environment, nodes.first['instance'])
60
+ else
61
+ puts "No instance specified, querying list."
62
+ nodes.each_index do |i|
63
+ puts "#{i}: #{nodes[i]['instance']}"
64
+ end
65
+ print "Select a node: ".color(:cyan)
66
+ @ssh = $api.ssh(role, environment, nodes[$stdin.gets.chomp.to_i]['instance'])
47
67
  end
48
- print "Select a node: ".color(:cyan)
49
- @ssh = $api.ssh(role, environment, nodes[$stdin.gets.chomp.to_i]['instance'])
50
68
  end
69
+ File.open('/tmp/gtkey', 'w') {|f| f.write(@ssh['key'])}
70
+ File.chmod(0600, '/tmp/gtkey')
71
+ system "SSH_AUTH_SOCK='' ssh -i /tmp/gtkey admin@#{@ssh['hostname']}"
51
72
  end
52
- File.open('/tmp/gtkey', 'w') {|f| f.write(@ssh['key'])}
53
- File.chmod(0600, '/tmp/gtkey')
54
- system "SSH_AUTH_SOCK='' ssh -i /tmp/gtkey admin@#{@ssh['hostname']}"
55
73
  end
56
-
57
74
  end
58
75
 
59
76
  class InfoCommand < Clamp::Command
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.2.2
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-16 00:00:00.000000000 Z
12
+ date: 2013-01-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -207,7 +207,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
207
207
  version: '0'
208
208
  segments:
209
209
  - 0
210
- hash: -1682468995549119550
210
+ hash: -2205502440360881386
211
211
  required_rubygems_version: !ruby/object:Gem::Requirement
212
212
  none: false
213
213
  requirements: