15
15
* Copyright (c) 2014-2016 Intel, Inc. All rights reserved.
16
16
* Copyright (c) 2015 Research Organization for Information Science
17
17
* and Technology (RIST). All rights reserved.
18
+ * Copyright (c) 2016 IBM Corporation. All rights reserved.
18
19
* $COPYRIGHT$
19
20
*
20
21
* Additional copyrights may follow
34
35
#include <ctype.h>
35
36
36
37
#include "opal/util/if.h"
38
+ #include "opal/util/net.h"
37
39
#include "opal/mca/hwloc/hwloc.h"
38
40
39
41
#include "orte/util/show_help.h"
@@ -70,9 +72,11 @@ static void sn_des(seq_node_t *p)
70
72
{
71
73
if (NULL != p -> hostname ) {
72
74
free (p -> hostname );
75
+ p -> hostname = NULL ;
73
76
}
74
77
if (NULL != p -> cpuset ) {
75
78
free (p -> cpuset );
79
+ p -> cpuset = NULL ;
76
80
}
77
81
}
78
82
OBJ_CLASS_INSTANCE (seq_node_t ,
@@ -101,7 +105,7 @@ static int orte_rmaps_seq_map(orte_job_t *jdata)
101
105
opal_list_t node_list , * seq_list , sq_list ;
102
106
orte_proc_t * proc ;
103
107
mca_base_component_t * c = & mca_rmaps_seq_component .base_version ;
104
- char * hosts , * sep , * eptr ;
108
+ char * hosts = NULL , * sep , * eptr ;
105
109
FILE * fp ;
106
110
opal_hwloc_resource_type_t rtype ;
107
111
@@ -156,7 +160,7 @@ static int orte_rmaps_seq_map(orte_job_t *jdata)
156
160
/* if there is a default hostfile, go and get its ordered list of nodes */
157
161
OBJ_CONSTRUCT (& default_seq_list , opal_list_t );
158
162
if (NULL != orte_default_hostfile ) {
159
- char * hstname ;
163
+ char * hstname = NULL ;
160
164
/* open the file */
161
165
fp = fopen (orte_default_hostfile , "r" );
162
166
if (NULL == fp ) {
@@ -170,6 +174,11 @@ static int orte_rmaps_seq_map(orte_job_t *jdata)
170
174
/* blank line - ignore */
171
175
continue ;
172
176
}
177
+ if ( '#' == hstname [0 ] ) {
178
+ free (hstname );
179
+ /* Comment line - ignore */
180
+ continue ;
181
+ }
173
182
sq = OBJ_NEW (seq_node_t );
174
183
if (NULL != (sep = strchr (hstname , ' ' ))) {
175
184
* sep = '\0' ;
@@ -182,6 +191,15 @@ static int orte_rmaps_seq_map(orte_job_t *jdata)
182
191
* (eptr + 1 ) = 0 ;
183
192
sq -> cpuset = strdup (sep );
184
193
}
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
+
185
203
sq -> hostname = hstname ;
186
204
opal_list_append (& default_seq_list , & sq -> super );
187
205
}
@@ -255,6 +273,16 @@ static int orte_rmaps_seq_map(orte_job_t *jdata)
255
273
goto error ;
256
274
}
257
275
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
+ }
258
286
sq = OBJ_NEW (seq_node_t );
259
287
if (NULL != (sep = strchr (hstname , ' ' ))) {
260
288
* sep = '\0' ;
@@ -267,6 +295,15 @@ static int orte_rmaps_seq_map(orte_job_t *jdata)
267
295
* (eptr + 1 ) = 0 ;
268
296
sq -> cpuset = strdup (sep );
269
297
}
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
+
270
307
sq -> hostname = hstname ;
271
308
opal_list_append (& sq_list , & sq -> super );
272
309
}
0 commit comments