ecl 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +20 -0
- data/Rakefile +1 -0
- data/bin/console +10 -0
- data/bin/setup +7 -0
- data/eclair.gemspec +29 -0
- data/exe/ecl +6 -0
- data/lib/eclair.rb +22 -0
- data/lib/eclair/cell.rb +101 -0
- data/lib/eclair/color.rb +19 -0
- data/lib/eclair/column.rb +52 -0
- data/lib/eclair/config.rb +68 -0
- data/lib/eclair/console.rb +56 -0
- data/lib/eclair/grid.rb +355 -0
- data/lib/eclair/group.rb +55 -0
- data/lib/eclair/helpers/aws_helper.rb +157 -0
- data/lib/eclair/helpers/benchmark_helper.rb +19 -0
- data/lib/eclair/helpers/common_helper.rb +24 -0
- data/lib/eclair/instance.rb +148 -0
- data/lib/eclair/less_viewer.rb +23 -0
- data/lib/eclair/matcher.rb +19 -0
- data/lib/eclair/version.rb +3 -0
- data/templates/eclrc.template +61 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9dbfb94853aaa48d41c193a65a592b78f3e19fff
|
4
|
+
data.tar.gz: f4c864a0e4d24fe98f31f3b8d55e8afb7c499753
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9bf087e07c4040d1e73343356ea050b431cdb04552c07b16d8a71b3a06dca668356868d3346cc90d5c70dbffea1a124ebf7fa16aea1fe013e7803157c2afe198
|
7
|
+
data.tar.gz: 8295911d2e74b3256364a3d5ed0cff8ff61052f2e4e9c439ca764ea67c104523e810cbd52f24039b5620eceb6c3f861865e8aa0e65669c60b1f32ba1e5bfe16b
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Minkyu Kim
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Eclair
|
2
|
+
|
3
|
+
Simple ssh helper for Amazon EC2
|
4
|
+
|
5
|
+
## Requirements
|
6
|
+
|
7
|
+
tmux
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
$ gem install eclair2
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
$ ecl
|
16
|
+
|
17
|
+
## License
|
18
|
+
|
19
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
20
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "eclair"
|
4
|
+
|
5
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
6
|
+
# with your gem easier. You can also use a different console, if you like.
|
7
|
+
|
8
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
9
|
+
require "pry"
|
10
|
+
Pry.start
|
data/bin/setup
ADDED
data/eclair.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'eclair/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ecl"
|
8
|
+
spec.version = Eclair::VERSION
|
9
|
+
spec.authors = ["Devsisters"]
|
10
|
+
spec.email = ["se@devsisters.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{EC2 ssh helper}
|
13
|
+
spec.description = %q{Simple ssh helper for Amazon EC2}
|
14
|
+
spec.homepage = "https://github.com/devsisters/eclair"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
|
25
|
+
spec.add_runtime_dependency "aws-sdk", "= 2.1.8"
|
26
|
+
spec.add_runtime_dependency "curses", "~> 1.0"
|
27
|
+
spec.add_runtime_dependency "pry", "~> 0.10"
|
28
|
+
spec.add_runtime_dependency "ruby-string-match-scorer", "~> 0.1"
|
29
|
+
end
|
data/exe/ecl
ADDED
data/lib/eclair.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Eclair
|
2
|
+
end
|
3
|
+
|
4
|
+
require "curses"
|
5
|
+
require "aws-sdk"
|
6
|
+
require "string_scorer"
|
7
|
+
require "pry"
|
8
|
+
|
9
|
+
require "eclair/helpers/benchmark_helper"
|
10
|
+
require "eclair/helpers/common_helper"
|
11
|
+
require "eclair/helpers/aws_helper"
|
12
|
+
require "eclair/config"
|
13
|
+
require "eclair/version"
|
14
|
+
require "eclair/less_viewer"
|
15
|
+
require "eclair/grid"
|
16
|
+
require "eclair/column"
|
17
|
+
require "eclair/cell"
|
18
|
+
require "eclair/group"
|
19
|
+
require "eclair/instance"
|
20
|
+
require "eclair/console"
|
21
|
+
require "eclair/color"
|
22
|
+
|
data/lib/eclair/cell.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
module Eclair
|
2
|
+
class Cell
|
3
|
+
include CommonHelper
|
4
|
+
|
5
|
+
attr_accessor :column
|
6
|
+
attr_accessor :selected
|
7
|
+
|
8
|
+
def initialize *args
|
9
|
+
@current = false
|
10
|
+
@selected = false
|
11
|
+
end
|
12
|
+
|
13
|
+
def color(*color)
|
14
|
+
if @current
|
15
|
+
color = config.current_color
|
16
|
+
elsif @selected
|
17
|
+
color = config.selected_color
|
18
|
+
end
|
19
|
+
|
20
|
+
if Grid.mode == :search && @current
|
21
|
+
color = config.search_color
|
22
|
+
end
|
23
|
+
|
24
|
+
Color.fetch(*color)
|
25
|
+
end
|
26
|
+
|
27
|
+
def render options = 0
|
28
|
+
drawy = y - column.scroll
|
29
|
+
return if drawy < 0 || drawy >= Grid.maxy
|
30
|
+
w = Grid.cell_width
|
31
|
+
setpos(drawy + Grid::HEADER_ROWS, x * w)
|
32
|
+
str = format.slice(0, w).ljust(w)
|
33
|
+
attron(color) do
|
34
|
+
addstr(str)
|
35
|
+
end
|
36
|
+
Grid.render_header
|
37
|
+
end
|
38
|
+
|
39
|
+
def deselect
|
40
|
+
@selected = false
|
41
|
+
Grid.selected.delete self
|
42
|
+
redraw
|
43
|
+
end
|
44
|
+
|
45
|
+
def select
|
46
|
+
@selected = true
|
47
|
+
Grid.selected << self
|
48
|
+
redraw
|
49
|
+
end
|
50
|
+
|
51
|
+
def toggle_select
|
52
|
+
if respond_to? :each
|
53
|
+
if all?(&:selected)
|
54
|
+
each(&:deselect)
|
55
|
+
else
|
56
|
+
each(&:select)
|
57
|
+
end
|
58
|
+
else
|
59
|
+
if @selected
|
60
|
+
deselect
|
61
|
+
else
|
62
|
+
select
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def current
|
68
|
+
@current = true
|
69
|
+
check_scroll
|
70
|
+
redraw
|
71
|
+
end
|
72
|
+
|
73
|
+
def check_scroll
|
74
|
+
unless column.drawable? y
|
75
|
+
column.rescroll y
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def decurrent
|
80
|
+
@current = false
|
81
|
+
redraw
|
82
|
+
end
|
83
|
+
|
84
|
+
def redraw
|
85
|
+
render
|
86
|
+
refresh
|
87
|
+
end
|
88
|
+
|
89
|
+
def select_indicator
|
90
|
+
if @selected
|
91
|
+
if Grid.mode == :select
|
92
|
+
"*"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def method_missing name, *args, &blk
|
98
|
+
object.send(name)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
data/lib/eclair/color.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Eclair
|
2
|
+
module Color
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def storage
|
6
|
+
@storage ||= {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def fetch fg, bg, options = 0
|
10
|
+
@idx ||= 1
|
11
|
+
unless storage[[fg,bg]]
|
12
|
+
Curses.init_pair(@idx, fg, bg)
|
13
|
+
storage[[fg,bg]] = @idx
|
14
|
+
@idx += 1
|
15
|
+
end
|
16
|
+
Curses.color_pair(storage[[fg,bg]]) | options
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Eclair
|
2
|
+
class Column
|
3
|
+
include CommonHelper
|
4
|
+
array_accessor :expand
|
5
|
+
attr_accessor :scroll
|
6
|
+
attr_accessor :items
|
7
|
+
|
8
|
+
def initialize index
|
9
|
+
@index = index
|
10
|
+
@items = []
|
11
|
+
@scroll = 0
|
12
|
+
end
|
13
|
+
|
14
|
+
def << item
|
15
|
+
@items << item
|
16
|
+
end
|
17
|
+
|
18
|
+
def x
|
19
|
+
@index
|
20
|
+
end
|
21
|
+
|
22
|
+
def drawable? y
|
23
|
+
(@scroll...Grid.maxy+@scroll).include? y
|
24
|
+
end
|
25
|
+
|
26
|
+
def rescroll y
|
27
|
+
if y < @scroll
|
28
|
+
@scroll = y
|
29
|
+
elsif y >= Grid.maxy
|
30
|
+
@scroll = y - Grid.maxy + 1
|
31
|
+
end
|
32
|
+
expand.each do |i|
|
33
|
+
i.render
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def expand
|
38
|
+
expanded = []
|
39
|
+
if config.group_by
|
40
|
+
@items.each do |item|
|
41
|
+
expanded << item
|
42
|
+
item.each do |instance|
|
43
|
+
expanded << instance
|
44
|
+
end
|
45
|
+
end
|
46
|
+
expanded
|
47
|
+
else
|
48
|
+
@items
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Eclair
|
2
|
+
class Config
|
3
|
+
RCFILE = ENV["ECLRC"] || "#{ENV['HOME']}/.eclrc"
|
4
|
+
include Curses
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@aws_region = nil
|
8
|
+
@columns = 4
|
9
|
+
@group_by = lambda do |instance|
|
10
|
+
if instance.security_groups.first
|
11
|
+
instance.security_groups.first.group_name
|
12
|
+
else
|
13
|
+
"no_group"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
@ssh_username = lambda do |image|
|
17
|
+
case image.name
|
18
|
+
when /ubuntu/
|
19
|
+
"ubuntu"
|
20
|
+
else
|
21
|
+
"ec2-user"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
@ssh_hostname = :public_ip_address
|
25
|
+
@ssh_ports = [22].freeze
|
26
|
+
@ssh_options = "-o ConnectTimeout=1 -o StrictHostKeyChecking=no".freeze
|
27
|
+
@instance_color = [COLOR_WHITE, -1].freeze
|
28
|
+
@group_color = [COLOR_WHITE, -1, A_BOLD].freeze
|
29
|
+
@current_color = [COLOR_BLACK, COLOR_CYAN].freeze
|
30
|
+
@selected_color = [COLOR_YELLOW, -1, A_BOLD].freeze
|
31
|
+
@disabled_color = [COLOR_BLACK, -1, A_BOLD].freeze
|
32
|
+
@search_color = [COLOR_BLACK, COLOR_YELLOW].freeze
|
33
|
+
@help_color = [COLOR_BLACK, COLOR_WHITE].freeze
|
34
|
+
|
35
|
+
instance_variables.each do |var|
|
36
|
+
Config.class_eval do
|
37
|
+
attr_accessor var.to_s.tr("@","").to_sym
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
unless File.exists? RCFILE
|
42
|
+
template_path = File.join(File.dirname(__FILE__), "..", "..", "templates", "eclrc.template")
|
43
|
+
FileUtils.cp(template_path, RCFILE)
|
44
|
+
puts "#{RCFILE} successfully created. Edit it and run again!"
|
45
|
+
exit
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
extend self
|
51
|
+
|
52
|
+
def config
|
53
|
+
unless @config
|
54
|
+
@config = Config.new
|
55
|
+
load Config::RCFILE
|
56
|
+
end
|
57
|
+
|
58
|
+
if @config.aws_region
|
59
|
+
::Aws.config.update(region: @config.aws_region)
|
60
|
+
end
|
61
|
+
|
62
|
+
@config
|
63
|
+
end
|
64
|
+
|
65
|
+
def configure
|
66
|
+
yield config
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Eclair
|
2
|
+
module Console
|
3
|
+
include CommonHelper
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def init
|
7
|
+
config
|
8
|
+
ENV['ESCDELAY'] = "0"
|
9
|
+
init_screen
|
10
|
+
stdscr.keypad = true
|
11
|
+
start_color
|
12
|
+
use_default_colors
|
13
|
+
crmode
|
14
|
+
noecho
|
15
|
+
curs_set(0)
|
16
|
+
Grid.start
|
17
|
+
trap("INT") { exit }
|
18
|
+
loop do
|
19
|
+
case k = stdscr.getch
|
20
|
+
when KEY_RESIZE
|
21
|
+
Grid.resize
|
22
|
+
when KEY_LEFT, KEY_RIGHT, KEY_UP, KEY_DOWN
|
23
|
+
Grid.move k
|
24
|
+
when " "
|
25
|
+
if Grid.mode == :search
|
26
|
+
Grid.end_search
|
27
|
+
end
|
28
|
+
Grid.select
|
29
|
+
when 10
|
30
|
+
case Grid.mode
|
31
|
+
when :search
|
32
|
+
Grid.end_search
|
33
|
+
else
|
34
|
+
Grid.ssh
|
35
|
+
end
|
36
|
+
when 27
|
37
|
+
if Grid.mode == :search
|
38
|
+
Grid.cancel_search
|
39
|
+
end
|
40
|
+
when ?!
|
41
|
+
Grid.debug
|
42
|
+
when ??
|
43
|
+
Grid.cursor_inspect
|
44
|
+
when KEY_BACKSPACE, 127
|
45
|
+
Grid.search(nil)
|
46
|
+
when String
|
47
|
+
Grid.search(k)
|
48
|
+
else
|
49
|
+
# Aws.reload_instances
|
50
|
+
# Grid.render_all
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|