Class: Expect4r::V
- Inherits:
-
BaseLoginObject
- Object
- Base
- BaseLoginObject
- Expect4r::V
- Includes:
- Expect4r, Router::Common, Router::Common::Modes, Router::Error, Router::Vyatta::Modes, Router::Vyatta::Ping, Router::Vyatta::Show
- Defined in:
- lib/router/vyatta/vyatta.rb
Instance Attribute Summary
Attributes inherited from BaseLoginObject
#host, #method, #port, #proxy, #ssh_options, #user
Class Method Summary collapse
-
.new_ssh(*args) ⇒ Object
v = V.new_ssh ‘hostname’.
-
.new_telnet(*args) ⇒ Object
v = V.new_telnet ‘hostname’.
Instance Method Summary collapse
- #commit(arg = {}) ⇒ Object
- #exit ⇒ Object
- #exit_discard ⇒ Object
-
#initialize(*args) ⇒ V
constructor
A new instance of V.
- #login(arg = {}) ⇒ Object (also: #_login_)
- #putline(line, arg = {}) ⇒ Object
- #top ⇒ Object
Methods included from Router::Vyatta::Show
Methods included from Router::Vyatta::Ping
Methods included from Router::Vyatta::Modes
#change_mode_to, #config, #config?, #exec, #exec?, #in?, #to_config, #to_exec
Methods included from Router::Common::Modes
#_mode_?, #change_mode_to, #in?
Methods included from Router::Common
Methods included from Expect4r
#_login, #child_exit, #connected?, #exp_print, #exp_puts, #exp_send, #expect, #get_prompt, #getc, #interact, #login_by_proxy, #logout, #putc, #putcr, #read_until, #readline, #spawn
Methods inherited from BaseLoginObject
add, #cmp, #connect_retry, #connect_retry=, #dup, #enable_password, #password, #spawnee, #spawnee_prompt, #spawnee_username
Methods inherited from Base
Constructor Details
#initialize(*args) ⇒ V
Returns a new instance of V.
30 31 32 33 |
# File 'lib/router/vyatta/vyatta.rb', line 30 def initialize(*args) super @ps1 = /([A-z\d]+)@([A-z\d]+)(:[^\$]+|)(#|\$) $/ end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Expect4r::Router::Vyatta::Show
Class Method Details
.new_ssh(*args) ⇒ Object
v = V.new_ssh ‘hostname’
21 22 23 24 25 26 27 |
# File 'lib/router/vyatta/vyatta.rb', line 21 def new_ssh(*args) if args.size==1 and args[0].is_a?(String) super :host=> args[0], :user=>'vyatta', :pwd=>'vyatta' else super end end |
.new_telnet(*args) ⇒ Object
v = V.new_telnet ‘hostname’
12 13 14 15 16 17 18 |
# File 'lib/router/vyatta/vyatta.rb', line 12 def new_telnet(*args) if args.size==1 and args[0].is_a?(String) super :host=> args[0], :user=>'vyatta', :pwd=>'vyatta' else super end end |
Instance Method Details
#commit(arg = {}) ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/router/vyatta/vyatta.rb', line 61 def commit(arg={}) return unless config? @matches << [/Exit with uncommitted changes.+\(yes\)/, 'yes'] output = putline "commit", arg if /error: configuration check-out failed/.match(output.join) rollack raise SemanticError.new(self.class.to_s, output) end output end |
#exit ⇒ Object
53 54 55 |
# File 'lib/router/vyatta/vyatta.rb', line 53 def exit putline 'exit' end |
#exit_discard ⇒ Object
57 58 59 |
# File 'lib/router/vyatta/vyatta.rb', line 57 def exit_discard putline 'exit discard' end |
#login(arg = {}) ⇒ Object Also known as: _login_
35 36 37 38 39 40 |
# File 'lib/router/vyatta/vyatta.rb', line 35 def login(arg={}) super(spawnee, arg) putline "terminal length 0" putline "terminal width 0" self end |
#putline(line, arg = {}) ⇒ Object
43 44 45 46 47 |
# File 'lib/router/vyatta/vyatta.rb', line 43 def putline(line,arg={}) o, rc = super raise SyntaxError.new(self.class.to_s, line) if o.join =~ /(% unknown|Invalid command)/ o end |
#top ⇒ Object
49 50 51 |
# File 'lib/router/vyatta/vyatta.rb', line 49 def top putline 'top' end |