Changeset 4539
- Timestamp:
- Jul 12, 2005, 7:05:52 AM (21 years ago)
- Location:
- trunk/Ohana/src/opihi/pantasks
- Files:
-
- 6 added
- 2 edited
-
controller.c (modified) (1 diff)
-
controller_check.c (added)
-
controller_host.c (added)
-
controller_status.c (added)
-
delete.c (added)
-
init.c (modified) (1 diff)
-
job.c (added)
-
kill.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pantasks/controller.c
r4450 r4539 1 1 # include "scheduler.h" 2 3 static Command controller_cmds[] = { 4 {"host", controller_host, "define host for controller"}, 5 {"status", controller_status, "check controller status"}, 6 {"check", controller_check, "check controller host/job"}, 7 }; 2 8 3 9 int controller (int argc, char **argv) { 4 10 5 11 int status; 6 char command[1024]; 7 IOBuffer buffer; 12 Function *func; 8 13 9 if (argc != 3) {10 fprintf (stderr, "USAGE: controller host (hostname)\n");14 if (argc < 2) { 15 fprintf (stderr, "USAGE: controller (command) ... \n"); 11 16 return (FALSE); 12 17 } 13 18 14 if (strcmp (argv[1], "host")) { 19 func = FindControllerCommand (argv[1]); 20 if (func == NULL) { 15 21 fprintf (stderr, "invalid controller command\n"); 16 22 return (FALSE); 17 23 } 18 24 19 /* start controller connection (if needed) */ 20 StartController (); 25 status = (*func)(argc - 1, argv + 1); 26 return (status); 27 } 21 28 22 sprintf (command, "host %s", argv[2]); 23 InitIOBuffer (&buffer, 0x100); 24 status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer); 25 FreeIOBuffer (&buffer); 29 Function *FindControllerCommand (char *cmd) { 26 30 27 /* check on success of controller command */ 28 switch (status) { 29 case CONTROLLER_DOWN: 30 fprintf (stderr, "controller is down\n"); 31 return (FALSE); 31 int i, N; 32 32 33 case CONTROLLER_HUNG: 34 fprintf (stderr, "controller is not responding\n"); 35 return (FALSE); 33 N = sizeof (controller_cmds) / sizeof (Command); 36 34 37 case CONTROLLER_GOOD: 38 fprintf (stderr, "controller command sent\n"); 39 return (TRUE); 40 41 default: 42 fprintf (stderr, "unknown status for controller command: programming error\n"); 43 exit (1); 35 for (i = 0; i < N; i++) { 36 if (!strcmp (controller_cmds[i].name, argv[1])) { 37 return (controller_cmds[i].func); 38 } 44 39 } 45 46 fprintf (stderr, "programming error: should not reach here\n"); 47 exit (1); 40 return (NULL); 48 41 } -
trunk/Ohana/src/opihi/pantasks/init.c
r4450 r4539 21 21 {"run", run, "run the scheduler"}, 22 22 {"stop", stop, "stop the scheduler"}, 23 24 {"kill", kill_sh, "kill job"}, 25 {"delete", delete, "delete job"}, 26 {"job", job, "add job"}, 27 {"host", host, "add / delete / modify host"}, 28 {"check", check, "get job or host status"}, 29 {"status", status, "get system status"}, 30 {"stdout", stdout_pc, "get stdout buffer for job"}, 31 {"stderr", stderr_pc, "get stderr buffer for job"}, 23 32 }; 24 33
Note:
See TracChangeset
for help on using the changeset viewer.
