Commit 10f1e248 authored by Mike Hibler's avatar Mike Hibler
Browse files

Mimic Kirk's change to event library (trying harder to get IP address)

in program-agent as well.

Print filename in error message from event lib.
parent 02042929
......@@ -151,8 +151,8 @@ event_register_withkeydata_withretry(char *name, int threaded,
memcpy((char *)&myip, he->h_addr, he->h_length);
strcpy(ipaddr, inet_ntoa(myip));
} else {
ERROR("could not get IP address from hostname: %s\n"
"Attempting to get IP from local file.\n", hostname);
ERROR("could not get IP address from hostname: %s, "
"reading IP from %s.\n", hostname, IPADDRFILE);
/* Try getting the node's ID from BOOTDIR/myip before giving up. */
fp = fopen(IPADDRFILE, "r");
if (fp != NULL) {
......
......@@ -599,8 +599,22 @@ main(int argc, char **argv)
}
setenv("NODE", buf, 1);
if ((he = gethostbyname(buf)) == NULL) {
warning("warning: cannot get hostname for '%s', "
"assuming no network links available\n", buf);
/* XXX should not be hardwired */
char *ipfile = "/var/emulab/boot/myip";
warning("warning: cannot resolve hostname '%s' to obtain IP address,"
" reading IP from %s instead\n", buf, ipfile);
fp = fopen(ipfile, "r");
if (fp == NULL)
warning("warning: cannot get IP address for hostname '%s',"
" assuming no network links available\n", buf);
else {
fgets(buf, sizeof(buf), fp);
(void) fclose(fp);
if ((idx = strchr(buf, '\n')) != NULL)
*idx = '\0';
setenv("NODEIP", buf, 1);
}
}
else {
struct in_addr ia;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment