Skip to content
Permalink
Browse files

Merge pull request #892 from grondo/hwloc-byrank-hostname

resource-hwloc: put HostName in by_rank directory
  • Loading branch information...
chu11 committed Nov 3, 2016
2 parents a06cf00 + b096018 commit e8f89685d14d5315e08832cd6f6369c895b736af
Showing with 21 additions and 0 deletions.
  1. +15 −0 src/modules/resource-hwloc/resource.c
  2. +6 −0 t/t2005-hwloc-basic.t
@@ -266,6 +266,17 @@ static int walk_topology (flux_t *h,
return ret;
}

static int put_hostname (flux_t *h, const char *base, const char *hostname)
{
int rc;
char *key;
if (asprintf (&key, "%s.HostName", base) < 0)
return (-1);
rc = kvs_put_string (h, key, hostname);
free (key);
return (rc);
}

static int load_info_to_kvs (flux_t *h, ctx_t *ctx)
{
char *base_path = NULL;
@@ -296,6 +307,10 @@ static int load_info_to_kvs (flux_t *h, ctx_t *ctx)
const char *hostname = hwloc_obj_get_info_by_name (machine, "HostName");
char *kvs_hostname = escape_kvs_key (hostname);
char *host_path = xasprintf ("resource.hwloc.by_host.%s", kvs_hostname);

if (put_hostname (h, base_path, hostname) < 0)
flux_log_error (h, "failed to record hostname for this rank");

free (kvs_hostname);
(void) kvs_unlink (h, host_path);
if (ctx->walk_topology &&
@@ -116,4 +116,10 @@ test_expect_success 'hwloc: reload fails on invalid rank' '
grep "No route to host" stderr
'

test_expect_success 'hwloc: HostName is populated in by_rank' '
HW_HOST=$(flux kvs get resource.hwloc.by_rank.0.HostName) &&
REAL_HOST=$(hostname) &&
test x"$HW_HOST" = x"$REAL_HOST"
'

test_done

0 comments on commit e8f8968

Please sign in to comment.
You can’t perform that action at this time.