Commit 3122103c authored by Huff, Israel's avatar Huff, Israel
Browse files

- changed parameters of some queue commands

- implemented/tweaked several SGE commands
- added several controls to test GUI for handling new commands and switching schedulers
parent f24be64a
Pipeline #96841 passed with stages
in 5 minutes and 22 seconds
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define RSMCORE_QUEUEBASE_HH_ #define RSMCORE_QUEUEBASE_HH_
#include <QString> #include <QString>
#include <QStringList>
namespace rsm namespace rsm
{ {
...@@ -9,13 +10,13 @@ class QueueBase ...@@ -9,13 +10,13 @@ class QueueBase
{ {
public: public:
virtual ~QueueBase(); virtual ~QueueBase();
virtual QString listAllNodeInfo() = 0; virtual QString listAllNodeInfo() = 0;
virtual QString listAllQueues() = 0; virtual QString listAllQueues() = 0;
virtual QString checkJob(QString params) = 0; virtual QString checkJobs(QStringList jobIDs) = 0;
virtual QString deleteJob(QString params) = 0; virtual QString deleteJobs(QStringList jobIDs) = 0;
virtual QString submitJob(QString params) = 0; virtual QString submitJob(QString params) = 0;
virtual QString showQueueInfo(QString params) = 0; virtual QString showQueueInfo(QString queueName) = 0;
virtual QString showFreeProcs(QString params) = 0; virtual QString showFreeProcs(QString params) = 0;
}; // class QueueBase }; // class QueueBase
} // namespace rsm } // namespace rsm
......
...@@ -5,13 +5,19 @@ namespace rsm ...@@ -5,13 +5,19 @@ namespace rsm
// QueuePBS::~QueuePBS() {} // QueuePBS::~QueuePBS() {}
QString QueuePBS::listAllNodeInfo() { return "pbsnodes -a"; } QString QueuePBS::listAllNodeInfo() { return "pbsnodes -a"; }
QString QueuePBS::listAllQueues() { return "qstat -q"; } QString QueuePBS::listAllQueues() { return "qstat -q"; }
QString QueuePBS::checkJob(QString params) QString QueuePBS::checkJobs(QStringList jobIDs)
{ {
// TODO: optional -f job_id // TODO: optional -f job_id job_id ...
return "qstat " + params; return "qstat ";
}
QString QueuePBS::deleteJobs(QStringList jobIDs)
{ // TODO: qdel job_id job_id ...
return "qdel ";
} }
QString QueuePBS::deleteJob(QString params) { return "qdel " + params; }
QString QueuePBS::submitJob(QString params) { return "qsub " + params; } QString QueuePBS::submitJob(QString params) { return "qsub " + params; }
QString QueuePBS::showQueueInfo(QString params) { return "showq " + params; } QString QueuePBS::showQueueInfo(QString queueName)
{
return "showq " + queueName;
}
QString QueuePBS::showFreeProcs(QString params) { return "showbf " + params; } QString QueuePBS::showFreeProcs(QString params) { return "showbf " + params; }
} // namespace rsm } // namespace rsm
...@@ -11,10 +11,10 @@ class QueuePBS : public QueueBase ...@@ -11,10 +11,10 @@ class QueuePBS : public QueueBase
// ~QueuePBS() override; // ~QueuePBS() override;
QString listAllNodeInfo() override; QString listAllNodeInfo() override;
QString listAllQueues() override; QString listAllQueues() override;
QString checkJob(QString params) override; QString checkJobs(QStringList jobIDs) override;
QString deleteJob(QString params) override; QString deleteJobs(QStringList jobIDs) override;
QString submitJob(QString params) override; QString submitJob(QString params) override;
QString showQueueInfo(QString params) override; QString showQueueInfo(QString queueName) override;
QString showFreeProcs(QString params) override; QString showFreeProcs(QString params) override;
}; // class QueuePBS }; // class QueuePBS
} // namespace rsm } // namespace rsm
......
#include "queuesge.hh" #include "queuesge.hh"
// TODO: input validation
namespace rsm namespace rsm
{ {
// QueueSGE::~QueueSGE() {} // QueueSGE::~QueueSGE() {}
QString QueueSGE::listAllNodeInfo() { return "qstat -F"; } QString QueueSGE::listAllNodeInfo() { return "qstat -F"; }
QString QueueSGE::listAllQueues() { return "qstat -g c"; } QString QueueSGE::listAllQueues() { return "qconf -sql"; }
QString QueueSGE::checkJob(QString params) QString QueueSGE::checkJobs(QStringList jobIDs)
{ // TODO: optional -j job_id {
return "qstat " + params; QString command = "qstat";
if (jobIDs.length() > 0) command += " -j " + jobIDs.join(",");
return command;
}
QString QueueSGE::deleteJobs(QStringList jobIDs)
{
if (jobIDs.length() == 0) return "";
return "qdel " + jobIDs.join(" ");
} }
QString QueueSGE::deleteJob(QString params) { return "qdel " + params; }
QString QueueSGE::submitJob(QString params) { return "qsub " + params; } QString QueueSGE::submitJob(QString params) { return "qsub " + params; }
QString QueueSGE::showQueueInfo(QString params) QString QueueSGE::showQueueInfo(QString queueName)
{ // TODO: optional -q queue_name {
return "qstat " + params; return "qconf -sq " + queueName;
} }
// TODO: how best to handle unsupported features?
QString QueueSGE::showFreeProcs(QString params) QString QueueSGE::showFreeProcs(QString params)
{ {
(void)sizeof(params); (void)sizeof(params);
return ""; return "qstat -g c";
} }
} // namespace rsm } // namespace rsm
...@@ -11,10 +11,10 @@ class QueueSGE : public QueueBase ...@@ -11,10 +11,10 @@ class QueueSGE : public QueueBase
// ~QueueSGE() override; // ~QueueSGE() override;
QString listAllNodeInfo() override; QString listAllNodeInfo() override;
QString listAllQueues() override; QString listAllQueues() override;
QString checkJob(QString params) override; QString checkJobs(QStringList jobIDs) override;
QString deleteJob(QString params) override; QString deleteJobs(QStringList jobIDs) override;
QString submitJob(QString params) override; QString submitJob(QString params) override;
QString showQueueInfo(QString params) override; QString showQueueInfo(QString queueName) override;
QString showFreeProcs(QString params) override; QString showFreeProcs(QString params) override;
}; // class QueueSGE }; // class QueueSGE
} // namespace rsm } // namespace rsm
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "rsmportalexample.hh" #include "rsmportalexample.hh"
#include <QApplication> #include <QApplication>
#include <QGridLayout> #include <QGridLayout>
#include <QHBoxLayout>
#include <QHeaderView> #include <QHeaderView>
#include <QInputDialog> #include <QInputDialog>
#include <QLabel> #include <QLabel>
...@@ -19,40 +20,92 @@ using namespace rsm; ...@@ -19,40 +20,92 @@ using namespace rsm;
ExamplePortalWidget::ExamplePortalWidget(QWidget *parent) ExamplePortalWidget::ExamplePortalWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
queue = &queueSGE;
QGridLayout *layout = new QGridLayout(this); QGridLayout *layout = new QGridLayout(this);
QLabel *proxyHostLabel = new QLabel("Proxy:", this); QLabel *proxyHostLabel = new QLabel("Proxy:", this);
QLabel *hostLabel = new QLabel("Host:", this); QLabel *hostLabel = new QLabel("Host:", this);
QLabel *portLabel = new QLabel("Port:", this); QLabel *portLabel = new QLabel("Port:", this);
QLabel *userNameLabel = new QLabel("Username:", this); QLabel *userNameLabel = new QLabel("Username:", this);
mProxyEdit = new QLineEdit(this); mProxyEdit = new QLineEdit(this);
mHostEdit = new QLineEdit(this); mHostEdit = new QLineEdit("", this);
mPortEdit = new QLineEdit(this); mPortEdit = new QLineEdit("", this);
mUserNameEdit = new QLineEdit(this); mUserNameEdit = new QLineEdit("", this);
mConnectButton = new QPushButton("Connect", this); mConnectButton = new QPushButton("Connect", this);
mCommandEdit = new QLineEdit(this); mCommandEdit = new QLineEdit(this);
mCommandSubmitButton = new QPushButton("Submit", this); mCommandSubmitButton = new QPushButton("Submit", this);
mSchedulerBox = new QGroupBox(this);
mPBSRadioButton = new QRadioButton("PBS", this);
mSGERadioButton = new QRadioButton("SGE", this);
mListAllQueuesButton = new QPushButton("List All Queues", this);
mGetQueueInfoButton = new QPushButton("Queue Info", this);
mGetQueueInfoTextEdit = new QLineEdit(this);
mGetAllNodeInfoButton = new QPushButton("Node Info", this);
mGetAllJobInfoButton = new QPushButton("Job Info", this);
mDeleteJobButton = new QPushButton("Delete Job", this);
mDeleteJobTextEdit = new QLineEdit(this);
mTextEdit = new QTextEdit(this); mTextEdit = new QTextEdit(this);
layout->addWidget(proxyHostLabel, 0, 0); int row = 0;
layout->addWidget(mProxyEdit, 0, 1); layout->addWidget(proxyHostLabel, row, 0);
layout->addWidget(hostLabel, 1, 0); layout->addWidget(mProxyEdit, row, 1);
layout->addWidget(mHostEdit, 1, 1); layout->addWidget(hostLabel, ++row, 0);
layout->addWidget(portLabel, 2, 0); layout->addWidget(mHostEdit, row, 1);
layout->addWidget(mPortEdit, 2, 1); layout->addWidget(portLabel, ++row, 0);
layout->addWidget(userNameLabel, 3, 0); layout->addWidget(mPortEdit, row, 1);
layout->addWidget(mUserNameEdit, 3, 1); layout->addWidget(userNameLabel, ++row, 0);
layout->addWidget(mConnectButton, 4, 1); layout->addWidget(mUserNameEdit, row, 1);
layout->addWidget(mCommandEdit, 5, 0, 1, 2); layout->addWidget(mConnectButton, ++row, 1);
layout->addWidget(mCommandSubmitButton, 6, 1);
QHBoxLayout *mSGBLayout = new QHBoxLayout(mSchedulerBox);
layout->addWidget(mTextEdit, 7, 0, 2, 2); mSchedulerBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum);
mSGBLayout->addWidget(mPBSRadioButton);
mSGBLayout->addWidget(mSGERadioButton);
layout->addWidget(mSchedulerBox, ++row, 1);
mSchedulerButtonGroup = new QButtonGroup(this);
mSchedulerButtonGroup->addButton(mPBSRadioButton);
mSchedulerButtonGroup->addButton(mSGERadioButton);
layout->addWidget(mSchedulerBox, ++row, 1);
layout->addWidget(mCommandSubmitButton, ++row, 1);
layout->addWidget(mCommandEdit, row, 2);
layout->addWidget(mListAllQueuesButton, ++row, 0);
layout->addWidget(mGetQueueInfoButton, row, 1);
layout->addWidget(mGetQueueInfoTextEdit, row, 2);
layout->addWidget(mGetAllNodeInfoButton, ++row, 1);
layout->addWidget(mGetAllJobInfoButton, ++row, 1);
layout->addWidget(mDeleteJobButton, ++row, 1);
layout->addWidget(mDeleteJobTextEdit, row, 2);
layout->addWidget(mTextEdit, ++row, 0, 2, 3);
connect(mConnectButton, &QPushButton::pressed, this, connect(mConnectButton, &QPushButton::pressed, this,
&ExamplePortalWidget::connectToHost); &ExamplePortalWidget::connectToHost);
connect(mSchedulerButtonGroup,
QOverload<int>::of(&QButtonGroup::buttonClicked), [=](int id) {
QString name = mSchedulerButtonGroup->checkedButton()->text();
if ("PBS" == name)
queue = &queuePBS;
else if ("SGE" == name)
queue = &queueSGE;
});
mSGERadioButton->click();
connect(mCommandSubmitButton, &QPushButton::pressed, this, connect(mCommandSubmitButton, &QPushButton::pressed, this,
&ExamplePortalWidget::submitCommandToHost); &ExamplePortalWidget::submitCommandToHost);
connect(mListAllQueuesButton, &QPushButton::pressed, this,
&ExamplePortalWidget::submitListAllQueuesToHost);
connect(mGetQueueInfoButton, &QPushButton::pressed, this,
&ExamplePortalWidget::submitGetQueueInfoToHost);
connect(mGetAllNodeInfoButton, &QPushButton::pressed, this,
&ExamplePortalWidget::submitGetAllNodeInfoToHost);
connect(mGetAllJobInfoButton, &QPushButton::pressed, this,
&ExamplePortalWidget::submitGetAllJobInfoToHost);
connect(mDeleteJobButton, &QPushButton::pressed, this,
&ExamplePortalWidget::submitDeleteJobToHost);
mSession = std::make_shared<SessionController>(); mSession = std::make_shared<SessionController>();
connect(mSession.get(), &SessionController::connectionFailed, this, connect(mSession.get(), &SessionController::connectionFailed, this,
...@@ -116,6 +169,48 @@ void ExamplePortalWidget::submitCommandToHost() ...@@ -116,6 +169,48 @@ void ExamplePortalWidget::submitCommandToHost()
mSession->requestExec(command); mSession->requestExec(command);
} }
void ExamplePortalWidget::submitListAllQueuesToHost()
{
radix_tagged_line("submitListAllQueuesToHost()");
QString command = queue->listAllQueues();
mSession->requestExec(command);
}
void ExamplePortalWidget::submitGetQueueInfoToHost()
{
radix_tagged_line("submitGetQueueInfoToHost()");
QString command = queue->showQueueInfo(mGetQueueInfoTextEdit->text());
fprintf(stderr, "%s\n", command.toStdString().c_str());
mSession->requestExec(command);
}
void ExamplePortalWidget::submitGetAllNodeInfoToHost()
{
radix_tagged_line("submitGetAllNodeInfoToHost()");
QString command = queue->listAllNodeInfo();
mSession->requestExec(command);
}
void ExamplePortalWidget::submitGetAllJobInfoToHost()
{
radix_tagged_line("submitGetAllJobInfoToHost()");
QString command = queue->checkJobs(QStringList());
fprintf(stderr, "%s\n", command.toStdString().c_str());
mSession->requestExec(command);
}
void ExamplePortalWidget::submitDeleteJobToHost()
{
radix_tagged_line("submitDeleteJobToHost()");
QStringList jobIDs = QStringList();
if (mDeleteJobTextEdit->text().length() > 0)
jobIDs = mDeleteJobTextEdit->text().split(QRegExp("[ ,]"));
QString command = queue->deleteJobs(jobIDs);
fprintf(stderr, "%d\n", jobIDs.size());
fprintf(stderr, "%s\n", command.toStdString().c_str());
mSession->requestExec(command);
}
void ExamplePortalWidget::slotExecOutputReady() void ExamplePortalWidget::slotExecOutputReady()
{ {
QByteArray output = mSession->readExecOutput(); QByteArray output = mSession->readExecOutput();
...@@ -210,13 +305,13 @@ void ExamplePortalWidget::hostPublicKeyChanged(QString host_hash) ...@@ -210,13 +305,13 @@ void ExamplePortalWidget::hostPublicKeyChanged(QString host_hash)
{ {
mTextEdit->append("Host key has changed.\nChanged key:"); mTextEdit->append("Host key has changed.\nChanged key:");
mTextEdit->append(host_hash); mTextEdit->append(host_hash);
mTextEdit->append("This could be a man-in-the-middle attach.\n"); mTextEdit->append("This could be a man-in-the-middle attack.\n");
mSession->disconnect(); mSession->disconnect();
} }
void ExamplePortalWidget::hostPublicKeyUnavailable() void ExamplePortalWidget::hostPublicKeyUnavailable()
{ {
mTextEdit->append("Host key is unavaible.\n"); mTextEdit->append("Host key is unavailable.\n");
mSession->disconnect(); mSession->disconnect();
} }
...@@ -291,7 +386,7 @@ void ExamplePortalWidget::execFinished() ...@@ -291,7 +386,7 @@ void ExamplePortalWidget::execFinished()
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
{ {
setGeometry(400, 250, 542, 390); setGeometry(120, 120, 720, 720);
ExamplePortalWidget *portalView = new ExamplePortalWidget(this); ExamplePortalWidget *portalView = new ExamplePortalWidget(this);
setCentralWidget(portalView); setCentralWidget(portalView);
......
...@@ -2,13 +2,18 @@ ...@@ -2,13 +2,18 @@
#define RSM_RSMWIDGETS_EXAMPLE_RSMPORTALEXAMPLE_HH_ #define RSM_RSMWIDGETS_EXAMPLE_RSMPORTALEXAMPLE_HH_
#include <QAbstractTableModel> #include <QAbstractTableModel>
#include <QButtonGroup>
#include <QGroupBox>
#include <QLineEdit> #include <QLineEdit>
#include <QMainWindow> #include <QMainWindow>
#include <QPushButton> #include <QPushButton>
#include <QRadioButton>
#include <QTextEdit> #include <QTextEdit>
#include <QWidget> #include <QWidget>
#include "rsmcore/sessioncontroller.hh" #include "rsmcore/queuepbs.hh"
#include "rsmcore/queuesge.hh"
#include "rsmpbs/pbssession.hh"
#include <memory> #include <memory>
...@@ -26,10 +31,27 @@ class ExamplePortalWidget : public QWidget ...@@ -26,10 +31,27 @@ class ExamplePortalWidget : public QWidget
QLineEdit *mHostEdit; QLineEdit *mHostEdit;
QLineEdit *mPortEdit; QLineEdit *mPortEdit;
QLineEdit *mUserNameEdit; QLineEdit *mUserNameEdit;
QGroupBox *mSchedulerBox;
QButtonGroup *mSchedulerButtonGroup;
QRadioButton *mPBSRadioButton;
QRadioButton *mSGERadioButton;
QLineEdit *mCommandEdit; QLineEdit *mCommandEdit;
QPushButton *mCommandSubmitButton; QPushButton *mCommandSubmitButton;
QPushButton *mListAllQueuesButton;
QPushButton *mGetQueueInfoButton;
QLineEdit *mGetQueueInfoTextEdit;
QPushButton *mGetAllNodeInfoButton;
QPushButton *mGetAllJobInfoButton;
QPushButton *mDeleteJobButton;
QLineEdit *mDeleteJobTextEdit;
QTextEdit *mTextEdit; QTextEdit *mTextEdit;
rsm::SessionController::SP mSession; rsm::SessionController::SP mSession;
rsm::QueuePBS queuePBS;
rsm::QueueSGE queueSGE;
rsm::QueueBase *queue;
public: public:
ExamplePortalWidget(QWidget *parent = nullptr); ExamplePortalWidget(QWidget *parent = nullptr);
...@@ -37,6 +59,11 @@ class ExamplePortalWidget : public QWidget ...@@ -37,6 +59,11 @@ class ExamplePortalWidget : public QWidget
public slots: public slots:
void connectToHost(); void connectToHost();
void submitCommandToHost(); void submitCommandToHost();
void submitListAllQueuesToHost();
void submitGetQueueInfoToHost();
void submitGetAllNodeInfoToHost();
void submitGetAllJobInfoToHost();
void submitDeleteJobToHost();
void slotExecOutputReady(); void slotExecOutputReady();
void connectionFailed(QString message); void connectionFailed(QString message);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment