/** * Main function that will be run by the scheduler. * * @param cls closure * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param config configuration */ static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *config) { unsigned int nhost; if (NULL == args[0]) { fprintf (stderr, _("No hosts-file specified on command line\n")); return; } if (0 == num_peers) { result = GNUNET_OK; return; } num_hosts = GNUNET_TESTBED_hosts_load_from_file (args[0], &hosts); if (0 == num_hosts) { fprintf (stderr, _("No hosts loaded. Need at least one host\n")); return; } for (nhost = 0; nhost < num_hosts; nhost++) { if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (hosts[nhost], config)) { fprintf (stderr, _("Host %s cannot start testbed\n"), GNUNET_TESTBED_host_get_hostname_ (hosts[nhost])); break; } } if (num_hosts != nhost) { fprintf (stderr, _("Exiting\n")); shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); return; } cfg = GNUNET_CONFIGURATION_dup (config); mc_proc = GNUNET_TESTBED_controller_start (GNUNET_TESTBED_host_get_hostname_ (hosts[0]), hosts[0], cfg, status_cb, NULL); abort_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), &do_abort, NULL); }
/** * Loads the set of host allocated by the LoadLeveler Job Scheduler. This * function is only available when compiled with support for LoadLeveler and is * used for running on the SuperMUC * * @param cfg the configuration to use as a template while starting a controller * on any of the loaded hosts. Operation queue sizes specific to a host * are also read from this configuration handle * @param hosts set to the hosts found in the file; caller must free this if * number of hosts returned is greater than 0 * @return number of hosts returned in 'hosts', 0 on error */ unsigned int GNUNET_TESTBED_hosts_load_from_loadleveler (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTBED_Host ***hosts) { #if !ENABLE_SUPERMUC LOG (GNUNET_ERROR_TYPE_ERROR, _("The function %s is only available when compiled with (--with-ll)\n"), __func__); GNUNET_assert (0); #else const char *hostfile; if (NULL == (hostfile = getenv ("MP_SAVEHOSTFILE"))) { GNUNET_break (0); return 0; } return GNUNET_TESTBED_hosts_load_from_file (hostfile, cfg, hosts); #endif }
/** * Main run function. * * @param cls NULL * @param args arguments passed to GNUNET_PROGRAM_run * @param cfgfile the path to configuration file * @param cfg the configuration file handle */ static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *config) { unsigned int cnt; cfg = GNUNET_CONFIGURATION_dup (config); host = GNUNET_TESTBED_host_create ("localhost", NULL, cfg, 0); GNUNET_assert (NULL != host); GNUNET_assert (0 != GNUNET_TESTBED_host_get_id_ (host)); GNUNET_TESTBED_host_destroy (host); host = GNUNET_TESTBED_host_create (NULL, NULL, cfg, 0); GNUNET_assert (NULL != host); GNUNET_assert (0 == GNUNET_TESTBED_host_get_id_ (host)); GNUNET_assert (host == GNUNET_TESTBED_host_lookup_by_id_ (0)); hosts = NULL; num_hosts = GNUNET_TESTBED_hosts_load_from_file ("sample_hosts.txt", cfg, &hosts); GNUNET_assert (7 == num_hosts); GNUNET_assert (NULL != hosts); for (cnt = 0; cnt < num_hosts; cnt++) { if (cnt < 3) { GNUNET_assert (0 == strcmp ("totakura", GNUNET_TESTBED_host_get_username_ (hosts[cnt]))); GNUNET_assert (NULL != GNUNET_TESTBED_host_get_hostname (hosts[cnt])); GNUNET_assert (22 == GNUNET_TESTBED_host_get_ssh_port_ (hosts[cnt])); } if (3 == cnt) { GNUNET_assert (0 == strcmp ("totakura", GNUNET_TESTBED_host_get_username_ (hosts[cnt]))); GNUNET_assert (NULL != GNUNET_TESTBED_host_get_hostname (hosts[cnt])); GNUNET_assert (2022 == GNUNET_TESTBED_host_get_ssh_port_ (hosts[cnt])); } if (4 == cnt) { GNUNET_assert (0 == strcmp ("totakura", GNUNET_TESTBED_host_get_username_ (hosts[cnt]))); GNUNET_assert (0 == strcmp ("asgard.realm", GNUNET_TESTBED_host_get_hostname (hosts[cnt]))); GNUNET_assert (22 == GNUNET_TESTBED_host_get_ssh_port_ (hosts[cnt])); } if (5 == cnt) { GNUNET_assert (NULL == GNUNET_TESTBED_host_get_username_ (hosts[cnt])); GNUNET_assert (0 == strcmp ("rivendal", GNUNET_TESTBED_host_get_hostname (hosts[cnt]))); GNUNET_assert (22 == GNUNET_TESTBED_host_get_ssh_port_ (hosts[cnt])); } if (6 == cnt) { GNUNET_assert (NULL == GNUNET_TESTBED_host_get_username_ (hosts[cnt])); GNUNET_assert (0 == strcmp ("rohan", GNUNET_TESTBED_host_get_hostname (hosts[cnt]))); GNUNET_assert (561 == GNUNET_TESTBED_host_get_ssh_port_ (hosts[cnt])); } } status = GNUNET_YES; shutdown_id = GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (0), &do_shutdown, NULL); }