def connect(switch): """Connect to the switch and log in. Login using public key is untested on this switch. """ console = _console.login(switch) # send a new line so that we can "expect" a prompt again if we already # matched when logged in using pubkey console.sendline('') prompts = _console.get_prompts(console) # create the dummy vlan for port_revert # this is a one time thing though; maybe we could remove this and let # the admin create the dummy vlan on the switch console.sendline('config') console.expect(prompts['config_prompt']) console.sendline('vlan ' + switch.dummy_vlan) console.sendline('exit') console.sendline('exit') console.expect(prompts['main_prompt']) return _DellN3000Session(switch=switch, dummy_vlan=switch.dummy_vlan, console=console, **prompts)
def connect(switch): # connect to the switch, and log in: console = pexpect.spawn('telnet ' + switch.hostname) console.expect('User:'******'Password:'******'>') console.sendline('en') logger.debug('Logged in to switch %r', switch) prompts = _console.get_prompts(console) # create the dummy vlan for port_revert # this is a one time thing though; maybe we could remove this and let # the admin create the dummy vlan on the switch console.sendline('config') console.expect(prompts['config_prompt']) console.sendline('vlan ' + switch.dummy_vlan) console.sendline('exit') console.sendline('exit') console.expect(prompts['main_prompt']) return _DellN3000Session(switch=switch, dummy_vlan=switch.dummy_vlan, console=console, **prompts)
def connect(switch): console = pexpect.spawn('telnet ' + switch.hostname) console.expect('login: '******'Password: ') console.sendline(switch.password) prompts = _console.get_prompts(console) return _Session(console=console, dummy_vlan=switch.dummy_vlan, switch=switch, **prompts)
def connect(switch): """Connect to the switch.""" console = _console.login(switch) # send a new line so that we can "expect" a prompt again if we already # matched when logged in using pubkey console.sendline('') prompts = _console.get_prompts(console) return _Session(console=console, dummy_vlan=switch.dummy_vlan, switch=switch, **prompts)
def connect(switch): # connect to the switch, and log in: console = pexpect.spawn('telnet ' + switch.hostname) console.expect('User Name:') console.sendline(switch.username) console.expect('Password:'******'Logged in to switch %r', switch) prompts = _console.get_prompts(console) return _PowerConnect55xxSession(switch=switch, console=console, **prompts)
def connect(switch): """Connect to the switch.""" console = pexpect.spawn( 'ssh ' + switch.username + '@' + switch.hostname) console.expect('Password: ') console.sendline(switch.password) prompts = _console.get_prompts(console) return _Session(console=console, dummy_vlan=switch.dummy_vlan, switch=switch, **prompts)
def connect(switch): """connect to the switch, and log in.""" console = _console.login(switch) # Send some string, so we expect the prompt again. Sending only new a # line doesn't work, it returns some unwanted ANSI sequences in # console.after # Eg; main_prompts looks like '\r\n\r\r\x1b[Kconsole#' # Here \x1b[K is unwanted and causes trouble parsing it. # Sending some other random string doesn't have this issue. console.sendline('some-unrecognized-command') prompts = _console.get_prompts(console) return _PowerConnect55xxSession(switch=switch, console=console, **prompts)
def connect(switch): """connect to the switch, and log in.""" console = pexpect.spawn('ssh ' + switch.username + '@' + switch.hostname) # dell switch gets user name for the second time console.expect('User Name:') console.sendline(switch.username) console.expect('Password:'******'Logged in to switch %r', switch) prompts = _console.get_prompts(console) return _PowerConnect55xxSession(switch=switch, console=console, **prompts)