Esempio n. 1
0
func (j *JnprIOProc) StartNetconf(t *netconf.TransportTelnet) error {
	switch j.cliMode {
	case CLIModeShell:
		t.Writeln([]byte(netconfCMDShell))
		return nil
	case CLIModeCLI:
		t.Writeln([]byte(netconfCMDCLI))
		return nil
	}
	return fmt.Errorf("Cannot start netconf: Unknown CLI mode '%d'", j.cliMode)
}
Esempio n. 2
0
func (j *JnprIOProc) StartNetconf(t *netconf.TransportTelnet) error {
	switch j.cliMode {
	case CLI_MODE_SHELL:
		t.Writeln([]byte(NETCONF_CMD_SHELL))
		return nil
	case CLI_MODE_CLI:
		t.Writeln([]byte(NETCONF_CMD_CLI))
		return nil
	}
	return fmt.Errorf("Cannot start netconf: Unknown CLI mode '%s'", j.cliMode)
}
Esempio n. 3
0
func (j *JnprIOProc) Login(t *netconf.TransportTelnet, username string, password string) error {
	t.WaitForString("ogin:")
	t.Writeln([]byte(username))

	t.WaitForString("assword:")
	t.Writeln([]byte(password))

	_, prompt, err := t.WaitForRegexp(promptRE)
	if err != nil {
		return err
	}

	switch string(prompt[0]) {
	case ">":
		j.cliMode = CLIModeCLI
	case "%":
		j.cliMode = CLIModeShell
	default:
		return fmt.Errorf("Cannot determine prompt '%s'", prompt[0])
	}
	return nil
}