static void doHosts (int argc, char **argv, int opCode) { if (optind == argc-1 && strcmp(argv[optind], "all") == 0) { doAllHosts(opCode); return; } for (; optind < argc; optind++) operateHost(argv[optind], opCode, 0); }
static void doAllHosts(int opCode) { int numhosts = 0, i; struct hostInfo *hostinfo; int ask = FALSE, try = FALSE; char msg[128]; hostinfo = ls_gethostinfo("-:server", &numhosts, NULL, 0, LOCAL_ONLY); if (hostinfo == NULL) { ls_perror("ls_gethostinfo"); fprintf(stderr, "Operation aborted\n"); exitrc = -1; return; } if (!fFlag) { if (opCode == LIM_CMD_REBOOT) sprintf(msg, "Do you really want to restart LIMs on all hosts? [y/n] "); else sprintf(msg, "Do you really want to shut down LIMs on all hosts? [y/n] "); ask = (!getConfirm(msg)); } for (i = 0; i < numhosts; i++) if (hostinfo[i].maxCpus > 0) operateHost (hostinfo[i].hostName, opCode, ask); else try = 1; if (try) { fprintf(stderr, "\n%s :\n\n", "Trying unavailable hosts"); for (i = 0; i < numhosts; i++) if (hostinfo[i].maxCpus <= 0) operateHost (hostinfo[i].hostName, opCode, ask); } }
int limCtrl(int argc, char **argv, int opCode) { char *optName; char *localHost; int vFlag = 0; int config = 0, checkReply; fFlag = 0; if (strcmp(argv[optind-1], "reconfig") == 0) { config = 1; } while ((optName = myGetOpt(argc, argv, "f|v|")) != NULL) { switch (optName[0]) { case 'v': if (opCode == LIM_CMD_SHUTDOWN) return(-2); vFlag = 1; break; case 'f': fFlag = 1; break; default: return(-2); } } exitrc = 0; if (config && optind != argc) return -2; switch (checkReply) { case EXIT_FATAL_ERROR: return -1; case EXIT_WARNING_ERROR: if (fFlag) break; if (!getConfirm(I18N(250, "Do you want to reconfigure? [y/n] "))) /* catgets 250 */ { fprintf(stderr, I18N(251, "Reconfiguration aborted.\n")); /* catgets 251 */ return(-1); } break; default: break; } if (config) { doAllHosts(opCode); return(exitrc); } if (optind == argc) { if ((localHost = ls_getmyhostname()) == NULL) { ls_perror("ls_getmyhostname"); return -1; } operateHost(localHost, opCode, 0); } else { doHosts(argc, argv, opCode); } return(exitrc); }