xlogin 0.13.9 → 0.13.10
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/README.md +7 -10
- data/lib/xlogin.rb +4 -5
- data/lib/xlogin/cli.rb +16 -19
- data/lib/xlogin/template.rb +1 -1
- data/lib/xlogin/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 719819143a56b26ad14b31cbe6e61ed9d4df208c36dc9c060709bce170974d43
|
4
|
+
data.tar.gz: e0d20e9e5cd5967cacb28a8d92bd0f342bd5ecf47e591e9b7b3fb6257e6d5690
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce9b1a9bd127b38edd212875887773264019eb25a137eb4f84793b284671915246b2055d5e36c85a0d65d9350910262e642940f5f71d78400e6dffa8addaf4a8
|
7
|
+
data.tar.gz: d57ea13b2a0fd0aee2e332cf941e4cf596253297695932944dda3a310932e50be72a9fd0ea099adce2c9784ac55da91c92c781d5b74d3238f418334796eb23f4
|
data/README.md
CHANGED
@@ -62,16 +62,13 @@ Some other commandline options are:
|
|
62
62
|
~~~sh
|
63
63
|
$ xlogin -h
|
64
64
|
xlogin HOST_PATTERN [Options]
|
65
|
-
-i, --inventory PATH The PATH to the inventory file
|
66
|
-
|
67
|
-
-
|
68
|
-
-
|
69
|
-
-
|
70
|
-
-
|
71
|
-
-
|
72
|
-
-j, --jobs NUM The NUM of jobs to execute in parallel(default: 1).
|
73
|
-
-E, --enable Try to gain enable priviledge.
|
74
|
-
-y, --assume-yes Automatically answer yes to any confirmation prompts.
|
65
|
+
-i, --inventory PATH The PATH to the inventory file.
|
66
|
+
-t, --template PATH The PATH to the template file or directory.
|
67
|
+
-L, --log-dir PATH The PATH to the log directory.
|
68
|
+
-l, --list List the inventory.
|
69
|
+
-e, --exec COMMAND Execute commands and quit.
|
70
|
+
-E, --env KEY=VAL Environment variables.
|
71
|
+
-j, --jobs NUM The NUM of jobs to execute in parallel.
|
75
72
|
~~~
|
76
73
|
|
77
74
|
## Development
|
data/lib/xlogin.rb
CHANGED
@@ -46,7 +46,7 @@ module Xlogin
|
|
46
46
|
pool = factory.build_pool(args, **opts)
|
47
47
|
|
48
48
|
return pool unless block
|
49
|
-
block.call(pool)
|
49
|
+
begin block.call(pool) ensure pool.close end
|
50
50
|
end
|
51
51
|
alias_method :create_pool, :get_pool
|
52
52
|
|
@@ -55,8 +55,7 @@ module Xlogin
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def settings
|
58
|
-
@settings
|
59
|
-
@rosettings ||= ReadOnlyStruct.new(@settings)
|
58
|
+
ReadOnlyStruct.new(@settings || {})
|
60
59
|
end
|
61
60
|
|
62
61
|
def generate_templates(dir)
|
@@ -70,7 +69,7 @@ module Xlogin
|
|
70
69
|
@factory ||= Xlogin::Factory.instance
|
71
70
|
end
|
72
71
|
|
73
|
-
def set(
|
72
|
+
def set(opts = {})
|
74
73
|
@settings ||= {}
|
75
74
|
opts.each do |key, val|
|
76
75
|
val = val.call if val.kind_of?(Proc)
|
@@ -79,7 +78,7 @@ module Xlogin
|
|
79
78
|
end
|
80
79
|
|
81
80
|
def source(*sources, &block)
|
82
|
-
return factory.instance_eval(&block) if block
|
81
|
+
return factory.instance_eval(&block) if block && sources.size == 0
|
83
82
|
|
84
83
|
sources.each do |path|
|
85
84
|
raise Xlogin::Error.new("Inventory file not found: #{path}") unless File.exist?(path)
|
data/lib/xlogin/cli.rb
CHANGED
@@ -15,13 +15,12 @@ module Xlogin
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def list(config)
|
18
|
-
|
18
|
+
puts Xlogin.list(*config[:pattern]).map { |e| e[:name] }.sort.uniq
|
19
19
|
end
|
20
20
|
|
21
21
|
def tty(config)
|
22
|
-
info = Xlogin.list(*config[:pattern]).
|
23
|
-
|
24
|
-
|
22
|
+
info = Xlogin.list(*config[:pattern]).shift
|
23
|
+
puts "Trying #{info[:name]}...", "Escape character is '^]'."
|
25
24
|
session, _ = exec(config.merge(pattern: info[:name], jobs: 1))
|
26
25
|
session.interact!
|
27
26
|
end
|
@@ -44,14 +43,14 @@ module Xlogin
|
|
44
43
|
loggers << File.expand_path(File.join(config[:"log-dir"], "#{info[:name]}.log"), ENV['PWD']) if config[:"log-dir"]
|
45
44
|
|
46
45
|
session = Xlogin.get(info.merge(log: loggers))
|
47
|
-
session.enable(info[:enable]) if
|
46
|
+
session.enable(info[:enable]) if info[:enable] && Xlogin.settings.enable?
|
48
47
|
|
49
48
|
command_lines = ['', *config[:exec].to_s.split(';').map(&:strip)]
|
50
49
|
command_lines.each { |line| session.cmd(line) }
|
51
50
|
|
52
|
-
buffer.string.lines.each { |line|
|
51
|
+
buffer.string.lines.each { |line| print prefix + line.gsub("\r", '') } if jobs > 1
|
53
52
|
rescue => e
|
54
|
-
buffer.string.lines.each { |line|
|
53
|
+
buffer.string.lines.each { |line| print prefix + line.gsub("\r", '') } if jobs > 1
|
55
54
|
raise e
|
56
55
|
end
|
57
56
|
|
@@ -61,6 +60,7 @@ module Xlogin
|
|
61
60
|
|
62
61
|
def run(args)
|
63
62
|
config = Hash.new
|
63
|
+
config[:env] = {}
|
64
64
|
config[:runner] = self.method(:tty)
|
65
65
|
config[:inventory] = DEFAULT_INVENTORY_FILE
|
66
66
|
config[:template] = DEFAULT_TEMPLATE_DIR
|
@@ -69,23 +69,20 @@ module Xlogin
|
|
69
69
|
parser.banner = "#{File.basename($0)} HOST_PATTERN [Options]"
|
70
70
|
parser.version = Xlogin::VERSION
|
71
71
|
|
72
|
-
parser.on('-i PATH',
|
73
|
-
parser.on('-
|
74
|
-
parser.on('-L
|
72
|
+
parser.on('-i PATH', '--inventory', String, 'The PATH to the inventory file.')
|
73
|
+
parser.on('-t PATH', '--template', String, 'The PATH to the template file or directory.')
|
74
|
+
parser.on('-L PATH', '--log-dir', String, 'The PATH to the log directory.') { |v| v || '.' }
|
75
75
|
|
76
|
-
parser.on('-
|
77
|
-
parser.on('-
|
78
|
-
parser.on('-e COMMAND', '--exec', 'Execute commands and quit.') { |v| config[:runner] = self.method(:exec); v }
|
76
|
+
parser.on('-l', '--list', TrueClass, 'List the inventory.') { |v| config[:runner] = self.method(:list) }
|
77
|
+
parser.on('-e COMMAND', '--exec', String, 'Execute commands and quit.') { |v| config[:runner] = self.method(:exec); v }
|
79
78
|
|
80
|
-
parser.on('-
|
81
|
-
parser.on('-
|
82
|
-
parser.on('-y', '--assume-yes', TrueClass, 'Automatically answer yes to prompts.')
|
79
|
+
parser.on('-E KEY=VAL', '--env', /(\w+=\w+)+/, 'Environment variables.')
|
80
|
+
parser.on('-j NUM', '--jobs', Integer, 'The NUM of jobs to execute in parallel.')
|
83
81
|
|
84
|
-
parser.parse!(args, into: config)
|
85
|
-
config[:pattern] = args
|
82
|
+
config[:pattern] = parser.parse!(args, into: config)
|
86
83
|
|
87
84
|
Xlogin.configure do
|
88
|
-
set
|
85
|
+
set Hash[config[:env].map{ |v| v.split('=') }]
|
89
86
|
source File.expand_path(config[:inventory], ENV['PWD'])
|
90
87
|
template File.expand_path(config[:template], ENV['PWD'])
|
91
88
|
end
|
data/lib/xlogin/template.rb
CHANGED
data/lib/xlogin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xlogin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- haccht
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-telnet
|
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
195
|
requirements: []
|
196
|
-
rubygems_version: 3.0.
|
196
|
+
rubygems_version: 3.0.3
|
197
197
|
signing_key:
|
198
198
|
specification_version: 4
|
199
199
|
summary: rancid clogin alternative
|