-// Copyright (C) 2009-2012 CEA/DEN, EDF R&D
+// Copyright (C) 2009-2013 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include "JM_EditSalomeResource.hxx"
#include "BL_Traces.hxx"
+using namespace std;
+
JM::EditSalomeResource::EditSalomeResource(QWidget *parent, BL::SALOMEServices * salome_services,
const std::string & resource_name) : QDialog(parent)
{
_protocol_line = new QComboBox(this);
_protocol_line->addItem("ssh");
_protocol_line->addItem("rsh");
- _protocol_line->addItem("srun");
- _protocol_line->addItem("pbsdsh");
- _protocol_line->addItem("blaunch");
- _protocol_line->setCurrentIndex(-1);
+ _protocol_line->addItem("sh");
+ _protocol_line->setCurrentIndex(0);
QLabel * componentList_label = new QLabel("Component List:");
_add_button = new QPushButton("Add");
QLabel * working_directory_label = new QLabel("Working Directory:");
_working_directory = new QLineEdit(this);
- QLabel * is_cluster_head_label = new QLabel("Is Cluster Head:");
- _is_cluster_head = new QPushButton(this);
- _is_cluster_head->setCheckable(true);
- connect(_is_cluster_head, SIGNAL(toggled(bool)), this, SLOT(toggle_is_cluster_head(bool)));
- toggle_is_cluster_head(false); // Default is false
+ _can_launch_batch_jobs = new QCheckBox("This resource can be used to launch batch jobs", this);
+ _can_run_containers = new QCheckBox("This resource can be used to run interactive containers", this);
QGridLayout * m_layout = new QGridLayout;
m_layout->addWidget(name_label, 0, 0);
m_layout->addWidget(_applipath_line, 4, 1);
m_layout->addWidget(componentList_label, 5, 0);
m_layout->addWidget(component_widget, 5, 1);
- m_layout->addWidget(is_cluster_head_label, 6, 0);
- m_layout->addWidget(_is_cluster_head, 6, 1);
- m_layout->addWidget(working_directory_label, 7, 0);
- m_layout->addWidget(_working_directory, 7, 1);
+ m_layout->addWidget(working_directory_label, 6, 0);
+ m_layout->addWidget(_working_directory, 6, 1);
+ m_layout->addWidget(_can_launch_batch_jobs, 7, 1);
+ m_layout->addWidget(_can_run_containers, 8, 1);
main_groupBox->setLayout(m_layout);
// Part 2
_iprotocol_line->addItem("srun");
_iprotocol_line->addItem("pbsdsh");
_iprotocol_line->addItem("blaunch");
- _iprotocol_line->setCurrentIndex(-1);
+ _iprotocol_line->setCurrentIndex(0);
- QLabel * batch_label = new QLabel("Batch:");
+ QLabel * batch_label = new QLabel("Batch Manager:");
_batch_line = new QComboBox(this);
- _batch_line->addItem("pbs");
- _batch_line->addItem("lsf");
- _batch_line->addItem("sge");
- _batch_line->addItem("ssh");
- _batch_line->addItem("ccc");
- _batch_line->addItem("slurm");
- _batch_line->addItem("ll");
- _batch_line->addItem("vishnu");
- _batch_line->setCurrentIndex(-1);
+ _batch_line->addItem("None", "ssh_batch");
+ _batch_line->addItem("CCC", "ccc");
+ _batch_line->addItem("LSF", "lsf");
+ _batch_line->addItem("SGE", "sge");
+ _batch_line->addItem("SLURM", "slurm");
+ _batch_line->addItem("VISHNU", "vishnu");
+ _batch_line->addItem("CooRM (limited support)", "coorm");
+ _batch_line->addItem("LoadLeveler (limited support)", "ll");
+ _batch_line->addItem("OAR (limited support)", "oar");
+ _batch_line->addItem("PBS (limited support)", "pbs");
+ _batch_line->setCurrentIndex(0);
QLabel * mpiImpl_label = new QLabel("MPI impl:");
_mpiImpl_line = new QComboBox(this);
_applipath_line->setText(QString(resource_descr.applipath.c_str()));
_os_line->setText(QString(resource_descr.OS.c_str()));
_working_directory->setText(QString(resource_descr.working_directory.c_str()));
- _is_cluster_head->setChecked(resource_descr.is_cluster_head);
+
+ if (resource_descr.can_launch_batch_jobs)
+ _can_launch_batch_jobs->setCheckState(Qt::Checked);
+ else
+ _can_launch_batch_jobs->setCheckState(Qt::Unchecked);
+
+ if (resource_descr.can_run_containers)
+ _can_run_containers->setCheckState(Qt::Checked);
+ else
+ _can_run_containers->setCheckState(Qt::Unchecked);
std::string protocol = resource_descr.protocol.c_str();
if (protocol == "ssh")
_protocol_line->setCurrentIndex(0);
else if(protocol == "rsh")
_protocol_line->setCurrentIndex(1);
- else if(protocol == "srun")
+ else if(protocol == "sh")
_protocol_line->setCurrentIndex(2);
- else if(protocol == "pbsdsh")
- _protocol_line->setCurrentIndex(3);
- else if(protocol == "blaunch")
- _protocol_line->setCurrentIndex(4);
else
_protocol_line->setCurrentIndex(-1);
else
_iprotocol_line->setCurrentIndex(-1);
- std::string batch = resource_descr.batch.c_str();
- if (batch == "pbs")
- _batch_line->setCurrentIndex(0);
- else if (batch == "lsf")
- _batch_line->setCurrentIndex(1);
- else if (batch == "sge")
- _batch_line->setCurrentIndex(2);
- else if (batch == "ssh")
- _batch_line->setCurrentIndex(3);
- else if (batch == "ccc")
- _batch_line->setCurrentIndex(4);
- else if (batch == "slurm")
- _batch_line->setCurrentIndex(5);
- else if (batch == "ll")
- _batch_line->setCurrentIndex(6);
- else if (batch == "vishnu")
- _batch_line->setCurrentIndex(7);
- else
- _batch_line->setCurrentIndex(-1);
+ for (int i=0 ; i<_batch_line->count() ; i++)
+ {
+ if (_batch_line->itemData(i).toString().toStdString() == resource_descr.batch)
+ {
+ _batch_line->setCurrentIndex(i);
+ }
+ }
std::string mpiImpl = resource_descr.mpiImpl.c_str();
if (mpiImpl == "lam")
BL::ResourceDescr resource;
// Text
- resource.name = _name_line->text().toStdString();
- resource.hostname = _hostname_line->text().toStdString();
- resource.username = _username_line->text().toStdString();
- resource.applipath = _applipath_line->text().toStdString();
- resource.OS = _os_line->text().toStdString();
- resource.working_directory = _working_directory->text().toStdString();
- if (_is_cluster_head->isChecked())
- resource.is_cluster_head = true;
- else
- resource.is_cluster_head = false;
+ resource.name = _name_line->text().trimmed().toStdString();
+ resource.hostname = _hostname_line->text().trimmed().toStdString();
+ resource.username = _username_line->text().trimmed().toStdString();
+ resource.applipath = _applipath_line->text().trimmed().toStdString();
+ resource.OS = _os_line->text().trimmed().toStdString();
+ resource.working_directory = _working_directory->text().trimmed().toStdString();
+ resource.can_launch_batch_jobs = (_can_launch_batch_jobs->checkState() == Qt::Checked);
+ resource.can_run_containers = (_can_run_containers->checkState() == Qt::Checked);
// Components
int count = _componentList->count();
for (int i = 0; i < count; i++)
- resource.componentList.push_back(_componentList->item(i)->text().toStdString());
+ resource.componentList.push_back(_componentList->item(i)->text().trimmed().toStdString());
// ComboBox
resource.protocol = _protocol_line->currentText().toStdString();
resource.iprotocol = _iprotocol_line->currentText().toStdString();
- resource.batch = _batch_line->currentText().toStdString();
- if (resource.batch == "ssh")
- resource.batch = "ssh_batch";
+ resource.batch = _batch_line->itemData(_batch_line->currentIndex()).toString().toStdString();
resource.mpiImpl = _mpiImpl_line->currentText().toStdString();
// QSpinBox
resource.hostname != "" &&
resource.protocol != "")
{
- _salome_services->addResource(resource);
- QDialog::accept();
+ try
+ {
+ _salome_services->addResource(resource);
+ QDialog::accept();
+ }
+ catch (const BL::Exception & ex)
+ {
+ QMessageBox::critical(this, "Error", QString("Cannot add resource: ") + ex.what());
+ }
}
else
{
QMessageBox::warning(NULL, "Values missing", "name, hostname and protocol are mandatory! Cancel or add values!");
}
}
-
-void
-JM::EditSalomeResource::toggle_is_cluster_head(bool checked)
-{
- if (checked)
- _is_cluster_head->setText("true");
- else
- _is_cluster_head->setText("false");
-}