xlogin 0.2.1 → 0.2.2

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
  SHA1:
3
- metadata.gz: 220f187297c3702d3cac89b41988734724bd3ecf
4
- data.tar.gz: 69c3556b40c2e4955500c3a9e45964ab7630304a
3
+ metadata.gz: 66ed84e83f0210fe7afb90cd49eb82e154c283a4
4
+ data.tar.gz: 4fe09e46fdfffbae74ea20c06052787422f4255b
5
5
  SHA512:
6
- metadata.gz: 5fcffdf0cb88156bc6ec2d4650d8916e73702a4ec50a3059204ea533a555bcd83c186d8050250fada1cf3539cac614bdb46ebe4b2e1e01826044424784ef3e5a
7
- data.tar.gz: 380fd408f3d51148e3fa455b4d4078d8a92c4df6b7143991a4fe21a0a9b38be9f4ba90b56cac7f4deb156e10ad0c1ac1f15d8ff67ccb0fe858491085cc2249ca
6
+ metadata.gz: 8f94c7c38965d65bcb02d958d243d50b9dbe9c725b5309e2fe5e7176f2bcca260cb7d349e4f1033bc7b4254453b3c4b2ed60c5b535f8bdab0843d390d1e149f7
7
+ data.tar.gz: 6b28b13d079ed877dc88d3ff64b63576af85a5d13250a49373adb3f9593a487a22aad7cf5f719d0edf2ff41ff08118812d034db86797880aa45639285b07fac4
data/bin/cmd_exec CHANGED
@@ -40,18 +40,19 @@ module Xlogin
40
40
  options = Hash.new
41
41
 
42
42
  opt = OptionParser.new
43
- opt.on('-e', '--enable', 'Try to gain enable priviledge.') { |v| options[:e] = v }
44
- opt.on('-l', '--log', 'Enable logging.') { |v| options[:l] = v }
45
- opt.on('-H', 'Display hostnames for each response.') { |v| options[:H] = v }
43
+ opt.on('-F', '--force', 'Automatically reply "yes" if confirmed.') { |v| options[:F] = v }
44
+ opt.on('-e', '--enable', 'Try to gain enable priviledge.') { |v| options[:e] = v }
45
+ opt.on('-l', '--log', 'Enable logging.') { |v| options[:l] = v }
46
+ opt.on('-H', 'Display hostnames for each response.') { |v| options[:H] = v }
46
47
 
47
- opt.on('-f FILE', 'Read target hostnames from FILE.') { |v| options[:f] = v }
48
- opt.on('-r FILE', 'Load extention library.') { |v| options[:r] = v }
48
+ opt.on('-f FILE', 'Read target hostnames from FILE.') { |v| options[:f] = v }
49
+ opt.on('-r FILE', 'Load extention library.') { |v| options[:r] = v }
49
50
 
50
- opt.on('-x VALUE', 'Read commands from VALUE.') { |v| options[:x] = v }
51
- opt.on('-c VALUE') { |v| options[:c] = v }
51
+ opt.on('-x VALUE', 'Read commands from VALUE.') { |v| options[:x] = v }
52
+ opt.on('-c VALUE') { |v| options[:c] = v }
52
53
 
53
- opt.on('-p VALUE', 'Specify concurrency pool size.') { |v| options[:p] = v }
54
- opt.on('-i VALUE', 'Specify interval time [sec].') { |v| options[:i] = v }
54
+ opt.on('-p VALUE', 'Specify concurrency pool size.') { |v| options[:p] = v }
55
+ opt.on('-i VALUE', 'Specify interval time [sec].') { |v| options[:i] = v }
55
56
 
56
57
  opt.banner += ' HOST...'
57
58
  opt.summary_width = 16
@@ -91,12 +92,13 @@ module Xlogin
91
92
  pool.run do
92
93
  begin
93
94
  resp = StringIO.new
94
-
95
+ force = options[:F] || false
95
96
  loggers = []
96
97
  loggers << $stdout unless size > 1
97
98
  loggers << (URI.regexp =~ node ? URI(node).host : node) + ".log" if options[:l]
98
99
 
99
- session = Xlogin.get(node, log: loggers)
100
+
101
+ session = Xlogin.get(node, force: force, log: loggers)
100
102
  session.enable if options[:e] && session.respond_to?(:enable)
101
103
 
102
104
  if options[:x]
@@ -6,7 +6,7 @@ module Xlogin
6
6
 
7
7
  def initialize
8
8
  @timeout = 5
9
- @on_exec = nil
9
+ @on_exec = nil
10
10
  @prompts = Array.new
11
11
  @methods = Hash.new
12
12
  end
@@ -68,7 +68,7 @@ module Xlogin
68
68
 
69
69
  klass.new(
70
70
  {
71
- node: uri.host,
71
+ host: uri.host,
72
72
  port: uri.port,
73
73
  userinfo: uri.userinfo,
74
74
  timeout: @timeout,
@@ -46,28 +46,28 @@ module Xlogin
46
46
  instance_eval(content)
47
47
  end
48
48
 
49
- def set(type, name, uri, opts = {})
50
- @database[name] = { name: name, type: type, uri: uri, opts: opts }
51
- end
52
-
53
49
  def get(name)
54
50
  @database[name]
55
51
  end
56
52
 
53
+ def set(type, name, uri, opts = {})
54
+ @database[name] = { name: name, type: type, uri: uri, opts: opts }
55
+ end
56
+
57
57
  def list
58
58
  @database.map { |nodename, args| args.merge(name: nodename) }
59
59
  end
60
60
 
61
- def build(item, args = {})
62
- item = item.kind_of?(Hash) ? item : @database[item]
63
- item_uri = item[:uri]
64
- firmware = Xlogin::FirmwareFactory[item[:type]]
65
- raise Xlogin::GeneralError.new("Invalid target - #{nodename}") unless item && item_uri && firmware
61
+ def build(name, args = {})
62
+ item = item.kind_of?(Hash) ? name : @database[name]
63
+ item_uri = item[:uri] if item
64
+ firmware = Xlogin::FirmwareFactory[item[:type]] if item
65
+ raise Xlogin::GeneralError.new("Hostname '#{name}' not found ") unless item && item_uri && firmware
66
66
 
67
67
  opts = item[:opts] || {}
68
68
  opts = opts.merge(args).reduce({}) { |a, (k, v)| a.merge(k.to_s.downcase.to_sym => v) }
69
69
 
70
- session = firmware.run(item_uri, opts)
70
+ session = firmware.dup.run(item_uri, opts)
71
71
  session.name = item[:name]
72
72
  session
73
73
  end
@@ -21,8 +21,8 @@ module Xlogin
21
21
  port: gateway.port || 22
22
22
  )
23
23
 
24
- @port = @gateway.open(@node, @port)
25
- @node = '127.0.0.1'
24
+ @port = @gateway.open(@host, @port)
25
+ @host = '127.0.0.1'
26
26
  end
27
27
  end
28
28
  end
@@ -19,9 +19,6 @@ module Xlogin
19
19
  current_namespace do
20
20
  description = Rake.application.last_description || "Run '#{RakeTask.current_namespace}'"
21
21
 
22
- desc description
23
- task all: names
24
-
25
22
  names.each do |name|
26
23
  desc "#{description} (#{name})"
27
24
  RakeTask.new(name, &block)
@@ -108,15 +105,6 @@ module Xlogin
108
105
  run_task
109
106
  end
110
107
  end
111
-
112
- [logfile, lockfile].each do |file|
113
- next unless file
114
-
115
- desc 'Remove any temporary products'
116
- task 'clean' do
117
- rm(file, verbose: true) if File.exist?(file)
118
- end
119
- end
120
108
  end
121
109
  end
122
110
 
@@ -3,19 +3,20 @@ require 'stringio'
3
3
  module Xlogin
4
4
  module Session
5
5
 
6
+ attr_reader :opts
6
7
  attr_accessor :name
7
8
 
8
9
  def configure_session(**opts)
9
- @name = opts[:node]
10
- @node = opts[:node]
11
- @port = opts[:port]
12
- @userinfo = opts[:userinfo].to_s.split(':')
13
- raise Xlogin::GeneralError.new('Argument error.') unless @node && @port
10
+ @opts = opts.dup
11
+ @host = @name = @opts.delete(:host)
12
+ @port = @opts.delete(:port)
13
+ @userinfo = @opts.delete(:userinfo).to_s.split(':')
14
+ raise Xlogin::GeneralError.new('Argument error.') unless @host && @port
14
15
 
15
- @prompts = opts[:prompts] || [[/[$%#>] ?\z/n, nil]]
16
- @timeout = opts[:timeout] || 60
16
+ @prompts = @opts.delete(:prompts) || [[/[$%#>] ?\z/n, nil]]
17
+ @timeout = @opts.delete(:timeout) || 60
17
18
 
18
- @loglist = [opts[:log]].flatten.compact
19
+ @loglist = [@opts.delete(:log)].flatten.compact
19
20
  @logger = update_logger
20
21
  end
21
22
 
data/lib/xlogin/ssh.rb CHANGED
@@ -12,7 +12,7 @@ module Xlogin
12
12
  username, password = *@userinfo
13
13
 
14
14
  @ssh = Net::SSH.start(
15
- @node,
15
+ @host,
16
16
  username,
17
17
  :port => @port,
18
18
  :timeout => @timeout,
data/lib/xlogin/telnet.rb CHANGED
@@ -11,7 +11,7 @@ module Xlogin
11
11
  configure_session(opts.merge(port: opts[:port] || 23))
12
12
 
13
13
  super(
14
- 'Host' => @node,
14
+ 'Host' => @host,
15
15
  'Port' => @port,
16
16
  'Timeout' => @timeout,
17
17
  'Prompt' => Regexp.union(*@prompts.map(&:first))
@@ -1,3 +1,3 @@
1
1
  module Xlogin
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  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.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - haccht
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-01 00:00:00.000000000 Z
11
+ date: 2017-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler