Class: Expect4r::J
Instance Attribute Summary
#host, #method, #port, #proxy, #ssh_options, #user
Instance Method Summary
collapse
#ping
#method_missing, #show
#clear_cli_logical_router, #config, #config?, #exec, #exec?, #set_cli_logical_router, #shell, #shell?
#_mode_?, #change_mode_to, #in?
#io_escape_char_cb
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
add, #cmp, #connect_retry, #connect_retry=, #dup, #enable_password, new_ssh, new_telnet, #password, #spawnee, #spawnee_prompt, #spawnee_username
Methods inherited from Base
add, all
Constructor Details
#initialize(*args) ⇒ J
Returns a new instance of J.
10
11
12
13
14
|
# File 'lib/router/juniper/junos/junos.rb', line 10
def initialize(*args)
super
@ps1 = /(^|\r\r)([-a-zA-z@_~=\.\(\)\d]+(>|\#|%)|%|\$) $/
@more = /---\(more(| \d+\%)\)---/
end
|
Instance Method Details
#cli ⇒ Object
50
51
52
|
# File 'lib/router/juniper/junos/junos.rb', line 50
def cli
putline 'cli'
end
|
#commit(arg = {}) ⇒ Object
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/router/juniper/junos/junos.rb', line 54
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)
rollback
raise SemanticError.new(self.class.to_s, output)
end
output
end
|
#console? ⇒ Boolean
26
27
28
|
# File 'lib/router/juniper/junos/junos.rb', line 26
def console?
@port>0
end
|
#exit ⇒ Object
46
47
48
|
# File 'lib/router/juniper/junos/junos.rb', line 46
def exit
putline 'exit'
end
|
#login(arg = {}) ⇒ Object
Also known as:
_login_
16
17
18
19
20
|
# File 'lib/router/juniper/junos/junos.rb', line 16
def login(arg={})
super(spawnee, arg)
exec 'set cli screen-length 0'
self
end
|
#putline(line, arg = {}) ⇒ Object
30
31
32
33
34
|
# File 'lib/router/juniper/junos/junos.rb', line 30
def putline(line,arg={})
o, rc = super
raise SyntaxError.new(self.class.to_s, line) if o.join =~ /(unknown command|syntax error)/
o
end
|
#rollback ⇒ Object
36
37
38
39
40
|
# File 'lib/router/juniper/junos/junos.rb', line 36
def rollback
return unless config?
top
putline 'rollback'
end
|
#top ⇒ Object
42
43
44
|
# File 'lib/router/juniper/junos/junos.rb', line 42
def top
putline 'top'
end
|