aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api_hosts.c
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-10-12 09:02:44 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-10-12 09:02:44 +0000
commit9a065e97118b882b4fb6f245b060f21aa1f3ee3b (patch)
treee0126ddfdbefa9136ec0e386e89f81def250c00f /src/testbed/testbed_api_hosts.c
parent9a2533ba086a2d45caf6abcb58d4fc97df1a52ca (diff)
downloadgnunet-9a065e97118b882b4fb6f245b060f21aa1f3ee3b.tar.gz
gnunet-9a065e97118b882b4fb6f245b060f21aa1f3ee3b.zip
host file support for testbed profiler
Diffstat (limited to 'src/testbed/testbed_api_hosts.c')
-rw-r--r--src/testbed/testbed_api_hosts.c68
1 files changed, 65 insertions, 3 deletions
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c
index efe65de7d..d80a663e3 100644
--- a/src/testbed/testbed_api_hosts.c
+++ b/src/testbed/testbed_api_hosts.c
@@ -26,12 +26,10 @@
26 * @author Christian Grothoff 26 * @author Christian Grothoff
27 */ 27 */
28#include "platform.h" 28#include "platform.h"
29#include "gnunet_util_lib.h"
29#include "gnunet_testbed_service.h" 30#include "gnunet_testbed_service.h"
30#include "gnunet_core_service.h" 31#include "gnunet_core_service.h"
31#include "gnunet_constants.h"
32#include "gnunet_transport_service.h" 32#include "gnunet_transport_service.h"
33#include "gnunet_hello_lib.h"
34#include "gnunet_container_lib.h"
35 33
36#include "testbed_api.h" 34#include "testbed_api.h"
37#include "testbed_api_hosts.h" 35#include "testbed_api_hosts.h"
@@ -475,4 +473,68 @@ GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host,
475} 473}
476 474
477 475
476/**
477 * Checks whether a host can be used to start testbed service
478 *
479 * @param host the host to check
480 * @return GNUNET_YES if testbed service can be started on the given host
481 * remotely; GNUNET_NO if not
482 */
483int
484GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host)
485{
486 char *remote_args[11];
487 char *portstr;
488 char *ssh_addr;
489 const char *hostname;
490 struct GNUNET_OS_Process *auxp;
491 unsigned long code;
492 enum GNUNET_OS_ProcessStatusType type;
493 int ret;
494 unsigned int argp;
495
496 portstr = NULL;
497 ssh_addr = NULL;
498 hostname = (NULL == host->hostname) ? "127.0.0.1" : host->hostname;
499 if (NULL == host->username)
500 ssh_addr = GNUNET_strdup (hostname);
501 else
502 GNUNET_asprintf (&ssh_addr, "%s@%s", host->username, hostname);
503 argp = 0;
504 remote_args[argp++] = "ssh";
505 GNUNET_asprintf (&portstr, "%u", host->port);
506 remote_args[argp++] = "-p";
507 remote_args[argp++] = portstr;
508 remote_args[argp++] = "-o";
509 remote_args[argp++] = "BatchMode=yes";
510 remote_args[argp++] = "-o";
511 remote_args[argp++] = "NoHostAuthenticationForLocalhost=yes";
512 remote_args[argp++] = ssh_addr;
513 remote_args[argp++] = "which";
514 remote_args[argp++] = "gnunet-helper-testbed";
515 remote_args[argp++] = NULL;
516 GNUNET_assert (argp == 11);
517 auxp =
518 GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL,
519 NULL, "ssh", remote_args);
520 if (NULL == auxp)
521 {
522 GNUNET_free (ssh_addr);
523 GNUNET_free (portstr);
524 return GNUNET_NO;
525 }
526 do
527 {
528 ret = GNUNET_OS_process_status (auxp, &type, &code);
529 GNUNET_assert (GNUNET_SYSERR != ret);
530 (void) usleep (300);
531 }
532 while (GNUNET_NO == ret);
533 //(void) GNUNET_OS_process_wait (auxp);
534 GNUNET_OS_process_destroy (auxp);
535 GNUNET_free (ssh_addr);
536 GNUNET_free (portstr);
537 return (0 != code) ? GNUNET_NO : GNUNET_YES;
538}
539
478/* end of testbed_api_hosts.c */ 540/* end of testbed_api_hosts.c */