/**
* Establish a SSH connection to the switch if necessary
*
* @throws ConnectionException If the connection fails
*/
protected function connect()
{
if (false == $this->ssh instanceof SSH2) {
$this->ssh = new SSH2($this->ip);
$this->ssh->setWindowSize($this->terminalColumn, $this->terminalLine);
if (false == @$this->ssh->login($this->user, $this->password)) {
throw new ConnectionException(sprintf("Connection to %s with user %s failed", $this->ip, $this->user));
}
$this->ssh->read('continue');
$this->ssh->write($this->enterKey);
$this->ssh->read('`' . $this->promptPattern . '`', SSH2::READ_REGEX);
}
}