From e5acdcd7a9eee13191ac524608928d322759956a Mon Sep 17 00:00:00 2001 From: ribes Date: Mon, 19 Mar 2012 16:55:59 +0000 Subject: [PATCH] Working on PAL# 2078 Adding is_cluster_head and working_directory support --- src/engine/BL_SALOMEServices.cxx | 4 +++ src/engine/BL_SALOMEServices.hxx | 3 ++ src/genericgui/JM_EditSalomeResource.cxx | 37 +++++++++++++++++++++--- src/genericgui/JM_EditSalomeResource.hxx | 10 +++++-- src/genericgui/JM_SalomeResource.cxx | 22 ++++++++++++++ src/genericgui/JM_SalomeResource.hxx | 4 +++ 6 files changed, 73 insertions(+), 7 deletions(-) diff --git a/src/engine/BL_SALOMEServices.cxx b/src/engine/BL_SALOMEServices.cxx index 0fb24e0..e64ce12 100644 --- a/src/engine/BL_SALOMEServices.cxx +++ b/src/engine/BL_SALOMEServices.cxx @@ -162,6 +162,8 @@ BL::SALOMEServices::getResourceDescr(const std::string& name) resource_descr.batch = resource_definition->batch.in(); resource_descr.mpiImpl = resource_definition->mpiImpl.in(); resource_descr.iprotocol = resource_definition->iprotocol.in(); + resource_descr.is_cluster_head = resource_definition->is_cluster_head; + resource_descr.working_directory = resource_definition->working_directory.in(); delete resource_definition; } @@ -196,6 +198,8 @@ BL::SALOMEServices::addResource(BL::ResourceDescr & new_resource) resource_definition->batch = CORBA::string_dup(new_resource.batch.c_str()); resource_definition->mpiImpl = CORBA::string_dup(new_resource.mpiImpl.c_str()); resource_definition->iprotocol = CORBA::string_dup(new_resource.iprotocol.c_str()); + resource_definition->is_cluster_head = new_resource.is_cluster_head; + resource_definition->working_directory = CORBA::string_dup(new_resource.working_directory.c_str()); try { diff --git a/src/engine/BL_SALOMEServices.hxx b/src/engine/BL_SALOMEServices.hxx index a69a3c1..8f35383 100644 --- a/src/engine/BL_SALOMEServices.hxx +++ b/src/engine/BL_SALOMEServices.hxx @@ -57,6 +57,9 @@ namespace BL{ std::string batch; std::string mpiImpl; std::string iprotocol; + + bool is_cluster_head; + std::string working_directory; }; class BL_Engine_EXPORT SALOMEServices : diff --git a/src/genericgui/JM_EditSalomeResource.cxx b/src/genericgui/JM_EditSalomeResource.cxx index 1014717..19b29bb 100644 --- a/src/genericgui/JM_EditSalomeResource.cxx +++ b/src/genericgui/JM_EditSalomeResource.cxx @@ -70,6 +70,14 @@ JM::EditSalomeResource::EditSalomeResource(QWidget *parent, BL::SALOMEServices * connect(_remove_button, SIGNAL(clicked()), this, SLOT(remove_components())); connect(_componentList, SIGNAL(itemSelectionChanged()), this, SLOT(itemSelectionChanged())); + 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 + QGridLayout * m_layout = new QGridLayout; m_layout->addWidget(name_label, 0, 0); m_layout->addWidget(_name_line, 0, 1); @@ -83,6 +91,10 @@ JM::EditSalomeResource::EditSalomeResource(QWidget *parent, BL::SALOMEServices * 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); main_groupBox->setLayout(m_layout); // Part 2 @@ -162,7 +174,7 @@ JM::EditSalomeResource::EditSalomeResource(QWidget *parent, BL::SALOMEServices * // Part 3 QDialogButtonBox * buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok - | QDialogButtonBox::Cancel); + | QDialogButtonBox::Cancel); connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); @@ -188,12 +200,14 @@ void JM::EditSalomeResource::get_infos() { BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(_resource_name); - + _name_line->setText(QString(resource_descr.name.c_str())); _hostname_line->setText(QString(resource_descr.hostname.c_str())); _username_line->setText(QString(resource_descr.username.c_str())); _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); std::string protocol = resource_descr.protocol.c_str(); if (protocol == "ssh") @@ -238,9 +252,9 @@ JM::EditSalomeResource::get_infos() _batch_line->setCurrentIndex(5); else if (batch == "ll") _batch_line->setCurrentIndex(6); - else + else _batch_line->setCurrentIndex(-1); - + std::string mpiImpl = resource_descr.mpiImpl.c_str(); if (mpiImpl == "lam") _mpiImpl_line->setCurrentIndex(0); @@ -280,6 +294,7 @@ JM::EditSalomeResource::get_infos() _username_line->setCursorPosition(0); _applipath_line->setCursorPosition(0); _os_line->setCursorPosition(0); + _working_directory->setCursorPosition(0); } @@ -325,6 +340,11 @@ JM::EditSalomeResource::accept() 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; // Components int count = _componentList->count(); @@ -357,3 +377,12 @@ JM::EditSalomeResource::accept() 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"); +} diff --git a/src/genericgui/JM_EditSalomeResource.hxx b/src/genericgui/JM_EditSalomeResource.hxx index 5dc418b..8ef2fa0 100644 --- a/src/genericgui/JM_EditSalomeResource.hxx +++ b/src/genericgui/JM_EditSalomeResource.hxx @@ -31,9 +31,9 @@ namespace JM Q_OBJECT public: - EditSalomeResource(QWidget *parent, - BL::SALOMEServices * salome_services, - const std::string & resource_name = ""); + EditSalomeResource(QWidget *parent, + BL::SALOMEServices * salome_services, + const std::string & resource_name = ""); virtual ~EditSalomeResource(); void get_infos(); @@ -43,6 +43,7 @@ namespace JM void add_component(); void remove_components(); void itemSelectionChanged(); + void toggle_is_cluster_head(bool checked); protected: QWidget* _parent; @@ -67,6 +68,9 @@ namespace JM QSpinBox * _nb_node_line; QSpinBox * _nb_proc_per_node_line; + QLineEdit * _working_directory; + QPushButton * _is_cluster_head; + QPushButton * _add_button; QPushButton * _remove_button; }; diff --git a/src/genericgui/JM_SalomeResource.cxx b/src/genericgui/JM_SalomeResource.cxx index f2ada7f..500de29 100644 --- a/src/genericgui/JM_SalomeResource.cxx +++ b/src/genericgui/JM_SalomeResource.cxx @@ -45,6 +45,11 @@ JM::SalomeResource::SalomeResource(QWidget *parent, BL::SALOMEServices * salome_ QLabel * componentList_label = new QLabel("Component List:"); _componentList = new QListWidget(this); _componentList->setViewMode(QListView::ListMode); + 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); + toggle_is_cluster_head(false); // Default is false QGridLayout * m_layout = new QGridLayout; m_layout->addWidget(name_label, 0, 0); m_layout->addWidget(_name_line, 0, 1); @@ -58,6 +63,10 @@ JM::SalomeResource::SalomeResource(QWidget *parent, BL::SALOMEServices * salome_ m_layout->addWidget(_applipath_line, 4, 1); m_layout->addWidget(componentList_label, 5, 0); m_layout->addWidget(_componentList, 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); main_groupBox->setLayout(m_layout); @@ -120,6 +129,7 @@ JM::SalomeResource::SalomeResource(QWidget *parent, BL::SALOMEServices * salome_ _batch_line->setCursorPosition(0); _mpiImpl_line->setCursorPosition(0); _iprotocol_line->setCursorPosition(0); + _working_directory->setCursorPosition(0); _name_line->setReadOnly(true); _hostname_line->setReadOnly(true); @@ -134,6 +144,7 @@ JM::SalomeResource::SalomeResource(QWidget *parent, BL::SALOMEServices * salome_ _batch_line->setReadOnly(true); _mpiImpl_line->setReadOnly(true); _iprotocol_line->setReadOnly(true); + _working_directory->setReadOnly(true); } JM::SalomeResource::~SalomeResource() @@ -155,6 +166,8 @@ JM::SalomeResource::get_infos() _batch_line->setText(QString(resource_descr.batch.c_str())); _mpiImpl_line->setText(QString(resource_descr.mpiImpl.c_str())); _iprotocol_line->setText(QString(resource_descr.iprotocol.c_str())); + _working_directory->setText(QString(resource_descr.working_directory.c_str())); + toggle_is_cluster_head(resource_descr.is_cluster_head); QString value; _mem_mb_line->setText(value.setNum(resource_descr.mem_mb)); @@ -166,3 +179,12 @@ JM::SalomeResource::get_infos() for(; it != resource_descr.componentList.end(); it++) _componentList->addItem(QString((*it).c_str())); } + +void +JM::SalomeResource::toggle_is_cluster_head(bool checked) +{ + if (checked) + _is_cluster_head->setText("true"); + else + _is_cluster_head->setText("false"); +} diff --git a/src/genericgui/JM_SalomeResource.hxx b/src/genericgui/JM_SalomeResource.hxx index 9b0d3f3..19f0a2e 100644 --- a/src/genericgui/JM_SalomeResource.hxx +++ b/src/genericgui/JM_SalomeResource.hxx @@ -38,6 +38,8 @@ namespace JM void get_infos(); + void toggle_is_cluster_head(bool checked); + protected: QWidget* _parent; BL::SALOMEServices * _salome_services; @@ -50,6 +52,8 @@ namespace JM QLineEdit * _username_line; QLineEdit * _applipath_line; QListWidget * _componentList; + QPushButton * _is_cluster_head; + QLineEdit * _working_directory; QLineEdit * _os_line; QLineEdit * _mem_mb_line; QLineEdit * _cpu_clock_line; -- 2.39.2