2005-03-14 20:57:21 +00:00
|
|
|
/*
|
2005-11-05 19:57:48 +00:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2005-03-14 20:57:21 +00:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 12:43:37 +00:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2005-03-14 20:57:21 +00:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
#include "orte_config.h"
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2005-07-03 16:22:16 +00:00
|
|
|
#include "opal/class/opal_list.h"
|
2005-07-03 23:31:27 +00:00
|
|
|
#include "opal/util/output.h"
|
2005-09-10 07:57:50 +00:00
|
|
|
#include "opal/util/argv.h"
|
2005-10-07 22:24:52 +00:00
|
|
|
#include "opal/mca/mca.h"
|
|
|
|
#include "opal/mca/base/base.h"
|
|
|
|
#include "orte/include/orte_constants.h"
|
|
|
|
#include "orte/util/sys_info.h"
|
|
|
|
#include "orte/mca/ns/ns.h"
|
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
|
|
|
#include "orte/mca/ras/ras.h"
|
|
|
|
#include "orte/mca/ras/base/ras_base_node.h"
|
|
|
|
#include "orte/mca/rds/rds.h"
|
|
|
|
#include "orte/mca/rds/base/base.h"
|
|
|
|
#include "orte/mca/rds/hostfile/rds_hostfile.h"
|
|
|
|
#include "orte/mca/rds/hostfile/rds_hostfile_lex.h"
|
2005-03-14 20:57:21 +00:00
|
|
|
|
|
|
|
#include "runtime/runtime_types.h"
|
|
|
|
|
2005-08-11 19:51:50 +00:00
|
|
|
static orte_cellid_t local_cellid;
|
|
|
|
static bool need_cellid = true;
|
2005-03-14 20:57:21 +00:00
|
|
|
|
2005-09-10 07:57:50 +00:00
|
|
|
static void orte_rds_hostfile_parse_error(int token)
|
2005-03-14 20:57:21 +00:00
|
|
|
{
|
2005-09-10 07:57:50 +00:00
|
|
|
switch (token) {
|
|
|
|
case ORTE_RDS_HOSTFILE_STRING:
|
|
|
|
opal_output(0, "Error reading hostfile at line %d: token:%d %s\n",
|
|
|
|
orte_rds_hostfile_line, token, orte_rds_hostfile_value.sval);
|
|
|
|
break;
|
|
|
|
case ORTE_RDS_HOSTFILE_IPV4:
|
|
|
|
case ORTE_RDS_HOSTFILE_INT:
|
|
|
|
opal_output(0, "Error reading hostfile at line %d: token:%d %d\n",
|
|
|
|
orte_rds_hostfile_line, token, orte_rds_hostfile_value.ival);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
opal_output(0, "Error reading hostfile at line %d token:%d\n",
|
|
|
|
orte_rds_hostfile_line, token);
|
|
|
|
break;
|
|
|
|
}
|
2005-03-14 20:57:21 +00:00
|
|
|
}
|
|
|
|
|
2005-09-10 07:57:50 +00:00
|
|
|
/**
|
|
|
|
* Return the integer following an = (actually may only return positive ints)
|
|
|
|
*/
|
2005-03-14 20:57:21 +00:00
|
|
|
static int orte_rds_hostfile_parse_int(void)
|
|
|
|
{
|
2005-09-10 08:01:47 +00:00
|
|
|
if (ORTE_RDS_HOSTFILE_EQUAL != orte_rds_hostfile_lex())
|
2005-03-14 20:57:21 +00:00
|
|
|
return -1;
|
2005-09-10 08:01:47 +00:00
|
|
|
if (ORTE_RDS_HOSTFILE_INT != orte_rds_hostfile_lex())
|
2005-03-14 20:57:21 +00:00
|
|
|
return -1;
|
|
|
|
return orte_rds_hostfile_value.ival;
|
|
|
|
}
|
|
|
|
|
2005-09-10 07:57:50 +00:00
|
|
|
/**
|
|
|
|
* Return the string following an = (option to a keyword)
|
|
|
|
*/
|
|
|
|
static char * orte_rds_hostfile_parse_string(void)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
if (ORTE_RDS_HOSTFILE_EQUAL != orte_rds_hostfile_lex())
|
|
|
|
return NULL;
|
|
|
|
rc = orte_rds_hostfile_lex();
|
|
|
|
if (ORTE_RDS_HOSTFILE_STRING != rc)
|
|
|
|
return NULL;
|
|
|
|
return strdup(orte_rds_hostfile_value.sval);
|
|
|
|
}
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
|
2005-08-11 19:51:50 +00:00
|
|
|
static orte_ras_node_t* orte_rds_hostfile_lookup(opal_list_t* nodes, const char* name)
|
2005-03-14 20:57:21 +00:00
|
|
|
{
|
2005-07-03 16:22:16 +00:00
|
|
|
opal_list_item_t* item;
|
|
|
|
for(item = opal_list_get_first(nodes);
|
|
|
|
item != opal_list_get_end(nodes);
|
|
|
|
item = opal_list_get_next(item)) {
|
2005-08-11 19:51:50 +00:00
|
|
|
orte_ras_node_t* node = (orte_ras_node_t*)item;
|
2005-03-14 20:57:21 +00:00
|
|
|
if(strcmp(node->node_name, name) == 0) {
|
2005-07-03 16:22:16 +00:00
|
|
|
opal_list_remove_item(nodes, item);
|
2005-03-14 20:57:21 +00:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-07-03 16:22:16 +00:00
|
|
|
static int orte_rds_hostfile_parse_line(int token, opal_list_t* existing, opal_list_t* updates)
|
2005-03-14 20:57:21 +00:00
|
|
|
{
|
|
|
|
int rc;
|
2005-08-11 19:51:50 +00:00
|
|
|
orte_ras_node_t* node;
|
2005-05-26 21:44:45 +00:00
|
|
|
bool update = false;
|
|
|
|
bool got_count = false;
|
2005-03-14 20:57:21 +00:00
|
|
|
|
2005-09-10 07:57:50 +00:00
|
|
|
if (ORTE_RDS_HOSTFILE_STRING == token ||
|
|
|
|
ORTE_RDS_HOSTFILE_HOSTNAME == token ||
|
|
|
|
ORTE_RDS_HOSTFILE_IPV4 == token) {
|
|
|
|
char* value = orte_rds_hostfile_value.sval;
|
|
|
|
char** argv = opal_argv_split (value, '@');
|
|
|
|
char* node_name = NULL;
|
|
|
|
char* username = NULL;
|
|
|
|
int cnt;
|
|
|
|
|
|
|
|
cnt = opal_argv_count (argv);
|
|
|
|
if (1 == cnt) {
|
|
|
|
node_name = strdup(argv[0]);
|
|
|
|
} else if (2 == cnt) {
|
|
|
|
username = strdup(argv[0]);
|
|
|
|
node_name = strdup(argv[1]);
|
|
|
|
} else {
|
|
|
|
opal_output(0, "WARNING: Unhandeled user@host-combination\n"); /* XXX */
|
|
|
|
}
|
|
|
|
opal_argv_free (argv);
|
2005-03-14 20:57:21 +00:00
|
|
|
|
2005-06-01 19:30:05 +00:00
|
|
|
/* convert this into something globally unique */
|
|
|
|
if(strcmp(node_name, "localhost") == 0) {
|
2005-09-10 07:57:50 +00:00
|
|
|
/* Nodename has been allocated, that is for sure */
|
|
|
|
free (node_name);
|
|
|
|
node_name = strdup(orte_system_info.nodename);
|
2005-03-14 20:57:21 +00:00
|
|
|
}
|
2005-05-26 21:44:45 +00:00
|
|
|
|
|
|
|
/* Do we need to make a new node object? First check to see
|
|
|
|
if it's in the existing list. */
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-05-26 19:43:21 +00:00
|
|
|
if (NULL == (node = orte_rds_hostfile_lookup(existing, node_name))) {
|
2005-05-26 21:44:45 +00:00
|
|
|
|
|
|
|
/* If it wasn't, see if it's already in the updates list */
|
|
|
|
|
2005-09-10 08:01:47 +00:00
|
|
|
if (NULL == (node = orte_rds_hostfile_lookup(updates,
|
2005-05-26 21:44:45 +00:00
|
|
|
node_name))) {
|
2005-08-11 19:51:50 +00:00
|
|
|
node = OBJ_NEW(orte_ras_node_t);
|
2005-09-10 07:57:50 +00:00
|
|
|
node->node_name = node_name;
|
|
|
|
node->node_username = username;
|
2005-05-26 21:44:45 +00:00
|
|
|
node->node_slots = 0;
|
|
|
|
|
2005-05-25 16:23:13 +00:00
|
|
|
#if 0
|
2005-05-26 21:44:45 +00:00
|
|
|
/* get a new cellid for this node */
|
|
|
|
/* JMS Temporarily turned off until cell IDs are
|
|
|
|
properly handled elsewhere in the code */
|
2005-08-11 19:51:50 +00:00
|
|
|
/* JJH This assumes that each hostname listed should be
|
|
|
|
placed in a new cell. Is this accurate to the design?
|
|
|
|
*/
|
2005-09-10 08:01:47 +00:00
|
|
|
if (ORTE_SUCCESS !=
|
2005-05-26 21:44:45 +00:00
|
|
|
(rc = orte_ns.create_cellid(&(node->node_cellid),
|
|
|
|
"UNKNOWN-SITE",
|
|
|
|
node->node_name))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
2005-05-25 16:23:13 +00:00
|
|
|
#endif
|
2005-05-26 21:44:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Note that we need to set update to true regardless of
|
|
|
|
whether the node was found on the updates list or not.
|
|
|
|
If it was found, we just removed it (in
|
|
|
|
orte_rds_hostfile_lookup()), so the update puts it back
|
|
|
|
(potentially after updating it, of course). If it was
|
|
|
|
not found, then we have a new node instance that needs
|
|
|
|
to be added to the updates list. */
|
|
|
|
|
|
|
|
update = true;
|
2005-03-14 20:57:21 +00:00
|
|
|
}
|
2005-08-11 19:51:50 +00:00
|
|
|
else {
|
|
|
|
/* If it was in the existing list, then we can use its cellid
|
|
|
|
* to add the reset of the hosts in the file to. */
|
|
|
|
local_cellid = node->node_cellid;
|
|
|
|
need_cellid = false;
|
|
|
|
}
|
2005-03-14 20:57:21 +00:00
|
|
|
} else {
|
2005-09-10 07:57:50 +00:00
|
|
|
orte_rds_hostfile_parse_error(token);
|
2005-03-14 20:57:21 +00:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
2005-05-26 21:44:45 +00:00
|
|
|
got_count = false;
|
2005-03-14 20:57:21 +00:00
|
|
|
while (!orte_rds_hostfile_done) {
|
|
|
|
token = orte_rds_hostfile_lex();
|
2005-09-10 07:57:50 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
switch (token) {
|
|
|
|
case ORTE_RDS_HOSTFILE_DONE:
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
case ORTE_RDS_HOSTFILE_NEWLINE:
|
|
|
|
goto done;
|
|
|
|
|
2005-09-10 07:57:50 +00:00
|
|
|
case ORTE_RDS_HOSTFILE_USERNAME:
|
|
|
|
node->node_username = orte_rds_hostfile_parse_string();
|
|
|
|
break;
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
case ORTE_RDS_HOSTFILE_COUNT:
|
|
|
|
case ORTE_RDS_HOSTFILE_CPU:
|
|
|
|
case ORTE_RDS_HOSTFILE_SLOTS:
|
|
|
|
rc = orte_rds_hostfile_parse_int();
|
|
|
|
if (rc < 0) {
|
|
|
|
OBJ_RELEASE(node);
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
2005-05-26 21:44:45 +00:00
|
|
|
node->node_slots += rc;
|
|
|
|
update = true;
|
|
|
|
got_count = true;
|
|
|
|
|
2005-03-18 23:40:08 +00:00
|
|
|
/* Ensure that node_slots_max >= node_slots */
|
2005-03-23 17:43:24 +00:00
|
|
|
if (node->node_slots_max != 0 && node->node_slots_max < node->node_slots) {
|
2005-03-18 23:40:08 +00:00
|
|
|
node->node_slots_max = node->node_slots;
|
|
|
|
}
|
2005-03-14 20:57:21 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORTE_RDS_HOSTFILE_SLOTS_MAX:
|
|
|
|
rc = orte_rds_hostfile_parse_int();
|
|
|
|
if (rc < 0) {
|
|
|
|
OBJ_RELEASE(node);
|
|
|
|
return OMPI_ERROR;
|
2005-03-18 23:40:08 +00:00
|
|
|
}
|
2005-04-15 13:42:14 +00:00
|
|
|
/* Only take this update if it puts us >= node_slots */
|
|
|
|
if (((size_t) rc) >= node->node_slots) {
|
2005-03-18 23:40:08 +00:00
|
|
|
if (node->node_slots_max != (size_t)rc) {
|
|
|
|
node->node_slots_max = rc;
|
2005-05-26 21:44:45 +00:00
|
|
|
update = true;
|
2005-03-18 23:40:08 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
|
|
|
|
OBJ_RELEASE(node);
|
|
|
|
return OMPI_ERROR;
|
2005-03-14 20:57:21 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2005-09-10 07:57:50 +00:00
|
|
|
orte_rds_hostfile_parse_error(token);
|
2005-03-14 20:57:21 +00:00
|
|
|
OBJ_RELEASE(node);
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
2005-05-26 21:44:45 +00:00
|
|
|
if (update) {
|
|
|
|
if (!got_count) {
|
|
|
|
++node->node_slots;
|
|
|
|
}
|
2005-07-03 16:22:16 +00:00
|
|
|
opal_list_append(updates, &node->super);
|
2005-03-14 20:57:21 +00:00
|
|
|
} else {
|
|
|
|
OBJ_RELEASE(node);
|
|
|
|
}
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse the specified file into a node list.
|
|
|
|
*/
|
|
|
|
|
2005-07-03 16:22:16 +00:00
|
|
|
static int orte_rds_hostfile_parse(const char *hostfile, opal_list_t* existing, opal_list_t* updates)
|
2005-03-14 20:57:21 +00:00
|
|
|
{
|
|
|
|
int token;
|
|
|
|
int rc = ORTE_SUCCESS;
|
|
|
|
|
2005-07-03 22:45:48 +00:00
|
|
|
OPAL_LOCK(&mca_rds_hostfile_component.lock);
|
2005-03-14 20:57:21 +00:00
|
|
|
|
|
|
|
orte_rds_hostfile_done = false;
|
|
|
|
orte_rds_hostfile_in = fopen(hostfile, "r");
|
|
|
|
if (NULL == orte_rds_hostfile_in) {
|
|
|
|
rc = ORTE_ERR_NOT_FOUND;
|
|
|
|
goto unlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!orte_rds_hostfile_done) {
|
|
|
|
token = orte_rds_hostfile_lex();
|
2005-09-10 07:57:50 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
switch (token) {
|
|
|
|
case ORTE_RDS_HOSTFILE_DONE:
|
|
|
|
orte_rds_hostfile_done = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORTE_RDS_HOSTFILE_NEWLINE:
|
|
|
|
break;
|
|
|
|
|
2005-09-10 07:57:50 +00:00
|
|
|
/*
|
|
|
|
* This looks odd, since we have several forms of host-definitions:
|
|
|
|
* hostname just plain as it is, being a ORTE_RDS_HOSTFILE_STRING
|
|
|
|
* IP4s and user@IPv4s
|
|
|
|
* hostname.domain and user@hostname.domain
|
|
|
|
*/
|
2005-03-14 20:57:21 +00:00
|
|
|
case ORTE_RDS_HOSTFILE_STRING:
|
2005-09-10 07:57:50 +00:00
|
|
|
case ORTE_RDS_HOSTFILE_HOSTNAME:
|
|
|
|
case ORTE_RDS_HOSTFILE_IPV4:
|
2005-03-14 20:57:21 +00:00
|
|
|
rc = orte_rds_hostfile_parse_line(token, existing, updates);
|
|
|
|
if (ORTE_SUCCESS != rc) {
|
|
|
|
goto unlock;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2005-09-10 07:57:50 +00:00
|
|
|
orte_rds_hostfile_parse_error(token);
|
2005-03-14 20:57:21 +00:00
|
|
|
goto unlock;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(orte_rds_hostfile_in);
|
|
|
|
orte_rds_hostfile_in = NULL;
|
|
|
|
|
|
|
|
unlock:
|
2005-07-03 22:45:48 +00:00
|
|
|
OPAL_UNLOCK(&mca_rds_hostfile_component.lock);
|
2005-03-14 20:57:21 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse the default file as specified by the MCA parameter,
|
|
|
|
* rds_hostfile_path, and add the nodes to the registry.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int orte_rds_hostfile_query(void)
|
|
|
|
{
|
2005-07-03 16:22:16 +00:00
|
|
|
opal_list_t existing;
|
2005-08-11 19:51:50 +00:00
|
|
|
opal_list_t updates, rds_updates;
|
2005-07-03 16:22:16 +00:00
|
|
|
opal_list_item_t *item;
|
2005-09-03 01:22:11 +00:00
|
|
|
orte_rds_cell_desc_t *rds_item;
|
|
|
|
orte_rds_cell_attr_t *new_attr;
|
|
|
|
orte_ras_node_t *ras_item;
|
2005-03-14 20:57:21 +00:00
|
|
|
int rc;
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-07-03 16:22:16 +00:00
|
|
|
OBJ_CONSTRUCT(&existing, opal_list_t);
|
|
|
|
OBJ_CONSTRUCT(&updates, opal_list_t);
|
2005-08-11 19:51:50 +00:00
|
|
|
OBJ_CONSTRUCT(&rds_updates, opal_list_t);
|
2005-10-07 22:24:52 +00:00
|
|
|
rc = orte_ras_base_node_query(&existing);
|
2005-03-14 20:57:21 +00:00
|
|
|
if(ORTE_SUCCESS != rc) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2005-03-18 23:40:08 +00:00
|
|
|
rc = mca_base_param_find("rds", "hostfile", "path");
|
|
|
|
mca_base_param_lookup_string(rc, &mca_rds_hostfile_component.path);
|
2005-08-11 19:51:50 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
rc = orte_rds_hostfile_parse(mca_rds_hostfile_component.path, &existing, &updates);
|
|
|
|
if (ORTE_ERR_NOT_FOUND == rc) {
|
2005-03-18 03:43:59 +00:00
|
|
|
if(mca_rds_hostfile_component.default_hostfile) {
|
|
|
|
rc = ORTE_SUCCESS;
|
|
|
|
} else {
|
2005-07-03 23:31:27 +00:00
|
|
|
opal_output(0, "orte_rds_hostfile: could not open %s\n", mca_rds_hostfile_component.path);
|
2005-03-18 03:43:59 +00:00
|
|
|
}
|
2005-03-14 20:57:21 +00:00
|
|
|
goto cleanup;
|
2005-05-26 21:44:45 +00:00
|
|
|
} else if (ORTE_SUCCESS != rc) {
|
|
|
|
goto cleanup;
|
2005-03-14 20:57:21 +00:00
|
|
|
}
|
2005-08-11 19:51:50 +00:00
|
|
|
|
|
|
|
if ( !opal_list_is_empty(&updates) ) {
|
|
|
|
|
|
|
|
/* Convert RAS update list to RDS update list */
|
2005-09-03 01:22:11 +00:00
|
|
|
for ( ras_item = (orte_ras_node_t*)opal_list_get_first(&updates);
|
|
|
|
ras_item != (orte_ras_node_t*)opal_list_get_end(&updates);
|
|
|
|
ras_item = (orte_ras_node_t*)opal_list_get_next(ras_item)) {
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-08-11 19:51:50 +00:00
|
|
|
rds_item = OBJ_NEW(orte_rds_cell_desc_t);
|
|
|
|
if (NULL == rds_item) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
rds_item->site = strdup("Hostfile");
|
|
|
|
rds_item->name = strdup(ras_item->node_name);
|
|
|
|
if (need_cellid) {
|
|
|
|
#if 0 /* JJH Repair when cellid's are fixed */
|
|
|
|
/* Create a new cellid for this hostfile */
|
|
|
|
rc = orte_ns.create_cellid(&local_cellid, rds_item->site, rds_item->name);
|
|
|
|
if (ORTE_SUCCESS != rc) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
local_cellid = 0;
|
|
|
|
need_cellid = false;
|
|
|
|
}
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-08-11 19:51:50 +00:00
|
|
|
rds_item->cellid = local_cellid;
|
|
|
|
ras_item->node_cellid = local_cellid;
|
|
|
|
|
|
|
|
new_attr = OBJ_NEW(orte_rds_cell_attr_t);
|
|
|
|
if (NULL == new_attr) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
new_attr->keyval.key = strdup(ORTE_RDS_NAME);
|
|
|
|
new_attr->keyval.type = ORTE_STRING;
|
|
|
|
new_attr->keyval.value.strptr = strdup(ras_item->node_name);
|
|
|
|
opal_list_append(&(rds_item->attributes), &new_attr->super);
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-08-11 19:51:50 +00:00
|
|
|
new_attr = OBJ_NEW(orte_rds_cell_attr_t);
|
|
|
|
if (NULL == new_attr) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
new_attr->keyval.key = strdup(ORTE_CELLID_KEY);
|
|
|
|
new_attr->keyval.type = ORTE_CELLID;
|
|
|
|
new_attr->keyval.value.cellid = rds_item->cellid;
|
|
|
|
opal_list_append(&(rds_item->attributes), &new_attr->super);
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-08-11 19:51:50 +00:00
|
|
|
opal_list_append(&rds_updates, &rds_item->super);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Insert the new node into the RDS */
|
|
|
|
rc = orte_rds.store_resource(&rds_updates);
|
|
|
|
if (ORTE_SUCCESS != rc) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Then the RAS, since we can assume that any
|
|
|
|
* resources listed in the hostfile have been
|
|
|
|
* already allocated for our use.
|
|
|
|
*/
|
2005-10-07 22:24:52 +00:00
|
|
|
rc = orte_ras_base_node_insert(&updates);
|
2005-08-11 19:51:50 +00:00
|
|
|
if (ORTE_SUCCESS != rc) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2005-03-22 00:31:17 +00:00
|
|
|
}
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
cleanup:
|
2005-04-01 19:51:47 +00:00
|
|
|
if (NULL != mca_rds_hostfile_component.path) {
|
|
|
|
free(mca_rds_hostfile_component.path);
|
2005-04-13 17:51:43 +00:00
|
|
|
mca_rds_hostfile_component.path = NULL;
|
2005-04-01 19:51:47 +00:00
|
|
|
}
|
2005-09-10 08:01:47 +00:00
|
|
|
|
2005-07-03 16:22:16 +00:00
|
|
|
while(NULL != (item = opal_list_remove_first(&existing))) {
|
2005-03-14 20:57:21 +00:00
|
|
|
OBJ_RELEASE(item);
|
|
|
|
}
|
2005-05-25 16:23:13 +00:00
|
|
|
|
2005-07-03 16:22:16 +00:00
|
|
|
while(NULL != (item = opal_list_remove_first(&updates))) {
|
2005-03-14 20:57:21 +00:00
|
|
|
OBJ_RELEASE(item);
|
|
|
|
}
|
2005-08-11 19:51:50 +00:00
|
|
|
|
2005-09-03 01:22:11 +00:00
|
|
|
while (NULL != (rds_item = (orte_rds_cell_desc_t*)opal_list_remove_first(&rds_updates))) {
|
|
|
|
while (NULL != (new_attr = (orte_rds_cell_attr_t*)opal_list_remove_first(&(rds_item->attributes)))) {
|
|
|
|
OBJ_RELEASE(new_attr);
|
2005-08-11 19:51:50 +00:00
|
|
|
}
|
2005-09-02 21:01:59 +00:00
|
|
|
OBJ_RELEASE(rds_item);
|
2005-08-11 19:51:50 +00:00
|
|
|
}
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
OBJ_DESTRUCT(&existing);
|
|
|
|
OBJ_DESTRUCT(&updates);
|
2005-08-11 19:51:50 +00:00
|
|
|
OBJ_DESTRUCT(&rds_updates);
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int orte_rds_hostfile_finalize(void)
|
|
|
|
{
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
orte_rds_base_module_t orte_rds_hostfile_module = {
|
|
|
|
orte_rds_hostfile_query,
|
2005-08-11 19:51:50 +00:00
|
|
|
orte_rds_base_store_resource,
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_rds_hostfile_finalize
|
|
|
|
};
|