From d91ab3f185085a4bb7ce19104e3ff430c54936b0 Mon Sep 17 00:00:00 2001 From: barate Date: Thu, 24 Jan 2013 10:27:25 +0000 Subject: [PATCH] Replace parameter "Is cluster head" by parameters "Can launch batch jobs" and "Can run containers" --- src/engine/BL_SALOMEServices.cxx | 13 +++++-- src/engine/BL_SALOMEServices.hxx | 5 +-- src/genericgui/BL_CreateJobWizard.cxx | 2 +- src/genericgui/BL_GenericGui.cxx | 2 +- src/genericgui/JM_EditSalomeResource.cxx | 43 +++++++++++------------- src/genericgui/JM_EditSalomeResource.hxx | 4 +-- src/genericgui/JM_ResourceCatalog.cxx | 8 +++-- src/genericgui/JM_ResourceCatalog.hxx | 3 +- src/genericgui/JM_SalomeResource.cxx | 35 +++++++++---------- src/genericgui/JM_SalomeResource.hxx | 5 ++- 10 files changed, 63 insertions(+), 57 deletions(-) diff --git a/src/engine/BL_SALOMEServices.cxx b/src/engine/BL_SALOMEServices.cxx index 273c517..06e1a1d 100644 --- a/src/engine/BL_SALOMEServices.cxx +++ b/src/engine/BL_SALOMEServices.cxx @@ -87,7 +87,7 @@ BL::SALOMEServices::initNS() } std::list -BL::SALOMEServices::getResourceList() +BL::SALOMEServices::getResourceList(bool batch_only) { std::list resource_list; @@ -95,6 +95,7 @@ BL::SALOMEServices::getResourceList() { Engines::ResourceParameters params; _lcc->preSet(params); + params.can_launch_batch_jobs = batch_only; Engines::ResourceList * resourceList = NULL; try { @@ -162,7 +163,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.can_launch_batch_jobs = resource_definition->can_launch_batch_jobs; + resource_descr.can_run_containers = resource_definition->can_run_containers; resource_descr.working_directory = resource_definition->working_directory.in(); delete resource_definition; @@ -177,6 +179,10 @@ BL::SALOMEServices::addResource(BL::ResourceDescr & new_resource) resource_definition->name = CORBA::string_dup(new_resource.name.c_str()); resource_definition->hostname = CORBA::string_dup(new_resource.hostname.c_str()); + if (new_resource.batch == "" || new_resource.batch == "ssh_batch") + resource_definition->type = CORBA::string_dup("single_machine"); + else + resource_definition->type = CORBA::string_dup("cluster"); resource_definition->protocol = CORBA::string_dup(new_resource.protocol.c_str()); resource_definition->username = CORBA::string_dup(new_resource.username.c_str()); resource_definition->applipath = CORBA::string_dup(new_resource.applipath.c_str()); @@ -198,7 +204,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->can_launch_batch_jobs = new_resource.can_launch_batch_jobs; + resource_definition->can_run_containers = new_resource.can_run_containers; 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 f3500cc..217fd64 100644 --- a/src/engine/BL_SALOMEServices.hxx +++ b/src/engine/BL_SALOMEServices.hxx @@ -58,7 +58,8 @@ namespace BL{ std::string mpiImpl; std::string iprotocol; - bool is_cluster_head; + bool can_launch_batch_jobs; + bool can_run_containers; std::string working_directory; }; @@ -74,7 +75,7 @@ namespace BL{ void set_manager(BL::JobsManager * manager) {_manager = manager;} - std::list getResourceList(); + std::list getResourceList(bool batch_only); BL::ResourceDescr getResourceDescr(const std::string& name); void addResource(BL::ResourceDescr & new_resource); void removeResource(const std::string & name); diff --git a/src/genericgui/BL_CreateJobWizard.cxx b/src/genericgui/BL_CreateJobWizard.cxx index 8b24f65..1e951b5 100644 --- a/src/genericgui/BL_CreateJobWizard.cxx +++ b/src/genericgui/BL_CreateJobWizard.cxx @@ -943,7 +943,7 @@ BL::ResourcePage::ResourcePage(BL::CreateJobWizard * parent, BL::SALOMEServices // input_Resource QGroupBox * resource_group_box = new QGroupBox("Resource List"); - _resource_list = new JM::ResourceCatalog(this, _salome_services); + _resource_list = new JM::ResourceCatalog(this, _salome_services, true); connect(_resource_list->getQListWidget(), SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*))); QVBoxLayout * resource_list_layout = new QVBoxLayout(); diff --git a/src/genericgui/BL_GenericGui.cxx b/src/genericgui/BL_GenericGui.cxx index b195661..a9bc1f7 100644 --- a/src/genericgui/BL_GenericGui.cxx +++ b/src/genericgui/BL_GenericGui.cxx @@ -64,7 +64,7 @@ BL::GenericGui::createDockWidgets() /* ResourceCatalog */ _dw_resource_catalog = new QDockWidget(_dock_parent); _dw_resource_catalog->setWindowTitle("Resource Catalog"); - _resource_catalog = new JM::ResourceCatalog(_dw_resource_catalog, _salome_services); + _resource_catalog = new JM::ResourceCatalog(_dw_resource_catalog, _salome_services, false); QScrollArea * scroll_widget_resource = new QScrollArea(_dw_resource_catalog); scroll_widget_resource->setWidget(_resource_catalog); scroll_widget_resource->setWidgetResizable(true); diff --git a/src/genericgui/JM_EditSalomeResource.cxx b/src/genericgui/JM_EditSalomeResource.cxx index 9d1edf6..030d434 100644 --- a/src/genericgui/JM_EditSalomeResource.cxx +++ b/src/genericgui/JM_EditSalomeResource.cxx @@ -72,11 +72,8 @@ JM::EditSalomeResource::EditSalomeResource(QWidget *parent, BL::SALOMEServices * 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); @@ -91,10 +88,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); + 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 @@ -208,7 +205,16 @@ JM::EditSalomeResource::get_infos() _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") @@ -245,7 +251,7 @@ JM::EditSalomeResource::get_infos() _batch_line->setCurrentIndex(1); else if (batch == "sge") _batch_line->setCurrentIndex(2); - else if (batch == "ssh") + else if (batch == "ssh_batch") _batch_line->setCurrentIndex(3); else if (batch == "ccc") _batch_line->setCurrentIndex(4); @@ -344,10 +350,8 @@ JM::EditSalomeResource::accept() 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.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(); @@ -380,12 +384,3 @@ 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 0938ca8..c36f592 100644 --- a/src/genericgui/JM_EditSalomeResource.hxx +++ b/src/genericgui/JM_EditSalomeResource.hxx @@ -43,7 +43,6 @@ namespace JM void add_component(); void remove_components(); void itemSelectionChanged(); - void toggle_is_cluster_head(bool checked); protected: QWidget* _parent; @@ -69,7 +68,8 @@ namespace JM QSpinBox * _nb_proc_per_node_line; QLineEdit * _working_directory; - QPushButton * _is_cluster_head; + QCheckBox * _can_launch_batch_jobs; + QCheckBox * _can_run_containers; QPushButton * _add_button; QPushButton * _remove_button; diff --git a/src/genericgui/JM_ResourceCatalog.cxx b/src/genericgui/JM_ResourceCatalog.cxx index 749f0af..6017d9b 100644 --- a/src/genericgui/JM_ResourceCatalog.cxx +++ b/src/genericgui/JM_ResourceCatalog.cxx @@ -22,7 +22,9 @@ #include "JM_SalomeResource.hxx" #include "JM_EditSalomeResource.hxx" -JM::ResourceCatalog::ResourceCatalog(QWidget *parent, BL::SALOMEServices * salome_services) : QWidget(parent) +JM::ResourceCatalog::ResourceCatalog(QWidget *parent, BL::SALOMEServices * salome_services, bool batch_only) +: QWidget(parent), + _batch_only(batch_only) { DEBTRACE("Creating JM::ResourceCatalog"); BL_ASSERT(parent); @@ -34,7 +36,7 @@ JM::ResourceCatalog::ResourceCatalog(QWidget *parent, BL::SALOMEServices * salom _refresh_button->show(); _resource_files_list = new QListWidget(this); _resource_files_list->setSelectionMode(QAbstractItemView::SingleSelection); - std::list resource_list = _salome_services->getResourceList(); + std::list resource_list = _salome_services->getResourceList(_batch_only); std::list::iterator it; for (it = resource_list.begin(); it != resource_list.end(); it++) { @@ -91,7 +93,7 @@ void JM::ResourceCatalog::refresh_resource_list() { _resource_files_list->clear(); - std::list resource_list = _salome_services->getResourceList(); + std::list resource_list = _salome_services->getResourceList(_batch_only); std::list::iterator it; for (it = resource_list.begin(); it != resource_list.end(); it++) { diff --git a/src/genericgui/JM_ResourceCatalog.hxx b/src/genericgui/JM_ResourceCatalog.hxx index 2d1b2f5..c66cd0d 100644 --- a/src/genericgui/JM_ResourceCatalog.hxx +++ b/src/genericgui/JM_ResourceCatalog.hxx @@ -34,7 +34,7 @@ namespace JM Q_OBJECT public: - ResourceCatalog(QWidget *parent, BL::SALOMEServices * salome_services); + ResourceCatalog(QWidget *parent, BL::SALOMEServices * salome_services, bool batch_only); virtual ~ResourceCatalog(); void get_infos(); @@ -60,6 +60,7 @@ namespace JM QPushButton * _add_button; QPushButton * _remove_button; QListWidget * _resource_files_list; + bool _batch_only; }; } diff --git a/src/genericgui/JM_SalomeResource.cxx b/src/genericgui/JM_SalomeResource.cxx index 6c2cb9c..c124ad5 100644 --- a/src/genericgui/JM_SalomeResource.cxx +++ b/src/genericgui/JM_SalomeResource.cxx @@ -47,9 +47,8 @@ JM::SalomeResource::SalomeResource(QWidget *parent, BL::SALOMEServices * salome_ _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 + _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(_name_line, 0, 1); @@ -63,10 +62,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); + 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); QGroupBox * config_groupBox = new QGroupBox("Configuration values"); @@ -144,6 +143,8 @@ JM::SalomeResource::SalomeResource(QWidget *parent, BL::SALOMEServices * salome_ _mpiImpl_line->setReadOnly(true); _iprotocol_line->setReadOnly(true); _working_directory->setReadOnly(true); + _can_launch_batch_jobs->setEnabled(false); + _can_run_containers->setEnabled(false); } JM::SalomeResource::~SalomeResource() @@ -166,7 +167,16 @@ JM::SalomeResource::get_infos() _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); + + 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); QString value; _mem_mb_line->setText(value.setNum(resource_descr.mem_mb)); @@ -178,12 +188,3 @@ 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 dc80b1c..62f5589 100644 --- a/src/genericgui/JM_SalomeResource.hxx +++ b/src/genericgui/JM_SalomeResource.hxx @@ -38,8 +38,6 @@ namespace JM void get_infos(); - void toggle_is_cluster_head(bool checked); - protected: QWidget* _parent; BL::SALOMEServices * _salome_services; @@ -52,7 +50,8 @@ namespace JM QLineEdit * _username_line; QLineEdit * _applipath_line; QListWidget * _componentList; - QPushButton * _is_cluster_head; + QCheckBox * _can_launch_batch_jobs; + QCheckBox * _can_run_containers; QLineEdit * _working_directory; QLineEdit * _os_line; QLineEdit * _mem_mb_line; -- 2.39.2