tmuxinator-bosh-console 0.1.3 → 0.2.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/.rubocop.yml +6 -1
- data/.travis.yml +3 -1
- data/Guardfile +1 -1
- data/README.markdown +8 -0
- data/Rakefile +5 -0
- data/exe/tmuxinator-bosh-console +23 -17
- data/lib/tmuxinator/bosh/console/director_gateway.rb +27 -0
- data/lib/tmuxinator/bosh/console/job.rb +12 -0
- data/lib/tmuxinator/bosh/console/template.rb +18 -0
- data/lib/tmuxinator/bosh/console/version.rb +1 -1
- data/templates/bosh-console.yml +5 -5
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fed7bba2c5ce851367554e8b5cfbec831077a36b
|
4
|
+
data.tar.gz: b6986938f82ccf78d487bee16f76758e29b0ee93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78e1a2988d056cc147120c6020a9eab258015f7bc4bca70e997afbcee5bc83bf9bd16761c29d34e66d03cb974cdc5d74ae95e6457aa5c21aeddedd1a5f287301
|
7
|
+
data.tar.gz: 7b3c106e8d6f22a99ec0c748d87ddd44565cb531e23d04541c82077816d54d43f675e6b57a8c7550ac2f4c566d7e2752564e78764842f7c59b590b60056303eb
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
2
|
+
TargetRubyVersion: 2.4
|
3
3
|
Include:
|
4
4
|
- '**/Gemfile'
|
5
5
|
- '**/Guardfile'
|
@@ -31,6 +31,11 @@ Lint/UnusedMethodArgument:
|
|
31
31
|
Metrics/AbcSize:
|
32
32
|
Enabled: false
|
33
33
|
|
34
|
+
Metrics/BlockLength:
|
35
|
+
Exclude:
|
36
|
+
- '*.gemspec'
|
37
|
+
- spec/**/*
|
38
|
+
|
34
39
|
Metrics/ClassLength:
|
35
40
|
Enabled: false
|
36
41
|
|
data/.travis.yml
CHANGED
data/Guardfile
CHANGED
data/README.markdown
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# BOSH tmuxinator console
|
2
2
|
|
3
|
+
[](https://travis-ci.org/suhlig/tmuxinator-bosh-console)
|
4
|
+
|
3
5
|
## Synopsis
|
4
6
|
|
5
7
|
```bash
|
@@ -20,3 +22,9 @@ $ gem install tmuxinator-bosh-console
|
|
20
22
|
## Prerequisites
|
21
23
|
|
22
24
|
`bosh instances` must return a zero or more instances.
|
25
|
+
|
26
|
+
## TODO
|
27
|
+
|
28
|
+
* repeated `--include`s
|
29
|
+
* `--exclude` this VM (blacklisting); may be repeated
|
30
|
+
* `--custom` bosh ssh command, e.g. gateway-host
|
data/Rakefile
CHANGED
data/exe/tmuxinator-bosh-console
CHANGED
@@ -3,18 +3,31 @@
|
|
3
3
|
|
4
4
|
$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
|
5
5
|
|
6
|
-
require '
|
6
|
+
require 'optparse'
|
7
7
|
require 'pathname'
|
8
|
+
require 'tmuxinator/bosh/console/director_gateway'
|
9
|
+
require 'tmuxinator/bosh/console/template'
|
8
10
|
|
9
11
|
def die(msg)
|
10
12
|
warn "Error: #{msg}"
|
11
13
|
exit(1)
|
12
14
|
end
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
filter = {}
|
17
|
+
|
18
|
+
OptionParser.new do |opts|
|
19
|
+
opts.banner = "Generates a tmuxinator configuration for the VMs of a BOSH deployment\n\n" + opts.banner
|
20
|
+
opts.separator "\nOptions:"
|
21
|
+
|
22
|
+
opts.on('-IFILTER', '--include=FILTER', 'include only jobs with a name matching FILTER') do |f|
|
23
|
+
filter[:include] = Regexp.new(f)
|
24
|
+
end
|
25
|
+
|
26
|
+
opts.on('-XFILTER', '--exclude=FILTER', 'exclude jobs with a name matching FILTER') do |f|
|
27
|
+
filter[:exclude] = Regexp.new(f)
|
28
|
+
end
|
29
|
+
end.parse!
|
30
|
+
|
18
31
|
project_name = ARGV.first || die('Missing argument for the tmuxinator project name')
|
19
32
|
project_file = Pathname("~/.tmuxinator/#{project_name}.yml").expand_path
|
20
33
|
|
@@ -22,16 +35,9 @@ if project_file.exist?
|
|
22
35
|
die("Not overriding tmuxinator project file #{project_file}")
|
23
36
|
end
|
24
37
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
if md
|
29
|
-
{
|
30
|
-
job: md['job'],
|
31
|
-
index: md['index'],
|
32
|
-
}
|
33
|
-
end
|
34
|
-
}.compact
|
38
|
+
include Tmuxinator::BOSH::Console
|
39
|
+
template = Template.new(Pathname(__dir__) / '../templates/bosh-console.yml')
|
35
40
|
|
36
|
-
|
37
|
-
|
41
|
+
instances = DirectorGateway.new.instances(filter)
|
42
|
+
output = template.render(binding)
|
43
|
+
project_file.write(output)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'tmuxinator/bosh/console/job'
|
3
|
+
|
4
|
+
module Tmuxinator
|
5
|
+
module BOSH
|
6
|
+
module Console
|
7
|
+
#
|
8
|
+
# Gateway to the BOSH director
|
9
|
+
#
|
10
|
+
class DirectorGateway
|
11
|
+
def initialize(report=`bosh instances`)
|
12
|
+
@report = report
|
13
|
+
end
|
14
|
+
|
15
|
+
def instances(filter={})
|
16
|
+
@report.lines.map { |line|
|
17
|
+
md = line.match(%r{\| (?<job>\w+)\/(?<index>\d+)})
|
18
|
+
Job.new(md['job'], md['index']) if md
|
19
|
+
}.compact.tap do |result|
|
20
|
+
result.select! { |job| filter[:include].match?(job.name) } if filter[:include]
|
21
|
+
result.reject! { |job| filter[:exclude].match?(job.name) } if filter[:exclude]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
module Tmuxinator
|
5
|
+
module BOSH
|
6
|
+
module Console
|
7
|
+
class Template
|
8
|
+
def initialize(io)
|
9
|
+
@content = io.read
|
10
|
+
end
|
11
|
+
|
12
|
+
def render(source_binding)
|
13
|
+
ERB.new(@content).result(source_binding)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/templates/bosh-console.yml
CHANGED
@@ -3,18 +3,18 @@
|
|
3
3
|
name: <%= project_name %>
|
4
4
|
|
5
5
|
windows:
|
6
|
-
<%
|
7
|
-
- <%= vm
|
6
|
+
<% instances.each do |vm| %>
|
7
|
+
- <%= vm.name %>/<%= vm.index %>:
|
8
8
|
layout: main-vertical
|
9
9
|
panes:
|
10
10
|
- shell:
|
11
|
-
- bosh ssh <%= vm
|
11
|
+
- bosh ssh <%= vm.name %>/<%= vm.index %>
|
12
12
|
- sudo su -
|
13
13
|
- cd /var/vcap
|
14
14
|
- monit:
|
15
|
-
- bosh ssh <%= vm
|
15
|
+
- bosh ssh <%= vm.name %>/<%= vm.index %>
|
16
16
|
- sudo watch -n 1 /var/vcap/bosh/bin/monit summary
|
17
17
|
- logs:
|
18
|
-
- bosh ssh <%= vm
|
18
|
+
- bosh ssh <%= vm.name %>/<%= vm.index %>
|
19
19
|
- tail -f /var/vcap/sys/log/*/*
|
20
20
|
<% end %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tmuxinator-bosh-console
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steffen Uhlig
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bosh_cli
|
@@ -171,6 +171,9 @@ files:
|
|
171
171
|
- README.markdown
|
172
172
|
- Rakefile
|
173
173
|
- exe/tmuxinator-bosh-console
|
174
|
+
- lib/tmuxinator/bosh/console/director_gateway.rb
|
175
|
+
- lib/tmuxinator/bosh/console/job.rb
|
176
|
+
- lib/tmuxinator/bosh/console/template.rb
|
174
177
|
- lib/tmuxinator/bosh/console/version.rb
|
175
178
|
- templates/bosh-console.yml
|
176
179
|
- tmuxinator-bosh-console.gemspec
|
@@ -194,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
197
|
version: '0'
|
195
198
|
requirements: []
|
196
199
|
rubyforge_project:
|
197
|
-
rubygems_version: 2.
|
200
|
+
rubygems_version: 2.6.8
|
198
201
|
signing_key:
|
199
202
|
specification_version: 4
|
200
203
|
summary: Generates the tmuxinator configuration for all VMs of a BOSH deployment
|