Skip to content

Commit

Permalink
yarpmanager: in ClusterWidget run-stop-kill now takes the entry of th…
Browse files Browse the repository at this point in the history
…e QlineEdit + various enhancements
  • Loading branch information
Nicogene authored and drdanz committed Oct 2, 2017
1 parent 04baf1a commit e718556
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 11 deletions.
65 changes: 54 additions & 11 deletions src/yarpmanager/src-manager/clusterWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ void ClusterWidget::onCheckServer()

void ClusterWidget::onRunServer()
{
updateServerEntries();

string cmdRunServer = getSSHCmd(cluster.user, cluster.nsNode, cluster.ssh_options);
if (ui->checkRos->isChecked())
{
Expand All @@ -143,26 +145,27 @@ void ClusterWidget::onRunServer()
}
if (system(cmdRunServer.c_str()) != 0)
{
std::string err = "ClusterWidget: failed to run the server on" + cluster.nsNode;
std::string err = "ClusterWidget: failed to run the server on " + cluster.nsNode;
logError(QString(err.c_str()));
}
else
{
yarp::os::Time::delay(1.0);
onCheckServer();
}

}

void ClusterWidget::onStopServer()
{
updateServerEntries();

string cmdStopServer = getSSHCmd(cluster.user, cluster.nsNode, cluster.ssh_options);

cmdStopServer = cmdStopServer + " killall yarpserver";
cmdStopServer = cmdStopServer + " killall yarpserver &";

if (system(cmdStopServer.c_str()) != 0)
{
std::string err = "ClusterWidget: failed to stop the server on" + cluster.nsNode;
std::string err = "ClusterWidget: failed to stop the server on " + cluster.nsNode;
logError(QString(err.c_str()));
}
else
Expand All @@ -176,19 +179,31 @@ void ClusterWidget::onStopServer()
{
onKillServer();
}
else
{
std::string info = "ClusterWidget: yarpserver successfully stopped on "+ cluster.nsNode;
logMessage(QString(info.c_str()));
}
}

void ClusterWidget::onKillServer()
{
updateServerEntries();

string cmdKillServer = getSSHCmd(cluster.user, cluster.nsNode, cluster.ssh_options);

cmdKillServer = cmdKillServer + " killall -9 yarpserver";
cmdKillServer = cmdKillServer + " killall -9 yarpserver &";

if (system(cmdKillServer.c_str()) != 0)
{
std::string err = "ClusterWidget: failed to kill the server on" + cluster.nsNode;
std::string err = "ClusterWidget: failed to kill the server on " + cluster.nsNode;
logError(QString(err.c_str()));
}
else
{
std::string info = "ClusterWidget: yarpserver successfully killed on "+ cluster.nsNode;
logMessage(QString(info.c_str()));
}


}
Expand Down Expand Up @@ -233,9 +248,14 @@ void ClusterWidget::onRunSelected()
}
if (system(cmdRunYarprun.c_str()) != 0)
{
std::string err = "ClusterWidget: failed to run yarprun on" + node.name;
std::string err = "ClusterWidget: failed to run yarprun on " + node.name;
logError(QString(err.c_str()));
}
else
{
std::string info = "ClusterWidget: yarprun successfully executed on "+ node.name;
logMessage(QString(info.c_str()));
}
}

yarp::os::Time::delay(2.0);
Expand All @@ -262,13 +282,18 @@ void ClusterWidget::onStopSelected()

string cmdStopYarprun = getSSHCmd(node.user, node.name, node.ssh_options);

cmdStopYarprun = cmdStopYarprun + " yarprun --exit --on "+ portName;
cmdStopYarprun = cmdStopYarprun + " yarprun --exit --on "+ portName + " &";

if (system(cmdStopYarprun.c_str()) != 0)
{
std::string err = "ClusterWidget: failed to stop yarprun on" + node.name;
std::string err = "ClusterWidget: failed to stop yarprun on " + node.name;
logError(QString(err.c_str()));
}
else
{
std::string info = "ClusterWidget: yarprun successfully stopped on "+ node.name;
logMessage(QString(info.c_str()));
}
}

yarp::os::Time::delay(2.0);
Expand All @@ -289,13 +314,18 @@ void ClusterWidget::onKillSelected()

string cmdKillYarprun = getSSHCmd(node.user, node.name, node.ssh_options);

cmdKillYarprun = cmdKillYarprun + " killall -9 yarprun";
cmdKillYarprun = cmdKillYarprun + " killall -9 yarprun &";

if (system(cmdKillYarprun.c_str()) != 0)
{
std::string err = "ClusterWidget: failed to kill yarprun on" + node.name;
std::string err = "ClusterWidget: failed to kill yarprun on " + node.name;
logError(QString(err.c_str()));
}
else
{
std::string info = "ClusterWidget: yarprun successfully killed on "+ node.name;
logMessage(QString(info.c_str()));
}
}
yarp::os::Time::delay(2.0);
onCheckAll();
Expand Down Expand Up @@ -323,7 +353,13 @@ void ClusterWidget::onExecute()
std::string err = "ClusterWidget: failed to run "+ ui->lineEditExecute->text().toStdString() + " on " + node.name;
logError(QString(err.c_str()));
}
else
{
std::string info = "ClusterWidget: command "+ ui->lineEditExecute->text().toStdString() + " successfully executed on " + node.name;
logMessage(QString(info.c_str()));
}
}
ui->lineEditExecute->clear();
}

void ClusterWidget::onNodeSelectionChanged()
Expand Down Expand Up @@ -470,6 +506,13 @@ bool ClusterWidget::checkNode(const string &name)

}

void ClusterWidget::updateServerEntries()
{
// remove all the whitespaces
cluster.user = ui->lineEditUser->text().simplified().replace( " ", "" ).toStdString();
cluster.nsNode = ui->lineEditNsNode->text().simplified().replace( " ", "" ).toStdString();
}

ClusterWidget::~ClusterWidget()
{
if (clusLoader)
Expand Down
2 changes: 2 additions & 0 deletions src/yarpmanager/src-manager/clusterWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ private slots:
void onNodeSelectionChanged();
signals:
void logError(QString);
void logMessage(QString);
public:
explicit ClusterWidget(QWidget *parent = 0);
~ClusterWidget();
Expand All @@ -44,6 +45,7 @@ private slots:
std::string getSSHCmd(const std::string& user, const std::string& host, const std::string& ssh_options);
bool checkNameserver();
bool checkNode(const std::string& name);
void updateServerEntries();
private:
Ui::ClusterWidget *ui;
std::string confFile;
Expand Down
1 change: 1 addition & 0 deletions src/yarpmanager/src-manager/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ MainWindow::MainWindow(QWidget *parent) :
ui->clusterWidget->setConfigFile(confFile);
ui->clusterWidget->init();
connect(ui->clusterWidget, SIGNAL(logError(QString)), this, SLOT(onLogError(QString)));
connect(ui->clusterWidget, SIGNAL(logMessage(QString)), this, SLOT(onLogMessage(QString)));
}
else
{
Expand Down

0 comments on commit e718556

Please sign in to comment.