diff --git a/orte/mca/plm/base/plm_base_launch_support.c b/orte/mca/plm/base/plm_base_launch_support.c index e6ccea6c82..c2f6f2dd98 100644 --- a/orte/mca/plm/base/plm_base_launch_support.c +++ b/orte/mca/plm/base/plm_base_launch_support.c @@ -16,6 +16,7 @@ * Copyright (c) 2013-2016 Intel, Inc. All rights reserved. * Copyright (c) 2014-2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2016 IBM Corporation. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -1528,7 +1529,7 @@ int orte_plm_base_setup_virtual_machine(orte_job_t *jdata) bool one_filter = false; int num_nodes; bool default_hostfile_used; - char *hosts; + char *hosts = NULL; bool singleton=false; bool multi_sim = false; diff --git a/orte/mca/rmaps/base/rmaps_base_support_fns.c b/orte/mca/rmaps/base/rmaps_base_support_fns.c index 8b9a3b0bfb..2b1a1ccdc3 100644 --- a/orte/mca/rmaps/base/rmaps_base_support_fns.c +++ b/orte/mca/rmaps/base/rmaps_base_support_fns.c @@ -13,6 +13,7 @@ * Copyright (c) 2011-2012 Los Alamos National Security, LLC. * All rights reserved. * Copyright (c) 2014-2016 Intel, Inc. All rights reserved. + * Copyright (c) 2016 IBM Corporation. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -147,7 +148,7 @@ int orte_rmaps_base_get_target_nodes(opal_list_t *allocated_nodes, orte_std_cntr orte_job_t *daemons; bool novm; opal_list_t nodes; - char *hosts; + char *hosts = NULL; /** set default answer */ *total_num_slots = 0; diff --git a/orte/mca/rmaps/rank_file/rmaps_rank_file.c b/orte/mca/rmaps/rank_file/rmaps_rank_file.c index 6676d9d852..ba39ed7c31 100644 --- a/orte/mca/rmaps/rank_file/rmaps_rank_file.c +++ b/orte/mca/rmaps/rank_file/rmaps_rank_file.c @@ -17,6 +17,7 @@ * Copyright (c) 2014-2016 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2016 IBM Corporation. All rights reserved. * * $COPYRIGHT$ * @@ -33,6 +34,9 @@ #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ +#if HAVE_ARPA_INET_H +#include +#endif #include #include "opal/util/argv.h" @@ -488,6 +492,20 @@ static int orte_rmaps_rank_file_parse(const char *rankfile) goto unlock; } opal_argv_free (argv); + + // Strip off the FQDN if present + if( !orte_keep_fqdn_hostnames ) { + char *ptr; + struct in_addr buf; + /* if the nodename is an IP address, do not mess with it! */ + if (0 == inet_pton(AF_INET, node_name, &buf) && + 0 == inet_pton(AF_INET6, node_name, &buf)) { + if (NULL != (ptr = strchr(node_name, '.'))) { + *ptr = '\0'; + } + } + } + /* check the rank item */ if (NULL == rfmap) { orte_show_help("help-rmaps_rank_file.txt", "bad-syntax", true, rankfile); diff --git a/orte/mca/rmaps/seq/rmaps_seq.c b/orte/mca/rmaps/seq/rmaps_seq.c index 0f7f5d24bf..d2da3c5035 100644 --- a/orte/mca/rmaps/seq/rmaps_seq.c +++ b/orte/mca/rmaps/seq/rmaps_seq.c @@ -15,6 +15,7 @@ * Copyright (c) 2014-2016 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2016 IBM Corporation. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -70,9 +71,11 @@ static void sn_des(seq_node_t *p) { if (NULL != p->hostname) { free(p->hostname); + p->hostname = NULL; } if (NULL != p->cpuset) { free(p->cpuset); + p->cpuset = NULL; } } OBJ_CLASS_INSTANCE(seq_node_t, @@ -101,7 +104,7 @@ static int orte_rmaps_seq_map(orte_job_t *jdata) opal_list_t node_list, *seq_list, sq_list; orte_proc_t *proc; mca_base_component_t *c = &mca_rmaps_seq_component.base_version; - char *hosts, *sep, *eptr; + char *hosts = NULL, *sep, *eptr; FILE *fp; opal_hwloc_resource_type_t rtype; @@ -156,7 +159,7 @@ static int orte_rmaps_seq_map(orte_job_t *jdata) /* if there is a default hostfile, go and get its ordered list of nodes */ OBJ_CONSTRUCT(&default_seq_list, opal_list_t); if (NULL != orte_default_hostfile) { - char *hstname; + char *hstname = NULL; /* open the file */ fp = fopen(orte_default_hostfile, "r"); if (NULL == fp) { @@ -170,6 +173,11 @@ static int orte_rmaps_seq_map(orte_job_t *jdata) /* blank line - ignore */ continue; } + if( '#' == hstname[0] ) { + free(hstname); + /* Comment line - ignore */ + continue; + } sq = OBJ_NEW(seq_node_t); if (NULL != (sep = strchr(hstname, ' '))) { *sep = '\0'; @@ -182,6 +190,21 @@ static int orte_rmaps_seq_map(orte_job_t *jdata) *(eptr+1) = 0; sq->cpuset = strdup(sep); } + + // Strip off the FQDN if present + if( !orte_keep_fqdn_hostnames ) { + char *ptr; + struct in_addr buf; + + /* if the nodename is an IP address, do not mess with it! */ + if (0 == inet_pton(AF_INET, hstname, &buf) && + 0 == inet_pton(AF_INET6, hstname, &buf)) { + if (NULL != (ptr = strchr(hstname, '.'))) { + *ptr = '\0'; + } + } + } + sq->hostname = hstname; opal_list_append(&default_seq_list, &sq->super); } @@ -255,6 +278,16 @@ static int orte_rmaps_seq_map(orte_job_t *jdata) goto error; } while (NULL != (hstname = orte_getline(fp))) { + if (0 == strlen(hstname)) { + free(hstname); + /* blank line - ignore */ + continue; + } + if( '#' == hstname[0] ) { + free(hstname); + /* Comment line - ignore */ + continue; + } sq = OBJ_NEW(seq_node_t); if (NULL != (sep = strchr(hstname, ' '))) { *sep = '\0'; @@ -267,6 +300,20 @@ static int orte_rmaps_seq_map(orte_job_t *jdata) *(eptr+1) = 0; sq->cpuset = strdup(sep); } + + // Strip off the FQDN if present + if( !orte_keep_fqdn_hostnames ) { + char *ptr; + struct in_addr buf; + /* if the nodename is an IP address, do not mess with it! */ + if (0 == inet_pton(AF_INET, hstname, &buf) && + 0 == inet_pton(AF_INET6, hstname, &buf)) { + if (NULL != (ptr = strchr(hstname, '.'))) { + (*ptr) = '\0'; + } + } + } + sq->hostname = hstname; opal_list_append(&sq_list, &sq->super); } diff --git a/orte/util/dash_host/dash_host.c b/orte/util/dash_host/dash_host.c index 34415c1231..b6663da84a 100644 --- a/orte/util/dash_host/dash_host.c +++ b/orte/util/dash_host/dash_host.c @@ -13,6 +13,7 @@ * Copyright (c) 2014-2016 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2016 IBM Corporation. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -23,6 +24,9 @@ #include "orte_config.h" #include +#if HAVE_ARPA_INET_H +#include +#endif #include "orte/constants.h" #include "orte/types.h" @@ -207,6 +211,19 @@ int orte_util_add_dash_host_nodes(opal_list_t *nodes, ndname = mini_map[i]; } + // Strip off the FQDN if present + if( !orte_keep_fqdn_hostnames ) { + char *ptr; + struct in_addr buf; + /* if the nodename is an IP address, do not mess with it! */ + if (0 == inet_pton(AF_INET, ndname, &buf) && + 0 == inet_pton(AF_INET6, ndname, &buf)) { + if (NULL != (ptr = strchr(ndname, '.'))) { + *ptr = '\0'; + } + } + } + /* see if the node is already on the list */ found = false; OPAL_LIST_FOREACH(node, &adds, orte_node_t) { diff --git a/orte/util/hostfile/hostfile.c b/orte/util/hostfile/hostfile.c index 80efa36b92..ee0ecf451b 100644 --- a/orte/util/hostfile/hostfile.c +++ b/orte/util/hostfile/hostfile.c @@ -15,6 +15,7 @@ * Copyright (c) 2013-2014 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2016 IBM Corporation. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -27,6 +28,9 @@ #ifdef HAVE_UNISTD_H #include #endif +#if HAVE_ARPA_INET_H +#include +#endif #include #include #include @@ -164,6 +168,19 @@ static int hostfile_parse_line(int token, opal_list_t* updates, } opal_argv_free (argv); + // Strip off the FQDN if present + if( !orte_keep_fqdn_hostnames ) { + char *ptr; + struct in_addr buf; + /* if the nodename is an IP address, do not mess with it! */ + if (0 == inet_pton(AF_INET, node_name, &buf) && + 0 == inet_pton(AF_INET6, node_name, &buf)) { + if (NULL != (ptr = strchr(node_name, '.'))) { + *ptr = '\0'; + } + } + } + /* if the first letter of the name is '^', then this is a node * to be excluded. Remove the ^ character so the nodename is * usable, and put it on the exclude list @@ -270,6 +287,20 @@ static int hostfile_parse_line(int token, opal_list_t* updates, opal_output(0, "WARNING: Unhandled user@host-combination\n"); /* XXX */ } opal_argv_free (argv); + + // Strip off the FQDN if present + if( !orte_keep_fqdn_hostnames ) { + char *ptr; + struct in_addr buf; + /* if the nodename is an IP address, do not mess with it! */ + if (0 == inet_pton(AF_INET, node_name, &buf) && + 0 == inet_pton(AF_INET6, node_name, &buf)) { + if (NULL != (ptr = strchr(node_name, '.'))) { + *ptr = '\0'; + } + } + } + /* Do we need to make a new node object? */ if (NULL == (node = hostfile_lookup(updates, node_name))) { node = OBJ_NEW(orte_node_t);