Exemplo n.º 1
0
int main (int argc, char *argv[]) {
	const char *options = "srl:u:v:k:a:c:hH";
	int opt;
	int service_load = 0;
	unsigned int nodeid;
	int service_unload = 0;
	char *service = NULL;
	unsigned int version = 0;

	if (argc == 1) {
		usage_do ();
	}
	while ( (opt = getopt(argc, argv, options)) != -1 ) {
		switch (opt) {
		case 's':
			ringstatusget_do ();
			break;
		case 'r':
			ringreenable_do ();
			break;
		case 'l':
			service_load = 1;
			service = xstrdup (optarg);
			break;
		case 'u':
			service_unload = 1;
			service = xstrdup (optarg);
			break;
		case 'k':
			nodeid = atoi (optarg);
			killnode_do(nodeid);
			break;
		case 'H':
			shutdown_do();
			break;
		case 'a':
			showaddrs_do( atoi(optarg) );
			break;
		case 'c':
			crypto_do( atoi(optarg) );
			break;
		case 'v':
			version = atoi (optarg);
			break;
		case 'h':
			usage_do();
			break;
		}
	}

	if (service_load) {
		service_load_do (service, version);
	} else
	if (service_unload) {
		service_unload_do (service, version);
	}

	return (0);
}
Exemplo n.º 2
0
int main (int argc, char *argv[]) {
	const char *options = "i:srRk:a:hH";
	int opt;
	unsigned int nodeid;
	char interface_name[128] = "";
	int rc=0;

	if (argc == 1) {
		usage_do ();
	}
	while ( (opt = getopt(argc, argv, options)) != -1 ) {
		switch (opt) {
		case 'i':
			strncpy(interface_name, optarg, sizeof(interface_name));
			break;
		case 's':
			printf("xxx 47000: tools/corosync-cfgtool.c main case \'s\' interface name (%s)", interface_name);
			rc = ringstatusget_do (interface_name);
			printf("xxx 47001: tools/corosync-cfgtool.c main case \'s\' interface name (%s)", interface_name);
			break;
		case 'R':
			rc = reload_config_do ();
			break;
		case 'r':
			ringreenable_do ();
			break;
		case 'k':
			nodeid = atoi (optarg);
			killnode_do(nodeid);
			break;
		case 'H':
			shutdown_do();
			break;
		case 'a':
			showaddrs_do( atoi(optarg) );
			break;
		case 'h':
			usage_do();
			break;
		}
	}

	return (rc);
}
int main (int argc, char *argv[]) {
	const char *options = "sr";
	int opt;

	if (argc == 1) {
		usage_do ();
	}
	while ( (opt = getopt(argc, argv, options)) != -1 ) {
		switch (opt) {
		case 's':
			ringstatusget_do ();
			break;
		case 'r':
			ringreenable_do ();
			break;
		}
	}

	return (0);
}
Exemplo n.º 4
0
int main (int argc, char *argv[]) {
	const char *options = "hd:ne";
	int opt;
	const char *prog_name = basename(argv[0]);
	char delimiter = 0;
	int escape = 1;
	operation_t operation = OPER_FULL_OUTPUT;
	int result;

	while ( (opt = getopt(argc, argv, options)) != -1 ) {
		switch (opt) {
		case 'd':
			if (strlen (optarg) > 0) {
				delimiter = optarg[0];
			}
		break;

		case 'n':
			operation = OPER_NAMES_ONLY;
		break;

		case 'e':
			escape = 0;
		break;

		case 'h':
			usage_do (prog_name);
			return (EXIT_SUCCESS);
		break;

		case '?':
		case ':':
			return (EXIT_FAILURE);
		break;
		}
	}

	result = cpg_initialize (&cpg_handle, NULL);

	if (result != CS_OK) {
		fprintf (stderr, "Could not initialize corosync cpg API error %d\n", result);
		return (EXIT_FAILURE);
	}

	result = corosync_cfg_initialize (&cfg_handle, NULL);
	if (result != CS_OK) {
		fprintf (stderr, "Could not initialize corosync configuration API error %d\n", result);
		return (EXIT_FAILURE);
	}

	switch (operation) {
	case OPER_NAMES_ONLY:
		result = display_groups (delimiter, escape);
		break;

	case OPER_FULL_OUTPUT:
		result = display_groups_with_members (delimiter, escape);
		break;
	}

	cpg_finalize (cpg_handle);
	corosync_cfg_finalize (cfg_handle);

	return (result ? EXIT_SUCCESS : EXIT_FAILURE);
}
Exemplo n.º 5
0
int main (int argc, char *argv[]) {
	const char *options = "i:sbrRk:a:hH";
	int opt;
	unsigned int nodeid = 0;
	char interface_name[128] = "";
	int rc = 0;
	enum user_action action = ACTION_NOOP;
	int brief = 0;

	while ( (opt = getopt(argc, argv, options)) != -1 ) {
		switch (opt) {
		case 'i':
			strncpy(interface_name, optarg, sizeof(interface_name));
			interface_name[sizeof(interface_name) - 1] = '\0';
			break;
		case 's':
			action = ACTION_LINKSTATUS_GET;
			break;
		case 'b':
			brief = 1;
			break;
		case 'R':
			action = ACTION_RELOAD_CONFIG;
			break;
		case 'k':
			nodeid = atoi (optarg);
			action = ACTION_KILL_NODE;
			break;
		case 'H':
			action = ACTION_SHUTDOW;
			break;
		case 'a':
			nodeid = atoi (optarg);
			action = ACTION_SHOWADDR;
			break;
		case '?':
			return (EXIT_FAILURE);
			break;
		case 'h':
		default:
			break;
		}
	}
	switch(action) {
	case ACTION_LINKSTATUS_GET:
		rc = linkstatusget_do(interface_name, brief);
		break;
	case ACTION_RELOAD_CONFIG:
		rc = reload_config_do();
		break;
	case ACTION_KILL_NODE:
		killnode_do(nodeid);
		break;
	case ACTION_SHUTDOW:
		shutdown_do();
		break;
	case ACTION_SHOWADDR:
		showaddrs_do(nodeid);
		break;
	case ACTION_NOOP:
	default:
		usage_do();
		break;
	}

	return (rc);
}