gaptool-client 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +15 -9
- data/VERSION +1 -1
- data/gaptool-client.gemspec +2 -2
- data/lib/gaptool-client.rb +51 -1
- metadata +3 -3
data/Gemfile.lock
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (3.2.
|
4
|
+
activesupport (3.2.11)
|
5
5
|
i18n (~> 0.6)
|
6
6
|
multi_json (~> 1.0)
|
7
|
+
bourne (1.1.2)
|
8
|
+
mocha (= 0.10.5)
|
7
9
|
clamp (0.5.0)
|
8
|
-
gaptool-api (0.
|
10
|
+
gaptool-api (0.2.4)
|
9
11
|
httparty
|
10
12
|
git (1.2.5)
|
11
|
-
httparty (0.
|
13
|
+
httparty (0.10.0)
|
12
14
|
multi_json (~> 1.0)
|
13
15
|
multi_xml
|
14
16
|
i18n (0.6.1)
|
@@ -17,20 +19,24 @@ GEM
|
|
17
19
|
git (>= 1.2.5)
|
18
20
|
rake
|
19
21
|
rdoc
|
20
|
-
json (1.7.
|
21
|
-
|
22
|
-
|
22
|
+
json (1.7.6)
|
23
|
+
metaclass (0.0.1)
|
24
|
+
mocha (0.10.5)
|
25
|
+
metaclass (~> 0.0.1)
|
26
|
+
multi_json (1.5.0)
|
27
|
+
multi_xml (0.5.2)
|
23
28
|
peach (0.5.1)
|
24
29
|
rainbow (1.1.4)
|
25
|
-
rake (10.0.
|
30
|
+
rake (10.0.3)
|
26
31
|
rdoc (3.12)
|
27
32
|
json (~> 1.4)
|
28
33
|
shoulda (3.3.2)
|
29
34
|
shoulda-context (~> 1.0.1)
|
30
35
|
shoulda-matchers (~> 1.4.1)
|
31
|
-
shoulda-context (1.0.
|
32
|
-
shoulda-matchers (1.4.
|
36
|
+
shoulda-context (1.0.2)
|
37
|
+
shoulda-matchers (1.4.2)
|
33
38
|
activesupport (>= 3.0.0)
|
39
|
+
bourne (~> 1.1.2)
|
34
40
|
simplecov (0.7.1)
|
35
41
|
multi_json (~> 1.0)
|
36
42
|
simplecov-html (~> 0.7.1)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1
|
1
|
+
0.2.1
|
data/gaptool-client.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "gaptool-client"
|
8
|
-
s.version = "0.1
|
8
|
+
s.version = "0.2.1"
|
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 = "
|
12
|
+
s.date = "2013-01-16"
|
13
13
|
s.description = "client for gaptool-server"
|
14
14
|
s.email = "m@mdb.io"
|
15
15
|
s.executables = ["gt"]
|
data/lib/gaptool-client.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
2
3
|
require 'rainbow'
|
3
4
|
require 'peach'
|
4
5
|
require 'json'
|
@@ -55,6 +56,54 @@ class SshCommand < Clamp::Command
|
|
55
56
|
|
56
57
|
end
|
57
58
|
|
59
|
+
class InfoCommand < Clamp::Command
|
60
|
+
option ["-r", "--role"], "ROLE", "Role name to ssh to", :required => false
|
61
|
+
option ["-e", "--environment"], "ENVIRONMENT", "Which environment, e.g. production", :required => false
|
62
|
+
option ["-i", "--instance"], "INSTANCE", "Node instance, leave blank to query avilable nodes", :required => false
|
63
|
+
option ["-p", "--parseable"], :flag, "Display in non-pretty parseable JSON"
|
64
|
+
option ["-g", "--grepable"], :flag, "Display in non-pretty grep-friendly text"
|
65
|
+
|
66
|
+
def execute
|
67
|
+
@nodes = Array.new
|
68
|
+
if instance
|
69
|
+
@nodes = [$api.getonenode(instance)]
|
70
|
+
elsif role && environment
|
71
|
+
@nodes = $api.getenvroles(role, environment)
|
72
|
+
elsif role && !environment
|
73
|
+
@nodes = $api.getrolenodes(role)
|
74
|
+
else
|
75
|
+
@nodes = $api.getallnodes()
|
76
|
+
end
|
77
|
+
infohelper(@nodes, parseable?, grepable?)
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
def infohelper(nodes, parseable, grepable)
|
84
|
+
if parseable
|
85
|
+
puts nodes.to_json
|
86
|
+
else
|
87
|
+
nodes.each do |node|
|
88
|
+
@host = "#{node['role']}:#{node['environment']}:#{node['instance']}"
|
89
|
+
unless grepable
|
90
|
+
puts @host.color(:green)
|
91
|
+
end
|
92
|
+
node.keys.each do |key|
|
93
|
+
if grepable
|
94
|
+
puts "#{@host}|#{key}|#{node[key]}"
|
95
|
+
else
|
96
|
+
unless key == node.keys.last
|
97
|
+
puts " ┠ #{key.color(:cyan)}: #{node[key]}"
|
98
|
+
else
|
99
|
+
puts " ┖ #{key.color(:cyan)}: #{node[key]}\n\n"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
58
107
|
def sshcmd(node, commands)
|
59
108
|
Net::SSH.start(
|
60
109
|
node['hostname'],
|
@@ -82,7 +131,7 @@ class ChefrunCommand < Clamp::Command
|
|
82
131
|
|
83
132
|
def execute
|
84
133
|
if !instance.nil?
|
85
|
-
nodes = [$api.getonenode(
|
134
|
+
nodes = [$api.getonenode(instance)]
|
86
135
|
else
|
87
136
|
nodes = $api.getenvroles(role, environment)
|
88
137
|
end
|
@@ -195,6 +244,7 @@ end
|
|
195
244
|
|
196
245
|
class MainCommand < Clamp::Command
|
197
246
|
|
247
|
+
subcommand "info", "Displays information about nodes", InfoCommand
|
198
248
|
subcommand "init", "Create new application cluster", InitCommand
|
199
249
|
subcommand "terminate", "Terminate instance", TerminateCommand
|
200
250
|
subcommand "ssh", "ssh to cluster host", SshCommand
|
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.1
|
4
|
+
version: 0.2.1
|
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:
|
12
|
+
date: 2013-01-16 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:
|
210
|
+
hash: 4229758815280355576
|
211
211
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
212
|
none: false
|
213
213
|
requirements:
|