xlogin 0.11.6 → 0.11.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 65379601a175fd8c600a374e312c4a03bb5ffeba056bab55f4b68414319c3507
4
- data.tar.gz: 70ee6c3eabc2bd6d982d0e583b3402156dad0651ae8c4932c7608b9b93af188f
3
+ metadata.gz: 6fb6b0b2b1b8ca4e21cabb2b4888092cf2d0858da9a69aa050c77a97b7a018f7
4
+ data.tar.gz: e30fe43223d680c1c7ca1c404a60cffceb5748832ada7db4b30d5e49a5a47267
5
5
  SHA512:
6
- metadata.gz: 40e15b65f6890bd6721260fafaacc0194b7f737c5a0377ad7d08a59fcb068be90896db242d333f67eea9cb05d7f1e1319a741ee9f6243ac351b221b1123c6c3e
7
- data.tar.gz: a3ada3ee5ff44393fec79e87da1746d09b608ac6428700a6bf4530f27e76107cc612e098a7b8c890c648e64a42b4f7445ca334acf907937fd1de4ef3a0955ae3
6
+ metadata.gz: 68cf84fc489f32734d16dec2e99e7760a976cbed54846dacd1ba9131aa717c8f864b63f3f5174a4a7495caa26f881625f9da4ffb5e2ec3fc5b461eb1f960c8bc
7
+ data.tar.gz: 79654b10f48a5e02254adc9b394f8a456ea32af5aef6575972e2749ced574011c3f5dbfd4aa4f213646f77b2548274c79e5ee9f98301c04530f383f83bc448b4
data/README.md CHANGED
@@ -1,34 +1,63 @@
1
1
  # xlogin
2
- rancid clogin alternative.
2
+
3
+ rancid clogin alternative.
4
+ xlogin is a tool to login devices and execute series of tasks.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'xlogin'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install xlogin
3
21
 
4
22
  ## Usage
5
23
 
6
- ネットワークデバイスへのログイン処理を自動化するツール群。  
7
- `~/.xlogin.d/`にファームウェア毎のログイン仕様(template)を記述することで自働化対象機器を任意に設定可能。
8
- templateの記述例は[lib/xlogin/templates](https://github.com/haccht/xlogin/tree/master/lib/xlogin/templates)を参照のこと。
24
+ Write a template file that describe how to login to the specific type of device, and store it to `~/.xlogin.d/`.
25
+ Take vyos as an example, template file would be:
9
26
 
10
- 各個別装置毎のログインのための認証情報は`~/.xloginrc`へ記述する。  
11
- `.xloginrc`のフォーマットはDSL形式で下記の通り。
27
+ ```ruby
28
+ prompt(/[$#] (?:\e\[K)?\z/n)
12
29
 
13
- ~~~
14
- #hosttype hostname telnet_uri_scheme options
30
+ login do |username, password|
31
+ waitfor(/login:\s/) && puts(username)
32
+ waitfor(/Password:\s/) && puts(password)
33
+ waitfor
34
+ end
35
+ ```
36
+
37
+ Some other example are in [lib/xlogin/templates](https://github.com/haccht/xlogin/tree/master/lib/xlogin/templates).
38
+
39
+ Beside template files, you need to prepare an inventory file `~/.xloginrc`.
40
+ In this file, you need to write all information required to login each device.
41
+
42
+ ```
43
+ #hosttype hostname uri scheme
15
44
  vyos 'vyos01', 'telnet://vagrant:vagrant@127.0.0.1:2200'
16
45
  vyos 'vyos02', 'telnet://vagrant:vagrant@127.0.0.1:2201'
17
- ~~~
46
+ ```
18
47
 
19
- 下記コマンドでvyos01へ自動ログインし、プロンプトをユーザに渡す。
48
+ Now you can login any device in your `.xloginrc` file with a command:
20
49
 
21
- ~~~sh
22
- xlogin vyos01
23
- ~~~
50
+ ```sh
51
+ $ xlogin vyos01
52
+ ```
24
53
 
25
- また下記コマンドでvyos01,vyos02へ同時に自動ログインし、コマンドを一括投入する。
54
+ And execute multiple operations with just a single command:
26
55
 
27
56
  ~~~sh
28
- xlogin 'vyos*' -e 'show configuration command | no-more; exit' -j 2
57
+ $ xlogin 'vyos*' -e 'show configuration command | no-more; exit' -j 2
29
58
  ~~~
30
59
 
31
- その他のオプションは下記の通り。
60
+ Some other commandline options are:
32
61
 
33
62
  ~~~sh
34
63
  $ xlogin -h
@@ -40,28 +69,11 @@ xlogin HOST_PATTERN [Options]
40
69
  -l, --list List all available devices.
41
70
  -e, --exec Execute commands and quit.
42
71
  -t, --tty Allocate a pseudo-tty.
43
- -p, --port NUM Run as server on specified port(default: 8080).
44
72
  -j, --jobs NUM The NUM of jobs to execute in parallel(default: 1).
45
73
  -E, --enable Try to gain enable priviledge.
46
- -y, --assume-yes Automatically answer yes to prompts.
74
+ -y, --assume-yes Automatically answer yes to any confirmation prompts.
47
75
  ~~~
48
76
 
49
- ## Installation
50
-
51
- Add this line to your application's Gemfile:
52
-
53
- ```ruby
54
- gem 'xlogin'
55
- ```
56
-
57
- And then execute:
58
-
59
- $ bundle
60
-
61
- Or install it yourself as:
62
-
63
- $ gem install xlogin
64
-
65
77
  ## Development
66
78
 
67
79
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,5 +1,6 @@
1
1
  $:.unshift File.dirname(__FILE__)
2
2
 
3
+ require 'net/http'
3
4
  require 'xlogin/factory'
4
5
  require 'xlogin/version'
5
6
 
@@ -58,7 +59,7 @@ module Xlogin
58
59
 
59
60
  def source(*source_files, &block)
60
61
  return source_file(*source_files) unless block
61
- factory.instance_eval(&block) unless source_files.empty?
62
+ factory.instance_eval(&block) if source_files.empty?
62
63
  end
63
64
 
64
65
  def source_file(*source_files)
@@ -69,17 +70,33 @@ module Xlogin
69
70
  end
70
71
 
71
72
  def template(name, *args, &block)
72
- return template_dir(name, *args) unless block
73
+ unless block
74
+ return template_url(name, *args) if name =~ URI.regexp(['http', 'https'])
75
+ return template_dir(name, *args)
76
+ end
73
77
 
74
78
  raise ArgumentError.new('missing template name') unless name
75
79
  factory.set_template(name, &block)
76
80
  end
77
81
 
82
+ def template_url(*template_urls)
83
+ template_urls.compact.each do |url|
84
+ uri = URI(url.to_s)
85
+ name = File.basename(uri.path, '.rb').scan(/\w+/).join('_')
86
+ text = Net::HTTP.get(uri)
87
+ if text =~ /\w+.rb$/
88
+ uri.path = File.join(File.dirname(uri.path), text.lines.first.chomp)
89
+ text = Net::HTTP.get(uri)
90
+ end
91
+ factory.set_template(name, text)
92
+ end
93
+ end
94
+
78
95
  def template_file(*template_files)
79
96
  template_files.compact.each do |file|
80
97
  raise TemplateError.new("Template file not found: #{file}") unless File.exist?(file)
81
98
  name = File.basename(file, '.rb').scan(/\w+/).join('_')
82
- factory.set_template(name, IO.read(file)) if File.exist?(file)
99
+ factory.set_template(name, IO.read(file))
83
100
  end
84
101
  end
85
102
 
@@ -1,3 +1,3 @@
1
1
  module Xlogin
2
- VERSION = "0.11.6"
2
+ VERSION = "0.11.7"
3
3
  end
@@ -37,6 +37,6 @@ Gem::Specification.new do |spec|
37
37
  spec.add_dependency "parallel"
38
38
  spec.add_dependency "addressable"
39
39
 
40
- spec.add_development_dependency "bundler", "~> 1.13"
41
- spec.add_development_dependency "rake", "~> 10.0"
40
+ spec.add_development_dependency "bundler"
41
+ spec.add_development_dependency "rake"
42
42
  end
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.11.6
4
+ version: 0.11.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - haccht
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-28 00:00:00.000000000 Z
11
+ date: 2019-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-telnet
@@ -98,30 +98,30 @@ dependencies:
98
98
  name: bundler
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: '1.13'
103
+ version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: '1.13'
110
+ version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rake
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: '10.0'
117
+ version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: '10.0'
124
+ version: '0'
125
125
  description: login to any devices with ease.
126
126
  email:
127
127
  - haccht@users.noreply.github.com