Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit 5aabc18

Browse files
authored
Merge pull request #1354 from jjhursey/topic/mixed-hostname
orte: Expand the application of !orte_keep_fqdn_hostnames
2 parents 60a418d + 112ecc6 commit 5aabc18

File tree

7 files changed

+91
-19
lines changed

7 files changed

+91
-19
lines changed

orte/mca/plm/base/plm_base_launch_support.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved.
1717
* Copyright (c) 2014-2015 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
19+
* Copyright (c) 2016 IBM Corporation. All rights reserved.
1920
* $COPYRIGHT$
2021
*
2122
* Additional copyrights may follow
@@ -1491,7 +1492,7 @@ int orte_plm_base_setup_virtual_machine(orte_job_t *jdata)
14911492
bool one_filter = false;
14921493
int num_nodes;
14931494
bool default_hostfile_used;
1494-
char *hosts;
1495+
char *hosts = NULL;
14951496
bool singleton=false;
14961497

14971498
OPAL_OUTPUT_VERBOSE((5, orte_plm_base_framework.framework_output,

orte/mca/rmaps/base/rmaps_base_support_fns.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Copyright (c) 2011-2012 Los Alamos National Security, LLC.
1414
* All rights reserved.
1515
* Copyright (c) 2014 Intel, Inc. All rights reserved.
16+
* Copyright (c) 2016 IBM Corporation. All rights reserved.
1617
* $COPYRIGHT$
1718
*
1819
* Additional copyrights may follow
@@ -147,7 +148,7 @@ int orte_rmaps_base_get_target_nodes(opal_list_t *allocated_nodes, orte_std_cntr
147148
orte_job_t *daemons;
148149
bool novm;
149150
opal_list_t nodes;
150-
char *hosts;
151+
char *hosts = NULL;
151152

152153
/** set default answer */
153154
*total_num_slots = 0;

orte/mca/rmaps/rank_file/rmaps_rank_file.c

+11
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* Copyright (c) 2014-2016 Intel, Inc. All rights reserved.
1818
* Copyright (c) 2015 Research Organization for Information Science
1919
* and Technology (RIST). All rights reserved.
20+
* Copyright (c) 2016 IBM Corporation. All rights reserved.
2021
*
2122
* $COPYRIGHT$
2223
*
@@ -37,6 +38,7 @@
3738

3839
#include "opal/util/argv.h"
3940
#include "opal/util/if.h"
41+
#include "opal/util/net.h"
4042
#include "opal/class/opal_pointer_array.h"
4143
#include "opal/mca/hwloc/base/base.h"
4244

@@ -489,6 +491,15 @@ static int orte_rmaps_rank_file_parse(const char *rankfile)
489491
goto unlock;
490492
}
491493
opal_argv_free (argv);
494+
495+
// Strip off the FQDN if present, ignore IP addresses
496+
if( !orte_keep_fqdn_hostnames && !opal_net_isaddr(node_name) ) {
497+
char *ptr;
498+
if (NULL != (ptr = strchr(node_name, '.'))) {
499+
*ptr = '\0';
500+
}
501+
}
502+
492503
/* check the rank item */
493504
if (NULL == rfmap) {
494505
orte_show_help("help-rmaps_rank_file.txt", "bad-syntax", true, rankfile);

orte/mca/rmaps/seq/rmaps_seq.c

+39-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Copyright (c) 2014-2016 Intel, Inc. All rights reserved.
1616
* Copyright (c) 2015 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
18+
* Copyright (c) 2016 IBM Corporation. All rights reserved.
1819
* $COPYRIGHT$
1920
*
2021
* Additional copyrights may follow
@@ -34,6 +35,7 @@
3435
#include <ctype.h>
3536

3637
#include "opal/util/if.h"
38+
#include "opal/util/net.h"
3739
#include "opal/mca/hwloc/hwloc.h"
3840

3941
#include "orte/util/show_help.h"
@@ -70,9 +72,11 @@ static void sn_des(seq_node_t *p)
7072
{
7173
if (NULL != p->hostname) {
7274
free(p->hostname);
75+
p->hostname = NULL;
7376
}
7477
if (NULL != p->cpuset) {
7578
free(p->cpuset);
79+
p->cpuset = NULL;
7680
}
7781
}
7882
OBJ_CLASS_INSTANCE(seq_node_t,
@@ -101,7 +105,7 @@ static int orte_rmaps_seq_map(orte_job_t *jdata)
101105
opal_list_t node_list, *seq_list, sq_list;
102106
orte_proc_t *proc;
103107
mca_base_component_t *c = &mca_rmaps_seq_component.base_version;
104-
char *hosts, *sep, *eptr;
108+
char *hosts = NULL, *sep, *eptr;
105109
FILE *fp;
106110
opal_hwloc_resource_type_t rtype;
107111

@@ -156,7 +160,7 @@ static int orte_rmaps_seq_map(orte_job_t *jdata)
156160
/* if there is a default hostfile, go and get its ordered list of nodes */
157161
OBJ_CONSTRUCT(&default_seq_list, opal_list_t);
158162
if (NULL != orte_default_hostfile) {
159-
char *hstname;
163+
char *hstname = NULL;
160164
/* open the file */
161165
fp = fopen(orte_default_hostfile, "r");
162166
if (NULL == fp) {
@@ -170,6 +174,11 @@ static int orte_rmaps_seq_map(orte_job_t *jdata)
170174
/* blank line - ignore */
171175
continue;
172176
}
177+
if( '#' == hstname[0] ) {
178+
free(hstname);
179+
/* Comment line - ignore */
180+
continue;
181+
}
173182
sq = OBJ_NEW(seq_node_t);
174183
if (NULL != (sep = strchr(hstname, ' '))) {
175184
*sep = '\0';
@@ -182,6 +191,15 @@ static int orte_rmaps_seq_map(orte_job_t *jdata)
182191
*(eptr+1) = 0;
183192
sq->cpuset = strdup(sep);
184193
}
194+
195+
// Strip off the FQDN if present, ignore IP addresses
196+
if( !orte_keep_fqdn_hostnames && !opal_net_isaddr(hstname) ) {
197+
char *ptr;
198+
if (NULL != (ptr = strchr(hstname, '.'))) {
199+
*ptr = '\0';
200+
}
201+
}
202+
185203
sq->hostname = hstname;
186204
opal_list_append(&default_seq_list, &sq->super);
187205
}
@@ -255,6 +273,16 @@ static int orte_rmaps_seq_map(orte_job_t *jdata)
255273
goto error;
256274
}
257275
while (NULL != (hstname = orte_getline(fp))) {
276+
if (0 == strlen(hstname)) {
277+
free(hstname);
278+
/* blank line - ignore */
279+
continue;
280+
}
281+
if( '#' == hstname[0] ) {
282+
free(hstname);
283+
/* Comment line - ignore */
284+
continue;
285+
}
258286
sq = OBJ_NEW(seq_node_t);
259287
if (NULL != (sep = strchr(hstname, ' '))) {
260288
*sep = '\0';
@@ -267,6 +295,15 @@ static int orte_rmaps_seq_map(orte_job_t *jdata)
267295
*(eptr+1) = 0;
268296
sq->cpuset = strdup(sep);
269297
}
298+
299+
// Strip off the FQDN if present, ignore IP addresses
300+
if( !orte_keep_fqdn_hostnames && !opal_net_isaddr(hstname) ) {
301+
char *ptr;
302+
if (NULL != (ptr = strchr(hstname, '.'))) {
303+
(*ptr) = '\0';
304+
}
305+
}
306+
270307
sq->hostname = hstname;
271308
opal_list_append(&sq_list, &sq->super);
272309
}

orte/util/dash_host/dash_host.c

+10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
1414
* Copyright (c) 2015 Research Organization for Information Science
1515
* and Technology (RIST). All rights reserved.
16+
* Copyright (c) 2016 IBM Corporation. All rights reserved.
1617
* $COPYRIGHT$
1718
*
1819
* Additional copyrights may follow
@@ -30,6 +31,7 @@
3031
#include "orte/util/show_help.h"
3132
#include "opal/util/argv.h"
3233
#include "opal/util/if.h"
34+
#include "opal/util/net.h"
3335

3436
#include "orte/mca/ras/base/base.h"
3537
#include "orte/mca/plm/plm_types.h"
@@ -207,6 +209,14 @@ int orte_util_add_dash_host_nodes(opal_list_t *nodes,
207209
ndname = mini_map[i];
208210
}
209211

212+
// Strip off the FQDN if present, ignore IP addresses
213+
if( !orte_keep_fqdn_hostnames && !opal_net_isaddr(ndname) ) {
214+
char *ptr;
215+
if (NULL != (ptr = strchr(ndname, '.'))) {
216+
*ptr = '\0';
217+
}
218+
}
219+
210220
/* see if the node is already on the list */
211221
found = false;
212222
OPAL_LIST_FOREACH(node, &adds, orte_node_t) {

orte/util/hostfile/hostfile.c

+19
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Copyright (c) 2013-2014 Intel, Inc. All rights reserved.
1616
* Copyright (c) 2015 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
18+
* Copyright (c) 2016 IBM Corporation. All rights reserved.
1819
* $COPYRIGHT$
1920
*
2021
* Additional copyrights may follow
@@ -37,6 +38,7 @@
3738
#include "opal/mca/mca.h"
3839
#include "opal/mca/base/base.h"
3940
#include "opal/util/if.h"
41+
#include "opal/util/net.h"
4042
#include "opal/mca/installdirs/installdirs.h"
4143

4244
#include "orte/util/show_help.h"
@@ -164,6 +166,14 @@ static int hostfile_parse_line(int token, opal_list_t* updates,
164166
}
165167
opal_argv_free (argv);
166168

169+
// Strip off the FQDN if present, ignore IP addresses
170+
if( !orte_keep_fqdn_hostnames && !opal_net_isaddr(node_name) ) {
171+
char *ptr;
172+
if (NULL != (ptr = strchr(node_name, '.'))) {
173+
*ptr = '\0';
174+
}
175+
}
176+
167177
/* if the first letter of the name is '^', then this is a node
168178
* to be excluded. Remove the ^ character so the nodename is
169179
* usable, and put it on the exclude list
@@ -270,6 +280,15 @@ static int hostfile_parse_line(int token, opal_list_t* updates,
270280
opal_output(0, "WARNING: Unhandled user@host-combination\n"); /* XXX */
271281
}
272282
opal_argv_free (argv);
283+
284+
// Strip off the FQDN if present, ignore IP addresses
285+
if( !orte_keep_fqdn_hostnames && !opal_net_isaddr(node_name) ) {
286+
char *ptr;
287+
if (NULL != (ptr = strchr(node_name, '.'))) {
288+
*ptr = '\0';
289+
}
290+
}
291+
273292
/* Do we need to make a new node object? */
274293
if (NULL == (node = hostfile_lookup(updates, node_name))) {
275294
node = OBJ_NEW(orte_node_t);

orte/util/proc_info.c

+8-15
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
12+
* Copyright (c) 2009-2016 Cisco Systems, Inc. All rights reserved.
1313
* Copyright (c) 2012 Los Alamos National Security, LLC.
1414
* All rights reserved.
1515
* Copyright (c) 2014-2015 Intel, Inc. All rights reserved
16+
* Copyright (c) 2016 IBM Corporation. All rights reserved.
1617
* $COPYRIGHT$
1718
*
1819
* Additional copyrights may follow
@@ -32,9 +33,6 @@
3233
#ifdef HAVE_SYS_TYPES_H
3334
#include <sys/types.h>
3435
#endif
35-
#if HAVE_ARPA_INET_H
36-
#include <arpa/inet.h>
37-
#endif
3836
#include <ctype.h>
3937

4038
#include "opal/mca/base/base.h"
@@ -102,7 +100,6 @@ int orte_proc_info(void)
102100
char hostname[OPAL_MAXHOSTNAMELEN];
103101
char **prefixes;
104102
bool match;
105-
struct in_addr buf;
106103

107104
if (init) {
108105
return ORTE_SUCCESS;
@@ -172,16 +169,12 @@ int orte_proc_info(void)
172169
/* add this to our list of aliases */
173170
opal_argv_append_nosize(&orte_process_info.aliases, hostname);
174171

175-
if (!orte_keep_fqdn_hostnames) {
176-
/* if the nodename is an IP address, do not mess with it! */
177-
if (0 == inet_pton(AF_INET, hostname, &buf) &&
178-
0 == inet_pton(AF_INET6, hostname, &buf)) {
179-
/* not an IP address, so remove any domain info */
180-
if (NULL != (ptr = strchr(hostname, '.'))) {
181-
*ptr = '\0';
182-
/* add this to our list of aliases */
183-
opal_argv_append_nosize(&orte_process_info.aliases, hostname);
184-
}
172+
// Strip off the FQDN if present, ignore IP addresses
173+
if( !orte_keep_fqdn_hostnames && !opal_net_isaddr(hostname) ) {
174+
if (NULL != (ptr = strchr(hostname, '.'))) {
175+
*ptr = '\0';
176+
/* add this to our list of aliases */
177+
opal_argv_append_nosize(&orte_process_info.aliases, hostname);
185178
}
186179
}
187180

0 commit comments

Comments
 (0)