2005-03-14 23:57:21 +03:00
|
|
|
/*
|
2005-11-05 22:57:48 +03: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-09-01 19:50:38 +04:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2005-03-14 23:57:21 +03:00
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2005-03-14 23:57:21 +03:00
|
|
|
* $COPYRIGHT$
|
2005-09-01 19:50:38 +04:00
|
|
|
*
|
2005-03-14 23:57:21 +03:00
|
|
|
* Additional copyrights may follow
|
2005-09-01 19:50:38 +04:00
|
|
|
*
|
2005-03-14 23:57:21 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
#include "orte_config.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
2007-04-01 20:16:54 +04:00
|
|
|
#endif /* HAVE_UNISTD_H */
|
2005-03-14 23:57:21 +03:00
|
|
|
#include <stdlib.h>
|
|
|
|
#ifdef HAVE_PWD_H
|
|
|
|
#include <pwd.h>
|
2007-04-01 20:16:54 +04:00
|
|
|
#endif /* HAVE_PWD_H */
|
2005-03-14 23:57:21 +03:00
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "orte/orte_constants.h"
|
2005-09-01 19:50:38 +04:00
|
|
|
#include "opal/mca/base/base.h"
|
|
|
|
#include "opal/mca/base/mca_base_param.h"
|
|
|
|
#include "orte/mca/ns/ns_types.h"
|
|
|
|
#include "orte/mca/schema/schema_types.h"
|
2005-07-04 03:31:27 +04:00
|
|
|
#include "opal/util/output.h"
|
2005-09-01 19:50:38 +04:00
|
|
|
#include "orte/util/proc_info.h"
|
|
|
|
#include "orte/util/sys_info.h"
|
2005-03-14 23:57:21 +03:00
|
|
|
|
2005-09-01 19:50:38 +04:00
|
|
|
#include "orte/util/univ_info.h"
|
2005-03-14 23:57:21 +03:00
|
|
|
|
2006-06-29 01:03:31 +04:00
|
|
|
static bool universe_info_has_been_created = false;
|
|
|
|
orte_universe_t orte_universe_info;
|
|
|
|
|
|
|
|
void orte_universe_construct(orte_universe_t *obj);
|
|
|
|
void orte_universe_destruct( orte_universe_t *obj);
|
|
|
|
|
|
|
|
OBJ_CLASS_INSTANCE(orte_universe_t,
|
|
|
|
opal_list_item_t,
|
|
|
|
orte_universe_construct,
|
|
|
|
orte_universe_destruct);
|
|
|
|
|
|
|
|
void orte_universe_construct(orte_universe_t *obj) {
|
|
|
|
obj->state = ORTE_UNIVERSE_STATE_PRE_INIT;
|
|
|
|
obj->persistence = false;
|
|
|
|
obj->console = false;
|
|
|
|
obj->console_connected = false;
|
|
|
|
|
2006-11-06 18:28:38 +03:00
|
|
|
obj->name = NULL;
|
|
|
|
obj->default_name = false;
|
|
|
|
obj->host = NULL;
|
|
|
|
obj->uid = NULL;
|
|
|
|
obj->scope = NULL;
|
|
|
|
obj->seed_uri = NULL;
|
|
|
|
obj->scriptfile = NULL;
|
2006-06-29 01:03:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void orte_universe_destruct( orte_universe_t *obj) {
|
|
|
|
if (NULL != obj->name) {
|
|
|
|
free(obj->name);
|
|
|
|
obj->name = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL != obj->host) {
|
|
|
|
free(obj->host);
|
|
|
|
obj->host = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL != obj->uid) {
|
|
|
|
free(obj->uid);
|
|
|
|
obj->uid = NULL;
|
|
|
|
}
|
2005-03-14 23:57:21 +03:00
|
|
|
|
2006-06-29 01:03:31 +04:00
|
|
|
if (NULL != obj->scope) {
|
|
|
|
free(obj->scope);
|
|
|
|
obj->scope = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL != obj->seed_uri) {
|
|
|
|
free(obj->seed_uri);
|
|
|
|
obj->seed_uri = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL != obj->scriptfile) {
|
|
|
|
free(obj->scriptfile);
|
|
|
|
obj->scriptfile = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
obj->state = ORTE_UNIVERSE_STATE_PRE_INIT;
|
|
|
|
obj->persistence = false;
|
|
|
|
obj->console = false;
|
|
|
|
obj->console_connected = false;
|
|
|
|
}
|
2005-03-14 23:57:21 +03:00
|
|
|
|
|
|
|
int orte_univ_info(void)
|
|
|
|
{
|
|
|
|
int id, tmp;
|
2005-05-13 01:44:23 +04:00
|
|
|
char *tmpname=NULL, *tptr, *ptr;
|
2005-09-01 19:50:38 +04:00
|
|
|
|
2006-06-29 01:03:31 +04:00
|
|
|
if(!universe_info_has_been_created) {
|
|
|
|
OBJ_CONSTRUCT(&orte_universe_info, orte_universe_t);
|
|
|
|
universe_info_has_been_created = true;
|
|
|
|
}
|
|
|
|
|
2005-09-03 01:07:21 +04:00
|
|
|
if (ORTE_UNIVERSE_STATE_PRE_INIT == orte_universe_info.state) {
|
2005-05-13 01:44:23 +04:00
|
|
|
id = mca_base_param_register_string("universe", NULL, NULL, NULL, NULL);
|
|
|
|
mca_base_param_lookup_string(id, &tmpname);
|
2005-09-01 19:50:38 +04:00
|
|
|
|
|
|
|
if (NULL != tmpname) {
|
2005-05-13 01:44:23 +04:00
|
|
|
/* Universe name info is passed as userid@hostname:univ_name */
|
|
|
|
/* extract the userid from the universe option, if provided */
|
|
|
|
tptr = tmpname;
|
|
|
|
if (NULL != (ptr = strchr(tptr, '@'))) {
|
|
|
|
*ptr = '\0';
|
|
|
|
orte_universe_info.uid = strdup(tptr);
|
|
|
|
ptr++;
|
|
|
|
tptr = ptr;
|
|
|
|
} else {
|
|
|
|
if (NULL == orte_system_info.user) {
|
|
|
|
orte_sys_info();
|
|
|
|
}
|
|
|
|
orte_universe_info.uid = strdup(orte_system_info.user);
|
|
|
|
}
|
2005-09-01 19:50:38 +04:00
|
|
|
|
2005-05-13 01:44:23 +04:00
|
|
|
/* extract the hostname, if provided */
|
|
|
|
if (NULL != (ptr = strchr(tptr, ':'))) {
|
|
|
|
*ptr = '\0';
|
|
|
|
orte_universe_info.host = strdup(tptr);
|
|
|
|
ptr++;
|
|
|
|
tptr = ptr;
|
|
|
|
} else {
|
|
|
|
orte_universe_info.host = strdup(orte_system_info.nodename);
|
|
|
|
}
|
2005-09-01 19:50:38 +04:00
|
|
|
|
2005-05-13 01:44:23 +04:00
|
|
|
/* now copy the universe name into the universe_info structure */
|
|
|
|
orte_universe_info.name = strdup(tptr);
|
2006-11-06 18:28:38 +03:00
|
|
|
|
|
|
|
/* indicate that the universe name was provided */
|
|
|
|
orte_universe_info.default_name = false;
|
|
|
|
|
2005-05-13 01:44:23 +04:00
|
|
|
} else {
|
|
|
|
/* if nothing was provided, then initialize the user and nodename
|
|
|
|
* to the local values
|
|
|
|
*/
|
|
|
|
orte_universe_info.uid = strdup(orte_system_info.user);
|
|
|
|
orte_universe_info.host = strdup(orte_system_info.nodename);
|
2006-06-29 01:03:31 +04:00
|
|
|
/* and the universe name to default-universe-PID */
|
|
|
|
asprintf(&orte_universe_info.name, "%s-%d", ORTE_DEFAULT_UNIVERSE, getpid());
|
2006-11-06 18:28:38 +03:00
|
|
|
|
|
|
|
/* indicate that the universe name is a default one */
|
|
|
|
orte_universe_info.default_name = true;
|
2005-05-13 01:44:23 +04:00
|
|
|
}
|
|
|
|
|
2005-03-24 18:45:44 +03:00
|
|
|
id = mca_base_param_register_int("universe", "persistence", NULL, NULL, orte_universe_info.persistence);
|
2005-03-19 02:40:08 +03:00
|
|
|
mca_base_param_lookup_int(id, &tmp);
|
2006-08-28 22:59:16 +04:00
|
|
|
orte_universe_info.persistence = OPAL_INT_TO_BOOL(tmp);
|
2005-09-01 19:50:38 +04:00
|
|
|
|
2005-03-24 18:45:44 +03:00
|
|
|
id = mca_base_param_register_string("universe", "scope", NULL, NULL, orte_universe_info.scope);
|
2005-03-19 02:40:08 +03:00
|
|
|
mca_base_param_lookup_string(id, &(orte_universe_info.scope));
|
2005-09-01 19:50:38 +04:00
|
|
|
|
2005-03-24 18:45:44 +03:00
|
|
|
id = mca_base_param_register_int("universe", "console", NULL, NULL, orte_universe_info.console);
|
2005-03-19 02:40:08 +03:00
|
|
|
mca_base_param_lookup_int(id, &tmp);
|
2006-08-28 22:59:16 +04:00
|
|
|
orte_universe_info.console = OPAL_INT_TO_BOOL(tmp);
|
2005-09-01 19:50:38 +04:00
|
|
|
|
2005-03-24 18:45:44 +03:00
|
|
|
id = mca_base_param_register_string("universe", "uri", NULL, NULL, orte_universe_info.seed_uri);
|
2005-03-19 02:40:08 +03:00
|
|
|
mca_base_param_lookup_string(id, &(orte_universe_info.seed_uri));
|
2005-09-01 19:50:38 +04:00
|
|
|
|
2005-03-19 02:40:08 +03:00
|
|
|
/* console connected is set elsewhere */
|
2005-03-24 18:45:44 +03:00
|
|
|
id = mca_base_param_register_string("universe", "script", NULL, NULL, orte_universe_info.scriptfile);
|
2005-03-19 02:40:08 +03:00
|
|
|
mca_base_param_lookup_string(id, &(orte_universe_info.scriptfile));
|
2005-03-14 23:57:21 +03:00
|
|
|
|
2005-09-03 01:07:21 +04:00
|
|
|
orte_universe_info.state = ORTE_UNIVERSE_STATE_INIT;
|
2005-03-14 23:57:21 +03:00
|
|
|
}
|
2005-09-01 19:50:38 +04:00
|
|
|
|
2005-03-19 02:40:08 +03:00
|
|
|
return(ORTE_SUCCESS);
|
|
|
|
}
|
2005-03-14 23:57:21 +03:00
|
|
|
|
|
|
|
|
2005-03-19 02:40:08 +03:00
|
|
|
int orte_univ_info_finalize(void)
|
|
|
|
{
|
2006-06-29 01:03:31 +04:00
|
|
|
OBJ_DESTRUCT(&orte_universe_info);
|
2005-05-22 07:11:33 +04:00
|
|
|
|
2005-03-19 02:40:08 +03:00
|
|
|
return ORTE_SUCCESS;
|
2005-03-14 23:57:21 +03:00
|
|
|
}
|