mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-09-13 16:39:48 +02:00
fixes #1008 dry run on PIX
This commit is contained in:
+18
-27
@@ -124,15 +124,12 @@ SSHCisco::~SSHCisco()
|
|||||||
QString SSHCisco::cmd(QProcess *proc,const QString &cmd)
|
QString SSHCisco::cmd(QProcess *proc,const QString &cmd)
|
||||||
{
|
{
|
||||||
if (fwbdebug) qDebug("Command '%s'", cmd.toAscii().constData());
|
if (fwbdebug) qDebug("Command '%s'", cmd.toAscii().constData());
|
||||||
stdoutBuffer="";
|
sendCommand(cmd);
|
||||||
|
//stdoutBuffer = "";
|
||||||
proc->write( (cmd + "\n").toAscii() );
|
//proc->write( (cmd + "\n").toAscii() );
|
||||||
state = EXECUTING_COMMAND;
|
state = EXECUTING_COMMAND;
|
||||||
local_event_loop->exec();
|
local_event_loop->exec();
|
||||||
//qApp->processEvents();
|
|
||||||
|
|
||||||
if (fwbdebug) qDebug("Command '%s' completed", cmd.toAscii().constData());
|
if (fwbdebug) qDebug("Command '%s' completed", cmd.toAscii().constData());
|
||||||
|
|
||||||
return stdoutBuffer;
|
return stdoutBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,7 +296,8 @@ void SSHCisco::stateMachine()
|
|||||||
QString cmd = pre_config_commands.front();
|
QString cmd = pre_config_commands.front();
|
||||||
pre_config_commands.pop_front();
|
pre_config_commands.pop_front();
|
||||||
if (cmd.indexOf("reload in")!=-1) state = SCHEDULE_RELOAD_DIALOG;
|
if (cmd.indexOf("reload in")!=-1) state = SCHEDULE_RELOAD_DIALOG;
|
||||||
proc->write( (cmd + "\n").toAscii() );
|
sendCommand(cmd);
|
||||||
|
//proc->write( (cmd + "\n").toAscii() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,7 +318,6 @@ void SSHCisco::stateMachine()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//proc->write( "config t\n" ); now part of configlet installer_commands_reg_user
|
|
||||||
state = WAITING_FOR_CONFIG_PROMPT;
|
state = WAITING_FOR_CONFIG_PROMPT;
|
||||||
// kick it so we get some output from the router and
|
// kick it so we get some output from the router and
|
||||||
// continue the state machine
|
// continue the state machine
|
||||||
@@ -349,6 +346,14 @@ void SSHCisco::stateMachine()
|
|||||||
state = ENABLE;
|
state = ENABLE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if ( cmpPrompt(stdoutBuffer, QRegExp(enable_prompt)) )
|
||||||
|
{
|
||||||
|
// reload did not ask for confirmation
|
||||||
|
stdoutBuffer="";
|
||||||
|
proc->write( "\n" );
|
||||||
|
state = ENABLE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EXECUTING_COMMAND:
|
case EXECUTING_COMMAND:
|
||||||
@@ -402,23 +407,14 @@ void SSHCisco::stateMachine()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dry_run)
|
sendCommand(s);
|
||||||
{
|
|
||||||
if ( !s.isEmpty()) ncmd++;
|
|
||||||
stdoutBuffer="";
|
|
||||||
proc->write( (s+"\n").toAscii() ); // send even if s is empty
|
|
||||||
break;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
emit printStdout_sign( s+"\n" );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
/* activation_commands.size()==0 */
|
/* activation_commands.size()==0 */
|
||||||
state = EXIT_FROM_CONFIG;
|
state = EXIT_FROM_CONFIG;
|
||||||
emit printStdout_sign( tr("End") + "\n" );
|
emit printStdout_sign( tr("End") + "\n" );
|
||||||
//proc->write( "exit\n" ); now part of the configlet
|
|
||||||
// kick it so we get some output from the router and
|
// kick it so we get some output from the router and
|
||||||
// continue the state machine
|
// continue the state machine
|
||||||
proc->write("\n");
|
proc->write("\n");
|
||||||
@@ -430,19 +426,14 @@ void SSHCisco::stateMachine()
|
|||||||
if ( cmpPrompt(stdoutBuffer,QRegExp(enable_prompt)) )
|
if ( cmpPrompt(stdoutBuffer,QRegExp(enable_prompt)) )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* NOTE: at this point we are still in the config mode!
|
* Execute post_config_commands
|
||||||
*
|
|
||||||
* Execute post_config_commands and exit from config mode.
|
|
||||||
*/
|
*/
|
||||||
if (post_config_commands.size()>0)
|
if (post_config_commands.size()>0)
|
||||||
{
|
{
|
||||||
stdoutBuffer="";
|
stdoutBuffer = "";
|
||||||
|
|
||||||
QString cmd = post_config_commands.front();
|
QString cmd = post_config_commands.front();
|
||||||
post_config_commands.pop_front();
|
post_config_commands.pop_front();
|
||||||
|
sendCommand(cmd);
|
||||||
proc->write( (cmd + "\n").toAscii() );
|
|
||||||
//proc->write( "\n" );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -78,7 +78,7 @@ void SSHPIX::stateMachine()
|
|||||||
QString cmd = pre_config_commands.front();
|
QString cmd = pre_config_commands.front();
|
||||||
pre_config_commands.pop_front();
|
pre_config_commands.pop_front();
|
||||||
if (cmd.indexOf("reload in")!=-1) state = SCHEDULE_RELOAD_DIALOG;
|
if (cmd.indexOf("reload in")!=-1) state = SCHEDULE_RELOAD_DIALOG;
|
||||||
proc->write( (cmd + "\n").toAscii() );
|
sendCommand(cmd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +99,6 @@ void SSHPIX::stateMachine()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//proc->write( "config t\n" ); now part of configlet installer_commands_reg_user
|
|
||||||
state = WAITING_FOR_CONFIG_PROMPT;
|
state = WAITING_FOR_CONFIG_PROMPT;
|
||||||
// kick it so we get some output from the router and
|
// kick it so we get some output from the router and
|
||||||
// continue the state machine
|
// continue the state machine
|
||||||
|
|||||||
@@ -615,4 +615,17 @@ bool SSHSession::cmpPrompt(const QString &str,const QRegExp &prompt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SSHSession::sendCommand(const QString &cmd)
|
||||||
|
{
|
||||||
|
stdoutBuffer = "";
|
||||||
|
if (!dry_run)
|
||||||
|
{
|
||||||
|
proc->write((cmd + "\n").toAscii());
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
emit printStdout_sign(QString("[DRY RUN] %1\n").arg(cmd));
|
||||||
|
proc->write("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -158,6 +158,10 @@ class SSHSession : public QObject {
|
|||||||
void startHeartBeat();
|
void startHeartBeat();
|
||||||
void stopHeartBeat();
|
void stopHeartBeat();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
void sendCommand(const QString &cmd);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SSHSession(QWidget *parent,
|
SSHSession(QWidget *parent,
|
||||||
|
|||||||
Reference in New Issue
Block a user